public BaseResult CheckImportInfo(Tb_Kh_Import model) { BaseResult br = new BaseResult(); if (string.IsNullOrEmpty(model.id_khfl)) { br.Success = false; br.Data = "id_khfl"; br.Message.Add("客户分类不能为空"); return(br); } //if (string.IsNullOrEmpty(model.bm)) //{ // br.Success = false; // br.Data = "bm"; // br.Message.Add("编码不能为空"); // return br; //} if (string.IsNullOrEmpty(model.mc)) { br.Success = false; br.Data = "mc"; br.Message.Add("名称不能为空"); return(br); } if (string.IsNullOrEmpty(model.flag_state) || (model.flag_state != "0" && model.flag_state != "1")) { br.Success = false; br.Data = "flag_state"; br.Message.Add("状态不符合要求"); return(br); } if (!string.IsNullOrEmpty(model.je_xyed) && !CyVerify.IsNumeric(model.je_xyed)) { br.Success = false; br.Data = "je_xyed"; br.Message.Add("信用额度不符合要求"); return(br); } if (!string.IsNullOrEmpty(model.je_xyed_temp) && !CyVerify.IsNumeric(model.je_xyed_temp)) { br.Success = false; br.Data = "je_xyed_temp"; br.Message.Add("临时额度不符合要求"); return(br); } br.Success = true; return(br); }
internal static MvcHtmlString NumberHelper(HtmlHelper html, object value, string fromatString, bool removeendzero) { string stringValue; stringValue = value == null ? "" : (CyVerify.IsNumeric(stringValue = value.ToString().Trim()) ? String.Format(fromatString, Convert.ToDecimal(stringValue)) : stringValue); if (removeendzero) { stringValue = RemoveEndZero(stringValue); } return(MvcHtmlString.Create(stringValue)); }
internal static MvcHtmlString NumberHelper(HtmlHelper html, object value, int decimals, bool removeendzero) { string stringValue; stringValue = value == null ? "" : (CyVerify.IsNumeric(stringValue = value.ToString().Trim()) ? Decimal.Round(Convert.ToDecimal(stringValue), decimals).ToString() : stringValue); if (removeendzero) { stringValue = RemoveEndZero(stringValue); } return(MvcHtmlString.Create(stringValue)); }
/// <summary> /// 初步检验表体数据 /// </summary> /// <param name="model"></param> /// <param name="message"></param> /// <returns></returns> public bool ParamError(Td_Kc_Kspd_2 model, out string message) { message = ""; if (model == null) { message = "参数不能为空!"; return(true); } else { if (!CyVerify.IsNumeric(model.sort_id) || model.sort_id <= 0) { message = "序号不符合要求!"; return(true); } else if (string.IsNullOrEmpty(model.id_shopsp)) { message = "商品id不符合要求!"; return(true); } else if (string.IsNullOrEmpty(model.id_kcsp)) { message = "库存id不符合要求!"; return(true); } else if (string.IsNullOrEmpty(model.barcode)) { message = "条码不符合要求!"; return(true); } else if (string.IsNullOrEmpty(model.dw)) { message = "单位不符合要求!"; return(true); } return(false); } }
public ActionResult Edit(Tb_Hy model) { BaseResult br = new BaseResult(); var oldParam = new Hashtable(); try { #region 获取参数 Hashtable param = base.GetParameters(); ParamVessel p = new ParamVessel(); p.Add("name", string.Empty, HandleType.ReturnMsg); //name p.Add("membercard", string.Empty, HandleType.DefaultValue); //membercard p.Add("phone", string.Empty, HandleType.DefaultValue); //phone p.Add("qq", string.Empty, HandleType.DefaultValue); //qq p.Add("email", string.Empty, HandleType.DefaultValue); //email p.Add("tel", string.Empty, HandleType.DefaultValue); //tel p.Add("address", string.Empty, HandleType.DefaultValue); //address p.Add("MMno", string.Empty, HandleType.DefaultValue); //MMno p.Add("zipcode", string.Empty, HandleType.DefaultValue); //zipcode p.Add("birthday", string.Empty, HandleType.DefaultValue); //birthday p.Add("flag_nl", "0", HandleType.DefaultValue); //flag_nl 是否农历 p.Add("id_shop_create", string.Empty, HandleType.Remove); //id_shop_create p.Add("id_hyfl", string.Empty, HandleType.ReturnMsg); //id_hyfl p.Add("rq_b", string.Empty, HandleType.ReturnMsg); //rq_b p.Add("rq_b_end", string.Empty, HandleType.ReturnMsg); //rq_b_end p.Add("birth_month", "", HandleType.DefaultValue); //birth_month p.Add("birth_day", "", HandleType.DefaultValue); //birth_day p.Add("zk", "0.00", HandleType.DefaultValue); //zk p.Add("flag_sex", "1", HandleType.DefaultValue); //flag_sex p.Add("flag_yhlx", "1", HandleType.DefaultValue); //flag_yhlx p.Add("password", "", HandleType.Remove); //password p.Add("id", "", HandleType.ReturnMsg);//id param = param.Trim(p); param.Add("id_masteruser", id_user_master); param.Add("id_user", id_user); param.Add("rq_e", param["rq_b_end"].ToString()); param.Remove("rq_b_end"); oldParam = (Hashtable)param.Clone(); #endregion #region 参数验证 if (string.IsNullOrEmpty(param["membercard"].ToString()) && string.IsNullOrEmpty(param["phone"].ToString())) { br.Success = false; br.Message.Add("会员卡号和手机号必须二选一!"); WriteDBLog("会员-编辑", oldParam, br); return(base.JsonString(br, 1)); } if (string.IsNullOrEmpty(param["zk"].ToString()) || !CyVerify.IsNumeric(param["zk"].ToString()) || decimal.Parse(param["zk"].ToString()) < 0 || decimal.Parse(param["zk"].ToString()) > 1) { br.Success = false; br.Message.Add("会员折扣不符合要求 折扣必须在0-1之间!"); WriteDBLog("会员-编辑", oldParam, br); return(base.JsonString(br, 1)); } if (!string.IsNullOrEmpty(param["flag_yhlx"].ToString()) && param["flag_yhlx"].ToString() == "2" && decimal.Parse(param["zk"].ToString()) != 1) { br.Success = false; br.Message.Add("优惠类型为会员价 折扣只能为1!"); WriteDBLog("会员-编辑", oldParam, br); return(base.JsonString(br, 1)); } if (!string.IsNullOrEmpty(param["birthday"].ToString())) { //计算生日 DateTime birthday = DateTime.Parse(param["birthday"].ToString()); string hysr = birthday.ToString("MMdd"); param.Add("hysr", hysr); } else { if (!string.IsNullOrEmpty(param["birth_month"].ToString()) && !string.IsNullOrEmpty(param["birth_day"].ToString())) { var month = param["birth_month"].ToString(); if (month.Length > 2 || month.Length < 1) { month = "00"; } else if (month.Length == 1) { month = "0" + month; } var day = param["birth_day"].ToString(); if (day.Length > 2 || day.Length < 1) { day = "00"; } else if (day.Length == 1) { day = "0" + day; } param.Add("hysr", month + day); } } #endregion #region 判断是否共享的处理 if (param.ContainsKey("id_shop_create")) { var br_Hy_ShopShare = BusinessFactory.Account.GetHy_ShopShare(param["id_shop_create"].ToString(), id_user_master);// GetHy_ShopShare(param["id_shop_create"].ToString()); if (!br_Hy_ShopShare.Success) { return(base.JsonString(br, 1)); } var param_Hy_ShopShare = (Hashtable)br_Hy_ShopShare.Data; param.Add("id_shop", param_Hy_ShopShare["id_shop"].ToString()); } else { param.Add("id_shop", id_shop); param.Add("id_shop_create", id_shop); } #endregion #region 新增 br = BusinessFactory.Tb_Hy_Shop.Update(param); #endregion #region 返回 WriteDBLog("会员-编辑", oldParam, br); return(base.JsonString(br, 1)); #endregion } catch (Exception ex) { #region 异常返回 br.Success = false; br.Data = ""; br.Message.Add("数据不符合要求!"); br.Level = ErrorLevel.Warning; WriteDBLog("会员-编辑", oldParam, br); return(base.JsonString(br, 1)); #endregion } }
public BaseResult ImportIn(Hashtable param) { #region 获取数据 BaseResult br = new BaseResult(); Hashtable ht = new Hashtable(); string FilePath = param["filePath"].ToString(); string id_masteruser = param["id_masteruser"].ToString(); string id_user = param["id_user"].ToString(); string id_shop = param["id_shop"].ToString(); List <Tb_JhShopsp_Import> list = (List <Tb_JhShopsp_Import>)param["list"]; List <Tb_JhShopsp_Import> successList = new List <Tb_JhShopsp_Import>(); List <Tb_JhShopsp_Import> failList = new List <Tb_JhShopsp_Import>(); #endregion #region 验证导入数据是否空 if (list == null || list.Count() <= 0) { br.Message.Add(String.Format("操作失败,没有数据!")); br.Success = false; br.Data = new Tb_JhShopsp_Import_All() { SuccessList = successList, FailList = list, AllList = list }; return(br); } #endregion #region 获取属于主用户所有门店商品 ht.Clear(); ht.Add("id_masteruser", id_masteruser); var shopspList = Tb_ShopspDAL.GetShopspList(typeof(Tb_Shopsp), ht); if (shopspList == null || shopspList.Count() <= 0) { br.Message.Add(String.Format("操作失败,未查询到用户的商品数据!")); br.Success = false; br.Data = new Tb_JhShopsp_Import_All() { SuccessList = successList, FailList = list, AllList = list }; return(br); } #endregion #region 验证导入的数据是否符合要求并相应简单处理赋值 foreach (var item in list) { #region 验证必要参数是否符合 int error = 0; if (string.IsNullOrEmpty(item.barcode)) { item.sysbz += " 条形码不能为空 "; error++; } if (!CyVerify.IsNumeric(item.sl) || item.sl == 0) { item.sysbz += " 数量不符合要求 "; error++; } if (item.dj != null && !CyVerify.IsNumeric(item.dj)) { item.sysbz += " 单价不符合要求 "; error++; } if (error > 0) { continue; } #endregion #region 验证数据库是否存在数据并简单赋值 var dbInfo = shopspList.Where(d => d.barcode == item.barcode && d.flag_delete == (byte)Enums.FlagDelete.NoDelete && d.id_shop == id_shop).FirstOrDefault(); if (dbInfo == null) { item.sysbz += " 不存在此条形码的商品 "; error++; continue; } else { if (dbInfo.flag_delete == (byte)Enums.FlagShopspStop.Deleted) { item.sysbz += " 此条形码的商品已被删除 "; error++; continue; } if (dbInfo.flag_state == (byte)Enums.FlagShopspStop.Stoped) { item.sysbz += " 此条形码的商品已被停用 "; error++; continue; } if (string.IsNullOrEmpty(item.mc)) { item.mc = dbInfo.mc; } if (item.dj == null || item.dj == 0) { item.dj = dbInfo.dj_jh; } item.id_shopsp = dbInfo.id; item.barcode = dbInfo.barcode; item.bm = dbInfo.bm; item.mc = dbInfo.mc; item.id_shop = dbInfo.id_shop; item.id_spfl = dbInfo.id_spfl; item.dw = dbInfo.dw; item.dj_jh = item.dj; item.dj_ls = dbInfo.dj_ls; item.id_kcsp = dbInfo.id_kcsp; item.zhl = dbInfo.zhl; item.sl_qm = dbInfo.sl_qm; item.id_sp = dbInfo.id_sp; item.dj_pf = dbInfo.dj_pf; } #endregion } #endregion failList = list.Where(d => d.sysbz != "").ToList(); successList = list.Where(d => d.sysbz == "").ToList(); br.Message.Add(String.Format("操作完毕!")); br.Success = true; br.Data = new Tb_JhShopsp_Import_All() { SuccessList = successList, FailList = failList, AllList = list }; return(br); }
public ActionResult Add(Td_Sk_1 model) { BaseResult br = new BaseResult(); var oldParam = new Hashtable(); try { #region 获取参数 Hashtable param = base.GetParameters(); ParamVessel p = new ParamVessel(); p.Add("skList", string.Empty, HandleType.ReturnMsg); //skList p.Add("flag_sklx", (int)Enums.FlagSKLX.YingShou, HandleType.DefaultValue); //收款类型 p.Add("remark", string.Empty, HandleType.DefaultValue); //备注 p.Add("id_kh", string.Empty, HandleType.ReturnMsg); //id_kh p.Add("id_shop", string.Empty, HandleType.ReturnMsg); //id_shop p.Add("id_jbr", string.Empty, HandleType.ReturnMsg); //id_jbr p.Add("dh", string.Empty, HandleType.ReturnMsg); //dh p.Add("rq", string.Empty, HandleType.ReturnMsg); //rq p.Add("type", string.Empty, HandleType.Remove); //type p.Add("id", string.Empty, HandleType.Remove); //id p.Add("je_pre", string.Empty, HandleType.DefaultValue); //je_pre param = param.Trim(p); param.Add("id_masteruser", id_user_master); param.Add("id_user", id_user); oldParam = (Hashtable)param.Clone(); #endregion List <Td_Sk_2> skList = JSON.Deserialize <List <Td_Sk_2> >(param["skList"].ToString()) ?? new List <Td_Sk_2>(); #region 验证数据 if (param["flag_sklx"].ToString() == ((int)Enums.FlagSKLX.YingShou).ToString() && (skList == null || skList.Count() <= 0)) { br.Success = false; br.Message.Add("类型为应收款时收款体不能为空!"); WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } if (string.IsNullOrEmpty(param["je_pre"].ToString()) || !CyVerify.IsNumeric(param["je_pre"].ToString())) { br.Success = false; br.Message.Add("收支金额不符合要求!"); WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } foreach (var item in skList) { #region 收款体参数验证 if (item.je_origin == null || item.je_ws == null || item.je_ys == null || item.je_sk == null ) { br.Success = false; br.Message.Add("必要金额不能为空 请重新刷新页面!"); WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } if (item.je_ws + item.je_ys != item.je_origin) { br.Success = false; br.Message.Add("已收金额 + 未付金额不等于原单总金额 请重新刷新页面!"); WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } if (item.je_sk + item.je_yh > item.je_ws) { br.Success = false; br.Message.Add("优惠金额 + 本次收款金额不能超过未收款金额!"); WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } #endregion } var digitHashtable = GetParm(); param.Remove("skList"); param.Add("skList", skList); param.Add("DigitHashtable", digitHashtable); param.Add("autoAudit", AutoAudit()); #endregion if (param.ContainsKey("type") && param["type"].ToString() == "edit") { //插入表 br = BusinessFactory.Td_Sk_1.Update(param); WriteDBLog("收款-Post编辑", oldParam, br); } else { //插入表 br = BusinessFactory.Td_Sk_1.Add(param); WriteDBLog("收款-Post新增", oldParam, br); } if (br.Success) { return(base.JsonString(new { status = "success", message = string.Join(";", br.Message) })); } else { return(base.JsonString(br, 1)); } } catch (CySoftException ex) { br.Success = false; br.Data = ""; br.Message.Add(ex.Message); br.Level = ErrorLevel.Warning; WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } catch (Exception ex) { br.Success = false; br.Data = ""; br.Message.Add("数据不符合要求_e!"); br.Level = ErrorLevel.Warning; WriteDBLog("收款-Post新增/编辑", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } }
public ActionResult Add(Tb_Shopsp model) { BaseResult br = new BaseResult(); var oldParam = new Hashtable(); try { #region 获取参数 Hashtable param = base.GetParameters(); ParamVessel p = new ParamVessel(); p.Add("shopspList", string.Empty, HandleType.ReturnMsg); //商品List p.Add("remark", string.Empty, HandleType.DefaultValue); //备注 p.Add("id_kh", string.Empty, HandleType.ReturnMsg); //id_kh p.Add("id_shop", string.Empty, HandleType.ReturnMsg); //id_shop p.Add("id_jbr", string.Empty, HandleType.ReturnMsg); //id_jbr p.Add("dh", string.Empty, HandleType.ReturnMsg); p.Add("rq", string.Empty, HandleType.ReturnMsg); p.Add("je_ss", string.Empty, HandleType.ReturnMsg); //je_ss p.Add("type", string.Empty, HandleType.Remove); //type p.Add("id", string.Empty, HandleType.Remove); //id p.Add("dh_origin", string.Empty, HandleType.DefaultValue); p.Add("bm_djlx_origin", string.Empty, HandleType.DefaultValue); p.Add("id_bill_origin", string.Empty, HandleType.DefaultValue); param = param.Trim(p); param.Add("id_masteruser", id_user_master); param.Add("id_user", id_user); oldParam = (Hashtable)param.Clone(); #endregion List <Td_Xs_2> shopspList = JSON.Deserialize <List <Td_Xs_2> >(param["shopspList"].ToString()) ?? new List <Td_Xs_2>(); #region 验证数据 if (shopspList == null || shopspList.Count() <= 0) { br.Success = false; br.Message.Add("商品不能为空!"); br.Level = ErrorLevel.Warning; br.Data = "shopspList"; WriteDBLog("销售出库-新增", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } if (param.ContainsKey("je_ss") && !CyVerify.IsNumeric(param["je_ss"].ToString())) { br.Success = false; br.Message.Add("实收金额不符合要求!"); br.Level = ErrorLevel.Warning; br.Data = "je_ss"; WriteDBLog("销售出库-新增", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } var digitHashtable = GetParm(); foreach (var item in shopspList) { item.sl = CySoft.Utility.DecimalExtension.Digit(item.sl, int.Parse(digitHashtable["sl_digit"].ToString())); item.dj = CySoft.Utility.DecimalExtension.Digit(item.dj, int.Parse(digitHashtable["dj_digit"].ToString())); item.je = CySoft.Utility.DecimalExtension.Digit(item.je, int.Parse(digitHashtable["je_digit"].ToString())); if (item.sl == 0) { if (string.IsNullOrEmpty(param["id_bill_origin"].ToString())) { br.Success = false; br.Message.Add("商品[" + item.barcode + "]数量不允许为0!"); br.Level = ErrorLevel.Warning; br.Data = "shopspList"; WriteDBLog("销售出库-新增", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } else { item.je = 0; continue; } } //此处验证数据是否符合 var tempJe = CySoft.Utility.DecimalExtension.Digit(item.sl * item.dj, int.Parse(digitHashtable["je_digit"].ToString())); var tempDj = CySoft.Utility.DecimalExtension.Digit(item.je / item.sl, int.Parse(digitHashtable["dj_digit"].ToString())); if (tempJe == item.je || tempDj == item.dj) { continue; } else { br.Success = false; br.Message.Add("商品中存在 单价*数量不等于金额的数据!"); WriteDBLog("销售出库-新增/更新", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } } param.Remove("shopspList"); param.Add("shopspList", shopspList); param.Add("DigitHashtable", digitHashtable); param.Add("autoAudit", AutoAudit()); #endregion if (param.ContainsKey("type") && param["type"].ToString() == "edit") { br = BusinessFactory.Td_Xs_1.Update(param); WriteDBLog("销售出库-更新", oldParam, br); } else { //插入表 br = BusinessFactory.Td_Xs_1.Add(param); WriteDBLog("销售出库-新增", oldParam, br); } if (br.Success) { return(base.JsonString(new { status = "success", message = string.Join(";", br.Message) })); } else { return(base.JsonString(br, 1)); } } catch (CySoftException brEx) { br.Success = false; br.Data = ""; br.Message.Clear(); br.Message.Add(brEx.Message.ToString()); br.Level = ErrorLevel.Warning; WriteDBLog("销售出库-新增/更新", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } catch (Exception ex) { br.Success = false; br.Data = ""; br.Message.Add("数据不符合要求!"); br.Level = ErrorLevel.Warning; WriteDBLog("销售出库-新增/更新", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } }
public ActionResult SetDBJF() { var oldParam = new Hashtable(); BaseResult br = new BaseResult(); try { Hashtable param = base.GetParameters(); ParamVessel p = new ParamVessel(); p.Add("dbjf", string.Empty, HandleType.ReturnMsg);//会员多倍积分 param = param.Trim(p); param.Add("id_user", id_user); param.Add("id_masteruser", id_user_master); param.Add("id_shop", id_shop); oldParam = (Hashtable)param.Clone(); var dbjf = JSON.Deserialize <Ts_HykDbjf>(param["dbjf"].ToString()) ?? new Ts_HykDbjf(); dbjf.id_masteruser = id_user_master; param.Remove("dbjf"); param.Add("dbjf", dbjf); #region 验证参数 if (!string.IsNullOrEmpty(dbjf.hy_jfsz_hysr_nbjf)) { if (string.IsNullOrEmpty(dbjf.hy_jfsz_hysr_lx)) { return(base.JsonString(new { status = "error", message = string.Join(";", "请选择会员生日期间类型") })); } } if (!string.IsNullOrEmpty(dbjf.hy_jfsz_week_nbjf)) { if (string.IsNullOrEmpty(dbjf.hy_jfsz_week_val)) { return(base.JsonString(new { status = "error", message = string.Join(";", "请选择星期积分倍数的星期") })); } } if (!string.IsNullOrEmpty(dbjf.hy_jfsz_day_nbjf)) { if (string.IsNullOrEmpty(dbjf.hy_jfsz_day_val)) { return(base.JsonString(new { status = "error", message = string.Join(";", "请选择日期积分倍数的日期") })); } } if (!string.IsNullOrEmpty(dbjf.hy_jfsz_xs_nbjf)) { if (string.IsNullOrEmpty(dbjf.hy_jfsz_xs_rq_b)) { return(base.JsonString(new { status = "error", message = string.Join(";", "请选择金额积分倍数的开始时间") })); } else if (string.IsNullOrEmpty(dbjf.hy_jfsz_xs_rq_e)) { return(base.JsonString(new { status = "error", message = string.Join(";", "请选择金额积分倍数的结束时间") })); } else if (string.IsNullOrEmpty(dbjf.hy_jfsz_xs_je) || !CyVerify.IsNumeric(dbjf.hy_jfsz_xs_je)) { return(base.JsonString(new { status = "error", message = string.Join(";", "请选择金额积分倍数的消费满金额") })); } } #endregion br = BusinessFactory.Tb_Hy_Jfrule.Active(param); WriteDBLog("会员多倍积分-设置", oldParam, br); if (br.Success) { base.ClearShopParm(dbjf.id_masteruser, dbjf.id_shop); return(base.JsonString(new { status = "success", message = "执行成功,正在载入页面..." })); } else { return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } } catch (CySoftException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public ActionResult SetJeMinMax() { BaseResult br = new BaseResult(); var oldParam = new Hashtable(); try { Hashtable param = base.GetParameters(); ParamVessel p = new ParamVessel(); p.Add("je_obj", string.Empty, HandleType.ReturnMsg);//je_obj param = param.Trim(p); param.Add("id_user", id_user); param.Add("id_masteruser", id_user_master); param.Add("id_shop", id_shop); oldParam = (Hashtable)param.Clone(); var je_obj = JSON.Deserialize <Ts_HykDbjf>(param["je_obj"].ToString()) ?? new Ts_HykDbjf(); je_obj.id_masteruser = id_user_master; param.Remove("je_obj"); param.Add("je_obj", je_obj); #region 验证参数 if (!string.IsNullOrEmpty(je_obj.hy_czje_min_onec) && !CyVerify.IsNumeric(je_obj.hy_czje_min_onec)) { return(base.JsonString(new { status = "error", message = string.Join(";", "每次最小金额格式错误") })); } if (!string.IsNullOrEmpty(je_obj.hy_czje_max_onec) && !CyVerify.IsNumeric(je_obj.hy_czje_max_onec)) { return(base.JsonString(new { status = "error", message = string.Join(";", "每次最大金额格式错误") })); } if (!string.IsNullOrEmpty(je_obj.hy_czje_max_month) && !CyVerify.IsNumeric(je_obj.hy_czje_max_month)) { return(base.JsonString(new { status = "error", message = string.Join(";", "每月最大金额格式错误") })); } if (!string.IsNullOrEmpty(je_obj.hy_czje_min_onec) && !string.IsNullOrEmpty(je_obj.hy_czje_max_onec)) { if (decimal.Parse(je_obj.hy_czje_min_onec) > decimal.Parse(je_obj.hy_czje_max_onec)) { return(base.JsonString(new { status = "error", message = string.Join(";", "每次最小金额 不能大于 每次最大金额!") })); } } if (!string.IsNullOrEmpty(je_obj.hy_czje_min_onec) && !string.IsNullOrEmpty(je_obj.hy_czje_max_month)) { if (decimal.Parse(je_obj.hy_czje_min_onec) > decimal.Parse(je_obj.hy_czje_max_month)) { return(base.JsonString(new { status = "error", message = string.Join(";", "每次最小金额 不能大于 每月最大金额!") })); } } if (!string.IsNullOrEmpty(je_obj.hy_czje_max_onec) && !string.IsNullOrEmpty(je_obj.hy_czje_max_month)) { if (decimal.Parse(je_obj.hy_czje_max_onec) > decimal.Parse(je_obj.hy_czje_max_month)) { return(base.JsonString(new { status = "error", message = string.Join(";", "每次最大金额 不能大于 每月最大金额!") })); } } #endregion br = BusinessFactory.Td_Hy_Czrule_1.Active(param); if (br.Success) { WriteDBLog("会员充值-充值设置金额参数", oldParam, br); base.ClearShopParm(je_obj.id_masteruser, je_obj.id_shop); return(base.JsonString(new { status = "success", message = "执行成功,正在载入页面..." })); } else { WriteDBLog("会员充值-充值设置金额参数", oldParam, br); return(base.JsonString(new { status = "error", message = string.Join(";", br.Message) })); } } catch (CySoftException ex) { WriteDBLog("会员充值-充值设置金额参数", oldParam, br); throw ex; } catch (Exception ex) { WriteDBLog("会员充值-充值设置金额参数", oldParam, br); throw ex; } }
/// <summary> /// 检查是否符合充值设置的金额 /// </summary> /// <param name="param"></param> /// <returns></returns> public BaseResult CheckCZMaxMoney(Hashtable param) { BaseResult br = new BaseResult(); try { Tb_Hy_Detail hyDetailModel = new Tb_Hy_Detail(); Hashtable ht = new Hashtable(); ht.Add("id_masteruser", param["id_masteruser"].ToString()); ht.Add("id_shop", param["id_shop"].ToString()); ht.Add("id_hy", param["id_hy"].ToString()); ht.Add("bm_djlx", "HY020"); var yczList = DAL.QueryList <Tz_Hy_Je_Flow>(typeof(Tz_Hy_Je_Flow), ht).ToList(); decimal moneyMonthYCZ = 0; if (yczList != null && yczList.Count() > 0) { moneyMonthYCZ = (decimal)yczList.Sum(d => d.je); } var shopParm = GetShopParm(param["id_masteruser"].ToString(), param["id_shop"].ToString()); var shopParmAll = GetShopParm(param["id_masteruser"].ToString(), "0"); if (shopParm != null && shopParm.ContainsKey("success") && shopParm["success"].ToString() == "1") { #region hy_czje_min_onec var hy_czje_min_onec = shopParm["hy_czje_min_onec"].ToString(); if (!string.IsNullOrEmpty(hy_czje_min_onec) && CyVerify.IsNumeric(hy_czje_min_onec)) { if (decimal.Parse(param["je"].ToString()) < decimal.Parse(hy_czje_min_onec)) { br.Success = false; br.Message.Add("操作失败:每次最小金额至少为: " + hy_czje_min_onec + " "); return(br); } } else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1") { var hy_czje_min_onec_all = shopParmAll["hy_czje_min_onec"].ToString(); if (!string.IsNullOrEmpty(hy_czje_min_onec_all) && CyVerify.IsNumeric(hy_czje_min_onec_all)) { if (decimal.Parse(param["je"].ToString()) < decimal.Parse(hy_czje_min_onec_all)) { br.Success = false; br.Message.Add("操作失败:每次充值金额最小为: " + hy_czje_min_onec_all + " "); return(br); } } } #endregion #region hy_czje_max_onec var hy_czje_max_onec = shopParm["hy_czje_max_onec"].ToString(); if (!string.IsNullOrEmpty(hy_czje_max_onec) && CyVerify.IsNumeric(hy_czje_max_onec)) { if (decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_onec)) { br.Success = false; br.Message.Add("操作失败:每次充值金额最大为: " + hy_czje_max_onec + " "); return(br); } } else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1") { var hy_czje_max_onec_all = shopParmAll["hy_czje_max_onec"].ToString(); if (!string.IsNullOrEmpty(hy_czje_max_onec_all) && CyVerify.IsNumeric(hy_czje_max_onec_all)) { if (decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_onec_all)) { br.Success = false; br.Message.Add("操作失败:每次充值金额最大为: " + hy_czje_max_onec_all + " "); return(br); } } } #endregion #region hy_czje_max_month var hy_czje_max_month = shopParm["hy_czje_max_month"].ToString(); if (!string.IsNullOrEmpty(hy_czje_max_month) && CyVerify.IsNumeric(hy_czje_max_month)) { if ((moneyMonthYCZ + decimal.Parse(param["je"].ToString())) > decimal.Parse(hy_czje_max_month)) { br.Success = false; br.Message.Add("操作失败:每月充值最大金额: " + hy_czje_max_month + " 本月已充值: " + moneyMonthYCZ + " "); return(br); } } else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1") { var hy_czje_max_month_all = shopParmAll["hy_czje_max_month"].ToString(); if (!string.IsNullOrEmpty(hy_czje_max_month_all) && CyVerify.IsNumeric(hy_czje_max_month_all)) { if (moneyMonthYCZ + decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_month_all)) { br.Success = false; br.Message.Add("操作失败:每月充值最大金额: " + hy_czje_max_month_all + " 本月已充值: " + moneyMonthYCZ + " "); return(br); } } } #endregion } else if (shopParmAll != null && shopParmAll.ContainsKey("success") && shopParmAll["success"].ToString() == "1") { #region hy_czje_min_onec hy_czje_max_onec hy_czje_max_month var hy_czje_min_onec = shopParm["hy_czje_min_onec"].ToString(); var hy_czje_max_onec = shopParm["hy_czje_max_onec"].ToString(); var hy_czje_max_month = shopParm["hy_czje_max_month"].ToString(); if (!string.IsNullOrEmpty(hy_czje_min_onec) && CyVerify.IsNumeric(hy_czje_min_onec)) { if (decimal.Parse(param["je"].ToString()) < decimal.Parse(hy_czje_min_onec)) { br.Success = false; br.Message.Add("操作失败:每次充值金额最小为: " + hy_czje_min_onec + " "); return(br); } } if (!string.IsNullOrEmpty(hy_czje_max_onec) && CyVerify.IsNumeric(hy_czje_max_onec)) { if (decimal.Parse(param["je"].ToString()) > decimal.Parse(hy_czje_max_onec)) { br.Success = false; br.Message.Add("操作失败:每次充值金额最大为: " + hy_czje_max_onec + " "); return(br); } } if (!string.IsNullOrEmpty(hy_czje_max_month) && CyVerify.IsNumeric(hy_czje_max_month)) { if ((moneyMonthYCZ + decimal.Parse(param["je"].ToString())) > decimal.Parse(hy_czje_max_month)) { br.Success = false; br.Message.Add("操作失败:每月充值最大金额: " + hy_czje_max_month + " 本月已充值: " + moneyMonthYCZ + " "); return(br); } } #endregion } br.Success = true; return(br); } catch (Exception ex) { br.Success = false; br.Message.Add("操作失败:检查是否符合充值设置的金额获取到异常 "); return(br); } }
public ActionResult JfEdit() { var sr = RequestResult(res => { #region 获取参数 Hashtable param = base.GetParameters(); ParamVessel p = new ParamVessel(); p.Add("id_shop", string.Empty, HandleType.ReturnMsg); //id_shop p.Add("id_masteruser", string.Empty, HandleType.ReturnMsg); //id_masteruser p.Add("id_hy", string.Empty, HandleType.ReturnMsg); //id_hy p.Add("id_bill", string.Empty, HandleType.ReturnMsg); //id_bill p.Add("bm_djlx", string.Empty, HandleType.ReturnMsg); //bm_djlx p.Add("rq", string.Empty, HandleType.ReturnMsg); //rq p.Add("jf", string.Empty, HandleType.ReturnMsg); //je p.Add("bz", string.Empty, HandleType.DefaultValue); //bz p.Add("sign", string.Empty, HandleType.ReturnMsg); //sign #endregion #region 验证参数 try { param = param.Trim(p); } catch (Exception ex) { res.State = ServiceState.Fail; res.Message = ServiceFailCode.A0001; return(res); } if (!CyVerify.IsNumeric(param["jf"].ToString())) { res.State = ServiceState.Fail; res.Message = ServiceFailCode.A0001; return(res); } DateTime timeTemp = DateTime.Now; if (!DateTime.TryParse(param["rq"].ToString(), out timeTemp)) { res.State = ServiceState.Fail; res.Message = ServiceFailCode.A0001; return(res); } #endregion #region 读取ticket //读取ticket Hashtable ht = new Hashtable(); ht.Add("key_y", param["id_masteruser"].ToString() + "_" + param["id_shop"].ToString()); var ticketBr = BusinessFactory.Tb_Ticket.Get(ht); if (!ticketBr.Success) { res.State = ServiceState.Fail; res.Message = ServiceFailCode.S0001; return(res); } var ticketModel = (Tb_Ticket)ticketBr.Data; if (ticketModel == null) { res.State = ServiceState.Fail; res.Message = ServiceFailCode.A0003; return(res); } var ticket = ticketModel.ticket; #endregion #region 验证签名 IDictionary <string, string> dic = base.GetParameters(new string[] { "id_shop", "id_masteruser", "id_hy", "id_bill", "bm_djlx", "rq", "jf", "bz" }); var validSign = SignUtils.SignRequest(dic, ticket); //验证签名 if (param["sign"].ToString() != validSign) { res.State = ServiceState.Fail; res.Message = ServiceFailCode.A0002; return(res); } #endregion #region 执行操作 param.Remove("sign"); if (decimal.Parse(param["jf"].ToString()) > 0) { param.Add("Type", "Add"); } else { param.Add("Type", "Del"); } var br = BusinessFactory.Tz_Hy_Jf.Add(param); #endregion #region 返回 res.State = br.Success ? ServiceState.Done : ServiceState.Fail; res.Message = br.Message.FirstOrDefault(); res.Data = br.Data; return(res); #endregion }); return(JsonString(sr)); }