Exemplo n.º 1
0
        public ActionResult AddShipRule(ShipRuleModel model)
        {
            if (ModelState.IsValid)
            {
                ShipRuleInfo shipRuleInfo = new ShipRuleInfo();
                shipRuleInfo.Name = model.Name;
                shipRuleInfo.Type = model.Type;
                shipRuleInfo.ExtCode1 = model.ExtCode1;
                if (model.Type == 0)
                    shipRuleInfo.ExtCode2 = model.ExtCode2;
                shipRuleInfo.FreeMoney = model.FreeMoney;
                shipRuleInfo.CODPayFee = model.CODPayFee;

                int regionId = 0;
                if (model.ProvinceId > 0)
                    regionId = model.ProvinceId;
                if (model.CityId > 0)
                    regionId = model.CityId;
                if (model.CountyId > 0)
                    regionId = model.CountyId;
                RegionInfo regionInfo = Regions.GetRegionById(regionId);
                if (regionInfo == null)
                {
                    shipRuleInfo.RegionId = 0;
                    shipRuleInfo.RegionTitle = "全国";
                }
                else
                {
                    if (regionInfo.Layer == 1)
                    {
                        shipRuleInfo.RegionId = regionId;
                        shipRuleInfo.RegionTitle = regionInfo.Name;
                    }
                    else if (regionInfo.Layer == 2)
                    {
                        shipRuleInfo.RegionId = regionId;
                        shipRuleInfo.RegionTitle = regionInfo.ProvinceName + regionInfo.Name;
                    }
                    else if (regionInfo.Layer == 3)
                    {
                        shipRuleInfo.RegionId = regionId;
                        shipRuleInfo.RegionTitle = regionInfo.ProvinceName + regionInfo.CityName + regionInfo.Name;
                    }
                }

                List<ShipRuleInfo> shipRuleList = PluginUtils.GetShipRuleList();
                shipRuleList.Add(shipRuleInfo);
                PluginUtils.SaveShipRuleList(shipRuleList);

                AddAdminOperateLog("添加申通快递配送规则");
                return PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "ShipRuleList" }), "配送规则添加成功");
            }

            return PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "AddShipRule" }), "内容有误,请重写填写");
        }
Exemplo n.º 2
0
 public ActionResult AddShipRule()
 {
     ShipRuleModel model = new ShipRuleModel();
     Load(-1, -1, -1);
     return View("~/plugins/BrnShop.ShipPlugin.STO/views/adminsto/addshiprule.cshtml", model);
 }
Exemplo n.º 3
0
        public ActionResult EditShipRule(string shipRuleName = "")
        {
            ShipRuleInfo shipRuleInfo = PluginUtils.GetShipRuleList().Find(x => x.Name == shipRuleName);
            if (shipRuleInfo == null)
                return PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "ShipRuleList" }), "配送规则不存在");

            ShipRuleModel model = new ShipRuleModel();
            model.Name = shipRuleInfo.Name;

            RegionInfo regionInfo = Regions.GetRegionById(shipRuleInfo.RegionId);
            if (regionInfo == null)
            {
                model.ProvinceId = -1;
                model.CityId = -1;
                model.CountyId = -1;
            }
            else
            {
                if (regionInfo.Layer == 1)
                {
                    model.ProvinceId = regionInfo.ProvinceId;
                    model.CityId = -1;
                    model.CountyId = -1;
                }
                else if (regionInfo.Layer == 2)
                {
                    model.ProvinceId = regionInfo.ProvinceId;
                    model.CityId = regionInfo.CityId;
                    model.CountyId = -1;
                }
                else if (regionInfo.Layer == 3)
                {
                    model.ProvinceId = regionInfo.ProvinceId;
                    model.CityId = regionInfo.CityId;
                    model.CountyId = regionInfo.RegionId;
                }
            }

            model.Type = shipRuleInfo.Type;
            model.ExtCode1 = shipRuleInfo.ExtCode1;
            model.ExtCode2 = shipRuleInfo.ExtCode2;
            model.FreeMoney = shipRuleInfo.FreeMoney;
            model.CODPayFee = shipRuleInfo.CODPayFee;

            Load(model.ProvinceId, model.CityId, model.CountyId);

            return View("~/plugins/BrnShop.ShipPlugin.STO/views/adminsto/editshiprule.cshtml", model);
        }