From 80aa425c4ca51f7c0224a6245968cdd08940321b Mon Sep 17 00:00:00 2001 From: 移动系统liao <liaoxujun@qq.com> Date: 星期四, 13 六月 2024 10:17:30 +0800 Subject: [PATCH] 修改校园代理 完成 --- CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsOrderController.cs | 89 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 83 insertions(+), 6 deletions(-) diff --git a/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsOrderController.cs b/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsOrderController.cs index dac6e3c..391da5a 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsOrderController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsOrderController.cs @@ -19,10 +19,12 @@ using CoreCms.Net.Configuration; using CoreCms.Net.Filter; using CoreCms.Net.IServices; +using CoreCms.Net.IServices.baifenbingfa; using CoreCms.Net.Loging; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.Entities.Expression; using CoreCms.Net.Model.FromBody; +using CoreCms.Net.Model.ViewModels.DTO; using CoreCms.Net.Model.ViewModels.Excel; using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; @@ -69,7 +71,7 @@ private readonly ICoreCmsOrderItemServices _orderItemServices; - + private readonly IBfbfComAPIService _bfbfServices; /// <summary> @@ -84,7 +86,14 @@ , ICoreCmsLogisticsServices logisticsServices , ICoreCmsBillPaymentsServices billPaymentsServices , ICoreCmsPaymentsServices paymentsServices - , ICoreCmsSettingServices settingServices, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IRedisOperationRepository redisOperationRepository, ICoreCmsBillDeliveryServices billDeliveryServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsOrderItemServices orderItemServices, IWeChatShippingDeliveryServices weChatShippingDeliveryServices) + , ICoreCmsSettingServices settingServices + , ICoreCmsUserWeChatInfoServices userWeChatInfoServices + , IRedisOperationRepository redisOperationRepository + , ICoreCmsBillDeliveryServices billDeliveryServices + , IWeChatApiHttpClientFactory weChatApiHttpClientFactory + , ICoreCmsOrderItemServices orderItemServices + , IWeChatShippingDeliveryServices weChatShippingDeliveryServices + , IBfbfComAPIService bfbfComAPIService) { _webHostEnvironment = webHostEnvironment; _coreCmsOrderServices = coreCmsOrderServices; @@ -102,6 +111,7 @@ _weChatApiHttpClientFactory = weChatApiHttpClientFactory; _orderItemServices = orderItemServices; _weChatShippingDeliveryServices = weChatShippingDeliveryServices; + _bfbfServices = bfbfComAPIService; } #region 鑾峰彇鍒楄〃============================================================ @@ -519,6 +529,16 @@ var storeList = await _storeServices.QueryAsync(); var logistics = await _logisticsServices.QueryListByClauseAsync(p => p.isDelete == false); + logistics.Add(new CoreCmsLogistics + { + id = int.MaxValue, + logiCode = "Distributor", + logiName = "鏍″洯浠g悊閰嶉��", + sort = -1, + + }); + + logistics = logistics.OrderBy(x => x.sort).ToList(); var deliveryCompany = await _weChatShippingDeliveryServices.GetCaChe(); var result = await _coreCmsOrderServices.GetOrderShipInfo(entity.id); if (!result.status) @@ -526,7 +546,40 @@ jm.msg = result.msg; return jm; } + string lat = ""; + try + { + lat = (result.data as AdminOrderShipResult).Coordinate; + } + catch (Exception) + { + lat = ""; + } + List<DistributorSort> Distributors = new List<DistributorSort>(); + if (!string.IsNullOrEmpty(lat)) + //璧版牎鍥唬鐞� + { + string[] latlist= lat.Split(','); + if (latlist.Length == 2) + { + try + { + var ProductsIds = await _bfbfServices.GetOderProductsIDs(entity.id); + Distributors = await _bfbfServices.GetDistributorsList(ProductsIds); + //Distributors = _bfbfServices.orderedDistributors(Distributors, latlist[0], latlist[1]); + + } + catch (Exception) + { + Distributors = new List<DistributorSort>(); + + + } + + } + } + if (storeList.Any()) { foreach (var store in storeList) @@ -546,6 +599,7 @@ deliveryCompany, storeList, logistics, + Distributors }; return jm; @@ -564,12 +618,23 @@ public async Task<AdminUiCallBack> DoShip([FromBody] AdminOrderShipPost entity) { var jm = new AdminUiCallBack(); + if (entity.logiCode== "Distributor") + //濡傛灉閫夋嫨浜嗘牎鍥唬鐞嗗彂璐� + { + if (entity.SendDistributionID == null && entity.SendDistributionID == 0) + { + jm.code= 1; + jm.msg = "蹇呴』閫夋嫨涓�涓牎鍥唬鐞嗛厤閫�"; + return jm; + } + } + WebApiCallBack result; if (entity.orderId.Contains(",")) { var ids = entity.orderId.Split(","); - result = await _coreCmsOrderServices.BatchShip(ids, entity.logiCode, entity.logiNo, entity.items, entity.shipName, entity.shipMobile, entity.shipAddress, entity.memo, entity.storeId, entity.shipAreaId, entity.deliveryCompanyId); + result = await _coreCmsOrderServices.BatchShip(ids, entity.logiCode, entity.logiNo, entity.items, entity.shipName, entity.shipMobile, entity.shipAddress, entity.memo, entity.storeId, entity.shipAreaId, entity.deliveryCompanyId,entity.SendDistributionID); if (result.status) { @@ -579,6 +644,8 @@ //渚濇鎺ㄥ叆闃熷垪. foreach (var item in orderPaymentIds) { + //缁忛攢鍟嗗彂璐т笉澶勭悊鍙戣揣淇℃伅 鏄簲璇ヤ綔涓哄悓鍩庡鐞嗭紵杩樻槸涓嶅鐞嗭紝闇�瑕佽繍琛屾椂鐮旂┒ + if(entity.logiCode != "Distributor") await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayShipping, item.paymentId); } } @@ -588,12 +655,14 @@ } else { - result = await _coreCmsOrderServices.Ship(entity.orderId, entity.logiCode, entity.logiNo, entity.items, entity.shipName, entity.shipMobile, entity.shipAddress, entity.memo, entity.storeId, entity.shipAreaId, entity.deliveryCompanyId); + result = await _coreCmsOrderServices.Ship(entity.orderId, entity.logiCode, entity.logiNo, entity.items, entity.shipName, entity.shipMobile, entity.shipAddress, entity.memo, entity.storeId, entity.shipAreaId, entity.deliveryCompanyId,entity.SendDistributionID); //寰俊鍙戣揣淇℃伅绠$悊API鍙戣揣 if (result.status && await _billPaymentsServices.QueryByClauseAsync(p => p.sourceId == entity.orderId && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed) is { } paymentInfo) { - await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayShipping, paymentInfo.paymentId); + //缁忛攢鍟嗗彂璐т笉澶勭悊鍙戣揣淇℃伅 + if (entity.logiCode != "Distributor") + await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayShipping, paymentInfo.paymentId); } } @@ -916,9 +985,17 @@ return jm; } jm.code = result.status ? 0 : 1; + var CmsOrder = result.data as CoreCmsOrder; + if(CmsOrder == null) + { + jm.msg = "涓嶅瓨鍦ㄦ淇℃伅"; + return jm; + } + //鍓旈櫎缁忛攢鍟嗗彇娑堢殑鐗╂祦淇℃伅 + CmsOrder.delivery = CmsOrder.delivery.Where(x => x.logiCode != "Distributor" || (x.logiCode == "Distributor" && x.sendDistributionAccept == sendDistributionAcceptType.Accepted)).ToList(); - var allConfigs = await _settingServices.GetConfigDictionaries(); + var allConfigs = await _settingServices.GetConfigDictionaries(); var shopName = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopName); var shopMobile = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopMobile); -- Gitblit v1.9.1