Пример #1
0
        public List <ExpressDTO> GetAllCanUseExpresses()
        {
            var expresses = DomainRegistry.ExpressRepository().GetAll();

            return(expresses.Select(ent => new ExpressDTO
            {
                Freight = ent.Freight,
                ID = ent.ID,
                Name = ent.Name
            }).ToList());
        }
Пример #2
0
        public Result SubmitOrder(SumbitOrderRequest request)
        {
            var cart = _confirmUserCartExistedDomainService.GetUserCart(request.UserId);

            if (cart.IsEmpty())
            {
                return(Result.Fail("当前购物车中并没有商品"));
            }

            var sellingPriceCart = DomainRegistry.SellingPriceService().Calculate(cart);

            var shippingAddress = DomainRegistry.UserService().GetShippingAddress(request.ShippingAddressId);

            if (shippingAddress == null)
            {
                return(Result.Fail("对不起,你选择的收货地址已不存在!"));
            }

            var paymentMethod = DomainRegistry.PaymentService().GetPaymentMethod(request.PaymentMethodId);

            if (paymentMethod == null)
            {
                return(Result.Fail("对不起,你选择的支付方式已不存在!"));
            }

            var express = DomainRegistry.ExpressRepository().GetByIdentity(request.ExpressId);

            if (express == null)
            {
                return(Result.Fail("对不起,你选择的配送方式已不存在!"));
            }

            var coupon = DomainRegistry.SellingPriceService().GetCoupon(request.CouponId);

            if (coupon == null)
            {
                return(Result.Fail("对不起,你选择的礼券不存在!"));
            }
            if (coupon.CanUse)
            {
                return(Result.Fail("对不起,你选择的礼券已使用!"));
            }
            if (coupon.ExpiryDate < DateTime.Now)
            {
                return(Result.Fail("对不起,你选择的礼券已过期!"));
            }

            var waitCreateOrder = ConvertToWaitCreateOrder(cart, sellingPriceCart, shippingAddress, paymentMethod,
                                                           express, coupon);

            return(DomainRegistry.OrderService().Create(waitCreateOrder));
        }