From 557c2711a3e103ebc3d0492344eca9730d5e92b2 Mon Sep 17 00:00:00 2001 From: 移动系统liao <liaoxujun@qq.com> Date: 星期一, 17 二月 2025 10:47:47 +0800 Subject: [PATCH] 增加司机配送单超时处理任务,防止一直不停手机定位信息, --- CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs | 74 ++++++++++++++++++++++++++++++------ 1 files changed, 61 insertions(+), 13 deletions(-) diff --git a/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs b/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs index fb5649a..af7246c 100644 --- a/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs +++ b/CoreCms.Net.Services/Bill/CoreCmsBillDeliveryServices.cs @@ -1,10 +1,10 @@ /*********************************************************************** - * Project: CoreCms - * ProjectName: 鏍稿績鍐呭绠$悊绯荤粺 - * Web: https://www.corecms.net - * Author: 澶х伆鐏� - * Email: jianweie@163.com - * CreateTime: 2021/1/31 21:45:10 + * Project: baifenBinfa + * ProjectName: 鐧惧垎鍏垫硶绠$悊绯荤粺 + * Web: http://chuanyin.com + * Author: + * Email: + * CreateTime: 202403/02 * Description: 鏆傛棤 ***********************************************************************/ @@ -12,22 +12,27 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using CoreCms.Net.Auth.HttpContextUser; using CoreCms.Net.Caching.AutoMate.RedisCache; using CoreCms.Net.Configuration; +using CoreCms.Net.DTO; using CoreCms.Net.IRepository; using CoreCms.Net.IRepository.UnitOfWork; using CoreCms.Net.IServices; using CoreCms.Net.Loging; using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.Entities.baifenbingfa.DistributionSendOder; using CoreCms.Net.Model.ViewModels.Api; using CoreCms.Net.Model.ViewModels.DTO; using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Helper; +using Essensoft.Paylink.Alipay.Domain; using Flurl.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinExpressDeliveryOpenMessageGetDeliveryListResponse.Types; namespace CoreCms.Net.Services @@ -45,7 +50,9 @@ private readonly IUnitOfWork _unitOfWork; private readonly IServiceProvider _serviceProvider; private readonly IRedisOperationRepository _redisOperationRepository; + private readonly ICoreCmsDistributionRepository _coreCmsDistributionRepository; + private readonly IHttpContextUser _user; public CoreCmsBillDeliveryServices( @@ -55,7 +62,10 @@ , ICoreCmsStoreServices storeServices , ICoreCmsBillDeliveryItemServices billDeliveryItemServices , ICoreCmsOrderLogServices orderLogServices - , ICoreCmsSettingServices settingServices, IRedisOperationRepository redisOperationRepository) + , ICoreCmsSettingServices settingServices + , IRedisOperationRepository redisOperationRepository, + ICoreCmsDistributionRepository coreCmsDistributionRepository + , IHttpContextUser user) { this._dal = dal; base.BaseDal = dal; @@ -66,6 +76,9 @@ _orderLogServices = orderLogServices; _settingServices = settingServices; _redisOperationRepository = redisOperationRepository; + _coreCmsDistributionRepository = coreCmsDistributionRepository; + _user = user; + } @@ -83,12 +96,17 @@ /// <param name="shipAddress">鏀惰揣鍦板潃</param> /// <param name="memo">鍙戣揣鎻忚堪</param> /// <param name="deliveryCompanyId">绗笁鏂瑰鎺ョ墿娴佺紪鐮�</param> + /// <param name="sendDistributionID">閫佽揣渚涘簲鍟咺D</param> /// <returns></returns> - public async Task<WebApiCallBack> BatchShip(string[] orderId, string logiCode, string logiNo, Dictionary<int, int> items, int storeId = 0, string shipName = "", string shipMobile = "", int shipAreaId = 0, string shipAddress = "", string memo = "", string deliveryCompanyId = "") + public async Task<WebApiCallBack> BatchShip(string[] orderId, string logiCode, string logiNo, Dictionary<int, int> items, int storeId = 0, string shipName = "", string shipMobile = "", int shipAreaId = 0, string shipAddress = "", string memo = "", string deliveryCompanyId = "", int? sendDistributionID = null) { using var container = _serviceProvider.CreateScope(); var jm = new WebApiCallBack(); - + if(sendDistributionID > 0) + { + jm.msg = "缁忛攢鍟嗗彂璐т笉鏀寔鎵归噺鍙戣揣"; + return jm; + } var orderService = container.ServiceProvider.GetService<ICoreCmsOrderServices>(); var stockServices = container.ServiceProvider.GetService<ICoreCmsStockServices>(); //鑾峰彇璁㈠崟璇︽儏 @@ -180,7 +198,7 @@ } if (tNum < 1) { - jm.msg = "璇疯嚦灏戝彂鐢熶竴浠跺晢鍝�!"; + jm.msg = "璇疯嚦灏戝彂涓�浠跺晢鍝�!"; return jm; } //浜嬪姟澶勭悊寮�濮� @@ -231,12 +249,13 @@ /// <param name="shipAddress">鏀惰揣鍦板潃</param> /// <param name="memo">鍙戣揣鎻忚堪</param> /// <param name="deliveryCompanyId">绗笁鏂瑰鎺ョ墿娴佺紪鐮�</param> + /// <param name="sendDistributionID">缁忛攢鍟嗛�佽揣ID</param> /// <returns></returns> - public async Task<WebApiCallBack> Ship(string orderId, string logiCode, string logiNo, Dictionary<int, int> items, int storeId = 0, string shipName = "", string shipMobile = "", int shipAreaId = 0, string shipAddress = "", string memo = "", string deliveryCompanyId = "") + public async Task<WebApiCallBack> Ship(string orderId, string logiCode, string logiNo, Dictionary<int, int> items, int storeId = 0, string shipName = "", string shipMobile = "", int shipAreaId = 0, string shipAddress = "", string memo = "", string deliveryCompanyId = "",int? sendDistributionID=null) { using var container = _serviceProvider.CreateScope(); var jm = new WebApiCallBack(); - + var orderService = container.ServiceProvider.GetService<ICoreCmsOrderServices>(); //鑾峰彇璁㈠崟璇︽儏 var dInfoResult = await orderService.GetOrderShipInfo(orderId); @@ -288,7 +307,33 @@ billDelivery.memo = memo; billDelivery.createTime = DateTime.Now; billDelivery.thirdPartylogiCode = deliveryCompanyId; + + if(sendDistributionID>0) + { + var a= _coreCmsDistributionRepository.QueryById(sendDistributionID); + if(a==null) + { + jm.msg = "缁忛攢鍟嗕笉瀛樺湪"; + return jm; + } + billDelivery.sendDistributionUserID= a.userId; + billDelivery.sendDistributionID = sendDistributionID; + billDelivery.sendDistributionAccept = sendDistributionAcceptType.NoAccted; + var mQ = new DistributionSendOder + { + + sendDistributionAccept = sendDistributionAcceptType.NoAccted, + distributionID = (int)sendDistributionID, + sendMangerID = _user.ID, + deliveryID = billDelivery.deliveryId, + sendTime = DateTime.Now, + userID= a.userId + + }; + //璁板綍鎿嶄綔璁板綍 + await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.AddDistributionSendOderMQ, JsonConvert.SerializeObject(mQ)); + } //璁剧疆鍙戣揣鏄庣粏 var bdRel = new List<CoreCmsBillDeliveryItem>(); @@ -335,7 +380,10 @@ //鎻掑叆鍙戣揣鍗曚富浣撹〃 - await _dal.InsertAsync(billDelivery); + await _dal.InsertAsync(billDelivery); + + + //鎻掑叆鍙戣揣鍗曟槑缁嗚〃 await _billDeliveryItemServices.InsertAsync(bdRel); -- Gitblit v1.9.1