/// <summary> /// 默认佣金设置 /// </summary> /// <returns></returns> public ActionResult DefaultBrokerage() { var data = DistributionApplication.GetDefaultBrokerageRate(curshopid); var model = new DistributionDefaultBrokerageModel() { BrokerageRate1 = data.BrokerageRate1, BrokerageRate2 = data.BrokerageRate2, BrokerageRate3 = data.BrokerageRate3, DistributionMaxBrokerageRate = SiteSettings.DistributionMaxBrokerageRate, DistributionMaxLevel = SiteSettings.DistributionMaxLevel }; model.IsConfigRight = true; if (model.BrokerageRate1 + model.BrokerageRate2 + model.BrokerageRate3 > model.DistributionMaxBrokerageRate) { model.IsConfigRight = false; } if (model.BrokerageRate1 <= 0) { model.IsConfigRight = false; } if (model.DistributionMaxLevel > 1 && model.BrokerageRate2 <= 0) { model.IsConfigRight = false; } if (model.DistributionMaxLevel > 2 && model.BrokerageRate3 <= 0) { model.IsConfigRight = false; } return(View(model)); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); bool isclose = !SiteSettingApplication.SiteSettings.DistributionIsEnable; if (isclose && RouteData.Values["action"].ToString().ToLower() != "nosetting") { Response.Clear(); Response.BufferOutput = true; Response.Redirect(Url.Action("NoSetting")); } curshopid = CurrentSellerManager.ShopId; var dbkdata = DistributionApplication.GetDefaultBrokerageRate(curshopid); isConfigRight = true; if (dbkdata.BrokerageRate1 < 0.1m || dbkdata.BrokerageRate1 > 100) { isConfigRight = false; } if (SiteSettings.DistributionMaxLevel > 1 && (dbkdata.BrokerageRate2 < 0.1m || dbkdata.BrokerageRate2 > 100)) { isConfigRight = false; } if (SiteSettings.DistributionMaxLevel > 2 && (dbkdata.BrokerageRate3 < 0.1m || dbkdata.BrokerageRate3 > 100)) { isConfigRight = false; } if (SiteSettings.DistributionMaxBrokerageRate < (dbkdata.BrokerageRate1 + dbkdata.BrokerageRate2 + dbkdata.BrokerageRate3)) { isConfigRight = false; } }
public JsonResult DefaultBrokerage(DistributionDefaultBrokerageModel model) { Result result = new Result { success = false, msg = "未知错误" }; bool isdataok = true; if (!ModelState.IsValid) { result.success = false; result.msg = "佣金比例不能为0,且总和需小于 " + SiteSettings.DistributionMaxBrokerageRate + "%"; isdataok = false; } if (SiteSettings.DistributionMaxLevel > 1 && model.BrokerageRate2 <= 0) { result.success = false; result.msg = "佣金比例不能为0,且总和需小于 " + SiteSettings.DistributionMaxBrokerageRate + "%"; isdataok = false; } if (SiteSettings.DistributionMaxLevel < 2) { model.BrokerageRate2 = 0; } if (SiteSettings.DistributionMaxLevel > 2 && model.BrokerageRate3 <= 0) { result.success = false; result.msg = "佣金比例不能为0,且总和需小于 " + SiteSettings.DistributionMaxBrokerageRate + "%"; isdataok = false; } if (SiteSettings.DistributionMaxLevel < 3) { model.BrokerageRate3 = 0; } if (model.BrokerageRate1 + model.BrokerageRate2 + model.BrokerageRate3 > SiteSettings.DistributionMaxBrokerageRate) { result.success = false; result.msg = "佣金比例不能为0,且总和需小于 " + SiteSettings.DistributionMaxBrokerageRate + "%"; isdataok = false; } if (isdataok) { string _str = model.BrokerageRate1.ToString(); //验证格式 if (!Regex.IsMatch(_str, @"^\d{1,2}(\.\d)?$")) { result.success = false; result.msg = "错误的数据格式,只可以保留一位小数"; isdataok = false; } _str = model.BrokerageRate2.ToString(); //验证格式 if (!Regex.IsMatch(_str, @"^\d{1,2}(\.\d)?$")) { result.success = false; result.msg = "错误的数据格式,只可以保留一位小数"; isdataok = false; } _str = model.BrokerageRate3.ToString(); //验证格式 if (!Regex.IsMatch(_str, @"^\d{1,2}(\.\d)?$")) { result.success = false; result.msg = "错误的数据格式,只可以保留一位小数"; isdataok = false; } } if (isdataok) { var data = DistributionApplication.GetDefaultBrokerageRate(curshopid); data.BrokerageRate1 = model.BrokerageRate1; data.BrokerageRate2 = model.BrokerageRate2; data.BrokerageRate3 = model.BrokerageRate3; DistributionApplication.UpdateDefaultBrokerageRate(curshopid, data); result.success = true; result.msg = "设置默认佣金比例成功!"; } return(Json(result)); }