示例#1
0
文件: Tb_HyflBLL.cs 项目: 17/YunPos
        /// <summary>
        /// 将Hashtable转换为Model
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        private Tb_Hyfl TurnTb_HyflModel(Hashtable param)
        {
            Tb_Hyfl model = new Tb_Hyfl();

            model.id_masteruser = param["id_masteruser"].ToString();
            model.id            = Guid.NewGuid().ToString();
            model.bm            = param["bm"].ToString();
            model.mc            = param["mc"].ToString();
            int sort_id = 0;

            int.TryParse(param["sort_id"].ToString(), out sort_id);
            model.sort_id     = sort_id;
            model.id_create   = Guid.NewGuid().ToString();
            model.rq_create   = DateTime.Now;
            model.flag_delete = (byte)Enums.FlagDelete.NoDelete;

            byte flag_yhlx = 0;

            byte.TryParse(param["flag_yhlx"].ToString(), out flag_yhlx);
            model.flag_yhlx = flag_yhlx;

            decimal zk = 0;

            decimal.TryParse(param["zk"].ToString(), out zk);
            model.zk = zk;

            return(model);
        }
示例#2
0
        public ActionResult Add(Tb_Hyfl model)
        {
            BaseResult br       = new BaseResult();
            var        oldParam = new Hashtable();

            try
            {
                #region 获取参数
                Hashtable   param = base.GetParameters();
                ParamVessel p     = new ParamVessel();
                p.Add("bm", string.Empty, HandleType.DefaultValue);     //bm
                p.Add("mc", string.Empty, HandleType.ReturnMsg);        //mc
                p.Add("sort_id", "0", HandleType.DefaultValue);         //sort_id
                p.Add("flag_yhlx", string.Empty, HandleType.ReturnMsg); //flag_yhlx
                p.Add("zk", 0m, HandleType.ReturnMsg);                  //zk

                param = param.Trim(p);
                param.Add("id_masteruser", id_user_master);
                param.Add("id_user", id_user);
                oldParam = (Hashtable)param.Clone();
                #endregion
                #region 新增
                br = BusinessFactory.Tb_Hyfl.Add(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
            }
        }
示例#3
0
        public ActionResult Edit(Tb_Hyfl model)
        {
            #region 获取参数
            var         oldParam    = new Hashtable();
            BaseResult  br          = new BaseResult();
            Hashtable   param       = base.GetParameters();
            Hashtable   param_model = null;
            ParamVessel pv          = new ParamVessel();
            pv.Add("bm", string.Empty, HandleType.DefaultValue);     //bm
            pv.Add("mc", string.Empty, HandleType.ReturnMsg);        //mc
            pv.Add("sort_id", "0", HandleType.DefaultValue);         //sort_id
            pv.Add("id", string.Empty, HandleType.ReturnMsg);        //id
            pv.Add("flag_yhlx", string.Empty, HandleType.ReturnMsg); //flag_yhlx
            pv.Add("zk", 0m, HandleType.ReturnMsg);                  //zk
            #endregion
            #region 执行更新
            try
            {
                param_model = param.Trim(pv);
                oldParam    = (Hashtable)param_model.Clone();
                br          = BusinessFactory.Tb_Hyfl.Update(new Tb_Hyfl()
                {
                    id            = param_model["id"].ToString(),
                    bm            = param_model["bm"].ToString(),
                    mc            = param_model["mc"].ToString(),
                    sort_id       = int.Parse(param_model["sort_id"].ToString()),
                    id_masteruser = id_user_master,
                    id_edit       = id_user,
                    flag_yhlx     = byte.Parse(param_model["flag_yhlx"].ToString()),
                    zk            = decimal.Parse(param_model["zk"].ToString())
                });
            }
            catch (Exception ex)
            {
                br.Message.Add(ex.Message);
            }
            #endregion
            #region 返回
            WriteDBLog("会员类别-编辑", oldParam, br);
            return(JsonString(br, 1));

            #endregion
        }
示例#4
0
文件: Tb_HyflBLL.cs 项目: 17/YunPos
        /// <summary>
        /// 更新
        /// lz
        /// 2016-09-18
        /// </summary>
        public override BaseResult Update(dynamic entity)
        {
            #region 获取参数
            BaseResult result = new BaseResult()
            {
                Success = true
            };
            Tb_Hyfl model = entity as Tb_Hyfl;
            if (model == null)
            {
                result.Success = false;
                result.Message.Add("参数有误!");
                return(result);
            }
            #endregion

            #region 验证折扣
            if (model.zk < 0 || model.zk > 1)
            {
                result.Success = false;
                result.Message.Add("折扣必须在 0 和 1 之间!");
                return(result);
            }
            #endregion

            #region 验证参数
            Hashtable ht = new Hashtable();
            //ht.Add("id_masteruser", model.id_masteruser);
            //ht.Add("bm", model.bm);
            //ht.Add("not_id", model.id);
            //ht.Add("flag_delete", (int)Enums.FlagDelete.NoDelete);
            //if (DAL.GetCount(typeof(Tb_Hyfl), ht) > 0)
            //{
            //    result.Success = false;
            //    result.Message.Add("输入编码重复!");
            //    return result;
            //}

            ht.Clear();
            ht.Add("id_masteruser", model.id_masteruser);
            ht.Add("mc", model.mc);
            ht.Add("not_id", model.id);
            ht.Add("flag_delete", (int)Enums.FlagDelete.NoDelete);
            if (DAL.GetCount(typeof(Tb_Hyfl), ht) > 0)
            {
                result.Success = false;
                result.Message.Add("输入名称重复!");
                return(result);
            }

            #endregion
            #region 执行更新
            ht.Clear();
            ht.Add("id", model.id);
            ht.Add("id_masteruser", model.id_masteruser);
            ht.Add("new_bm", model.bm);
            ht.Add("new_mc", model.mc);
            ht.Add("new_sort_id", model.sort_id);
            ht.Add("new_rq_edit", DateTime.Now);
            ht.Add("new_id_edit", model.id_edit);
            ht.Add("new_flag_yhlx", model.flag_yhlx);
            ht.Add("new_zk", model.zk);
            try
            {
                DAL.UpdatePart(typeof(Tb_Hyfl), ht);
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message.Add("更新操作异常!");
            }
            #endregion
            #region 返回
            return(result);

            #endregion
        }
示例#5
0
        public ActionResult Add()
        {
            var sr = RequestResult(res =>
            {
                #region 获取参数
                Hashtable param = base.GetParameters();
                ParamVessel p   = new ParamVessel();
                p.Add("id_shop", string.Empty, HandleType.ReturnMsg);       //id_shop_create
                p.Add("id_masteruser", string.Empty, HandleType.ReturnMsg); //id_masteruser
                p.Add("membercard", string.Empty, HandleType.DefaultValue); //membercard
                p.Add("phone", string.Empty, HandleType.ReturnMsg);         //phone
                p.Add("name", string.Empty, HandleType.ReturnMsg);          //name
                p.Add("id_hyfl", string.Empty, HandleType.ReturnMsg);       //id_hyfl
                p.Add("rq_b", string.Empty, HandleType.Remove);             //rq_b
                p.Add("rq_e", string.Empty, HandleType.Remove);             //rq_e
                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("hysr", "", HandleType.DefaultValue);                 //hysr

                p.Add("zk", "0.00", HandleType.Remove);                     //zk
                p.Add("flag_nl", "0", HandleType.DefaultValue);             //flag_nl 是否农历
                p.Add("flag_sex", "1", HandleType.Remove);                  //flag_sex
                p.Add("password", "", HandleType.DefaultValue);             //password
                p.Add("flag_yhlx", "1", HandleType.Remove);                 //flag_yhlx


                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);
                }
                #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);

                var ticketBr = base.GetTicketInfo(param["id_masteruser"].ToString() + "_" + param["id_shop"].ToString());

                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", "membercard", "phone", "name", "id_hyfl", "qq", "email", "tel", "address", "mmno", "zipcode", "birthday", "flag_nl", "hysr", "rq_b", "rq_e", "zk", "flag_sex", "password", "flag_yhlx" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 验证参数是否符合
                //验证参数是否符合
                //if (string.IsNullOrEmpty(param["phone"].ToString()) || !CyVerify.IsPhone(param["phone"].ToString()) || (param["flag_nl"].ToString() != "0" && param["flag_nl"].ToString() != "1"))
                if (string.IsNullOrEmpty(param["phone"].ToString()) || (param["flag_nl"].ToString() != "0" && param["flag_nl"].ToString() != "1"))
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0006;
                    return(res);
                }
                #endregion
                #region 参数处理
                param.Add("id_shop_create", param["id_shop"].ToString());
                param.Add("MMno", param["mmno"].ToString());
                param.Remove("mmno");

                if (!param.ContainsKey("rq_b"))
                {
                    param.Add("rq_b", DateTime.Now.ToString("yyyy-MM-dd 00:00:01"));
                }
                if (!param.ContainsKey("rq_e"))
                {
                    param.Add("rq_e", DateTime.Parse(param["rq_b"].ToString()).AddYears(1).ToString("yyyy-MM-dd 23:59:59"));
                }
                if (!param.ContainsKey("flag_nl"))
                {
                    param.Add("flag_nl", "0");
                }
                if (!param.ContainsKey("flag_sex"))
                {
                    param.Add("flag_sex", "1");
                }


                if (!param.ContainsKey("zk") || !param.ContainsKey("flag_yhlx"))
                {
                    Hashtable ht_hyfl = new Hashtable();
                    ht_hyfl.Add("id", param["id_hyfl"].ToString());
                    var hyflBr = BusinessFactory.Tb_Hyfl.Get(ht_hyfl);
                    if (!hyflBr.Success || hyflBr.Data == null)
                    {
                        res.State   = ServiceState.Fail;
                        res.Message = "操作失败 查询会员类别失败!";
                        return(res);
                    }

                    Tb_Hyfl hyflModel = (Tb_Hyfl)hyflBr.Data;
                    if (hyflModel == null || string.IsNullOrEmpty(hyflModel.id))
                    {
                        res.State   = ServiceState.Fail;
                        res.Message = "操作失败 会员类别不存在!";
                        return(res);
                    }

                    if (!param.ContainsKey("zk"))
                    {
                        param.Add("zk", hyflModel.zk);
                    }
                    if (!param.ContainsKey("flag_yhlx"))
                    {
                        param.Add("flag_yhlx", hyflModel.flag_yhlx);
                    }
                }

                #endregion
                #region 计算生日
                if (!string.IsNullOrEmpty(param["birthday"].ToString()))
                {
                    //计算生日
                    DateTime birthday = DateTime.Parse(param["birthday"].ToString());
                    string hysr       = birthday.ToString("MMdd");
                    if (param.ContainsKey("hysr"))
                    {
                        param.Remove("hysr");
                    }
                    param.Add("hysr", hysr);
                }
                else
                {
                    if (!string.IsNullOrEmpty(param["hysr"].ToString()))
                    {
                        var hysr = param["hysr"].ToString();
                        if (hysr.Length != 4)
                        {
                            res.State   = ServiceState.Fail;
                            res.Message = ServiceFailCode.A0006;
                            return(res);
                        }
                        else
                        {
                            var month = hysr.Substring(0, 2);
                            var day   = hysr.Substring(2, 2);
                            if (!this.CheckMonthDay(month, day))
                            {
                                res.State   = ServiceState.Fail;
                                res.Message = ServiceFailCode.A0006;
                                return(res);
                            }
                        }
                    }
                }
                #endregion
                #region 判断是否共享的处理
                var br_Hy_ShopShare = BusinessFactory.Account.GetHy_ShopShare(param["id_shop_create"].ToString(), param["id_masteruser"].ToString()); //GetHy_ShopShare(param["id_shop_create"].ToString(), param["id_masteruser"].ToString());
                if (!br_Hy_ShopShare.Success)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = br_Hy_ShopShare.Message.FirstOrDefault();
                    return(res);
                }
                var param_Hy_ShopShare = (Hashtable)br_Hy_ShopShare.Data;
                param["id_shop"]       = param_Hy_ShopShare["id_shop"].ToString();
                #endregion
                #region 新增
                var br = BusinessFactory.Tb_Hy_Shop.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));
        }