Ejemplo n.º 1
0
        /// <summary>
        /// 编辑配送地址
        /// </summary>
        public ActionResult EditShipAddress()
        {
            if (WebHelper.IsGet())
            {
                int saId = WebHelper.GetQueryInt("saId");
                FullShipAddressInfo fullShipAddressInfo = ShipAddresses.GetFullShipAddressBySAId(saId, WorkContext.Uid);
                if (fullShipAddressInfo == null)
                    return PromptView(Url.Action("shipaddresslist"), "地址不存在");

                ShipAddressModel model = new ShipAddressModel();
                model.Alias = fullShipAddressInfo.Alias;
                model.Consignee = fullShipAddressInfo.Consignee;
                model.Mobile = fullShipAddressInfo.Mobile;
                model.Phone = fullShipAddressInfo.Phone;
                model.Email = fullShipAddressInfo.Email;
                model.ZipCode = fullShipAddressInfo.ZipCode;
                model.ProvinceId = fullShipAddressInfo.ProvinceId;
                model.CityId = fullShipAddressInfo.CityId;
                model.RegionId = fullShipAddressInfo.RegionId;
                model.Address = fullShipAddressInfo.Address;
                model.IsDefault = fullShipAddressInfo.IsDefault;

                return View(model);
            }
            else
            {
                int saId = WebHelper.GetQueryInt("saId");
                int regionId = WebHelper.GetFormInt("regionId");
                string alias = WebHelper.GetFormString("alias");
                string consignee = WebHelper.GetFormString("consignee");
                string mobile = WebHelper.GetFormString("mobile");
                string phone = WebHelper.GetFormString("phone");
                string email = WebHelper.GetFormString("email");
                string zipcode = WebHelper.GetFormString("zipcode");
                string address = WebHelper.GetFormString("address");
                int isDefault = WebHelper.GetFormInt("isDefault");

                string verifyResult = VerifyShipAddress(regionId, alias, consignee, mobile, phone, email, zipcode, address);
                if (verifyResult.Length == 0)
                {
                    ShipAddressInfo shipAddressInfo = ShipAddresses.GetShipAddressBySAId(saId, WorkContext.Uid);
                    //检查地址
                    if (shipAddressInfo == null)
                        return AjaxResult("noexist", "配送地址不存在");

                    shipAddressInfo.Uid = WorkContext.Uid;
                    shipAddressInfo.RegionId = regionId;
                    shipAddressInfo.IsDefault = isDefault == 0 ? 0 : 1;
                    shipAddressInfo.Alias = WebHelper.HtmlEncode(alias);
                    shipAddressInfo.Consignee = WebHelper.HtmlEncode(consignee);
                    shipAddressInfo.Mobile = mobile;
                    shipAddressInfo.Phone = phone;
                    shipAddressInfo.Email = email;
                    shipAddressInfo.ZipCode = zipcode;
                    shipAddressInfo.Address = WebHelper.HtmlEncode(address);
                    ShipAddresses.UpdateShipAddress(shipAddressInfo);
                    return AjaxResult("success", "编辑成功");
                }
                else
                {
                    return AjaxResult("error", verifyResult, true);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加配送地址
        /// </summary>
        public ActionResult AddShipAddress()
        {
            if (WebHelper.IsGet())
            {
                ShipAddressModel model = new ShipAddressModel();
                return View(model);
            }
            else
            {
                int regionId = WebHelper.GetFormInt("regionId");
                string alias = WebHelper.GetFormString("alias");
                string consignee = WebHelper.GetFormString("consignee");
                string mobile = WebHelper.GetFormString("mobile");
                string phone = WebHelper.GetFormString("phone");
                string email = WebHelper.GetFormString("email");
                string zipcode = WebHelper.GetFormString("zipcode");
                string address = WebHelper.GetFormString("address");
                int isDefault = WebHelper.GetFormInt("isDefault");

                string verifyResult = VerifyShipAddress(regionId, alias, consignee, mobile, phone, email, zipcode, address);

                if (verifyResult.Length == 0)
                {
                    //检查配送地址数量是否达到系统所允许的最大值
                    int shipAddressCount = ShipAddresses.GetShipAddressCount(WorkContext.Uid);
                    if (shipAddressCount >= WorkContext.MallConfig.MaxShipAddress)
                        return AjaxResult("full", "配送地址的数量已经达到系统所允许的最大值");

                    ShipAddressInfo shipAddressInfo = new ShipAddressInfo();
                    shipAddressInfo.Uid = WorkContext.Uid;
                    shipAddressInfo.RegionId = regionId;
                    shipAddressInfo.IsDefault = isDefault == 0 ? 0 : 1;
                    shipAddressInfo.Alias = WebHelper.HtmlEncode(alias);
                    shipAddressInfo.Consignee = WebHelper.HtmlEncode(consignee);
                    shipAddressInfo.Mobile = mobile;
                    shipAddressInfo.Phone = phone;
                    shipAddressInfo.Email = email;
                    shipAddressInfo.ZipCode = zipcode;
                    shipAddressInfo.Address = WebHelper.HtmlEncode(address);
                    int saId = ShipAddresses.CreateShipAddress(shipAddressInfo);
                    return AjaxResult("success", saId.ToString());
                }
                else
                {
                    return AjaxResult("error", verifyResult, true);
                }
            }
        }