Browse Source

测试支付

lcl 1 year ago
parent
commit
4b049edd19

+ 4 - 4
Areas/Api/Controllers/Main/ConsumerOrdersController.cs

@@ -56,7 +56,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             var merchant = MerchantInfoService.Query(qrcode.MerchantId);
             var merchantAdd = MerchantAddInfoService.Query(qrcode.MerchantId);
             var merchantset = MerchantParamSetService.Query(qrcode.MerchantId);
-            var ledgerModel = merchantset.IsAll == 1 ? "1" : "2";
+            var ledgerModel = merchantset.IsAll == 1 ? "1" : "5";
             string openid = "";
             if (PayMode == 1)
             {
@@ -114,15 +114,15 @@ namespace MySystem.Areas.Api.Controllers.v1
             }
             else if (PayMode == 2)
             {
-                var dic = JsonMapper.ToObject(HaoDaHelper.Instance.WeChatPay(merchantAdd.SubMchid.ToString(), merchantAdd.AlipayPid, OrderNo, PayMoney.ToString(), SpHost + "/api/wechat/notice", openid, function.get_Random(4), merchantAdd.AppAppid, "MINI_PROGRAM", ledgerModel));
+                var dic = JsonMapper.ToObject(HaoDaHelper.Instance.WeChatPay(merchantAdd.OutMchtNo, merchantAdd.StoreNo, OrderNo, PayMoney, SpHost + "/api/wechat/notice", openid, function.get_Random(4), AppConfig.WeChat.AppId, "MINI_PROGRAM", ledgerModel));
                 Obj.Add("appId", dic["payInfo"]["appId"].ToString()); //微信小程序appid
                 Obj.Add("timeStamp", dic["payInfo"]["timeStamp"].ToString()); //时间戳
                 Obj.Add("nonceStr", dic["payInfo"]["nonceStr"].ToString()); //随机字符串
-                Obj.Add("package", dic["payInfo"]["package"].ToString()); //统一支付接口返回的prepayid参数值
+                Obj.Add("package", dic["payInfo"]["wxPackage"].ToString()); //统一支付接口返回的prepayid参数值
                 Obj.Add("paySign", dic["payInfo"]["paySign"].ToString()); //支付签名
                 Obj.Add("ConsumerId", ConsumerId);
             }
-            return Json(Json(new AppResultJson() { Status = "1", Info = "", Data = Obj }));
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
         }
         #endregion
 

+ 10 - 0
Config/WeChat.cs

@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using Library;
+
+namespace AppConfig
+{
+    public class WeChat
+    {
+        public static string AppId = "wx6e074b8e07b6577e"; //微信小程序APPID
+    }
+}

+ 4 - 0
Models/Main/MerchantAddInfo.cs

@@ -138,5 +138,9 @@ namespace MySystem.Models.Main
         public string LicenceType { get; set; }
         public string ResserveMobile { get; set; }
         public string MchtNo { get; set; }
+        public string ToAcctNo { get; set; }
+        public int OpenAct { get; set; }
+        public string StoreNo { get; set; }
+        public string OutMchtNo { get; set; }
     }
 }

+ 13 - 0
Models/Main/OpenBankAll.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main
+{
+    public partial class OpenBankAll
+    {
+        public string BankChild { get; set; }
+        public string BankChildNo { get; set; }
+        public string BankParentNo { get; set; }
+        public string BankParent { get; set; }
+    }
+}

+ 55 - 0
Models/Main/WebCMSEntities.cs

@@ -112,6 +112,7 @@ namespace MySystem.Models.Main
         public virtual DbSet<MsgSms> MsgSms { get; set; }
         public virtual DbSet<MsgSmsSet> MsgSmsSet { get; set; }
         public virtual DbSet<MsgTemplate> MsgTemplate { get; set; }
+        public virtual DbSet<OpenBankAll> OpenBankAll { get; set; }
         public virtual DbSet<OpenBankCityTable> OpenBankCityTable { get; set; }
         public virtual DbSet<OpenBankTable> OpenBankTable { get; set; }
         public virtual DbSet<OpenReward> OpenReward { get; set; }
@@ -5464,6 +5465,10 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.OpenAct)
+                    .HasColumnType("int(11)")
+                    .HasComment("是否开通分账");
+
                 entity.Property(e => e.OpenBankAccName)
                     .HasColumnType("varchar(50)")
                     .HasComment("开户许可证-开户名")
@@ -5520,6 +5525,12 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.OutMchtNo)
+                    .HasColumnType("varchar(100)")
+                    .HasComment("慧掌柜商户号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
                 entity.Property(e => e.Owner)
                     .HasColumnType("bit(1)")
                     .HasDefaultValueSql("b'0'");
@@ -5624,6 +5635,12 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.StoreNo)
+                    .HasColumnType("varchar(100)")
+                    .HasComment("门店号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
                 entity.Property(e => e.SubCorpId)
                     .HasColumnType("varchar(50)")
                     .HasCharSet("utf8")
@@ -5659,6 +5676,12 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.ToAcctNo)
+                    .HasColumnType("varchar(100)")
+                    .HasComment("分账接收方")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
                 entity.Property(e => e.UboInfoIdCardCopy)
                     .HasColumnType("varchar(200)")
                     .HasCharSet("utf8")
@@ -7645,6 +7668,38 @@ namespace MySystem.Models.Main
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<OpenBankAll>(entity =>
+            {
+                entity.HasKey(e => e.BankChild)
+                    .HasName("PRIMARY");
+
+                entity.HasComment("银行行号表");
+
+                entity.Property(e => e.BankChild)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("支行名称")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.BankChildNo)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("支行行号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.BankParent)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("总行名称")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.BankParentNo)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("总行行号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+            });
+
             modelBuilder.Entity<OpenBankCityTable>(entity =>
             {
                 entity.HasKey(e => e.CityName)

+ 8 - 7
Util/HaoDa/HaoDaHelper.cs

@@ -28,7 +28,7 @@ namespace MySystem
         // string BrhCode = "001040";
 
         //生产环境
-        string BoxRequestUrl = "https://openapi-test.iboxpay.com";
+        string BoxRequestUrl = "https://openapi.iboxpay.com";
         string BoxAppId = "AP7175619323825451008";
         string BoxAppSecret = "hUfR53gdjyfiZTBR5bILanMqRD1dXD7y";
         string BoxPublicKey = "";
@@ -305,14 +305,15 @@ namespace MySystem
         /// <param name="subAppIdType">对应的类型,默认为公众号, SUBSCRIPTION: 公众号 MINI_PROGRAM: 小程序</param>
         /// <param name="ledgerModel">分账类型:1不分账 2分账,注意只有开通了分账才能传这个字段</param>
         /// <returns></returns>
-        public string WeChatPay(string mchtNo, string storeNo, string outOrderNo, string transAmount, string callbackUrl, string subOpenId, string confirmCode, string subAppId, string subAppIdType, string ledgerModel)
+        public string WeChatPay(string mchtNo, string storeNo, string outOrderNo, decimal transAmount, string callbackUrl, string subOpenId, string confirmCode, string subAppId, string subAppIdType, string ledgerModel)
         {
             function.WriteLog(DateTime.Now.ToString(), "好哒微信公众号和小程序支付");
             Dictionary<string, object> reqdic = new Dictionary<string, object>();
             reqdic.Add("mchtNo", mchtNo); //盒子的商户编号
             reqdic.Add("storeNo", storeNo); //盒子的门店编码	
             reqdic.Add("outOrderNo", outOrderNo); //商户订单号
-            reqdic.Add("transAmount", transAmount); //交易金额,单位:分
+            int payMonth = (int)(transAmount * 100);
+            reqdic.Add("transAmount", payMonth); //交易金额,单位:分
             reqdic.Add("callbackUrl", callbackUrl); //交易完成之后,商户接收交易结果通知的地址	
             reqdic.Add("subOpenId", subOpenId); //用户子标识
             reqdic.Add("confirmCode", confirmCode); //支付确认码,由4位纯数字组成,每次请求时随机生成	
@@ -326,8 +327,8 @@ namespace MySystem
             string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
             function.WriteLog("请求头\n" + head, "好哒微信公众号和小程序支付");
             function.WriteLog("请求参数\n" + req, "好哒微信公众号和小程序支付");
-            function.WriteLog("请求地址:" + BoxRequestUrl + "/hzg/v2/unitedtrade/wechat_js_pay", "好哒微信公众号和小程序支付");
-            string result = PostWebRequest(BoxRequestUrl + "/hzg/v2/unitedtrade/wechat_js_pay", req, headdic);
+            function.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", "好哒微信公众号和小程序支付");
+            string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", req, headdic);
             function.WriteLog("返回\n" + result + "\n\n", "好哒微信公众号和小程序支付");
 
             return result;
@@ -376,8 +377,8 @@ namespace MySystem
         {
             Dictionary<string, string> headdic = new Dictionary<string, string>();
             string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-            headdic.Add("appid", BoxAppId);//开发者id
-            headdic.Add("appsecret", BoxAppSecret);//开发者密码
+            // headdic.Add("appid", BoxAppId);//开发者id
+            // headdic.Add("appsecret", BoxAppSecret);//开发者密码
             headdic.Add("X-Up-AppId", BoxAppId);
             headdic.Add("X-Timestamp", timestamp);
             headdic.Add("X-Sign-Type", "SHA-256");