|
@@ -112,9 +112,11 @@ namespace MySystem
|
|
|
order.ReturnFlag = 1;
|
|
|
db.SaveChanges();
|
|
|
DiviMoney = DiviMoney / DiviPersons;
|
|
|
- DiviMoney = Math.Round(DiviMoney, 2);
|
|
|
+ DiviMoney = PublicFunction.NumberFormat(DiviMoney);
|
|
|
List<int> deletes = new List<int>();
|
|
|
long CurDiviPersons = DiviPersons;
|
|
|
+ int DiviTimes = 0;
|
|
|
+ int CheckTime = 0;
|
|
|
long QueueCount = RedisDbconn.Instance.Count("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId);
|
|
|
long CurQueueCount = QueueCount;
|
|
|
if (CurDiviPersons >= CurQueueCount)
|
|
@@ -151,30 +153,51 @@ namespace MySystem
|
|
|
function.WriteLog("GetMoney:" + GetMoney, "返现逻辑日志");
|
|
|
if (GetMoney > minProfit)
|
|
|
{
|
|
|
- suborder.CurDivi += GetMoney;
|
|
|
MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == suborder.MerchantId) ?? new MerchantAddInfo();
|
|
|
|
|
|
//聚合支付退款
|
|
|
bool BackStatus = false;
|
|
|
|
|
|
//拆单算法
|
|
|
- int CheckTime = SplitOrder(suborder.PayMoney,subset.MinPayMoney);
|
|
|
- if(CheckTime > 0)
|
|
|
+ string MerchantList = function.CheckNull(RedisDbconn.Instance.Get<string>("SplitOrderMerchants"));
|
|
|
+ string SplitOrderStatus = function.CheckNull(RedisDbconn.Instance.Get<string>("SplitOrderStatus"));
|
|
|
+ if(MerchantList.Contains("," + suborder.MerchantId + ",") || SplitOrderStatus == "1")
|
|
|
{
|
|
|
- GetMoney = GetMoney * CheckTime;
|
|
|
- db.SaveChanges();
|
|
|
- CurDiviPersons -= CheckTime - 1;
|
|
|
+ CheckTime = SplitOrder(suborder.PayMoney,subset.MinPayMoney);
|
|
|
+ function.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
|
|
|
+ if(CheckTime > 0)
|
|
|
+ {
|
|
|
+ if(subset.DiviPersons - DiviTimes < CheckTime)
|
|
|
+ {
|
|
|
+ CheckTime = subset.DiviPersons - DiviTimes;
|
|
|
+ }
|
|
|
+ function.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
|
|
|
+ GetMoney = GetMoney * CheckTime;
|
|
|
+ db.SaveChanges();
|
|
|
+ function.WriteLog("CurDiviPersons1:" + CurDiviPersons, "返现逻辑日志");
|
|
|
+ if(RedisDbconn.Instance.Count("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId) >= subset.DiviPersons)
|
|
|
+ {
|
|
|
+ CurDiviPersons -= CheckTime - 1;
|
|
|
+ }
|
|
|
+ function.WriteLog("CurDiviPersons2:" + CurDiviPersons, "返现逻辑日志");
|
|
|
+ decimal CheckMoney = suborder.MaxDivi - suborder.CurDivi;
|
|
|
+ if (GetMoney >= CheckMoney)
|
|
|
+ {
|
|
|
+ GetMoney = CheckMoney;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ suborder.CurDivi += GetMoney;
|
|
|
|
|
|
decimal RefundAmount = GetMoney * 100;
|
|
|
- RefundAmount = Math.Round(RefundAmount, 2);
|
|
|
- if(!orderids.Contains(suborder.Id))
|
|
|
+ RefundAmount = PublicFunction.NumberFormat(RefundAmount, 0);
|
|
|
+ if(!orderids.Contains(suborder.Id) && DiviTimes < subset.DiviPersons)
|
|
|
{
|
|
|
function.WriteLog("请求退款接口", "返现逻辑日志");
|
|
|
string RefundNo = "HDTK" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
|
|
|
- // var info = HaoDaHelper.Instance.AggregatedPayRefund(merchantAdd.OutMchtNo, merchantAdd.StoreNo, RefundNo, suborder.OrderNo, RefundAmount.ToString("f0"));
|
|
|
- // if(info.Contains("\"resultCode\":\"1\"") && info.Contains("\"tradeStatus\":\"2\""))
|
|
|
- // {
|
|
|
+ var info = HaoDaHelper.Instance.AggregatedPayRefund(merchantAdd.OutMchtNo, merchantAdd.StoreNo, RefundNo, suborder.OrderNo, RefundAmount.ToString("f0"));
|
|
|
+ if(info.Contains("\"resultCode\":\"1\"") && info.Contains("\"tradeStatus\":\"2\""))
|
|
|
+ {
|
|
|
db.ConsumerProfit.Add(new ConsumerProfit()
|
|
|
{
|
|
|
CreateDate = DateTime.Now,
|
|
@@ -190,9 +213,10 @@ namespace MySystem
|
|
|
});
|
|
|
db.SaveChanges();
|
|
|
BackStatus = true;
|
|
|
- // }
|
|
|
- // function.WriteLog("接口返回:" + info, "返现逻辑日志");
|
|
|
+ }
|
|
|
+ function.WriteLog("接口返回:" + info, "返现逻辑日志");
|
|
|
orderids.Add(suborder.Id);
|
|
|
+ DiviTimes += CheckTime;
|
|
|
}
|
|
|
|
|
|
if(BackStatus)
|
|
@@ -218,6 +242,7 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.MaxDivi + "\"}");
|
|
|
}
|
|
|
+ function.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
|
|
|
RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
|
|
|
}
|
|
|
}
|
|
@@ -236,6 +261,7 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.MaxDivi + "\"}");
|
|
|
}
|
|
|
+ function.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
|
|
|
RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
|
|
|
CurDiviPersons += 1;
|
|
|
function.WriteLog("出局:CurDiviPersons:" + CurDiviPersons, "返现逻辑日志");
|