コード例 #1
0
        /// <summary>
        /// 订单付款成功  分单到商家
        /// </summary>
        /// <param name="evnt"></param>
        /// <returns></returns>
        public Task <AsyncTaskResult> HandleAsync(OrderSuccessedEvent evnt)
        {
            //如果付款成功分单到商家
            if (evnt.PayInfo.Total > 0)
            {
                var tasks = new List <Task>();
                //商品按商家ID 分组
                var groupInfo = evnt.OrderTotal.Lines.GroupBy(m => m.SpecificationQuantity.Specification.StoreId).ToList();
                foreach (var item in groupInfo)
                {
                    //分单到商家
                    var storeId = item.Key;
                    var goods   = item.ToList();
                    //商家订单的付款详情计算
                    var storeOrderPayDetailInfo = CalculateStoreOrderPayDetail(
                        evnt.PayInfo,
                        goods.Sum(x => x.LineTotal),
                        goods.Sum(x => x.StoreLineTotal));

                    tasks.Add(_commandService.SendAsync(new CreateStoreOrderCommand(
                                                            GuidUtil.NewSequentialId(),
                                                            evnt.UserId,
                                                            storeId,
                                                            evnt.AggregateRootId,
                                                            DateTime.Now.ToSerialNumber(),
                                                            "",                      //订单备注
                                                            evnt.ExpressAddressInfo,
                                                            evnt.PayInfo,            //这是Order 的付款信息,不一定全是该商家的
                                                            storeOrderPayDetailInfo, //这里放置该商家订单付款信息,根据订单付款信息计算
                                                            goods.Select(x => new OrderGoods(
                                                                             x.SpecificationQuantity.Specification.GoodsId,
                                                                             x.SpecificationQuantity.Specification.SpecificationId,
                                                                             x.SpecificationQuantity.Specification.GoodsName,
                                                                             x.SpecificationQuantity.Specification.GoodsPic,
                                                                             x.SpecificationQuantity.Specification.SpecificationName,
                                                                             x.SpecificationQuantity.Specification.Price,
                                                                             x.SpecificationQuantity.Specification.OriginalPrice,
                                                                             x.SpecificationQuantity.Quantity,
                                                                             CalculateOrderGoodsPayDetail(
                                                                                 storeOrderPayDetailInfo,
                                                                                 x.LineTotal,
                                                                                 x.StoreLineTotal),//这里是商品的付款详情,根据商家订单计算
                                                                             x.SpecificationQuantity.Specification.Benevolence
                                                                             )).ToList())));
                }
                Task.WaitAll(tasks.ToArray());
            }
            return(Task.FromResult(AsyncTaskResult.Success));
        }
コード例 #2
0
 public Task <AsyncTaskResult> HandleAsync(OrderSuccessedEvent evnt)
 {
     return(TryUpdateRecordAsync(connection =>
     {
         return connection.UpdateAsync(new
         {
             Status = (int)OrderStatus.Success,
             Version = evnt.Version
         }, new
         {
             OrderId = evnt.AggregateRootId,
             //Version = evnt.Version - 1
         }, ConfigSettings.OrderTable);
     }));
 }
コード例 #3
0
        /// <summary>
        /// 订单付款成功  分单到商家
        /// </summary>
        /// <param name="evnt"></param>
        /// <returns></returns>
        public Task <AsyncTaskResult> HandleAsync(OrderSuccessedEvent evnt)
        {
            var tasks = new List <Task>();
            //商品按商家ID 分组
            var groupInfo = evnt.OrderTotal.Lines.GroupBy(m => m.SpecificationQuantity.Specification.StoreId).ToList();

            foreach (var item in groupInfo)
            {
                //遍历每个商家
                var storeId = item.Key;
                var goods   = item.ToList <OrderLine>();
                tasks.Add(_commandService.SendAsync(new CreateStoreOrderCommand(
                                                        GuidUtil.NewSequentialId(),
                                                        evnt.UserId,
                                                        storeId,
                                                        evnt.AggregateRootId,
                                                        DateTime.Now.ToSerialNumber(),
                                                        "",//订单备注
                                                        new Shop.Commands.Stores.StoreOrders.ExpressAddressInfo(
                                                            evnt.ExpressAddressInfo.Region,
                                                            evnt.ExpressAddressInfo.Address,
                                                            evnt.ExpressAddressInfo.Name,
                                                            evnt.ExpressAddressInfo.Mobile,
                                                            evnt.ExpressAddressInfo.Zip),
                                                        goods.Select(x => new OrderGoods(
                                                                         x.SpecificationQuantity.Specification.GoodsId,
                                                                         x.SpecificationQuantity.Specification.SpecificationId,
                                                                         x.SpecificationQuantity.Specification.GoodsName,
                                                                         x.SpecificationQuantity.Specification.GoodsPic,
                                                                         x.SpecificationQuantity.Specification.SpecificationName,
                                                                         x.SpecificationQuantity.Specification.Price,
                                                                         x.SpecificationQuantity.Specification.OriginalPrice,
                                                                         x.SpecificationQuantity.Quantity,
                                                                         x.LineTotal,
                                                                         x.StoreLineTotal,
                                                                         x.SpecificationQuantity.Specification.Benevolence
                                                                         )).ToList())));
            }
            Task.WaitAll(tasks.ToArray());
            return(Task.FromResult(AsyncTaskResult.Success));
        }
コード例 #4
0
 private void Handle(OrderSuccessedEvent evnt)
 {
     _status = OrderStatus.Success;
     _specificationConfirmStatus = null;
 }
コード例 #5
0
ファイル: Order.cs プロジェクト: hardweight/ShopBackend
 private void Handle(OrderSuccessedEvent evnt)
 {
     _status = OrderStatus.Success;
 }