| | |
| | | /*********************************************************************** |
| | | * 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: 暂无 |
| | | ***********************************************************************/ |
| | | |
| | |
| | | using SKIT.FlurlHttpClient.Wechat.Api.Models; |
| | | using SqlSugar; |
| | | using Yitter.IdGenerator; |
| | | using static SKIT.FlurlHttpClient.Wechat.Api.Models.ChannelsECLeagueHeadSupplierOrderGetResponse.Types.CommssionOrder.Types.OrderDetail.Types; |
| | | |
| | | |
| | | namespace CoreCms.Net.Services |
| | |
| | | private readonly IRedisOperationRepository _redisOperationRepository; |
| | | private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices; |
| | | private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; |
| | | private readonly ICoreCmsPlanOrderServices _planOrderServices; |
| | | |
| | | private IUnitOfWork _unitOfWork; |
| | | |
| | |
| | | , ICoreCmsPaymentsServices paymentsServices |
| | | , ICoreCmsBillRefundServices billRefundServices |
| | | , ICoreCmsBillLadingServices billLadingServices |
| | | , ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IUnitOfWork unitOfWork) |
| | | , ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IUnitOfWork unitOfWork |
| | | , ICoreCmsPlanOrderServices planOrderServices) |
| | | { |
| | | this._dal = dal; |
| | | base.BaseDal = dal; |
| | |
| | | _userWeChatInfoServices = userWeChatInfoServices; |
| | | _weChatApiHttpClientFactory = weChatApiHttpClientFactory; |
| | | _unitOfWork = unitOfWork; |
| | | _planOrderServices = planOrderServices; |
| | | } |
| | | |
| | | #region 查询团购秒杀下单数量(获取货品的秒杀团购数据) |
| | |
| | | /// <param name="requireOrder">微信自定义组件(是否需要推单,1:需要,0:不需要)</param> |
| | | /// <param name="requiredFundType">微信自定义组件(requireOrder = 1时生效,0,非二级商户号订单,1,二级商户号订单,2,两种方式皆可(后续只会存在1))</param> |
| | | /// <param name="traceId">微信自定义组件(跟踪ID,有效期十分钟,会影响主播归因、分享员归因等,需创建订单前调用,调用生成订单 api 时需传入该参数)</param> |
| | | /// <param name="planorderId">计划订单id</param> |
| | | /// <returns></returns> |
| | | public async Task<WebApiCallBack> ToAdd(int userId, int orderType, string cartIds, int receiptType, int ushipId, int storeId, string ladingName, string ladingMobile, string memo, int point, string couponCode, int source, int scene, int taxType, string taxName, string taxCode, int objectId, int teamId, int requireOrder, int requiredFundType, string traceId) |
| | | public async Task<WebApiCallBack> ToAdd(int userId, int orderType, string cartIds, int receiptType, int ushipId, int storeId, string ladingName, string ladingMobile, string memo, int point, string couponCode, int source, int scene, int taxType, string taxName, string taxCode, int objectId, int teamId, int requireOrder, int requiredFundType, string traceId, string planorderId) |
| | | { |
| | | var jm = new WebApiCallBack() { methodDescription = "创建订单" }; |
| | | try |
| | |
| | | order.confirmStatus = (int)GlobalEnumVars.OrderConfirmStatus.ReceiptNotConfirmed; |
| | | order.createTime = DateTime.Now; |
| | | order.scene = scene; |
| | | order.planorderId = planorderId; |
| | | |
| | | //上面保存好订单表,下面保存订单的其他信息 |
| | | if (orderItems == null) |
| | |
| | | } |
| | | else |
| | | { |
| | | await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString(), JObject.FromObject(order)); |
| | | if (!string.IsNullOrEmpty(planorderId)) |
| | | { |
| | | //查询计划订单 |
| | | var planOrder = await _planOrderServices.QueryByIdAsync(planorderId); |
| | | //上面保存好订单表,下面保存订单的其他信息 |
| | | if (planOrder == null || planOrder.isdelete == true) |
| | | { |
| | | _unitOfWork.RollbackTran(); |
| | | jm.msg = "计划订单获取失败"; |
| | | return jm; |
| | | } |
| | | if (planOrder.status != 2) |
| | | { |
| | | _unitOfWork.RollbackTran(); |
| | | jm.msg = "计划订单没有锁单"; |
| | | return jm; |
| | | } |
| | | |
| | | if ((planOrder.keYongAmount - planOrder.huaFeiAmount - order.orderAmount)<0) |
| | | { |
| | | _unitOfWork.RollbackTran(); |
| | | jm.msg = "计划订单可用余额不足"; |
| | | return jm; |
| | | } |
| | | planOrder.huaFeiAmount = planOrder.huaFeiAmount + order.orderAmount; |
| | | //修改计划订单的已花费金额 |
| | | var crr = await _planOrderServices.UpdateAsync(planOrder); |
| | | |
| | | |
| | | |
| | | //创建支付单 |
| | | var billPayments = new CoreCmsBillPayments(); |
| | | billPayments.paymentId = CommonHelper.GetSerialNumberType((int)GlobalEnumVars.SerialNumberType.支付单编号); |
| | | billPayments.sourceId = order.orderId; |
| | | billPayments.money = order.orderAmount; |
| | | billPayments.userId = userId; |
| | | billPayments.type = order.orderType; |
| | | billPayments.status = (int)GlobalEnumVars.BillPaymentsStatus.Payed; |
| | | billPayments.paymentCode = GlobalEnumVars.PaymentsTypes.planorderpay.ToString(); |
| | | billPayments.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1"; |
| | | billPayments.payedMsg = "计划订单直接支付成功"; |
| | | billPayments.parameters = ""; |
| | | billPayments.createTime = DateTime.Now; |
| | | billPayments.updateTime = DateTime.Now; |
| | | |
| | | |
| | | await _billPaymentsServices.InsertAsync(billPayments); |
| | | |
| | | //调整直接支付成功 |
| | | await _dal.UpdateAsync(p => new CoreCmsOrder() |
| | | { |
| | | payedAmount = order.orderAmount, |
| | | paymentTime = DateTime.Now, |
| | | updateTime = DateTime.Now, |
| | | paymentCode = GlobalEnumVars.PaymentsTypes.planorderpay.ToString(), |
| | | payStatus = (int)GlobalEnumVars.OrderPayStatus.Yes, |
| | | orderAmount = order.orderAmount |
| | | }, p => p.orderId == order.orderId); |
| | | |
| | | //记录订单日志 |
| | | orderLog = new CoreCmsOrderLog |
| | | { |
| | | userId = userId, |
| | | orderId = order.orderId, |
| | | type = (int)GlobalEnumVars.OrderLogTypes.LOG_TYPE_PAY, |
| | | msg = "计划订单直接支付成功", |
| | | data = JsonConvert.SerializeObject(order), |
| | | createTime = DateTime.Now |
| | | }; |
| | | await _orderLogServices.InsertAsync(orderLog); |
| | | |
| | | //如果是门店自提,应该自动跳过发货,生成提货单信息,使用提货单核销。 |
| | | if (order.receiptType == (int)GlobalEnumVars.OrderReceiptType.SelfDelivery) |
| | | { |
| | | var allConfigs = await _settingServices.GetConfigDictionaries(); |
| | | var storeOrderAutomaticDelivery = CommonHelper |
| | | .GetConfigDictionary(allConfigs, SystemSettingConstVars.StoreOrderAutomaticDelivery) |
| | | .ObjectToInt(1); |
| | | if (storeOrderAutomaticDelivery == 1) |
| | | { |
| | | //订单自动发货 |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.OrderAutomaticDelivery, JsonConvert.SerializeObject(order)); |
| | | } |
| | | } |
| | | |
| | | //用户升级处理 |
| | | // await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.UserUpGrade, JsonConvert.SerializeObject(order)); |
| | | //发送支付成功信息,增加发送内容 |
| | | await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.OrderPayed.ToString(), JObject.FromObject(order)); |
| | | await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.SellerOrderNotice.ToString(), JObject.FromObject(order)); |
| | | //易联云打印机打印 |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.OrderPrint, JsonConvert.SerializeObject(order)); |
| | | |
| | | } |
| | | else |
| | | { |
| | | await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString(), JObject.FromObject(order)); |
| | | } |
| | | |
| | | } |
| | | |
| | | _unitOfWork.CommitTran(); |
| | |
| | | weight = Math.Round(item.weight * item.nums, 2), |
| | | sendNums = 0, |
| | | addon = item.products.spesDesc, |
| | | createTime = DateTime.Now |
| | | createTime = DateTime.Now, |
| | | CustomizableMoney= item.CustomizableMoney, |
| | | IsCustomizable = item.isCustomizable, |
| | | |
| | | }; |
| | | if (item.products.promotionList.Count > 0) |
| | | { |
| | |
| | | { |
| | | if (payStatus == (int)GlobalEnumVars.OrderPayStatus.No) |
| | | { |
| | | html.Append("<a class='layui-btn layui-btn-xs pay-order' lay-active='payOrder' data-id='" + orderId + "'>支付</a><br>"); |
| | | //html.Append("<a class='layui-btn layui-btn-xs pay-order' lay-active='payOrder' data-id='" + orderId + "'>支付</a><br>"); |
| | | html.Append("<a class='layui-btn layui-btn-xs edit-order' lay-active='editOrder' data-id='" + orderId + "'>编辑</a><br>"); |
| | | html.Append("<a class='layui-btn layui-btn-xs cancel-order' lay-active='cancelOrder' data-id='" + orderId + "'>取消</a><br>"); |
| | | } |
| | |
| | | createTime = DateTime.Now |
| | | }; |
| | | await _orderLogServices.InsertAsync(orderLog); |
| | | //百分兵法特殊奖励 |
| | | var allConfigs = await _settingServices.GetConfigDictionaries(); |
| | | var pointExchangeModel = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryAchievementOnOff).ObjectToInt(); |
| | | if (pointExchangeModel == 1) |
| | | { |
| | | //开启业绩奖励模式 |
| | | var user = await _userServices.QueryByIdAsync(orderInfo.userId, isDataCache: true, cacheTimes: 1); |
| | | if (user.parentId != 0) |
| | | { |
| | | //如果是 |
| | | CreateDAOrderInParam data = new CreateDAOrderInParam |
| | | { |
| | | Money = money, |
| | | OderId = orderInfo.orderId, |
| | | SourceTypes = GlobalEnumVars.UserBalanceSourceTypes.GoodsOder, |
| | | UserID = user.parentId, |
| | | |
| | | |
| | | }; |
| | | //经销商业务订单结算 |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.DistributionAchievementOder, JsonConvert.SerializeObject(data)); |
| | | } |
| | | } |
| | | //订单完成结算订单 |
| | | await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.OrderFinishCommand, orderInfo.orderId); |
| | | |