增加用户结算
This commit is contained in:
1 parent
4dbcd6542e
commit
69bfe9ff05
6 files changed
+273
-47
No files matched your search
@@ -641,54 +641,59 @@ namespace KJD_Web.BLL.WXXD
|
||||
|
||||
if (flowDt != null && flowDt.Rows.Count > 0)
|
||||
{
|
||||
HashSet<string> deductedOrderSet = new HashSet<string>(); // type=23 已扣减的订单
|
||||
HashSet<string> giftsOrderSet = new HashSet<string>(); // type=34 礼物已扣减的订单
|
||||
List<long> settleIdLst = new List<long>(); // 参与结算的流水id
|
||||
List<user_payment_record_info> flowList = new List<user_payment_record_info>();//流水记录
|
||||
|
||||
foreach (DataRow row in flowDt.Rows)
|
||||
{
|
||||
int type = row["type"].ParseToInt();
|
||||
decimal amount = row["amount"].ParseToDecimal();
|
||||
decimal oem_amount = row["oem_amount"].ParseToDecimal();
|
||||
long flowId = row["id"].ParseToLong();
|
||||
settleIdLst.Add(flowId);
|
||||
|
||||
decimal itemAmount = 0m;
|
||||
if (type == 20)
|
||||
itemAmount = amount - 2.2m;
|
||||
else if (type == 26)
|
||||
itemAmount = amount - 2.5m;
|
||||
else if (type == 16)
|
||||
itemAmount = oem_amount;
|
||||
else if (type == 31)
|
||||
itemAmount = oem_amount;
|
||||
else if (type == 23)
|
||||
var item = new user_payment_record_info
|
||||
{
|
||||
// 同一个订单只能减少一次
|
||||
string orderId = row["order_id"].ParseToString();
|
||||
if (orderId.IsNullOrEmpty() || deductedOrderSet.Contains(orderId))
|
||||
continue;
|
||||
deductedOrderSet.Add(orderId);
|
||||
itemAmount = -(amount - 2.2m);
|
||||
}
|
||||
else if (type == 34)
|
||||
{
|
||||
// 同一个订单只能减少一次
|
||||
string orderId = row["order_id"].ParseToString();
|
||||
if (orderId.IsNullOrEmpty() || giftsOrderSet.Contains(orderId))
|
||||
continue;
|
||||
giftsOrderSet.Add(orderId);
|
||||
itemAmount = -oem_amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue; // 其他类型不计入
|
||||
}
|
||||
|
||||
total_amount += itemAmount;
|
||||
rebate_amount += itemAmount;
|
||||
|
||||
id = row["id"].ParseToLong(),
|
||||
type = row["type"].ParseToInt(),
|
||||
amount = row["amount"].ParseToDecimal(),
|
||||
oem_amount = row["oem_amount"].ParseToDecimal(),
|
||||
};
|
||||
flowList.Add(item);
|
||||
settleIdLst.Add(item.id);
|
||||
}
|
||||
var flowUniqueList = flowList
|
||||
.GroupBy(x => new
|
||||
{
|
||||
x.type,
|
||||
x.order_id
|
||||
})
|
||||
.Select(x => x.First())
|
||||
.ToList(); // 去重后的流水记录
|
||||
|
||||
List<user_payment_record_info> flowFilterList = new List<user_payment_record_info>();//去除后的流水记录 23-20 34-16
|
||||
foreach (var item in flowUniqueList)//去除退款返回
|
||||
{
|
||||
if (item.type == 20)
|
||||
{
|
||||
item.oem_amount = item.amount - 2.2m;
|
||||
}
|
||||
else if (item.type == 26)
|
||||
{
|
||||
item.oem_amount = item.amount - 2.5m;
|
||||
}
|
||||
if (item.type == 23)
|
||||
{
|
||||
var temp = flowFilterList.FirstOrDefault(a => a.type == 20 && a.order_id == item.order_id);
|
||||
if (temp != null)
|
||||
flowFilterList.Remove(temp);//23 移除 20
|
||||
}
|
||||
else if (item.type == 34)
|
||||
{
|
||||
item.oem_amount = -item.oem_amount;
|
||||
}
|
||||
flowFilterList.Add(item);
|
||||
}
|
||||
|
||||
decimal paymentAmount = flowFilterList.Sum(x => x.oem_amount);
|
||||
total_amount += paymentAmount;
|
||||
rebate_amount += paymentAmount;
|
||||
|
||||
|
||||
|
||||
if (settleIdLst.Count == 0)
|
||||
return 0;
|
||||
@@ -698,13 +703,13 @@ namespace KJD_Web.BLL.WXXD
|
||||
var flowRst = mySql.ExecuteAffectedRows(sql);
|
||||
if (!string.IsNullOrEmpty(mySql.Message) || flowRst <= 0)
|
||||
throw new Exception("标记流水结算失败");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//读取用户店铺续费
|
||||
sql = "SELECT id,delta_points FROM `wxxd`.`user_points_record` WHERE user_name IN ('" + string.Join("','", userLst) + "') AND option_type ='续费' AND settlement=0 ORDER BY id ASC";
|
||||
var userPointsDt = mySql.ExecuteDataTable(sql);
|
||||
|
||||
Reference in new issue
Block a user