|
@@ -55,7 +55,7 @@ namespace MySystem
|
|
|
JsonData jsonObj = JsonMapper.ToObject(content);
|
|
|
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 HdOrderNo = jsonObj["orderNo"].ToString();
|
|
|
string TradeNo = "";
|
|
@@ -63,21 +63,21 @@ namespace MySystem
|
|
|
{
|
|
|
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();
|
|
|
ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 0);
|
|
|
if (order != null)
|
|
|
{
|
|
|
- LogHelper.Instance.WriteLog("找到订单", "微信支付回调监控");
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "找到订单", "微信支付回调监控");
|
|
|
order.Status = 1;
|
|
|
order.UpdateDate = DateTime.Now;
|
|
|
order.PayMoney = order.PayMoney;
|
|
|
order.MaxDivi = order.MaxDivi;
|
|
|
order.SeoTitle = HdOrderNo;
|
|
|
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();
|
|
|
MerchantAddInfo addinfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
|
|
|
if (addinfo.Status == 1 && order.PayMode == 2)
|
|
@@ -103,7 +103,7 @@ namespace MySystem
|
|
|
}
|
|
|
}
|
|
|
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);
|
|
|
if (check != null)
|
|
|
{
|
|
@@ -114,7 +114,7 @@ namespace MySystem
|
|
|
order.QueryCount = 1;
|
|
|
}
|
|
|
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();
|
|
|
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();
|
|
|
- LogHelper.Instance.WriteLog("执行完毕", "微信支付回调监控");
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "执行完毕", "微信支付回调监控");
|
|
|
+
|
|
|
+ //发送订单到客小爽MQ
|
|
|
+ OrderMessageHelper.SendOrderMsg(order);
|
|
|
}
|
|
|
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();
|
|
|
- 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();
|
|
|
//发起分账
|
|
|
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();
|