Commit 904eb13d authored by liudong1993's avatar liudong1993

售后时间

parent 109fdae5
...@@ -6205,6 +6205,18 @@ namespace Mall.Module.Product ...@@ -6205,6 +6205,18 @@ namespace Mall.Module.Product
Type = 1 Type = 1
}); });
if (type == 6) if (type == 6)
{
bool IsUpdateCommission = true;
var mallModel = mallBaseRepository.GetEntity(mallBaseId);
if (mallModel!=null && mallModel.AfterTime > 0)
{
var OrderM = goods_OrderRepository.GetEntity(orderModel.OrderId);
if (OrderM != null && OrderM.ReceivingTime.HasValue && OrderM.ReceivingTime.Value.AddDays(mallModel.AfterTime) > DateTime.Now)
{
IsUpdateCommission = false;
}
}
if (IsUpdateCommission)
{ {
//更新返佣为已返佣 //更新返佣为已返佣
var ocList = goods_OrderCommissionRepository.GetList(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderModel.OrderId }); var ocList = goods_OrderCommissionRepository.GetList(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderModel.OrderId });
...@@ -6253,6 +6265,7 @@ namespace Mall.Module.Product ...@@ -6253,6 +6265,7 @@ namespace Mall.Module.Product
} }
} }
} }
}
//积分赠送 //积分赠送
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = orderModel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId }); var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = orderModel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
if (dlist.Any()) if (dlist.Any())
......
...@@ -270,5 +270,40 @@ left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and o ...@@ -270,5 +270,40 @@ left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and o
string sql = $@"SELECT * FROM rb_goods_ordercommission oc WHERE oc.CommissionState=2 and oc.UserId={UserId} and oc.OrderId in ({OrderIds}) and oc.IsRemit = 1"; string sql = $@"SELECT * FROM rb_goods_ordercommission oc WHERE oc.CommissionState=2 and oc.UserId={UserId} and oc.OrderId in ({OrderIds}) and oc.IsRemit = 1";
return Get<RB_Goods_OrderCommission_Extend>(sql).ToList(); return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
} }
/// <summary>
/// 获取所有订单已完成 未结算佣金的订单
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_OrderCommission_Extend> GetAllOrderCompletedNoCommissionForOrder(int tenantId, int mallBaseId)
{
string sql = $@"SELECT oc.OrderId FROM rb_goods_ordercommission oc
INNER JOIN rb_goods_orderdetail od on oc.OrderDetailId = od.Id
INNER JOIN rb_goods_order o on oc.OrderId = o.OrderId
left join rb_goods_orderaftersale oa on oc.OrderId = oa.OrderId and oc.OrderDetailId = oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (1,2,3,4,5)
where oc.TenantId={tenantId} and oc.MallBaseId={mallBaseId} and oc.CommissionState =1 and o.OrderStatus =5 and o.Recycled=2 and o.Status=0 and oa.ReOrderId is null
GROUP BY oc.OrderId";
return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
}
/// <summary>
/// 获取所有订单已完成 未结算佣金的订单
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_OrderCommission_Extend> GetAllOrderCompletedNoCommissionList(int tenantId, int mallBaseId)
{
string sql = $@"SELECT oc.* FROM rb_goods_ordercommission oc
INNER JOIN rb_goods_orderdetail od on oc.OrderDetailId = od.Id
INNER JOIN rb_goods_order o on oc.OrderId = o.OrderId
left join rb_goods_orderaftersale oa on oc.OrderId = oa.OrderId and oc.OrderDetailId = oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (1,2,3,4,5)
where oc.TenantId={tenantId} and oc.MallBaseId={mallBaseId} and oc.CommissionState =1 and o.OrderStatus =5 and o.Recycled=2 and o.Status=0 and oa.ReOrderId is null
";
return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
}
} }
} }
...@@ -482,8 +482,8 @@ GROUP BY o.OrderId)t"; ...@@ -482,8 +482,8 @@ GROUP BY o.OrderId)t";
string sql = $@"SELECT oc.OrderId FROM rb_goods_ordercommission oc string sql = $@"SELECT oc.OrderId FROM rb_goods_ordercommission oc
INNER JOIN rb_goods_orderdetail od on oc.OrderDetailId = od.Id INNER JOIN rb_goods_orderdetail od on oc.OrderDetailId = od.Id
INNER JOIN rb_goods_order o on oc.OrderId = o.OrderId INNER JOIN rb_goods_order o on oc.OrderId = o.OrderId
left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (1,2,3,4,5)
where oc.TenantId=1 and oc.MallBaseId=1 and oc.CommissionState =1 and o.OrderStatus =5 and o.Recycled=2 and oa.ReOrderId is null where oc.TenantId={tenantId} and oc.MallBaseId={mallBaseId} and oc.CommissionState =1 and o.OrderStatus =5 and o.Recycled=2 and oa.ReOrderId is null
GROUP BY oc.OrderId"; GROUP BY oc.OrderId";
return Get<RB_Goods_Order_Extend>(sql).ToList(); return Get<RB_Goods_Order_Extend>(sql).ToList();
} }
......
...@@ -63,6 +63,10 @@ namespace Mall.WindowsService.Helper ...@@ -63,6 +63,10 @@ namespace Mall.WindowsService.Helper
Module.FinanceModule.AutoReceivingOrder(); Module.FinanceModule.AutoReceivingOrder();
LogHelper.Write("AutoReceivingOrder=====End"); LogHelper.Write("AutoReceivingOrder=====End");
} }
LogHelper.Write("AutoAfterSaleOrderSendCommission=====Start");
Module.FinanceModule.AutoAfterSaleOrderSendCommission();
LogHelper.Write("AutoAfterSaleOrderSendCommission=====End");
Interlocked.Exchange(ref inTimer2, 0); Interlocked.Exchange(ref inTimer2, 0);
} }
} }
......
...@@ -577,7 +577,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -577,7 +577,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
TenantId = item.TenantId TenantId = item.TenantId
}); });
//自动确认订单 //自动确认订单
SetOrderOperation(qitem, 6, "", 0, "", item.TenantId, item.MallBaseId); SetOrderOperation(qitem, 6, "", 0, "", item.TenantId, item.MallBaseId, item.AfterTime);
} }
} }
} }
...@@ -602,8 +602,9 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -602,8 +602,9 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
/// <param name="address"></param> /// <param name="address"></param>
/// <param name="tenantId"></param> /// <param name="tenantId"></param>
/// <param name="mallBaseId"></param> /// <param name="mallBaseId"></param>
/// <param name="afterTime">售后时间</param>
/// <returns></returns> /// <returns></returns>
public static bool SetOrderOperation(RB_Goods_Order_Extend orderModel, int type, string remark, decimal income, string address, int tenantId, int mallBaseId) public static bool SetOrderOperation(RB_Goods_Order_Extend orderModel, int type, string remark, decimal income, string address, int tenantId, int mallBaseId,int afterTime)
{ {
Dictionary<string, object> keyValues = new Dictionary<string, object>() { }; Dictionary<string, object> keyValues = new Dictionary<string, object>() { };
switch (type) switch (type)
...@@ -682,6 +683,16 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -682,6 +683,16 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
Type = 1 Type = 1
}); });
if (type == 6) if (type == 6)
{
bool IsUpdateCommission = true;
if (afterTime > 0)
{
var omodel = goods_OrderRepository.GetEntity(orderModel.OrderId);
if (omodel!=null && omodel.ReceivingTime.HasValue && omodel.ReceivingTime.Value.AddDays(afterTime) > DateTime.Now) {
IsUpdateCommission = false;
}
}
if (IsUpdateCommission)
{ {
//更新返佣为已返佣 //更新返佣为已返佣
var ocList = goods_OrderCommissionRepository.GetList(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderModel.OrderId }); var ocList = goods_OrderCommissionRepository.GetList(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderModel.OrderId });
...@@ -730,6 +741,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -730,6 +741,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
} }
} }
} }
}
//积分赠送 //积分赠送
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = orderModel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId }); var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = orderModel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
if (dlist.Any()) if (dlist.Any())
...@@ -787,7 +799,6 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -787,7 +799,6 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
#endregion #endregion
#region 售后时间到了发放佣金 #region 售后时间到了发放佣金
/// <summary> /// <summary>
...@@ -802,22 +813,138 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -802,22 +813,138 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
foreach (var item in list) foreach (var item in list)
{ {
//查询该商户下 所有已完成 未发放佣金的单子 //查询该商户下 所有已完成 未发放佣金的单子
var CommList = goods_OrderRepository.GetAllOrderCompletedNoCommission(item.TenantId, item.MallBaseId); var OrderList = goods_OrderCommissionRepository.GetAllOrderCompletedNoCommissionForOrder(item.TenantId, item.MallBaseId);
var CommList = goods_OrderCommissionRepository.GetAllOrderCompletedNoCommissionList(item.TenantId, item.MallBaseId);
foreach (var Order in OrderList) {
var omodel = goods_OrderRepository.GetEntity(Order.OrderId);
if (omodel.ReceivingTime.HasValue) {
if (item.AfterTime > 0) if (item.AfterTime > 0)
{ {
//判断是否到了时间 //判断是否到了时间
if (omodel.ReceivingTime.Value.AddDays(item.AfterTime) < DateTime.Now) {
//结算佣金
//更新返佣为已返佣
var ocList = CommList.Where(x => x.OrderId == Order.OrderId).ToList();
if (ocList.Any())
{
foreach (var qitem in ocList)
{
try
{
//查询是否有申请退款
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = qitem.OrderDetailId, Type = 1, MallBaseId = item.MallBaseId, TenantId = item.TenantId });
if (!afterSaleList.Any())
{
//获取分销商信息
var disInfo = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = qitem.UserId, TenantId = item.TenantId, MallBaseId = item.MallBaseId }).FirstOrDefault();
if (disInfo != null && disInfo.AuditStatus == DistributorAuditStatusEnum.Audited)
{
//更新分销商佣金
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_Distributor_Info_Extend.TotalCommission),(disInfo.TotalCommission ?? 0) + (qitem.Commission ?? 0)},
{ nameof(RB_Distributor_Info_Extend.CommissionWithdrawal),(disInfo.CommissionWithdrawal ?? 0) + (qitem.Commission ?? 0)},
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=disInfo.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag1 = distributor_InfoRepository.Update(keyValues2, wheres2);
if (flag1)
{
//更新返佣状态
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderCommission_Extend.CommissionState),2},
{ nameof(RB_Goods_OrderCommission_Extend.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderCommission_Extend.Id),
FiledValue=qitem.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_OrderCommissionRepository.Update(keyValues1, wheres1);
}
}
}
}
catch (Exception ex)
{
Helper.LogHelper.Write("AutoAfterSaleOrderSendCommission: OrderId=" + Order.OrderId + " 错误:" + ex.Message);
}
}
}
}
} }
else else
{ {
//直接结算佣金 //直接结算佣金
//更新返佣为已返佣
var ocList = CommList.Where(x => x.OrderId == Order.OrderId).ToList();
if (ocList.Any())
{
foreach (var qitem in ocList)
{
try
{
//查询是否有申请退款
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = qitem.OrderDetailId, Type = 1, MallBaseId = item.MallBaseId, TenantId = item.TenantId });
if (!afterSaleList.Any())
{
//获取分销商信息
var disInfo = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = qitem.UserId, TenantId = item.TenantId, MallBaseId = item.MallBaseId }).FirstOrDefault();
if (disInfo != null && disInfo.AuditStatus == DistributorAuditStatusEnum.Audited)
{
//更新分销商佣金
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_Distributor_Info_Extend.TotalCommission),(disInfo.TotalCommission ?? 0) + (qitem.Commission ?? 0)},
{ nameof(RB_Distributor_Info_Extend.CommissionWithdrawal),(disInfo.CommissionWithdrawal ?? 0) + (qitem.Commission ?? 0)},
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=disInfo.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag1 = distributor_InfoRepository.Update(keyValues2, wheres2);
if (flag1)
{
//更新返佣状态
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderCommission_Extend.CommissionState),2},
{ nameof(RB_Goods_OrderCommission_Extend.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderCommission_Extend.Id),
FiledValue=qitem.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_OrderCommissionRepository.Update(keyValues1, wheres1);
}
}
}
}
catch (Exception ex)
{
Helper.LogHelper.Write("AutoAfterSaleOrderSendCommission: OrderId=" + Order.OrderId + " 错误:" + ex.Message);
}
}
}
}
}
} }
} }
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Helper.LogHelper.Write("AutoCancelOrder:" + ex.Message); Helper.LogHelper.Write("AutoAfterSaleOrderSendCommission:" + ex.Message);
return false; return false;
} }
} }
......
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