|
@@ -131,7 +131,7 @@ namespace MySystem
|
|
{
|
|
{
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
DateTime checkDate = DateTime.Now.AddMinutes(-2);
|
|
DateTime checkDate = DateTime.Now.AddMinutes(-2);
|
|
- var list = db.ConsumerOrders.Select(m => new { m.Id, m.UpdateDate, m.Status, m.IsAct, m.PayMode }).Where(m => m.Status == 1 && m.IsAct == 1 && m.UpdateDate < checkDate).OrderBy(m => m.Id).Take(10).ToList();
|
|
|
|
|
|
+ var list = db.ConsumerOrders.Select(m => new { m.Id, m.SettleAmount, m.Status, m.IsAct, m.PayMode }).Where(m => m.Status == 1 && m.IsAct == 1 && m.SettleAmount > 0).OrderBy(m => m.Id).Take(10).ToList();
|
|
foreach (var sub in list)
|
|
foreach (var sub in list)
|
|
{
|
|
{
|
|
ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == sub.Id);
|
|
ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == sub.Id);
|
|
@@ -154,17 +154,20 @@ namespace MySystem
|
|
string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
|
|
string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
|
|
string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
|
|
string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
|
|
|
|
|
|
|
|
+ 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);
|
|
decimal hdfee = 0.0038M * order.PayMoney * (1 - set.GetPercent / 100 - 0.01M);
|
|
hdfee = decimal.Parse(hdfee.ToString("f2"));
|
|
hdfee = decimal.Parse(hdfee.ToString("f2"));
|
|
decimal servicefee = 0.01M * order.PayMoney - hdfee;
|
|
decimal servicefee = 0.01M * order.PayMoney - hdfee;
|
|
servicefee = decimal.Parse(servicefee.ToString("f2"));
|
|
servicefee = decimal.Parse(servicefee.ToString("f2"));
|
|
decimal amount = order.PayMoney*(1-0.0038M) - servicefee;
|
|
decimal amount = order.PayMoney*(1-0.0038M) - servicefee;
|
|
-
|
|
|
|
- // 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 = decimal.Parse(amount.ToString("f2"));
|
|
|
|
+ decimal otherAmt = settleAmount - servicefee - amount;
|
|
|
|
+ if(otherAmt != 0)
|
|
|
|
+ {
|
|
|
|
+ amount += otherAmt;
|
|
|
|
+ }
|
|
|
|
|
|
amount = amount * 100; //金额(分)
|
|
amount = amount * 100; //金额(分)
|
|
servicefee = servicefee * 100;
|
|
servicefee = servicefee * 100;
|
|
@@ -251,15 +254,26 @@ namespace MySystem
|
|
string acctNo = AppConfig.Haoda.AcctNo; //账户号,分账接收方账户号
|
|
string acctNo = AppConfig.Haoda.AcctNo; //账户号,分账接收方账户号
|
|
string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
|
|
string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
|
|
string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
|
|
string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
|
|
- decimal hdfee = 0.0038M * order.PayMoney;
|
|
|
|
|
|
+ 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"));
|
|
hdfee = decimal.Parse(hdfee.ToString("f2"));
|
|
- decimal servicefee = 0.01M * order.PayMoney;
|
|
|
|
|
|
+ decimal servicefee = 0.01M * order.SettleAmount - hdfee;
|
|
servicefee = decimal.Parse(servicefee.ToString("f2"));
|
|
servicefee = decimal.Parse(servicefee.ToString("f2"));
|
|
- decimal amount = order.PayMoney - hdfee - servicefee;
|
|
|
|
|
|
+ decimal amount = order.SettleAmount*(1-0.0038M) - servicefee;
|
|
|
|
+ amount = decimal.Parse(amount.ToString("f2"));
|
|
|
|
+ decimal otherAmt = divideAmt - servicefee - amount;
|
|
|
|
+ if(otherAmt != 0)
|
|
|
|
+ {
|
|
|
|
+ amount += otherAmt;
|
|
|
|
+ }
|
|
|
|
+
|
|
amount = amount * 100; //金额(分)
|
|
amount = amount * 100; //金额(分)
|
|
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 amountAmount = amount.ToString("f0");
|
|
|
|
+ string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amountAmount, seviceAmount));
|
|
order.DivideLog = "请求分账日志:" + result;
|
|
order.DivideLog = "请求分账日志:" + result;
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
@@ -277,5 +291,51 @@ namespace MySystem
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //监听支付结算订单
|
|
|
|
+ public void StartSettleOrder()
|
|
|
|
+ {
|
|
|
|
+ Thread th = new Thread(SettleOrderListen);
|
|
|
|
+ th.IsBackground = true;
|
|
|
|
+ th.Start();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void SettleOrderListen()
|
|
|
|
+ {
|
|
|
|
+ bool op = true;
|
|
|
|
+ while (op)
|
|
|
|
+ {
|
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("PartOrderQueue");
|
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ //{"id":137403,"mchtNo":"1494637","tradeMchtNo":"030500107115593","channelMchtNo":"030500107115593","orderNo":"G2231123C02179895853","channelOrderNo":"50231123B00032642694","txSubCode":31,"paymentType":2,"status":0,"partStatus":0,"partAmount":0,"payAmount":1000,"payServiceFee":4,"settleAmount":996,"totalPerkAmount":0,"payTime":"2023-11-23 23:36:05","algoDate":"2023-11-23 00:00:00","bizDate":"2023-11-23 00:00:00","storeNo":"21627867","deviceSn":" ","cupsNo":"ylzf","cardType":0,"notPartAmount":996,"realAmount":996}
|
|
|
|
+ if(content.Contains("\"settleAmount\""))
|
|
|
|
+ {
|
|
|
|
+ JsonData jsonObj = JsonMapper.ToObject(content);
|
|
|
|
+ string orderNo = jsonObj["orderNo"].ToString();
|
|
|
|
+ int settleAmount = int.Parse(function.CheckInt(jsonObj["settleAmount"].ToString()));
|
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.SeoTitle == orderNo);
|
|
|
|
+ if(order != null)
|
|
|
|
+ {
|
|
|
|
+ order.SettleAmount = settleAmount;
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+ db.Dispose();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "监听支付结算订单异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Thread.Sleep(2000);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|