Esempio n. 1
0
        public ActionResult ShipRuleList()
        {
            ShipRuleListModel model = new ShipRuleListModel();

            model.ShipRuleList = PluginUtils.GetShipRuleList();
            return(View("~/plugins/BrnShop.ShipPlugin.STO/views/adminsto/shiprulelist.cshtml", model));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        /// <summary>
        /// 删除配送规则
        /// </summary>
        public ActionResult DelShipRule(string shipRuleName = "")
        {
            List <ShipRuleInfo> shipRuleList = PluginUtils.GetShipRuleList();

            foreach (ShipRuleInfo shipRuleInfo in shipRuleList)
            {
                if (shipRuleInfo.Name == shipRuleName)
                {
                    shipRuleList.Remove(shipRuleInfo);
                    break;
                }
            }

            PluginUtils.SaveShipRuleList(shipRuleList);
            AddAdminOperateLog("删除申通快递配送规则");
            return(PromptView(Url.Action("config", "plugin", new { configController = "AdminSTO", configAction = "ShipRuleList" }), "配送规则删除成功"));
        }
Esempio n. 4
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" }), "内容有误,请重写填写"));
        }