33 Commits 22b6f30350 ... a1aee198fc

Author SHA1 Message Date
  lcl a1aee198fc 商户查询审核状态判断商户号为空不 6 months ago
  lcl 00b7e8bc5f Merge branch 'DuGuYang' 6 months ago
  lcl 974fc32dee 释放屏蔽的队列 6 months ago
  lcl b5e111f8ac Merge branch 'test-mainserver' 6 months ago
  lcl 79856949b5 Merge branch 'feature-dgy-功能测试' into test-mainserver 6 months ago
  lcl f81470030a 发送订单到客小爽MQ 6 months ago
  lcl 1be57ad703 发送订单到客小爽MQ 6 months ago
  lcl 8e82e7dae6 补分账重置方法 6 months ago
  lcl f30e1a19c8 补分账重置方法 6 months ago
  DuGuYang 4ec549a3ff Merge branch 'feature-dgy-进件区分银联品牌' into feature-dgy-功能测试 6 months ago
  DuGuYang 5400799ea7 Merge branch 'feature-dgy-进件区分银联品牌' into feature-dgy-功能测试 6 months ago
  DuGuYang ef34784c9d Merge branch 'feature-dgy-进件区分银联品牌' into feature-dgy-功能测试 6 months ago
  DuGuYang 190fe39e32 调整参数 6 months ago
  DuGuYang 80f649e156 Merge branch 'feature-dgy-进件区分银联品牌' into feature-dgy-功能测试 6 months ago
  lcl db46686c46 查不到的订单放到私信队列 6 months ago
  lcl 6cb1d5d5e4 微信回调日志记录执行时间 6 months ago
  DuGuYang 9b29307a9c Merge branch 'feature-dgy-变更结算卡信息' into feature-dgy-功能测试 6 months ago
  DuGuYang 4800694285 Merge branch 'DuGuYang' into feature-dgy-变更结算卡信息 6 months ago
  DuGuYang 8f8a914ffe 修改数据链接 6 months ago
  DuGuYang c07b1be67f 调整数据链接 6 months ago
  DuGuYang 060fe60b13 调整数据链接 6 months ago
  DuGuYang 773ad575fc Merge branch 'feature-dgy-放开腾讯地址解析' into feature-dgy-功能测试 7 months ago
  DuGuYang 10d3ea79c1 Merge branch 'feature-dgy-放开腾讯地址解析' into feature-dgy-功能测试 7 months ago
  DuGuYang e4d1dde5ee 暂存 7 months ago
  DuGuYang 0abd97cabc Merge branch 'feature-dgy-小微经营场所选择' into feature-dgy-功能测试 7 months ago
  DuGuYang b2b9206346 暂存 7 months ago
  DuGuYang bea899a459 暂存 7 months ago
  DuGuYang ebba9d8c69 Merge branch 'feature-dgy-获取好哒商户门店号' into feature-dgy-功能测试 7 months ago
  DuGuYang 277c318b5a 暂存 7 months ago
  DuGuYang 64d6f1bb22 Merge branch 'DuGuYang' into feature-dgy-功能测试 7 months ago
  DuGuYang 8a9d864500 暂存 7 months ago
  DuGuYang 19e38b988f 暂存 10 months ago
  DuGuYang 77166e91f8 暂存 11 months ago

+ 22 - 0
Entity/OrderMessage.cs

@@ -0,0 +1,22 @@
+using System;
+namespace MySystem
+{
+    public class OrderMessage
+    {
+        public int brandId { get; set; } //品牌/通道(0直联,1银联,2好哒)
+        public int status { get; set; } //订单状态(0待支付,1已支付)
+        public DateTime createDate { get; set; } //创建时间
+        public DateTime payDate { get; set; } //支付时间
+        public string hdOrderNo { get; set; } //好哒订单号
+        public string tradeNo { get; set; } //支付宝微信平台交易号
+        public string snNo { get; set; } //码牌SN
+        public decimal payMoney { get; set; } //支付金额
+        public int payMode { get; set; } //支付方式(1支付宝,2微信)
+        public string orderNo { get; set; } //订单号
+        public int consumerId { get; set; } //消费者Id
+        public int merchantId { get; set; } //商户Id
+        public int isAct { get; set; } //活动标识(1活动,0非活动)
+        public int userId { get; set; } //创客Id
+        public decimal merchantActualAmount { get; set; } //商家实收金额
+    }
+}

+ 4 - 0
Util/HaoDa/HaoDaHelper.cs

@@ -83,6 +83,10 @@ namespace MySystem
         /// <returns></returns>
         /// <returns></returns>
         public string QueryMerchantStatus(string instId, string mchtNo, int BrandId = 0)
         public string QueryMerchantStatus(string instId, string mchtNo, int BrandId = 0)
         {
         {
+            if(string.IsNullOrEmpty(mchtNo))
+            {
+                return "{}";
+            }
             var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
             var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
             if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
             if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
 
 

+ 31 - 24
Util/HaoDa/TestChangeMerchantCardSetUtil.cs

@@ -16,41 +16,48 @@ namespace MySystem
     /// </summary>
     /// </summary>
     public class TestChangeMerchantCardSetUtil
     public class TestChangeMerchantCardSetUtil
     {
     {
-        public static ChangeMerchantCard SetValue(MerchantAddInfo AddInfo, string BankCard = "/static/upload/2023/9/11/nb.jpg")
+        // bankCard	银行卡正面	结算类型为1和2时必填,0不填,传上传图片接口得到的token
+        // openAccountLicenses	开户许可证	企业类型商户或结算类型为0时必填,1和2不填,传上传图片接口得到的token
+        // priLicAgreement	企业法人对私授权书	结算类型为1且为企业商户时必填,传上传图片接口得到的token
+        // agentProtocol	委托结算授权书	结算类型为2时必填,传上传图片接口得到的token
+        // agentIdCardFront	被委托人身份证人像面	结算类型为2时必填,传上传图片接口得到的token
+        // agentIdCardBack	被委托人身份证国徽面	结算类型为2时必填,传上传图片接口得到的token
+        // holdAgentProtocol	法人手持委托结算授权书	结算类型为2时必填,传上传图片接口得到的token
+        public static ChangeMerchantCard SetValue(MerchantAddInfo AddInfo, string BankCard = "/static/upload/2024/3/12/Card.jpg")
         {
         {
             ChangeMerchantCard changeMerchantCard = new ChangeMerchantCard();
             ChangeMerchantCard changeMerchantCard = new ChangeMerchantCard();
-            changeMerchantCard.mchtNo = "030510106621391"; //收款商户号
-            changeMerchantCard.accountNo = "6217359952003511113"; //卡号(账户类型 0-对公 时填写对公账号,1-对私 时填写银行卡号)
-            changeMerchantCard.accoutType = "1"; //账户类型 0-对公,1-对私
+            changeMerchantCard.mchtNo = "030510106722615"; //收款商户号
+            changeMerchantCard.accountNo = "694330345"; //卡号(账户类型 0-对公 时填写对公账号,1-对私 时填写银行卡号)
+            changeMerchantCard.accoutType = "0"; //账户类型 0-对公,1-对私
             if (changeMerchantCard.accoutType == "1")
             if (changeMerchantCard.accoutType == "1")
             {
             {
-                changeMerchantCard.accountName = "王亦君"; //开户名(账户名称 账户类型 0-对公 时填写对公账户名,1-对私 时填写银行卡户名)
+                changeMerchantCard.accountName = "黄全芳"; //开户名(账户名称 账户类型 0-对公 时填写对公账户名,1-对私 时填写银行卡户名)
             }
             }
             else
             else
             {
             {
-                changeMerchantCard.accountName = "四川探火网络科技有限责任公司"; //开户名(账户名称 账户类型 0-对公 时填写对公账户名,1-对私 时填写银行卡户名)
+                changeMerchantCard.accountName = "四川佰人商贸有限公司"; //开户名(账户名称 账户类型 0-对公 时填写对公账户名,1-对私 时填写银行卡户名)
             }
             }
-            changeMerchantCard.zbankNo = "313701013316"; //开户支行号
-            changeMerchantCard.alterType = "1"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
+            changeMerchantCard.zbankNo = "305651000261"; //开户支行号
+            changeMerchantCard.alterType = "0"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             // if (AddInfo.AccountType == "0" && AddInfo.LicenceType == "0") changeMerchantCard.alterType = "0"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             // if (AddInfo.AccountType == "0" && AddInfo.LicenceType == "0") changeMerchantCard.alterType = "0"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             // if (AddInfo.AccountType == "1" && (AddInfo.LicenceType == "0" || AddInfo.LicenceType == "1")) changeMerchantCard.alterType = "1"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             // if (AddInfo.AccountType == "1" && (AddInfo.LicenceType == "0" || AddInfo.LicenceType == "1")) changeMerchantCard.alterType = "1"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             // if (AddInfo.AccountType == "1" && AddInfo.LicenceType == null) changeMerchantCard.alterType = "2"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             // if (AddInfo.AccountType == "1" && AddInfo.LicenceType == null) changeMerchantCard.alterType = "2"; //结算类型:0-对公结算银行卡;1-法人对私结算银行卡;2-非法人结算
             changeMerchantCard.acctZbankCode = "510107"; //开户支行地区码
             changeMerchantCard.acctZbankCode = "510107"; //开户支行地区码
-            changeMerchantCard.idCard = "620522199407080017"; //非法人身份证号
-            if (changeMerchantCard.alterType == "2")
-            {
-                changeMerchantCard.idCard = "620522199407080017"; //非法人身份证号(结算类型为2时必填)
-                if (AddInfo.CardPeriodEnd.Value.Year == 2050)
-                {
-                    changeMerchantCard.agentCardDate = AddInfo.CardPeriodBegin.Value.ToString("yyyyMMdd") + "-" + "长期"; //法人身份证有效期 格式:20150101-20200101,若结束日期为长期填20150101-长期
-                }
-                else
-                {
-                    changeMerchantCard.agentCardDate = AddInfo.CardPeriodBegin.Value.ToString("yyyyMMdd") + "-" + AddInfo.CardPeriodEnd.Value.ToString("yyyyMMdd"); //法人身份证有效期 格式:20150101-20200101,若结束日期为长期填20150101-长期
-                }
-                // changeMerchantCard.agentCardDate = "" + "-" + "长期"; //非法人身份证有效期(结算类型为2时必填,格式:20210101-20220101,如长期:20210101-长期)
-                // changeMerchantCard.agentCardDate = "" + "-" + ""; //非法人身份证有效期(结算类型为2时必填,格式:20210101-20220101,如长期:20210101-长期)
-            }
+            // changeMerchantCard.idCard = ""; //非法人身份证号
+            // if (changeMerchantCard.alterType == "2")
+            // {
+            //     changeMerchantCard.idCard = "340123200410150349"; //非法人身份证号(结算类型为2时必填)
+            //     if (AddInfo.CardPeriodEnd.Value.Year == 2050)
+            //     {
+            //         changeMerchantCard.agentCardDate = AddInfo.CardPeriodBegin.Value.ToString("yyyyMMdd") + "-" + "长期"; //法人身份证有效期 格式:20150101-20200101,若结束日期为长期填20150101-长期
+            //     }
+            //     else
+            //     {
+            //         changeMerchantCard.agentCardDate = AddInfo.CardPeriodBegin.Value.ToString("yyyyMMdd") + "-" + AddInfo.CardPeriodEnd.Value.ToString("yyyyMMdd"); //法人身份证有效期 格式:20150101-20200101,若结束日期为长期填20150101-长期
+            //     }
+            //     // changeMerchantCard.agentCardDate = "" + "-" + "长期"; //非法人身份证有效期(结算类型为2时必填,格式:20210101-20220101,如长期:20210101-长期)
+            //     // changeMerchantCard.agentCardDate = "" + "-" + ""; //非法人身份证有效期(结算类型为2时必填,格式:20210101-20220101,如长期:20210101-长期)
+            // }
             List<PhotoItem> photoList = new List<PhotoItem>();
             List<PhotoItem> photoList = new List<PhotoItem>();
             PhotoItem photoItem = new PhotoItem();
             PhotoItem photoItem = new PhotoItem();
             // alterType结算类型为 0 时,上传 开户许可证照片
             // alterType结算类型为 0 时,上传 开户许可证照片
@@ -74,7 +81,7 @@ namespace MySystem
             }
             }
             if (changeMerchantCard.alterType == "1")
             if (changeMerchantCard.alterType == "1")
             {
             {
-                var info = "/static/upload/2023/8/14/dd.jpg";
+                var info = "/static/upload/2024/3/12/Card.jpg";
                 if (!string.IsNullOrEmpty(info))
                 if (!string.IsNullOrEmpty(info))
                 {
                 {
                     var tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken(info.Substring(info.LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
                     var tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken(info.Substring(info.LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));

+ 41 - 11
Util/HaoDa/TestHaoDaService.cs

@@ -38,9 +38,11 @@ namespace MySystem
             // AlipayAddInfo(828,"202309011037906510");//查询支付宝开户意愿申请状态
             // AlipayAddInfo(828,"202309011037906510");//查询支付宝开户意愿申请状态
             // WeChatAddInfo(826);//提交微信开户意愿申请单
             // WeChatAddInfo(826);//提交微信开户意愿申请单
             // WeChatAddInfo(825,"2000002424428809");//查询微信开户意愿申请状态
             // WeChatAddInfo(825,"2000002424428809");//查询微信开户意愿申请状态
-            // QueryMerchantStatus(867);//新建商户查询状态
-            // ConfiemMer(808);//新建商户
+            // ConfiemMer(1833);//新建商户
+            // QueryMerchantStatus(1833);//新建商户查询状态
+            // GetTencentAddressInfo(112); //获取商户经纬坐标
             // ChangeMerchantCard(1);//商户修改银行卡
             // ChangeMerchantCard(1);//商户修改银行卡
+            // QueryChangeCardStatus(1874);//商户修改银行卡状态
             // AddOpenDivideAccounts(832); //添加分账方
             // AddOpenDivideAccounts(832); //添加分账方
             // QueryAuthStatus(1845);//查询实名认证状态
             // QueryAuthStatus(1845);//查询实名认证状态
             // WeChatFunctionForHD.Instance.QueryAuthMerchant("600955391");
             // WeChatFunctionForHD.Instance.QueryAuthMerchant("600955391");
@@ -741,10 +743,10 @@ namespace MySystem
         public void ChangeMerchantCard(int MerchantId)
         public void ChangeMerchantCard(int MerchantId)
         {
         {
             WebCMSEntities db = new WebCMSEntities();
             WebCMSEntities db = new WebCMSEntities();
-            // MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId);
-            // var request = TestChangeMerchantCardSetUtil.SetValue(AddInfo);
-            // JsonData Infos = JsonMapper.ToObject(HaoDaHelper.Instance.ChangeMerchantCard(request));
-            // JsonData results = JsonMapper.ToObject(HaoDaHelper.Instance.QueryChangeCardStatus(AddInfo.MchtNo, Infos["taskId"].ToString()));
+            MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId);
+            var request = TestChangeMerchantCardSetUtil.SetValue(AddInfo);
+            JsonData Infos = JsonMapper.ToObject(HaoDaHelper.Instance.ChangeMerchantCard(request));
+            JsonData results = JsonMapper.ToObject(HaoDaHelper.Instance.QueryChangeCardStatus(AddInfo.MchtNo, Infos["data"]["taskId"].ToString()));
             //TODO:修改结算卡变更商户相关信息
             //TODO:修改结算卡变更商户相关信息
             // AccountNumber
             // AccountNumber
             // BankName
             // BankName
@@ -762,12 +764,40 @@ namespace MySystem
         }
         }
 
 
 
 
+        //获取商户经纬坐标
+        public void GetTencentAddressInfo(int Id)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id);
+            string Address = merchant.Areas + merchant.Address;
+            string Key = Library.ConfigurationManager.AppSettings["TencentKey"].ToString();
+            LogHelper.Instance.WriteLog("商户Id\n" + Id + "\n\n", "获取商户经纬坐标");
+            LogHelper.Instance.WriteLog("请求参数\n" + Address + "\n\n", "获取商户经纬坐标");
+            var info = function.GetWebRequest("https://apis.map.qq.com/ws/geocoder/v1/?address=" + Address + "&key=" + Key);
+            JsonData result = JsonMapper.ToObject(info);
+            //创建成功
+            if (result["status"].ToString() == "0")
+            {
+                var merInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                if (merInfo.Id > 0)
+                {
+                    merInfo.Longitude = decimal.Parse(result["result"]["location"]["lng"].ToString());
+                    merInfo.Latitude = decimal.Parse(result["result"]["location"]["lat"].ToString());
+                    db.SaveChanges();
+                    db.Dispose();
+                }
+            }
+            LogHelper.Instance.WriteLog("返回\n" + info + "\n\n", "获取商户经纬坐标");
+            db.Dispose();
+        }
 
 
-
-
-
-
-
+        public void QueryChangeCardStatus(int MerchantId)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId);
+            // JsonData results = JsonMapper.ToObject(HaoDaHelper.Instance.QueryChangeCardStatus(AddInfo.MchtNo, Infos["data"]["taskId"].ToString()));
+            JsonData results = JsonMapper.ToObject(HaoDaHelper.Instance.QueryChangeCardStatus(AddInfo.MchtNo, "16592654"));
+        }
         public void refund()
         public void refund()
         {
         {
             Thread th = new Thread(refunddo);
             Thread th = new Thread(refunddo);

+ 59 - 39
Util/HaoDa/WeChatPayBackService.cs

@@ -55,7 +55,7 @@ namespace MySystem
             JsonData jsonObj = JsonMapper.ToObject(content);
             JsonData jsonObj = JsonMapper.ToObject(content);
             if (jsonObj.Count > 0)
             if (jsonObj.Count > 0)
             {
             {
-                LogHelper.Instance.WriteLog("json通过", "微信支付回调监控");
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "json通过", "微信支付回调监控");
                 string OrderNo = jsonObj["outOrderNo"].ToString();
                 string OrderNo = jsonObj["outOrderNo"].ToString();
                 string HdOrderNo = jsonObj["orderNo"].ToString();
                 string HdOrderNo = jsonObj["orderNo"].ToString();
                 string TradeNo = "";
                 string TradeNo = "";
@@ -63,21 +63,21 @@ namespace MySystem
                 {
                 {
                     TradeNo = jsonObj["payChannelOrderNo"].ToString();
                     TradeNo = jsonObj["payChannelOrderNo"].ToString();
                 }
                 }
-                LogHelper.Instance.WriteLog("OrderNo:" + OrderNo, "微信支付回调监控");
-                LogHelper.Instance.WriteLog("HdOrderNo:" + HdOrderNo, "微信支付回调监控");
-                LogHelper.Instance.WriteLog("TradeNo:" + TradeNo, "微信支付回调监控");
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "OrderNo:" + OrderNo, "微信支付回调监控");
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "HdOrderNo:" + HdOrderNo, "微信支付回调监控");
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "TradeNo:" + TradeNo, "微信支付回调监控");
                 WebCMSEntities db = new WebCMSEntities();
                 WebCMSEntities db = new WebCMSEntities();
                 ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 0);
                 ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 0);
                 if (order != null)
                 if (order != null)
                 {
                 {
-                    LogHelper.Instance.WriteLog("找到订单", "微信支付回调监控");
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "找到订单", "微信支付回调监控");
                     order.Status = 1;
                     order.Status = 1;
                     order.UpdateDate = DateTime.Now;
                     order.UpdateDate = DateTime.Now;
                     order.PayMoney = order.PayMoney;
                     order.PayMoney = order.PayMoney;
                     order.MaxDivi = order.MaxDivi;
                     order.MaxDivi = order.MaxDivi;
                     order.SeoTitle = HdOrderNo;
                     order.SeoTitle = HdOrderNo;
                     order.SeoKeyword = TradeNo;
                     order.SeoKeyword = TradeNo;
-                    LogHelper.Instance.WriteLog("赋值", "微信支付回调监控");
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "赋值", "微信支付回调监控");
                     MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
                     MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
                     MerchantAddInfo addinfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
                     MerchantAddInfo addinfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
                     if (addinfo.Status == 1 && order.PayMode == 2)
                     if (addinfo.Status == 1 && order.PayMode == 2)
@@ -103,7 +103,7 @@ namespace MySystem
                         }
                         }
                     }
                     }
                     order.UserId = merchant.UserId;
                     order.UserId = merchant.UserId;
-                    LogHelper.Instance.WriteLog("创客:" + merchant.UserId, "微信支付回调监控");
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "创客:" + merchant.UserId, "微信支付回调监控");
                     ConsumerOrders check = db.ConsumerOrders.FirstOrDefault(m => m.Id < order.Id && m.Status > 0 && m.PayMode == order.PayMode && m.MerchantId == order.MerchantId);
                     ConsumerOrders check = db.ConsumerOrders.FirstOrDefault(m => m.Id < order.Id && m.Status > 0 && m.PayMode == order.PayMode && m.MerchantId == order.MerchantId);
                     if (check != null)
                     if (check != null)
                     {
                     {
@@ -114,7 +114,7 @@ namespace MySystem
                         order.QueryCount = 1;
                         order.QueryCount = 1;
                     }
                     }
                     db.SaveChanges();
                     db.SaveChanges();
-                    LogHelper.Instance.WriteLog("检测商户订单数:" + order.QueryCount, "微信支付回调监控");
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "检测商户订单数:" + order.QueryCount, "微信支付回调监控");
 
 
                     Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
                     Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
                     var machines = db1.PosMachines.Select(m => new { m.SeoDescription, m.DeviceKind, m.BrandId, m.Detail, m.BindMerchantId }).Where(m => m.DeviceKind == "2" && m.BindMerchantId == order.MerchantId);
                     var machines = db1.PosMachines.Select(m => new { m.SeoDescription, m.DeviceKind, m.BrandId, m.Detail, m.BindMerchantId }).Where(m => m.DeviceKind == "2" && m.BindMerchantId == order.MerchantId);
@@ -134,16 +134,26 @@ namespace MySystem
                         }
                         }
                     }
                     }
                     db1.Dispose();
                     db1.Dispose();
-                    LogHelper.Instance.WriteLog("执行完毕", "微信支付回调监控");
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "执行完毕", "微信支付回调监控");
+
+                    //发送订单到客小爽MQ
+                    OrderMessageHelper.SendOrderMsg(order);
                 }
                 }
                 else
                 else
                 {
                 {
-                    LogHelper.Instance.WriteLog("没找到订单", "微信支付回调监控");
-                    Thread.Sleep(2000);
-                    RedisDbconn.Instance.AddList("WeChatPayBackHd", content);
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "没找到订单", "微信支付回调监控");
+                    ConsumerOrders checkorder = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 2);
+                    if (checkorder != null)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "找到订单状态为2", "微信支付回调监控");
+                    }
+                    else
+                    {
+                        RedisDbconn.Instance.AddList("WeChatPayBackHdDead", content);
+                    }
                 }
                 }
                 db.Dispose();
                 db.Dispose();
-                LogHelper.Instance.WriteLog("结束", "微信支付回调监控");
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "结束", "微信支付回调监控");
             }
             }
         }
         }
 
 
@@ -281,34 +291,44 @@ namespace MySystem
                                 MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
                                 MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
                                 //发起分账
                                 //发起分账
                                 decimal fee = order.PayMoney;
                                 decimal fee = order.PayMoney;
-                                string applyNo = "FZ" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8); //批次号
-                                string mchtNo = merchantAdd.OutMchtNo; //慧掌柜商户号
-                                string orderNo = order.SeoTitle; //交易订单号(好哒平台订单号,G开头)
-                                string acctNo = AppConfig.Haoda.AcctNo; //账户号,分账接收方账户号
-                                string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
-                                string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
-                                decimal settleAmount = (decimal)order.SettleAmount / 100M;
-                                decimal divideAmt = (1 - 0.0038M) * order.SettleAmount;
-                                divideAmt = decimal.Parse(divideAmt.ToString("f2"));
-                                decimal hdfee = 0.0038M * order.SettleAmount * (1 - set.GetPercent / 100 - 0.01M);
-                                hdfee = decimal.Parse(hdfee.ToString("f2"));
-                                decimal servicefee = 0.01M * order.SettleAmount - hdfee;
-                                servicefee = decimal.Parse(servicefee.ToString("f2"));
-                                decimal amount = order.SettleAmount * (1 - 0.0038M) - servicefee;
-                                amount = decimal.Parse(amount.ToString("f2"));
-                                decimal otherAmt = divideAmt - servicefee - amount;
-                                if (otherAmt != 0)
+                                if (fee >= 1)
                                 {
                                 {
-                                    amount += otherAmt;
-                                }
+                                    string applyNo = "FZ" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8); //批次号
+                                    string mchtNo = merchantAdd.OutMchtNo; //慧掌柜商户号
+                                    string orderNo = order.SeoTitle; //交易订单号(好哒平台订单号,G开头)
+                                    string acctNo = AppConfig.Haoda.AcctNo; //账户号,分账接收方账户号
+                                    string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
+                                    string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
 
 
-                                amount = amount * 100; //金额(分)
-                                servicefee = servicefee * 100;
-                                string seviceAmount = servicefee.ToString("f0"); //服务费
-                                string amountAmount = amount.ToString("f0");
-                                string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amountAmount, seviceAmount), merchantAdd.BrandId);
-                                order.DivideLog = "请求分账日志:" + result;
-                                db.SaveChanges();
+                                    decimal settleAmount = (decimal)order.SettleAmount / 100M;
+                                    decimal divideAmt = (1 - 0.0038M) * order.PayMoney;
+                                    divideAmt = decimal.Parse(divideAmt.ToString("f2"));
+                                    decimal hdfee = 0.0038M * order.PayMoney * (1 - set.GetPercent / 100 - 0.01M);
+                                    hdfee = decimal.Parse(hdfee.ToString("f2"));
+                                    decimal servicefee = 0.01M * order.PayMoney - hdfee;
+                                    servicefee = decimal.Parse(servicefee.ToString("f2"));
+                                    decimal amount = order.PayMoney * (1 - 0.0038M) - servicefee;
+                                    amount = decimal.Parse(amount.ToString("f2"));
+                                    decimal otherAmt = settleAmount - servicefee - amount;
+                                    if (otherAmt != 0)
+                                    {
+                                        amount += otherAmt;
+                                    }
+
+                                    amount = amount * 100; //金额(分)
+                                    servicefee = servicefee * 100;
+                                    string seviceAmount = servicefee.ToString("f0"); //服务费
+                                    string amountAmount = amount.ToString("f0");
+                                    string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amountAmount, seviceAmount));
+                                    order.DivideLog = "请求分账日志:" + result;
+
+                                    //开始监听分账状态
+                                    // Dictionary<string, object> req = new Dictionary<string, object>();
+                                    // req.Add("ApplyNo", applyNo);
+                                    // req.Add("OrderNo", order.OrderNo);
+                                    // req.Add("MchtNo", mchtNo);
+                                    // RedisDbconn.Instance.AddList("ProfitShareHdQueue", Newtonsoft.Json.JsonConvert.SerializeObject(req));
+                                }
                             }
                             }
                         }
                         }
                         db.Dispose();
                         db.Dispose();

+ 36 - 0
Util/OrderMessageHelper.cs

@@ -0,0 +1,36 @@
+using System;
+using MySystem.Models.Main;
+using System.Linq;
+
+namespace MySystem
+{
+    public class OrderMessageHelper
+    {
+        public static void SendOrderMsg(ConsumerOrders order)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
+            OrderMessage msg = new OrderMessage()
+            {
+                brandId = merchant.BrandId + 1, //品牌/通道(0直联,1银联,2好哒)
+                status = order.Status, //订单状态(0待支付,1已支付)
+                createDate = order.CreateDate.Value, //创建时间
+                payDate = order.UpdateDate.Value, //支付时间
+                hdOrderNo = order.SeoTitle, //好哒订单号
+                tradeNo = order.SeoKeyword, //支付宝微信平台交易号
+                snNo = order.SnNo, //码牌SN
+                payMoney = order.PayMoney, //支付金额
+                payMode = order.PayMode, //支付方式(1支付宝,2微信)
+                orderNo = order.OrderNo, //订单号
+                consumerId = order.ConsumerId, //消费者Id
+                merchantId = order.MerchantId, //商户Id
+                isAct = (int)order.IsAct, //活动标识(1活动,0非活动)
+                userId = order.UserId, //创客Id
+                merchantActualAmount = order.MerchantActualAmount, //商家实收金额
+            };
+            db.Dispose();
+
+            RedisDbconn.Instance.AddList("MpOrderQueue", Newtonsoft.Json.JsonConvert.SerializeObject(msg));
+        }
+    }
+}