Commit 7455fbb4 authored by liudong1993's avatar liudong1993

1

parent e21aa283
......@@ -179,6 +179,10 @@ INNER JOIN rb_member_user mu on mu.Id=oas.UserId
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.Type)}={dmodel.Type}";
}
if (dmodel.ReOrderStatus > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)}={(int)dmodel.ReOrderStatus}";
}
if (!string.IsNullOrEmpty(dmodel.ReOrderNo))
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.ReOrderNo)} like '%{dmodel.ReOrderNo}%'";
......
......@@ -488,6 +488,22 @@ GROUP BY oc.OrderId";
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
/// <summary>
/// 获取已退款 待制单的订单列表
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<RB_Goods_Order_Extend> GetOrderRefunedCreateList(int tenantId, int mallBaseId, string startTime, string endTime)
{
string sql = $@"SELECT * FROM rb_goods_order o
WHERE o.TenantId={tenantId} and o.MallBaseId={mallBaseId} and o.OrderStatus = 7 AND o.PaymentTime IS NOT NULL AND DATE_FORMAT(o.PaymentTime,'%Y-%m-%d') <> DATE_FORMAT(o.CancelTime,'%Y-%m-%d') AND o.CancelTime>='{startTime}' AND o.CancelTime <'{endTime}'";
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
#region 数据统计-数据概况
/// <summary>
/// 数据概况
......
......@@ -181,5 +181,72 @@ namespace Test.Helper
}
}
#region 处理徐总说的二级返佣
/// <summary>
/// 返佣
/// </summary>
public static void SetOrderTwoCommissionData()
{
string citySql = $@"
SELECT o.OrderId,o.OrderNo,od.Id AS DetailId,o.UserId,u.`Name`,o.Income,o.Consignee,o.Mobile,o.ShoppingAddress,od.GoodsName,od.Specification,od.Final_Price,
od.Number,
CASE WHEN d1.Id IS NULL THEN d2.OneCommission * od.Number ELSE d1.OneCommission * od.Number END AS OneCommission,
CASE WHEN d1.Id IS NULL THEN d2.TwoCommission * od.Number ELSE d1.TwoCommission * od.Number END AS TwoCommission
FROM rb_goods_order o
INNER JOIN rb_goods_orderdetail od on o.OrderId=od.OrderId
INNER JOIN rb_member_user u on o.UserId = u.Id
LEFT JOIN rb_goods_distributioncommission d1 on d1.GoodsId=od.GoodsId AND d1.DistributorGrade=74 and d1.SpecificationSort=od.SpecificationSort
LEFT JOIN rb_goods_distributioncommission d2 on d2.GoodsId=od.GoodsId AND d2.DistributorGrade=74 and d2.SpecificationSort=''
WHERE o.OrderId in(
SELECT t.OrderId FROM(
SELECT cm.OrderId,cm.UserId FROM rb_goods_ordercommission cm WHERE CommissionState = 2 AND TenantId =1 AND MallBaseId =1
GROUP BY cm.OrderId,cm.UserId
)t GROUP BY t.OrderId HAVING COUNT(0)=1)
AND o.OrderId >=34137 and o.OrderId <=80622 and o.OrderId <> 63803 AND o.OrderId <> 63839
AND o.UserId in(
SELECT Id FROM rb_member_user WHERE SuperiorId BETWEEN 1 and 20
) AND o.UserId <> 39370
ORDER BY o.OrderId ASC ";
DataSet OrderCommList = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, citySql, null);
string Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
foreach (DataRow item in OrderCommList.Tables[0].Rows)
{
int OrderId = Convert.ToInt32(item["OrderId"].ToString());
int DetailId = Convert.ToInt32(item["DetailId"].ToString());
int UserId = Convert.ToInt32(item["UserId"].ToString());
decimal TwoCommission = Convert.ToDecimal(item["TwoCommission"].ToString());
if (TwoCommission > 0)
{
//插入返佣
string InertComm = $@"
insert into rb_goods_ordercommission (OrderId,OrderDetailId,UserId,Grade,Commission,IsGoodsDistribution,CommissionState,Remark,TenantId,MallBaseId,CreateDate,UpdateDate,Type,IsRemit)
values ({OrderId},{DetailId},{UserId},2,{TwoCommission},2,2,'补充二级返佣',1,1,'{Time}','{Time}',1,2)
";
var InertCommResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, InertComm, null);
if (InertCommResult > 0)
{
string UserComm = $@"update rb_distributor_info set TotalCommission=TotalCommission+{TwoCommission},CommissionWithdrawal=CommissionWithdrawal+{TwoCommission}";
var UserCommResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, UserComm, null);
if (UserCommResult <= 0)
{
Console.WriteLine("更新用户返佣失败 OrderId:" + OrderId + ",DetailId:" + DetailId + ",UserId:" + UserId + " TwoCommission:" + TwoCommission);
}
}
else
{
Console.WriteLine("返佣插入失败 OrderId:" + OrderId + ",DetailId:" + DetailId + ",UserId:" + UserId + " TwoCommission:" + TwoCommission);
}
}
else
{
Console.WriteLine("OrderId:" + OrderId + ",DetailId:" + DetailId + ",UserId:" + UserId + " TwoCommission:" + TwoCommission);
}
}
}
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment