Example #1
0
        public async Task <OrderOutput> Order(OrderInput input)
        {
            var goods    = _sellAppService.GetGoodsInfoById(input.GoodId, input.SellType);
            var discount = _sellAppService.GetDiscount(goods.AuthRankId, input.SellType);

            if (goods.Term.HasValue)
            {
                if (input.Count != goods.Term.Value && input.UnitPrice.Equals(goods.UnitPrice) &&
                    input.Discount.Equals(discount))
                {
                    throw new LotteryDataException("订单信息错误,核对您的订单");
                }
            }
            else
            {
                if (input.UnitPrice.Equals(goods.UnitPrice) &&
                    input.Discount.Equals(discount))
                {
                    throw new LotteryDataException("订单信息错误,核对您的订单");
                }
            }
            var orderInfo = GenerateOrder(input, goods, discount);

            await SendCommandAsync(orderInfo);

            var orderDic = new List <OrderInfoItem>();

            orderDic.Add(new OrderInfoItem()
            {
                Label = "订单号",
                Value = orderInfo.SalesOrderNo,
                Key   = "SalesOrderNo",
            });
            orderDic.Add(new OrderInfoItem()
            {
                Label = "商品名称",
                Value = goods.GoodName,
                Key   = "GoodName"
            });
            orderDic.Add(new OrderInfoItem()
            {
                Label = "授权版本",
                Value = ((MemberRank)goods.MemberRank).GetChineseDescribe(),
                Key   = "MemberRank"
            });

            orderDic.Add(new OrderInfoItem()
            {
                Label = "有效期",
                Value = DateTime.Now.AddMonths(orderInfo.Count).ToString("yyyy-MM-dd HH:mm:ss"),
                Key   = "ValidDate"
            });

            if (!discount.Equals(1.00))
            {
                orderDic.Add(new OrderInfoItem()
                {
                    Label = "原价",
                    Value = orderInfo.OriginalCost.ToString("0.00"),
                    Key   = "OriginalCost"
                });

                orderDic.Add(new OrderInfoItem()
                {
                    Label = "折扣",
                    Value = discount.ToString("0.00"),
                    Key   = "discount"
                });
            }

            var output = new OrderOutput()
            {
                OrderPrice = orderInfo.OrderCost,
                OrderInfo  = orderDic,
                OrderNo    = orderInfo.SalesOrderNo,
            };

            return(output);
        }