DuGuYang 6 bulan lalu
induk
melakukan
7b14805584
1 mengubah file dengan 142 tambahan dan 10 penghapusan
  1. 142 10
      Util/HaoDa/TestHaoDaService.cs

+ 142 - 10
Util/HaoDa/TestHaoDaService.cs

@@ -22,15 +22,19 @@ namespace MySystem
 
         public void Start()
         {
-            Thread th = new Thread(StartListen);
-            th.IsBackground = true;
-            th.Start();
+            while (true)
+            {
+                Thread th = new Thread(StartListen);
+                th.IsBackground = true;
+                th.Start();
+                Thread.Sleep(10000);
+            }
         }
 
         public void StartListen()
         {
             // GetFTPListInfo(); // 获取好哒FTPInfo
-            GetFTPDataInfo(); //获取好哒FTPDataInfo
+            // GetFTPDataInfo(); //获取好哒FTPDataInfo
             //开户意愿申请
             // RedisDbconn.Instance.AddList("AlipayForHaoDaQueue",824);
             // RedisDbconn.Instance.AddList("WeChatForHaoDaQueue",824);
@@ -39,7 +43,7 @@ namespace MySystem
             // WeChatAddInfo(826);//提交微信开户意愿申请单
             // WeChatAddInfo(825,"2000002424428809");//查询微信开户意愿申请状态
             // ConfiemMer(1833);//新建商户
-            // QueryMerchantStatus(1833);//新建商户查询状态
+            QueryMerchantStatus(3197);//新建商户查询状态
             // GetTencentAddressInfo(112); //获取商户经纬坐标
             // ChangeMerchantCard(1);//商户修改银行卡
             // QueryChangeCardStatus(1874);//商户修改银行卡状态
@@ -374,13 +378,141 @@ namespace MySystem
         public void QueryMerchantStatus(int MerchantId)
         {
             WebCMSEntities db = new WebCMSEntities();
-            MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId);
+            MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId);
 
             var BrhCode = HaodaUnionParam.BrhCode;
-            if (AddInfo.BrandId == 1) BrhCode = HaodaParam.BrhCode;
-            var returnInfo = HaoDaHelper.Instance.QueryMerchantStatus(BrhCode, AddInfo.MchtNo);
-            // string result = HaoDaHelper.Instance.AddNewMerchant(AddNewMerchantSetUtil.SetValue(AddInfo));
-            db.Dispose();
+            if (merchantadd.BrandId == 1) BrhCode = HaodaParam.BrhCode;
+
+            //查询商户审核状态
+            var returnInfo = HaoDaHelper.Instance.QueryMerchantStatus(BrhCode, merchantadd.MchtNo, merchantadd.BrandId);
+            JsonData dic = JsonMapper.ToObject(returnInfo);
+            //审核成功(1- 待审核 2 -审核中 3 -审核被拒绝 4 -审核通过 6 -待复核)
+            if (dic["data"]["code"].ToString() == "4" && !string.IsNullOrEmpty(dic["data"]["storeNo"].ToString()) && !string.IsNullOrEmpty(dic["data"]["outMchtNo"].ToString()))
+            {
+                //查询商户是否存在
+                if (merchantadd != null)
+                {
+                    MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
+                    merchantadd.StoreNo = dic["data"]["storeNo"].ToString();
+                    merchantadd.HdStatus = 1; //0 待审核 1 已通过 2 已开通分账 3 已添加接收方
+                    merchantadd.OutMchtNo = dic["data"]["outMchtNo"].ToString();
+                    if (merchantadd.BrandId == 1)
+                    {
+                        merchantadd.Status = 2;
+                        merchantadd.QueryCount = 2;
+
+                        merchant.Status = 2;
+                        merchant.QueryCount = 2;
+                    }
+                    else
+                    {
+                        if (merchant != null)
+                        {
+                            merchant.Status = 1;
+                        }
+                        //商户开通分账
+                        JsonData Info = JsonMapper.ToObject(HaoDaHelper.Instance.OpenDivideAccounts(merchantadd.OutMchtNo, merchantadd.StoreNo, merchantadd.BrandId));
+                        //开通失败
+                        if (Info["resultCode"].ToString() == "0")
+                        {
+                            merchantadd.Status = -1;
+                            merchantadd.WeChatRemark = Info["errorDesc"].ToString();
+                        }
+                        //开通成功
+                        if (Info["resultCode"].ToString() == "1")
+                        {
+                            merchantadd.OpenAct = 1;//是否开通分账(1 是 0 否)
+                            merchantadd.HdStatus = 2; //0 待审核 1 已通过 2 已开通分账 3 已添加接收方
+                                                      //分账接收方签约
+                            JsonData Infos = JsonMapper.ToObject(HaoDaHelper.Instance.DivideAccountsSign(AppConfig.Haoda.AcctNo, merchantadd.OutMchtNo, merchantadd.StoreNo, merchantadd.BrandId));
+                            //失败
+                            if (Infos["resultCode"].ToString() == "0")
+                            {
+                                merchantadd.WeChatRemark = Infos["errorDesc"].ToString();
+                            }
+                            //成功
+                            else
+                            {
+                                merchantadd.HdStatus = 3; //0 待审核 1 已通过 2 已开通分账 3 已添加接收方
+                                if (!string.IsNullOrEmpty(merchantadd.ToAcctNo))
+                                {
+                                    if (!merchantadd.ToAcctNo.Contains("," + AppConfig.Haoda.AcctNo + ","))
+                                    {
+                                        merchantadd.ToAcctNo += "," + AppConfig.Haoda.AcctNo + ",";
+                                    }
+                                }
+                                else
+                                {
+                                    merchantadd.ToAcctNo += "," + AppConfig.Haoda.AcctNo + ",";
+                                }
+                                merchantadd.HdPassDate = DateTime.Now;
+                            }
+                        }
+
+                        //开户意愿申请
+                        RedisDbconn.Instance.AddList("AlipayForHaoDaQueue", MerchantId);
+                        RedisDbconn.Instance.AddList("WeChatForHaoDaQueue", MerchantId);
+                    }
+                    db.SaveChanges();
+
+                    //创客账号
+                    Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
+                    string pwd = merchantadd.MobilePhone.Substring(5);
+                    merchant.LoginPwd = function.MD532(pwd);
+                    Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
+                    if (info == null)
+                    {
+                        info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
+                        {
+                            LoginMobile = merchantadd.MobilePhone,
+                        }).Entity;
+                        db1.SaveChanges();
+                    }
+                    info.LoginPwd = function.MD532(pwd);
+                    db1.SaveChanges();
+                    Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
+                    if (infolink == null)
+                    {
+                        infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
+                        {
+                            LoginId = info.Id,
+                            MerchantId = merchantadd.Id,
+                            Kind = 2,
+                        }).Entity;
+                        db1.SaveChanges();
+                    }
+                    db1.Dispose();
+                }
+            }
+            //审核被拒绝
+            else if (dic["data"]["code"].ToString() == "3")
+            {
+                if (merchantadd != null)
+                {
+                    string WeChatRemark = dic["data"]["option"].ToString();
+                    if (WeChatRemark.Contains("租赁协议") && WeChatRemark.Contains("水电煤") && WeChatRemark.Contains("门头合影") && WeChatRemark.Contains("下载地址"))
+                    {
+                        WeChatRemark = "门头不一致需补充 “名称不一致说明函”";
+                    }
+                    if (WeChatRemark.Contains("盒伙人在门头合影"))
+                    {
+                        WeChatRemark = "门头不一致需补充 “名称不一致说明函”";
+                    }
+                    if (WeChatRemark.Contains("不支持跨商户进件"))
+                    {
+                        WeChatRemark = "该商户已注册,错误指令【404】";
+                    }
+                    merchantadd.WeChatRemark = WeChatRemark;
+                    merchantadd.Status = -1;
+                    MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
+                    if (merchant != null)
+                    {
+                        merchant.Status = -1;
+                    }
+                    db.SaveChanges();
+                }
+                db.Dispose();
+            }
         }
 
         //提交支付宝开户意愿申请单