コード例 #1
0
        public JsonResult updateRate(long id, decimal rate)
        {
            Result result = new Result {
                success = false, msg = "未知错误"
            };
            List <long> ids = new List <long>();

            if (id > 0)
            {
                ids.Add(id);
                bool isdataok = true;
                if (rate < 0.1m || rate > 90)
                {
                    result.success = false;
                    result.msg     = "比例需在 0.1% ~ 90% 之间";
                    isdataok       = false;
                }
                if (isdataok)
                {
                    string _str = rate.ToString();
                    //验证格式
                    if (!Regex.IsMatch(_str, @"^\d{1,2}(\.\d)?$"))
                    {
                        result.success = false;
                        result.msg     = "错误的数据格式,只可以保留一位小数";
                        isdataok       = false;
                    }
                }
                if (isdataok)
                {
                    _iDistributionService.SetProductBrokerage(rate, ids, curshopid);
                    result.success = true;
                    result.msg     = "修改佣金比例成功";
                }
            }
            else
            {
                result = new Result {
                    success = false, msg = "错误的商品编号"
                };
            }
            return(Json(result));
        }