| | |
| | | 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 |
| | |
| | | private readonly IUnitOfWork _unitOfWork; |
| | | private readonly IServiceProvider _serviceProvider; |
| | | private readonly IRedisOperationRepository _redisOperationRepository; |
| | | private readonly ICoreCmsDistributionRepository _coreCmsDistributionRepository; |
| | | |
| | | private readonly IHttpContextUser _user; |
| | | |
| | | |
| | | public CoreCmsBillDeliveryServices( |
| | |
| | | , ICoreCmsStoreServices storeServices |
| | | , ICoreCmsBillDeliveryItemServices billDeliveryItemServices |
| | | , ICoreCmsOrderLogServices orderLogServices |
| | | , ICoreCmsSettingServices settingServices, IRedisOperationRepository redisOperationRepository) |
| | | , ICoreCmsSettingServices settingServices |
| | | , IRedisOperationRepository redisOperationRepository, |
| | | ICoreCmsDistributionRepository coreCmsDistributionRepository |
| | | , IHttpContextUser user) |
| | | { |
| | | this._dal = dal; |
| | | base.BaseDal = dal; |
| | |
| | | _orderLogServices = orderLogServices; |
| | | _settingServices = settingServices; |
| | | _redisOperationRepository = redisOperationRepository; |
| | | _coreCmsDistributionRepository = coreCmsDistributionRepository; |
| | | _user = user; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | /// <param name="shipAddress">收货地址</param> |
| | | /// <param name="memo">发货描述</param> |
| | | /// <param name="deliveryCompanyId">第三方对接物流编码</param> |
| | | /// <param name="sendDistributionID">送货供应商ID</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>(); |
| | | //获取订单详情 |
| | |
| | | } |
| | | if (tNum < 1) |
| | | { |
| | | jm.msg = "请至少发生一件商品!"; |
| | | jm.msg = "请至少发一件商品!"; |
| | | return jm; |
| | | } |
| | | //事务处理开始 |
| | |
| | | /// <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(); |
| | |
| | | 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>(); |
| | | |
| | |
| | | //插入发货单主体表 |
| | | await _dal.InsertAsync(billDelivery); |
| | | |
| | | |
| | | |
| | | |
| | | //插入发货单明细表 |
| | | await _billDeliveryItemServices.InsertAsync(bdRel); |
| | | |