Ejemplo n.º 1
0
        /// <summary>
        /// 查询用户优惠券
        /// </summary>
        /// <param name="query">查询信息</param>
        /// <returns></returns>
        public static QueryResult <CustomerCouponInfo> QueryCouponCode(CustomerCouponCodeQueryInfo query)
        {
            var memberInfo = CustomerDA.GetCustomerInfo(query.CustomerSysNo);

            query.CustomerRank = (int)memberInfo.CustomerRank;
            return(CustomerDA.QueryCouponCode(query));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取客户信息
        /// </summary>
        /// <param name="sysNo">客户SysNo</param>
        /// <returns>客户信息</returns>
        public static CustomerInfo GetCustomerInfo(int sysNo)
        {
            CustomerInfo item = CustomerDA.GetCustomerInfo(sysNo);

            if (item != null)
            {
                item.ExtendInfo = CustomerDA.GetCustomerExtendInfo(sysNo);
            }
            return(item);
        }
Ejemplo n.º 3
0
        public static CheckOutResult GetPayAndShipTypeList(CheckOutContext context, int customerSysNo, ShoppingCart shoppingCart)
        {
            CheckOutResult result = new CheckOutResult();

            CheckOutContext newCheckoutContenxt = new CheckOutContext();

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

            MemberInfo memberInfo = CustomerDA.GetCustomerInfo(customerSysNo);

            //取得用户选择的收货地址信息
            var custShippingAddrResult = GetCustomerShippingAddressList(newCheckoutContenxt, customerSysNo);

            result.SelShippingAddress = custShippingAddrResult.SelShippingAddress;

            #region 支付类别选择
            result.PaymentCategoryList = GetAllPaymentCategoryList();
            //优先取context指定的支付类型
            //其次取配送地址指定的支付类型
            if (!result.PaymentCategoryList.Exists(x =>
            {
                if (x.Key.ToString() == newCheckoutContenxt.PaymentCategoryID ||
                    x.Key == result.SelShippingAddress.PaymentCategoryID)
                {
                    result.SelPaymentCategoryID = x.Key;
                    return(true);
                }
                return(false);
            }))
            {
                //都没有就取第一条支付类型
                result.SelPaymentCategoryID = result.PaymentCategoryList.First().Key;
            }
            #endregion



            #region 配送方式选择
            //step1 取得配送地址支持的所有配送方式
            List <ShipTypeInfo> ShipTypeInfoList = new List <ShipTypeInfo>();
            List <ShipTypeInfo> shipTypeList     = new List <ShipTypeInfo>();
            foreach (ShoppingItemGroup ShoppingItemGroup in shoppingCart.ShoppingItemGroupList)
            {
                foreach (ShoppingItem ShoppingItem in ShoppingItemGroup.ShoppingItemList)
                {
                    ProductBasicInfo    basicInfo   = ProductFacade.GetProductBasicInfoBySysNo(ShoppingItem.ProductSysNo);
                    List <ShipTypeInfo> ShipTypeNew = ShipTypeFacade.Checkout_GetStockShippingType(basicInfo.VendorSysno);
                    if (ShipTypeNew.Count > 0)
                    {
                        if (ShipTypeInfoList.Count <= 0)
                        {
                            ShipTypeInfoList.AddRange(ShipTypeNew);
                            shipTypeList.AddRange(ShipTypeNew);
                        }
                        else
                        {
                            shipTypeList = new List <ShipTypeInfo>();
                            for (int i = 0; i < ShipTypeInfoList.Count; i++)
                            {
                                for (int j = 0; j < ShipTypeNew.Count; j++)
                                {
                                    if (ShipTypeInfoList[i].ShipTypeName == ShipTypeNew[j].ShipTypeName)
                                    {
                                        shipTypeList.Add(ShipTypeInfoList[i]);
                                    }
                                }
                            }
                            if (shipTypeList.Count <= 0)
                            {
                                result.ErrorMessages.Add("不同商家的商品,没有相同的配送方式,请分开下单!");
                                break;
                            }
                            else
                            {
                                ShipTypeInfoList = shipTypeList;
                            }
                        }
                    }
                    else
                    {
                        string error = string.Format("商品【{0}】没有对应配送方式,暂时无法为您配送!", basicInfo.ProductName);
                        result.ErrorMessages.Add(error);
                        result.ShipTypeList = null;
                        break;
                    }
                }
                if (result.ErrorMessages.Count > 0)
                {
                    break;
                }
            }
            //var shipTypeList = ShipTypeFacade.GetSupportedShipTypeList(result.SelShippingAddress.ReceiveAreaSysNo, null);
            //step2 如果不存在支持货到付款的配送方式, 则移除掉货到付款支付类别
            if (shipTypeList.Count(x => x.IsPayWhenRecv) <= 0)
            {
                result.PaymentCategoryList  = result.PaymentCategoryList.FindAll(x => x.Key == (int)PaymentCategory.OnlinePay);
                result.SelPaymentCategoryID = (int)PaymentCategory.OnlinePay;
            }
            //step3 如果选择的是货到付款,则移除掉不支持货到付款的配送方式
            if (result.SelPaymentCategoryID == (int)PaymentCategory.PayWhenRecv)
            {
                result.ShipTypeList = shipTypeList.Where(x => x.IsPayWhenRecv).ToList();
                //step4 移除掉不支持货到付款的配送方式后没有可用的配送方式时,系统自动选择在线支付
                if (result.ShipTypeList.Count <= 0)
                {
                    result.ShipTypeList         = shipTypeList;
                    result.PaymentCategoryList  = result.PaymentCategoryList.FindAll(x => x.Key == (int)PaymentCategory.OnlinePay);
                    result.SelPaymentCategoryID = (int)PaymentCategory.OnlinePay;
                }
            }
            else
            {
                result.ShipTypeList = shipTypeList;
            }

            //优先取context指定的配送方式
            result.SelShipType = result.ShipTypeList.Find(x => x.ShipTypeSysNo.ToString() == newCheckoutContenxt.ShipTypeID);
            //其次取配送地址指定的配送方式
            if (result.SelShipType == null && result.SelShippingAddress != null)
            {
                result.SelShipType = result.ShipTypeList.Find(x => x.ShipTypeSysNo == result.SelShippingAddress.ShipTypeSysNo);
            }
            //都没有就取第一条配送方式
            if (result.SelShipType == null && result.ShipTypeList.Count > 0)
            {
                result.SelShipType = result.ShipTypeList.First();
            }
            result.ShipTypeList = EnsureNotNullObject(result.ShipTypeList);
            result.SelShipType  = EnsureNotNullObject(result.SelShipType);
            #endregion

            #region 支付方式选择
            result.PayTypeList = GetAllPayTypeList();
            if (result.SelPaymentCategoryID == (int)PaymentCategory.PayWhenRecv)
            {
                result.PayTypeList = result.PayTypeList.FindAll(x => x.IsPayWhenRecv == 1);
            }
            //优先取用户上次下单使用的支付方式
            result.SelPayType = result.PayTypeList.Find(x => x.PayTypeID == memberInfo.ExtendInfo.LastPayTypeSysNo);
            if (result.SelPayType == null && result.PayTypeList.Count > 0)
            {
                result.SelPayType = result.PayTypeList.First();
            }
            if (result.SelPayType != null && result.PayTypeList.Count > 0)
            {
                var cateId             = result.SelPayType.IsPayWhenRecv == 1 ? (int)PaymentCategory.PayWhenRecv : (int)PaymentCategory.OnlinePay;
                var isPayWhenRecvValue = result.SelPaymentCategoryID == (int)PaymentCategory.PayWhenRecv ? 1 : 0;
                //如果上次下单用户使用的支付方式类型跟本次下单选择的支付类型不一致
                //则选择符合当前选择的支付类型的第一个支付方式
                if (cateId != result.SelPaymentCategoryID)
                {
                    result.SelPayType = result.PayTypeList.Where(x => x.IsPayWhenRecv == isPayWhenRecvValue).First();
                }

                if (context != null && context.PayTypeID.HasValue)
                {
                    result.SelPayType = result.PayTypeList.Where(x => x.PayTypeID == context.PayTypeID.Value).First();
                }
            }
            result.PayTypeList = EnsureNotNullObject(result.PayTypeList);
            result.SelPayType  = EnsureNotNullObject(result.SelPayType);
            #endregion

            return(result);
        }
Ejemplo n.º 4
0
        public static CustomerBasicInfo GetCustomerInfo(int customerSysNo)
        {
            CustomerBasicInfo customerInfo = CustomerDA.GetCustomerInfo(customerSysNo);

            return(customerInfo);
        }
Ejemplo n.º 5
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);
        }