From 445d14becca6b5251814934343d7a6394ada6009 Mon Sep 17 00:00:00 2001
From: 小飞侠 <8277136+liaoxujun@user.noreply.gitee.com>
Date: 星期五, 17 十月 2025 16:55:19 +0800
Subject: [PATCH] no message
---
CoreCms.Net.Services/baifenbingfa/DistributorDeliveryServices.cs | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 169 insertions(+), 6 deletions(-)
diff --git a/CoreCms.Net.Services/baifenbingfa/DistributorDeliveryServices.cs b/CoreCms.Net.Services/baifenbingfa/DistributorDeliveryServices.cs
index c2f751b..c88065d 100644
--- a/CoreCms.Net.Services/baifenbingfa/DistributorDeliveryServices.cs
+++ b/CoreCms.Net.Services/baifenbingfa/DistributorDeliveryServices.cs
@@ -19,6 +19,12 @@
using CoreCms.Net.Configuration;
using Newtonsoft.Json;
using CoreCms.Net.DTO;
+using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinExpressDeliveryOpenMessageGetDeliveryListResponse.Types;
+
+using CoreCms.Net.Loging;
+using CoreCms.Net.Model.Entities.baifenbingfa.DistributionSendOder;
+using StackExchange.Redis;
+using Microsoft.Extensions.Logging;
namespace CoreCms.Net.Services.baifenbingfa
{
@@ -38,7 +44,9 @@
private readonly IRedisOperationRepository _redisOperationRepository;
private readonly IHttpContextUser _user;
+
public readonly ICoreCmsDistributionServices _coreCmsDistributionServices;
+ private readonly ICoreCmsOrderServices _orderServices;
public DistributorDeliveryServices(
IUnitOfWork unitOfWork,
@@ -50,7 +58,8 @@
, ICoreCmsSettingServices settingServices
, IRedisOperationRepository redisOperationRepository
, IHttpContextUser user
- ,ICoreCmsDistributionServices coreCmsDistributionServices )
+ ,ICoreCmsDistributionServices coreCmsDistributionServices
+ ,ICoreCmsOrderServices orderServices)
{
this._dal = dal;
base.BaseDal = dal;
@@ -63,6 +72,7 @@
_redisOperationRepository = redisOperationRepository;
_user = user;
_coreCmsDistributionServices = coreCmsDistributionServices;
+ _orderServices = orderServices;
}
public async Task<(List< CoreCmsBillDelivery>,int )> GetDeliveryList(GetDeliveryListPost Param)
@@ -76,7 +86,42 @@
}
if (Param.distributionAcceptStatus != null)
{
- where= where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
+ switch (Param.distributionAcceptStatus)
+ {
+ case sendDistributionAcceptType.Accepted:
+ ///杩涜涓紝鍞悗绌�
+ where = where.And(x => x.sendDistributionAccept == sendDistributionAcceptType.Accepted
+ && x.order.status == (int)GlobalEnumVars.OrderStatus.Normal && !x.order.aftersalesItem1.Any()&& x.order.confirmStatus != (int)GlobalEnumVars.OrderConfirmStatus.ConfirmReceipt);
+ //where = where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
+ break;
+ case sendDistributionAcceptType.NoAccted:
+ ///鏈‘璁ゆ帴鍙楃殑锛屼笉鑳藉敭鍚庣┖
+ where = where.And(x => x.sendDistributionAccept == sendDistributionAcceptType.NoAccted
+ && x.order.status == (int)GlobalEnumVars.OrderStatus.Normal && !x.order.aftersalesItem1.Any());
+ //where = where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
+ break;
+
+ case sendDistributionAcceptType.OderFreeComplete:
+
+ where = where.And(x => x.sendDistributionAccept == sendDistributionAcceptType.Accepted
+ && x.order.status == (int)GlobalEnumVars.OrderStatus.Complete && !x.order.aftersalesItem1.Any());
+ //where = where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
+ break;
+ case sendDistributionAcceptType.Cancelled:
+
+ where = where.And(x =>( x.sendDistributionAccept == sendDistributionAcceptType.Cancelled
+ || x.order.status == (int)GlobalEnumVars.OrderStatus.Cancel || x.order.aftersalesItem1.Any()));
+ //where = where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
+ break;
+ case sendDistributionAcceptType.Delivered:
+ where = where.And(x => x.sendDistributionAccept == sendDistributionAcceptType.Delivered
+ || x.order.confirmStatus == (int)GlobalEnumVars.OrderConfirmStatus.ConfirmReceipt );
+ //where = where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
+ break;
+ default:
+ break;
+ }
+ //where= where.And(x => x.sendDistributionAccept == Param.distributionAcceptStatus);
}
where= where.And(x => x.sendDistributionUserID == _user.ID);
//蹇呴』鏄嚭浜庡彂璐х姸鎬�
@@ -84,8 +129,63 @@
//蹇呴』鏄湁鏁堢姸鎬�
//where= where.And(x => x.order.status == (int)GlobalEnumVars.OrderStatus.Normal);
RefAsync<int> totl = 0;
- var list= await _unitOfWork.GetDbClient().Queryable<CoreCmsBillDelivery>().Includes(x => x.order, order => order.Orderitems, ite => ite.productInfo)
- .Where(where).OrderByDescending(x => x.createTime)
+ var list = await _unitOfWork.GetDbClient().Queryable<CoreCmsBillDelivery>()
+ .Includes(x => x.order, order => order.Orderitems, ite => ite.productInfo)
+ .Includes(x => x.order, Order => Order.aftersalesItem1)
+ .Where(where)
+ .Select(x => new CoreCmsBillDelivery
+ {
+
+ order = x.order,
+ }, true)
+ .MergeTable()
+ //.Mapper(x => x.order.billAftersalesId = SqlFunc.Subqueryable<CoreCmsBillAftersales>().Where(core => core.orderId == x.orderId).Select(core => core.aftersalesId))
+ .Mapper(
+ x =>
+ {
+ switch (x.sendDistributionAccept)
+ {
+ case sendDistributionAcceptType.Accepted:
+
+ if (x.order.status == (int)GlobalEnumVars.OrderStatus.Cancel)
+ x.sendDistributionAccept = sendDistributionAcceptType.Cancelled;
+ else
+ if (x.order.status == (int)GlobalEnumVars.OrderStatus.Complete && !x.order.aftersalesItem1.Any())
+ x.sendDistributionAccept = sendDistributionAcceptType.OderFreeComplete;
+ if (x.order.status == (int)GlobalEnumVars.OrderStatus.Complete && x.order.aftersalesItem1.Any())
+ x.sendDistributionAccept = sendDistributionAcceptType.Cancelled;
+
+ else if (x.order.status == (int)GlobalEnumVars.OrderStatus.Normal && x.order.aftersalesItem1.Any())
+ x.sendDistributionAccept = sendDistributionAcceptType.Cancelled;
+ else
+ if (x.order.confirmStatus == (int)GlobalEnumVars.OrderConfirmStatus.ConfirmReceipt)
+ x.sendDistributionAccept = sendDistributionAcceptType.Delivered;
+ else
+ x.sendDistributionAccept = x.sendDistributionAccept;
+ break;
+ case sendDistributionAcceptType.NoAccted:
+ ///鏈‘璁ゆ帴鍙楃殑锛屼笉鑳藉敭鍚庣┖
+ if(x.order.status== (int)GlobalEnumVars.OrderStatus.Complete||x.order.status== (int)GlobalEnumVars.OrderStatus.Cancel|| x.order.aftersalesItem1.Any())
+ x.sendDistributionAccept= sendDistributionAcceptType.Cancelled;
+ else
+ x.sendDistributionAccept = x.sendDistributionAccept;
+ break;
+
+ case sendDistributionAcceptType.OderFreeComplete:
+
+ //姘歌繙涓嶄細鍒拌繖
+ break;
+ case sendDistributionAcceptType.Cancelled:
+ //涓嶉渶瑕佸鐞�
+
+ break;
+ default:
+ break;
+ }
+ }
+ )
+
+ .OrderByDescending(x => x.createTime)
.ToPageListAsync(Param.page, Param.limit, totl);
var listdata= new PageList<CoreCmsBillDelivery>(list, Param.page, Param.limit, totl);
@@ -95,16 +195,31 @@
public async Task<int> GetNoAcceptedDeliveryCount()
{
- return await _dal.GetCountAsync(x => x.sendDistributionUserID == _user.ID && x.sendDistributionAccept == sendDistributionAcceptType.NoAccted);
+ var lista= await _unitOfWork.GetDbClient().Queryable<CoreCmsBillDelivery>().Includes(x => x.order,ord=>ord.aftersalesItem1)
+ .Where(x => x.sendDistributionUserID == _user.ID && x.sendDistributionAccept == sendDistributionAcceptType.NoAccted
+ && x.order.status != (int)GlobalEnumVars.OrderStatus.Complete ).ToListAsync();
+
+ return lista.Where(x=>(x.order.aftersalesItem1==null|| x.order.aftersalesItem1.Count()==0)).Count();//鍒犻�夊嚭娌℃湁鍞悗鐢宠鐨勮鍗�
+
+
}
public async Task<bool> GetShowDelivery()
{
return (await _coreCmsDistributionServices.GetCountAsync(x => x.userId == _user.ID && x.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes&&x.profession=="鏍″洯浠g悊", isDataCache: true, cacheTimes: 60)>0);
}
- public async Task<WebApiCallBack> SetDeliveryAccepted(sendDistributionAcceptType acceptType, string DeliveryID, string CancelledDec = null)
+ public async Task<WebApiCallBack> SetDeliveryAccepted(sendDistributionAcceptType acceptType, string DeliveryID, string CancelledDec = null)
{
+
WebApiCallBack ret = new WebApiCallBack();
+
+ if (acceptType == sendDistributionAcceptType.OderFreeComplete)
+ {
+ //鍙湁鍦ㄥ畬鎴愯鍗曚腑璁剧疆璇ョ姸鎬侊紝璇ョ姸鎬佷細瀵归厤鍞敹鐩婅繘琛屾彁鍙栨暣鍚�
+ ret.status = false;
+ ret.msg = "鐘舵�佽缃敊璇�";
+ return ret;
+ }
var data = await _dal.QueryByIdAsync(DeliveryID);
if (data == null)
{
@@ -200,5 +315,53 @@
throw;
}
}
+
+ public async Task<WebApiCallBack> FinishOrder(string orderId)
+ {
+
+
+ var jm = new WebApiCallBack();
+
+ var order = await _orderServices.QueryByClauseAsync(p =>
+ p.orderId == orderId && p.status == (int)GlobalEnumVars.OrderStatus.Complete);
+ if (order == null)
+ {
+ jm.msg = "璁㈠崟鏌ヨ澶辫触";
+ return jm;
+ }
+ var distributionSendOder = await _unitOfWork.GetDbClient().Queryable<DistributionSendOder>().Includes(x=>x.delivery)
+ .Where(x=>x.delivery.orderId==order.orderId&&(x.sendDistributionAccept== sendDistributionAcceptType.Accepted|| x.sendDistributionAccept== sendDistributionAcceptType.Shipped||x.sendDistributionAccept== sendDistributionAcceptType.Delivered))
+ .ToListAsync();
+ if( distributionSendOder.Count==1)
+ {
+ //婊¤冻鎵�鏈夋潯浠跺紑濮嬪垎閰嶉�昏緫
+ var mQ = new ActiveDistributionSendOderMQ
+ {
+
+ SendOderActive = sendDistributionAcceptType.OderFreeComplete,
+ deliveryID = distributionSendOder[0].deliveryID,
+ userID = order.userId
+ };
+
+ await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.ActiveDistributionSendOderMQ, JsonConvert.SerializeObject(mQ));
+ jm.status = true;
+
+ }
+ else if( distributionSendOder.Count>1)
+ {
+ jm.status= false;
+ jm.msg = "鍙戠幇澶氫釜閰嶉�佽鍗曪紝闇�瑕佹墜鍔ㄦ帓鏌�";
+ NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Order, "澶勭悊缁忛攢鍟嗛厤閫佹敹鐩婃椂閿欒", $"璁㈠崟ID{orderId} 鍙戠幇澶氫釜婊¤冻缁忛攢鍟嗘淳閫佸崟锛屾斁寮冨鐞�,闇�鎺掓煡");
+
+ }
+ jm.status = true;
+ return jm;
+
+ //if (order.shipStatus is (int)GlobalEnumVars.OrderShipStatus.No or (int)GlobalEnumVars.OrderShipStatus.PartialYes)
+ // {
+ // return jm;
+ // }
+
+ }
}
}
--
Gitblit v1.9.1