Exemplo n.º 1
0
 /// <summary>
 /// 取得用户购物发票信息
 /// </summary>
 /// <param name="customerSysNo"></param>
 /// <returns></returns>
 public static CustomerInvoiceInfo GetCustomerInvoiceInfo(int customerSysNo)
 {
     return(CustomerDA.GetCustomerInvoiceInfo(customerSysNo));
 }
Exemplo n.º 2
0
        private static CheckOutResult PreCheckAndBuild(CheckOutContext context, ShoppingCart shoppingCart, int customerSysNo, int orderSource
                                                       , Func <OrderInfo, OrderPipelineProcessResult> action)
        {
            CheckOutResult result = new CheckOutResult();

            MemberInfo memberInfo = CustomerDA.GetCustomerInfo(customerSysNo);

            CheckOutContext newCheckoutContenxt = new CheckOutContext();

            if (context != null)
            {
                newCheckoutContenxt = context.Clone();
            }

            CustomerInfo customerInfo = new CustomerInfo()
            {
                AccountBalance   = memberInfo.ValidPrepayAmt,
                AccountPoint     = memberInfo.ValidScore,
                CustomerRank     = (int)memberInfo.CustomerRank,
                ID               = memberInfo.CustomerID,
                SysNo            = memberInfo.SysNo,
                Name             = memberInfo.CustomerName,
                IsEmailConfirmed = memberInfo.IsEmailConfirmed,
                IsPhoneValided   = memberInfo.IsPhoneValided,
                CellPhone        = memberInfo.CellPhone,
                SocietyID        = memberInfo.SocietyID
            };

            result.Customer = customerInfo;
            //用户个人实名认证信息
            result.CustomerAuthenticationInfo = CustomerDA.GetCustomerAuthenticationInfo(customerSysNo);

            //用户购物发票信息
            result.CustomerInvoiceInfo = CustomerDA.GetCustomerInvoiceInfo(customerSysNo);
            if (result.CustomerInvoiceInfo == null)
            {
                result.CustomerInvoiceInfo = new Entity.Member.CustomerInvoiceInfo()
                {
                    CustomerSysNo = customerSysNo, InvoiceTitle = customerInfo.Name
                };
            }

            //收货地址
            var custShippingAddressListResult = GetCustomerShippingAddressList(context, customerSysNo);

            result.ShippingAddressList = custShippingAddressListResult.ShippingAddressList;
            result.SelShippingAddress  = custShippingAddressListResult.SelShippingAddress;

            //支付方式&配送方式
            var payAndShipTypeResult = GetPayAndShipTypeList(context, customerSysNo, shoppingCart);

            result.PaymentCategoryList  = payAndShipTypeResult.PaymentCategoryList;
            result.SelPaymentCategoryID = payAndShipTypeResult.SelPaymentCategoryID;
            result.PayTypeList          = payAndShipTypeResult.PayTypeList;
            result.SelPayType           = payAndShipTypeResult.SelPayType;
            result.ShipTypeList         = payAndShipTypeResult.ShipTypeList;
            result.SelShipType          = payAndShipTypeResult.SelShipType;

            //根据CheckOutContext 进一步构造shoppingCartResult.ReturnData对象
            OrderInfo preOrderInfo = SOPipelineProcessor.Convert2OrderInfo(shoppingCart);

            preOrderInfo.Customer               = customerInfo;
            preOrderInfo.PayTypeID              = result.SelPayType.PayTypeID.ToString();
            preOrderInfo.ShipTypeID             = result.SelShipType.ShipTypeSysNo.ToString();
            preOrderInfo.Memo                   = newCheckoutContenxt.OrderMemo;
            preOrderInfo.CouponCode             = newCheckoutContenxt.PromotionCode;
            preOrderInfo.ChannelID              = shoppingCart.ChannelID;
            preOrderInfo.LanguageCode           = shoppingCart.LanguageCode;
            preOrderInfo.OrderSource            = orderSource;
            preOrderInfo.VirualGroupBuyOrderTel = context != null ? context.VirualGroupBuyOrderTel : "";

            preOrderInfo.Contact = new ContactInfo()
            {
                AddressAreaID = result.SelShippingAddress.ReceiveAreaSysNo,
                //AddressAreaID = result.SelShippingAddress.ReceiveAreaCitySysNo,
                AddressTitle  = result.SelShippingAddress.AddressTitle,
                AddressDetail = result.SelShippingAddress.ReceiveAddress,
                MobilePhone   = result.SelShippingAddress.ReceiveCellPhone,
                Phone         = result.SelShippingAddress.ReceivePhone,
                Name          = result.SelShippingAddress.ReceiveName,
                ZipCode       = result.SelShippingAddress.ReceiveZip,
                ID            = result.SelShippingAddress.SysNo,
            };
            //使用余额进行支付,给订单的余额支付金额赋值,在SOPipline中会对订单的余额支付金额重新进行计算
            if (newCheckoutContenxt.IsUsedPrePay > 0)
            {
                preOrderInfo.BalancePayAmount = customerInfo.AccountBalance;
            }
            //积分
            preOrderInfo.PointPay = newCheckoutContenxt.PointPay;
            //礼品卡
            if (newCheckoutContenxt.GiftCardList != null && newCheckoutContenxt.GiftCardList.Count > 0)
            {
                preOrderInfo.GiftCardList = new List <GiftCardInfo>();
                foreach (var giftCardContext in newCheckoutContenxt.GiftCardList)
                {
                    if (!string.IsNullOrWhiteSpace(giftCardContext.Crypto))
                    {
                        giftCardContext.Password = ExtractGiftCardPassword(giftCardContext.Password, customerSysNo);
                    }
                    GiftCardInfo giftCardInfo = new GiftCardInfo()
                    {
                        Code     = giftCardContext.Code,
                        Password = giftCardContext.Password
                    };
                    giftCardInfo["Crypto"] = giftCardContext.Crypto;
                    preOrderInfo.GiftCardList.Add(giftCardInfo);
                }
            }
            //购物发票,1表示要开发票
            if (newCheckoutContenxt.NeedInvoice == 1)
            {
                preOrderInfo.Receipt = new ReceiptInfo()
                {
                    PersonalInvoiceTitle = result.CustomerInvoiceInfo.InvoiceTitle
                };
            }
            //执行真正的action操作
            OrderPipelineProcessResult checkOutResult = action(preOrderInfo);

            SetCheckoutResult(checkOutResult, result, newCheckoutContenxt);

            return(result);
        }