コード例 #1
0
        //public static CheckOutResult GetPayAndShipTypeList(CheckOutContext context, int customerSysNo)
        //{
        //    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 取得配送地址支持的所有配送方式
        //    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();
        //        }
        //    }
        //    result.PayTypeList = EnsureNotNullObject(result.PayTypeList);
        //    result.SelPayType = EnsureNotNullObject(result.SelPayType);
        //    #endregion

        //    return result;
        //}

        public static CheckOutResult GetCustomerShippingAddressList(CheckOutContext context, int customerSysNo)
        {
            CheckOutResult             result                      = new CheckOutResult();
            ShippingContactInfo        curShippingAddress          = null;
            List <ShippingContactInfo> customerShippingAddressList = CustomerShippingAddresssFacade.GetCustomerShippingAddressList(customerSysNo);

            if (customerShippingAddressList != null && customerShippingAddressList.Count > 0)
            {
                if (context == null)
                {
                    curShippingAddress = customerShippingAddressList.Find(x => x.IsDefault);
                }
                else
                {
                    curShippingAddress = customerShippingAddressList.Find(x => x.SysNo == context.ShippingAddressID);
                }
                if (curShippingAddress == null)
                {
                    curShippingAddress = customerShippingAddressList.First();
                }
            }
            result.ShippingAddressList = EnsureNotNullObject(customerShippingAddressList);
            result.SelShippingAddress  = EnsureNotNullObject(curShippingAddress);

            return(result);
        }
コード例 #2
0
        public ActionResult AjaxGetShipTypeList(string paymentcateid, string shipaddrsysno)
        {
            PaymentCategory paymentCate;
            int             shipAddrSysNo;

            if (!Enum.TryParse(paymentcateid, out paymentCate))
            {
                throw new BusinessException("无效的请求");
            }
            if (!int.TryParse(shipaddrsysno, out shipAddrSysNo))
            {
                throw new BusinessException("无效的请求");
            }

            var shippingAddress = CustomerShippingAddresssFacade.GetCustomerShippingAddress(shipAddrSysNo, CurrUser.UserSysNo);

            if (shippingAddress == null)
            {
                return(PartialView("_ShipTypePanel", new List <ShipTypeInfo>(0)));
            }
            ShoppingCart   shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
            CheckOutResult result       = ShoppingFacade.GetPayAndShipTypeList(null, CurrUser.UserSysNo, shoppingCart);
            var            shipTypeList = result.ShipTypeList;

            //var shipTypeList = ShipTypeFacade.GetSupportedShipTypeList(shippingAddress.ReceiveAreaSysNo, paymentCate);
            return(PartialView("_ShipTypePanel", shipTypeList));
        }
コード例 #3
0
        public ActionResult EditShippingAddress()
        {
            if (Request["cmd"] == null)
            {
                throw new BusinessException("无效的请求");
            }

            int    contactAddressSysNo;
            string command = Request["cmd"].Trim().ToUpper();

            switch (command)
            {
            case "GET":

                if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo))
                {
                    throw new BusinessException("无效的请求");
                }
                else
                {
                    ShippingContactInfo customerShippingAddressInfo = CustomerShippingAddresssFacade.GetCustomerShippingAddress(contactAddressSysNo, CurrUser.UserSysNo);
                    if (customerShippingAddressInfo == null)
                    {
                        throw new BusinessException("无效的收货地址");
                    }
                    return(PartialView("_RMAShippingAddressEditPanel", customerShippingAddressInfo));
                }

            case "DEL":

                if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo))
                {
                    throw new BusinessException("无效的请求");
                }
                else
                {
                    CustomerShippingAddresssFacade.DeleteCustomerContactInfo(contactAddressSysNo, CurrUser.UserSysNo);
                    return(Json(new { sysno = contactAddressSysNo }));
                }

            case "DEFAULT":
                if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo))
                {
                    throw new BusinessException("无效的请求");
                }
                else
                {
                    CustomerShippingAddresssFacade.SetCustomerContactAsDefault(contactAddressSysNo, CurrUser.UserSysNo);
                    return(Content("y"));
                }

            default:
                break;
            }

            return(Json(""));
        }
コード例 #4
0
        public ActionResult AjaxGetShippingAddress()
        {
            int contactAddressSysNo;

            if (Request["id"] == null || !int.TryParse(Request["id"], out contactAddressSysNo))
            {
                throw new BusinessException("无效的请求");
            }
            else
            {
                ShippingContactInfo customerShippingAddressInfo = CustomerShippingAddresssFacade.GetCustomerShippingAddress(contactAddressSysNo, CurrUser.UserSysNo);
                if (customerShippingAddressInfo == null)
                {
                    throw new BusinessException("无效的收货地址");
                }
                return(PartialView("_ReceiveAddressEdit", customerShippingAddressInfo));
            }
        }
コード例 #5
0
        public ActionResult AjaxEditPayAndShipType(CheckOutContext context)
        {
            if (context == null)
            {
                throw new BusinessException("无效的请求");
            }
            PaymentCategory paymentCate;
            int             shipTypeID;

            if (!Enum.TryParse(context.PaymentCategoryID, out paymentCate) ||
                !int.TryParse(context.ShipTypeID, out shipTypeID))
            {
                throw new BusinessException("无效的请求");
            }
            CustomerShippingAddresssFacade.UpdateCustomerContactInfo(context.ShippingAddressID,
                                                                     (int)paymentCate, shipTypeID, CurrUser.UserSysNo);
            return(Content("y"));
        }
コード例 #6
0
        public ActionResult AjaxSubmitShippingAddress(FormCollection form)
        {
            ShippingContactInfo shippingAddressInfo = new ShippingContactInfo();

            if (TryUpdateModel(shippingAddressInfo))
            {
                int receiveAreaIdD;
                if (int.TryParse(Request["District"], out receiveAreaIdD) && receiveAreaIdD > 0)
                {
                    shippingAddressInfo.ReceiveAreaSysNo = receiveAreaIdD;
                    //checkout页面“收货人”和“联系人”写成同一个值
                    shippingAddressInfo.ReceiveContact = shippingAddressInfo.ReceiveName;
                    CustomerShippingAddresssFacade.EditCustomerContactInfo(shippingAddressInfo, CurrUser.UserSysNo);
                    return(Json(shippingAddressInfo));
                }
                return(Json(BuildAjaxErrorObject("收货区域不能为空")));
            }
            return(Json(BuildAjaxErrorObject("无效的请求")));
        }
コード例 #7
0
        public ActionResult GetShippingAddressList(CheckOutContext context)
        {
            if (context == null)
            {
                throw new BusinessException("无效的请求");
            }

            CheckOutResult result = new CheckOutResult();

            result.ShippingAddressList = CustomerShippingAddresssFacade.GetCustomerShippingAddressList(CurrUser.UserSysNo);
            if (result.ShippingAddressList != null)
            {
                result.SelShippingAddress = result.ShippingAddressList.Find(x => x.SysNo == context.ShippingAddressID);
                if (result.SelShippingAddress == null)
                {
                    result.SelShippingAddress = result.ShippingAddressList.Find(x => x.IsDefault);
                }
            }
            return(PartialView("_RMAShippingAddressPanel", result));
        }
コード例 #8
0
        public ActionResult CreateCustomerShippingInfo(FormCollection form)
        {
            string Action = Request["Action"].ToString();
            string Data   = Request["Data"].ToString();

            Data = System.Web.HttpUtility.UrlDecode(Data);
            JavaScriptSerializer jss             = new JavaScriptSerializer();
            ShippingContactInfo  shippingAddress = jss.Deserialize <ShippingContactInfo>(Data); // JsonHelper.JsonToObject<ShippingContactInfo>(Data);

            shippingAddress.ReceiveName = shippingAddress.ReceiveContact;
            if (Action == "2")
            {
                CustomerShippingAddresssFacade.DeleteCustomerContactInfo(shippingAddress.SysNo, CurrUser.UserSysNo);
            }
            else
            {
                CustomerShippingAddresssFacade.EditCustomerContactInfo(shippingAddress, CurrUser.UserSysNo);
            }
            return(Json("s", JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public ActionResult SubmitShippingAddress()
        {
            ShippingContactInfo shippingAddressInfo = new ShippingContactInfo()
            {
                IsDefault = true
            };

            if (TryUpdateModel(shippingAddressInfo))
            {
                int receiveAreaIdD;
                if (int.TryParse(Request["District"], out receiveAreaIdD) && receiveAreaIdD > 0)
                {
                    shippingAddressInfo.ReceiveAreaSysNo = receiveAreaIdD;
                    //checkout页面“收货人”和“联系人”写成同一个值
                    shippingAddressInfo.ReceiveContact = shippingAddressInfo.ReceiveName;
                    shippingAddressInfo = CustomerShippingAddresssFacade.EditCustomerContactInfo(shippingAddressInfo, CurrUser.UserSysNo);
                    return(Json(shippingAddressInfo));
                }
                throw new BusinessException("收货区域不能为空");
            }
            throw new BusinessException("无效的请求");
        }