|
|
@@ -66,7 +66,7 @@ namespace MySystem
|
|
|
|
|
|
public void ReturnStat(string orderidstring, int PayMode)
|
|
|
{
|
|
|
- function.WriteLog("开始返现:" + orderidstring, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("开始返现:" + orderidstring, "返现逻辑日志");
|
|
|
int OrderId = int.Parse(function.CheckInt(orderidstring));
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
using (var tran = db.Database.BeginTransaction())
|
|
|
@@ -78,7 +78,7 @@ namespace MySystem
|
|
|
{
|
|
|
decimal PayMoney = order.PayMoney;
|
|
|
int MerchantId = order.MerchantId;
|
|
|
- function.WriteLog("MerchantId:" + MerchantId, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("MerchantId:" + MerchantId, "返现逻辑日志");
|
|
|
MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
|
|
|
if (merchant != null)
|
|
|
{
|
|
|
@@ -102,12 +102,12 @@ namespace MySystem
|
|
|
// decimal TotalActual = 0;
|
|
|
if (IsAll == 0 && PayMoney >= MinPayMoney && GetPercent < 1)
|
|
|
{
|
|
|
- function.WriteLog("活动开启", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("活动开启", "返现逻辑日志");
|
|
|
// PayMoney * (1 - 0.1 - 0.0038 - 0.01);
|
|
|
decimal DiviMoney = PayMoney * (1 - GetPercent - cusumerFeePercent - profitPercent);
|
|
|
if (DiviMoney > 0)
|
|
|
{
|
|
|
- function.WriteLog("返现队列开始", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("返现队列开始", "返现逻辑日志");
|
|
|
RedisDbconn.Instance.AddRightList("ConsumerOrdersHd:Divi:" + PayMode + ":" + order.MerchantId, order);
|
|
|
order.ReturnFlag = 1;
|
|
|
db.SaveChanges();
|
|
|
@@ -130,27 +130,27 @@ namespace MySystem
|
|
|
|
|
|
// 减去自己付的订单
|
|
|
List<int> orderids = new List<int>();
|
|
|
- function.WriteLog("人数:" + CurDiviPersons, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("人数:" + CurDiviPersons, "返现逻辑日志");
|
|
|
while (CurDiviPersons > 0)
|
|
|
{
|
|
|
ConsumerOrders suborder = RedisDbconn.Instance.RPopLPush<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, "ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId);
|
|
|
if (suborder != null)
|
|
|
{
|
|
|
decimal TmpCurDivi = suborder.CurDivi;
|
|
|
- function.WriteLog("返现对象订单:" + suborder.Id, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("返现对象订单:" + suborder.Id, "返现逻辑日志");
|
|
|
MerchantParamSet subset = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(suborder.SeoDescription);
|
|
|
int subProfitDays = subset.ProfitDays; //分红期限(天)
|
|
|
bool IsOut = suborder.UpdateDate.Value.AddDays(subProfitDays) < DateTime.Now ? true : false;
|
|
|
if (suborder.CurDivi < suborder.MaxDivi && suborder.MaxDivi - suborder.CurDivi >= 0.01M && !IsOut)
|
|
|
{
|
|
|
- function.WriteLog("没出局:" + suborder.CurDivi + "--" + suborder.MaxDivi, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("没出局:" + suborder.CurDivi + "--" + suborder.MaxDivi, "返现逻辑日志");
|
|
|
//如果没过期并且当前退款金额没超过最大退款金额,就执行
|
|
|
decimal GetMoney = suborder.MaxDivi - suborder.CurDivi;
|
|
|
if (GetMoney >= DiviMoney)
|
|
|
{
|
|
|
GetMoney = DiviMoney;
|
|
|
}
|
|
|
- function.WriteLog("GetMoney:" + GetMoney, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("GetMoney:" + GetMoney, "返现逻辑日志");
|
|
|
if (GetMoney > minProfit)
|
|
|
{
|
|
|
MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == suborder.MerchantId) ?? new MerchantAddInfo();
|
|
|
@@ -164,22 +164,22 @@ namespace MySystem
|
|
|
if (MerchantList.Contains("," + suborder.MerchantId + ",") || SplitOrderStatus == "1")
|
|
|
{
|
|
|
CheckTime = SplitOrder(suborder.PayMoney, subset.MinPayMoney);
|
|
|
- function.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
|
|
|
if (CheckTime > 0)
|
|
|
{
|
|
|
if (set.DiviPersons - DiviTimes < CheckTime)
|
|
|
{
|
|
|
CheckTime = set.DiviPersons - DiviTimes;
|
|
|
}
|
|
|
- function.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
|
|
|
GetMoney = GetMoney * CheckTime;
|
|
|
db.SaveChanges();
|
|
|
- function.WriteLog("CurDiviPersons1:" + CurDiviPersons, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("CurDiviPersons1:" + CurDiviPersons, "返现逻辑日志");
|
|
|
if (RedisDbconn.Instance.Count("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId) >= set.DiviPersons)
|
|
|
{
|
|
|
CurDiviPersons -= CheckTime - 1;
|
|
|
}
|
|
|
- function.WriteLog("CurDiviPersons2:" + CurDiviPersons, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("CurDiviPersons2:" + CurDiviPersons, "返现逻辑日志");
|
|
|
decimal CheckMoney = suborder.MaxDivi - suborder.CurDivi;
|
|
|
if (GetMoney >= CheckMoney)
|
|
|
{
|
|
|
@@ -193,7 +193,7 @@ namespace MySystem
|
|
|
RefundAmount = PublicFunction.NumberFormat(RefundAmount, 0);
|
|
|
if (!orderids.Contains(suborder.Id) && DiviTimes < set.DiviPersons)
|
|
|
{
|
|
|
- function.WriteLog("请求退款接口", "返现逻辑日志");
|
|
|
+ Utils.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"), merchantAdd.BrandId);
|
|
|
if (info.Contains("\"resultCode\":\"1\"") && info.Contains("\"tradeStatus\":\"2\""))
|
|
|
@@ -214,7 +214,7 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
BackStatus = true;
|
|
|
}
|
|
|
- function.WriteLog("接口返回:" + info, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("接口返回:" + info, "返现逻辑日志");
|
|
|
orderids.Add(suborder.Id);
|
|
|
DiviTimes += CheckTime;
|
|
|
}
|
|
|
@@ -223,10 +223,10 @@ namespace MySystem
|
|
|
{
|
|
|
merchant.ActCurrentAmount += Math.Round(GetMoney, 2); //活动已返金额
|
|
|
db.SaveChanges();
|
|
|
- function.WriteLog(suborder.CurDivi + ":" + suborder.MaxDivi, "返现逻辑日志");
|
|
|
+ Utils.WriteLog(suborder.CurDivi + ":" + suborder.MaxDivi, "返现逻辑日志");
|
|
|
if (suborder.CurDivi < suborder.MaxDivi)
|
|
|
{
|
|
|
- function.WriteLog("返现未达最大值继续", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("返现未达最大值继续", "返现逻辑日志");
|
|
|
// RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
|
|
|
RedisDbconn.Instance.SetList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, 0, suborder);
|
|
|
RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.CurDivi + "\"}");
|
|
|
@@ -234,7 +234,7 @@ namespace MySystem
|
|
|
else
|
|
|
{
|
|
|
suborder.CurDivi = TmpCurDivi;
|
|
|
- function.WriteLog("返现达最大值,出局", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("返现达最大值,出局", "返现逻辑日志");
|
|
|
ConsumerOrders editOrder = db.ConsumerOrders.FirstOrDefault(m => m.Id == suborder.Id);
|
|
|
if (editOrder != null)
|
|
|
{
|
|
|
@@ -242,7 +242,7 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.MaxDivi + "\"}");
|
|
|
}
|
|
|
- function.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
|
|
|
+ Utils.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
|
|
|
RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
|
|
|
}
|
|
|
}
|
|
|
@@ -253,7 +253,7 @@ namespace MySystem
|
|
|
{
|
|
|
//否者计算人数不计入退款名额
|
|
|
suborder.CurDivi = TmpCurDivi;
|
|
|
- function.WriteLog("返现达最大值,出局", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("返现达最大值,出局", "返现逻辑日志");
|
|
|
ConsumerOrders editOrder = db.ConsumerOrders.FirstOrDefault(m => m.Id == suborder.Id);
|
|
|
if (editOrder != null)
|
|
|
{
|
|
|
@@ -261,28 +261,28 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.MaxDivi + "\"}");
|
|
|
}
|
|
|
- function.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
|
|
|
+ Utils.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
|
|
|
RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
|
|
|
CurDiviPersons += 1;
|
|
|
- function.WriteLog("出局:CurDiviPersons:" + CurDiviPersons, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("出局:CurDiviPersons:" + CurDiviPersons, "返现逻辑日志");
|
|
|
}
|
|
|
}
|
|
|
CurDiviPersons -= 1;
|
|
|
QueueCount = RedisDbconn.Instance.Count("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId);
|
|
|
- function.WriteLog("当前队列数量:" + QueueCount, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("当前队列数量:" + QueueCount, "返现逻辑日志");
|
|
|
if (QueueCount == 0)
|
|
|
{
|
|
|
CurDiviPersons = 0;
|
|
|
}
|
|
|
}
|
|
|
- function.WriteLog("返现队列结束", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("返现队列结束", "返现逻辑日志");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- function.WriteLog("没找到订单:" + orderidstring, "返现逻辑日志");
|
|
|
+ Utils.WriteLog("没找到订单:" + orderidstring, "返现逻辑日志");
|
|
|
// Thread.Sleep(2000);
|
|
|
// List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId + "", 1, 100000);
|
|
|
// ConsumerOrders check = list.FirstOrDefault(m => m.Id == order.Id);
|
|
|
@@ -302,7 +302,7 @@ namespace MySystem
|
|
|
}
|
|
|
}
|
|
|
db.Dispose();
|
|
|
- function.WriteLog("结束返现:" + orderidstring + "\n\n\n", "返现逻辑日志");
|
|
|
+ Utils.WriteLog("结束返现:" + orderidstring + "\n\n\n", "返现逻辑日志");
|
|
|
}
|
|
|
|
|
|
//拆单算法
|
|
|
@@ -633,7 +633,7 @@ namespace MySystem
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "设置订单当前返现金额异常");
|
|
|
+ Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "设置订单当前返现金额异常");
|
|
|
}
|
|
|
}
|
|
|
}
|