Commit 362d4771 authored by liudong1993's avatar liudong1993

自动确认收货

parent 46fc1f02
......@@ -4253,6 +4253,9 @@ namespace Mall.Module.Product
TenantId = tenantId,
Type = 1
});
//收货 自动确认订单
SetOrderOperation(omodel.RefMapperTo<RB_Goods_Order_Extend>(), 6, "", 0, "", tenantId, mallBaseId);
}
return flag;
}
......@@ -6296,10 +6299,15 @@ namespace Mall.Module.Product
}
}
}
else if (type == 3) {
else if (type == 3)
{
//强制取消 (作废 使用新方法)
}
else if (type == 5) {
//收货 自动确认订单
SetOrderOperation(orderModel, 6, "", 0, "", tenantId, mallBaseId);
}
}
return flag;
}
......
......@@ -248,5 +248,15 @@ left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and o
return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
}
/// <summary>
/// 获取未提现的佣金列表
/// </summary>
/// <param name="UserId"></param>
/// <returns></returns>
public List<RB_Goods_OrderCommission_Extend> GetUserCommissionRemit(int UserId) {
string sql = $@"SELECT * FROM rb_goods_ordercommission oc WHERE oc.CommissionState=2 and oc.UserId={UserId} and oc.IsRemit <> 1";
return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
}
}
}
......@@ -4,6 +4,7 @@ using Mall.Common.Enum.Goods;
using Mall.Common.Enum.User;
using Mall.Common.Plugin;
using Mall.Model.Entity.Finance;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Finance;
using Mall.Model.Extend.Product;
using Mall.Model.Extend.User;
......@@ -73,6 +74,22 @@ namespace Mall.WindowsService.Module
/// 优惠卷
/// </summary>
private static RB_Member_CouponRepository member_CouponRepository = new RB_Member_CouponRepository();
/// <summary>
/// 返佣
/// </summary>
private static RB_Goods_OrderCommissionRepository goods_OrderCommissionRepository = new RB_Goods_OrderCommissionRepository();
/// <summary>
/// 售后订单列表
/// </summary>
private static RB_Goods_OrderAfterSaleRepository goods_OrderAfterSaleRepository = new RB_Goods_OrderAfterSaleRepository();
/// <summary>
/// 分销商
/// </summary>
private static RB_Distributor_InfoRepository distributor_InfoRepository = new RB_Distributor_InfoRepository();
/// <summary>
/// 订单明细
/// </summary>
private static RB_Goods_OrderDetailRepository goods_OrderDetailRepository = new RB_Goods_OrderDetailRepository();
#region 收入
......@@ -549,7 +566,6 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
bool flag = goods_OrderRepository.Update(keyValues, wheres);
if (flag)
{
goods_LogRepository.Insert(new Mall.Model.Entity.Product.RB_Goods_Log()
{
Id = 0,
......@@ -560,6 +576,8 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
MallBaseId = item.MallBaseId,
TenantId = item.TenantId
});
//自动确认订单
SetOrderOperation(qitem, 6, "", 0, "", item.TenantId, item.MallBaseId);
}
}
}
......@@ -573,6 +591,200 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
}
}
/// <summary>
/// 设置订单操作
/// </summary>
/// <param name="orderModel"></param>
/// <param name="type">类型 1修改备注 2修改金额 3强制取消 4放入回收站 5确认收货 6确认完成 7回收恢复 8回收删除</param>
/// <param name="remark"></param>
/// <param name="income"></param>
/// <param name="address"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public static bool SetOrderOperation(RB_Goods_Order_Extend orderModel, int type, string remark, decimal income, string address, int tenantId, int mallBaseId)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() { };
switch (type)
{
case 1:
keyValues.Add(nameof(RB_Goods_Order.Remark), remark); break;
case 2:
keyValues.Add(nameof(RB_Goods_Order.Income), income); break;
case 3:
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), OrderStatusEnum.Cancel); break;
case 4:
keyValues.Add(nameof(RB_Goods_Order.Recycled), 1); break;
case 5://确认收货
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), OrderStatusEnum.Received);
keyValues.Add(nameof(RB_Goods_Order.ReceivingTime), DateTime.Now);
break;
case 6://确认完成
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), OrderStatusEnum.Completed);
keyValues.Add(nameof(RB_Goods_Order.FinishTime), DateTime.Now);
break;
case 7:
keyValues.Add(nameof(RB_Goods_Order.Recycled), 2); break;
case 8:
keyValues.Add(nameof(RB_Goods_Order.Status), 1); break;
}
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Order.OrderId),
FiledValue=orderModel.OrderId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_Order.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_Order.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = goods_OrderRepository.Update(keyValues, wheres);
if (flag)
{
//记录日志
string Content = "";
switch (type)
{
case 1:
Content = "修改备注信息"; break;
case 2:
Content = "修改付款金额"; break;
case 3:
Content = "强制取消订单"; break;
case 4:
Content = "放入回收站"; break;
case 5:
Content = "确认收货"; break;
case 6:
Content = "确认完成"; break;
case 7:
Content = "回收站恢复订单"; break;
case 8:
Content = "确认删除订单"; break;
}
goods_LogRepository.Insert(new RB_Goods_Log()
{
Content = Content,
CreateDate = DateTime.Now,
Id = 0,
MallBaseId = mallBaseId,
SourceId = orderModel.OrderId,
TenantId = tenantId,
Type = 1
});
if (type == 6)
{
//更新返佣为已返佣
var ocList = goods_OrderCommissionRepository.GetList(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderModel.OrderId });
if (ocList.Any())
{
foreach (var item in ocList)
{
//查询是否有申请退款
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = item.OrderDetailId, Type = 1, MallBaseId = mallBaseId, TenantId = tenantId });
if (!afterSaleList.Any())
{
//获取分销商信息
var disInfo = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = item.UserId, TenantId = tenantId, MallBaseId = 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)+(item.Commission??0)},
{ nameof(RB_Distributor_Info_Extend.CommissionWithdrawal),(disInfo.CommissionWithdrawal??0)+(item.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=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_OrderCommissionRepository.Update(keyValues1, wheres1);
}
}
}
}
}
//积分赠送
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = orderModel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
if (dlist.Any())
{
int IntegralGoodsPresent = 0;
foreach (var item in dlist)
{
if (item.IntegralGoodsPresent > 0)
{
IntegralGoodsPresent += (item.IntegralGoodsPresent ?? 0);
}
}
if (IntegralGoodsPresent > 0)
{
//保存积分赠送
var umodel = member_UserRepository.GetEntity(orderModel.UserId);
//用户订单数增加
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_User_Extend.Integral), (umodel.Integral ?? 0)+IntegralGoodsPresent }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_UserRepository.Update(keyValues1, wheres1);
member_IntegralRepository.Insert(new Mall.Model.Entity.User.RB_Member_Integral()
{
Id = 0,
CreateDate = DateTime.Now,
Description = "订单购买赠送积分,订单号:" + orderModel.OrderNo,
Image = 0,
Integral = IntegralGoodsPresent,
MallBaseId = orderModel.MallBaseId,
PlatformType = orderModel.OrderSource,
Remarks = "",
TenantId = orderModel.TenantId,
Type = Common.Enum.MarketingCenter.RecordTypeEnum.Income,
UserId = orderModel.UserId,
OrderId = orderModel.OrderId
});
}
}
}
else if (type == 3)
{
//强制取消 (作废 使用新方法)
}
}
return flag;
}
#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