|
@@ -162,6 +162,7 @@ namespace MySystem
|
|
servicefee = servicefee * 100;
|
|
servicefee = servicefee * 100;
|
|
string seviceAmount = servicefee.ToString("f0"); //服务费
|
|
string seviceAmount = servicefee.ToString("f0"); //服务费
|
|
string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amount.ToString().Split('.')[0], seviceAmount));
|
|
string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amount.ToString().Split('.')[0], seviceAmount));
|
|
|
|
+ order.DivideLog = "请求分账日志:" + result;
|
|
if(result.Contains("\"resultCode\":\"0\"") && (result.Contains("分账金额不足") || result.Contains("不存在")))
|
|
if(result.Contains("\"resultCode\":\"0\"") && (result.Contains("分账金额不足") || result.Contains("不存在")))
|
|
{
|
|
{
|
|
Status = 1;
|
|
Status = 1;
|
|
@@ -197,5 +198,75 @@ namespace MySystem
|
|
Thread.Sleep(2000);
|
|
Thread.Sleep(2000);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //触发分账接口
|
|
|
|
+ public void StartDivi()
|
|
|
|
+ {
|
|
|
|
+ Thread th = new Thread(ListenDivi);
|
|
|
|
+ th.IsBackground = true;
|
|
|
|
+ th.Start();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void ListenDivi()
|
|
|
|
+ {
|
|
|
|
+ bool op = true;
|
|
|
|
+ while (op)
|
|
|
|
+ {
|
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("AddHdDiviQueue");
|
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ int id = int.Parse(function.CheckInt(content));
|
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == id);
|
|
|
|
+ if (order != null)
|
|
|
|
+ {
|
|
|
|
+ MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
|
|
|
|
+ MerchantParamSet set = db.MerchantParamSet.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantParamSet();
|
|
|
|
+ if (order.IsAct == 1 && order.PayMoney >= set.MinPayMoney)
|
|
|
|
+ {
|
|
|
|
+ MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
|
|
|
|
+ //发起分账
|
|
|
|
+ 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 hdfee = 0.0038M * order.PayMoney;
|
|
|
|
+ hdfee = decimal.Parse(hdfee.ToString("f2"));
|
|
|
|
+ decimal servicefee = 0.01M * order.PayMoney;
|
|
|
|
+ servicefee = decimal.Parse(servicefee.ToString("f2"));
|
|
|
|
+ decimal amount = order.PayMoney - hdfee - servicefee;
|
|
|
|
+ amount = amount * 100; //金额(分)
|
|
|
|
+ servicefee = servicefee * 100;
|
|
|
|
+ string seviceAmount = servicefee.ToString("f0"); //服务费
|
|
|
|
+ string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amount.ToString().Split('.')[0], seviceAmount));
|
|
|
|
+ order.DivideLog = "请求分账日志:" + result;
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.Dispose();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "补分账异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Thread.Sleep(2000);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|