Пример #1
0
        /// <summary>
        /// 线程池方法处理
        /// lz
        /// 2016-10-31
        /// </summary>
        /// <param name="obj"></param>
        public void HandOutDataToSvr(object obj)
        {
            try
            {
                Hashtable param = (Hashtable)obj;
                //System.Web.HttpContext.Current = (System.Web.HttpContext)param["context"];
                //Hashtable loginInfo = new Hashtable();
                //loginInfo.Add("id_user", param["id_user"].ToString());
                //loginInfo.Add("flag_from", 3);
                //BusinessFactory.Log.Add(loginInfo, LogFlag.Bill, param["content"].ToString());

                var paramters = new Dictionary <string, string>();
                paramters.Add("id_user", HttpUtility.UrlEncode(param["id_user"].ToString(), Encoding.UTF8));
                paramters.Add("flag_from", HttpUtility.UrlEncode("computer", Encoding.UTF8));
                paramters.Add("flag_lx", HttpUtility.UrlEncode("Bill", Encoding.UTF8));
                string mySign = SignUtils.SignRequest(paramters, "CY2016");
                paramters.Add("content", HttpUtility.UrlEncode("[" + param["content"].ToString() + "]", Encoding.UTF8));
                paramters.Add("sign", mySign);
                paramters.Add("ip", HttpUtility.UrlEncode(param["ip"].ToString(), Encoding.UTF8));
                var result = new WebUtils().DoPost(_logAPIUrl, paramters, 20000);
            }
            catch (Exception ex)
            {
            }
        }
Пример #2
0
        public ActionResult PurchaseReceipt()
        {
            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_user", string.Empty, HandleType.ReturnMsg);           //id_user
                p.Add("shopspList", string.Empty, HandleType.ReturnMsg);        //商品List
                p.Add("remark", string.Empty, HandleType.DefaultValue);         //remark
                p.Add("id_gys", string.Empty, HandleType.ReturnMsg);            //id_gys
                p.Add("id_jbr", string.Empty, HandleType.ReturnMsg);            //id_jbr
                p.Add("rq", string.Empty, HandleType.ReturnMsg);                //rq
                p.Add("je_sf", string.Empty, HandleType.ReturnMsg);             //je_sf
                p.Add("dh_origin", string.Empty, HandleType.DefaultValue);      //dh_origin
                p.Add("bm_djlx_origin", string.Empty, HandleType.DefaultValue); //bm_djlx_origin
                p.Add("id_bill_origin", string.Empty, HandleType.DefaultValue); //id_bill_origin
                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);
                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_user",
                    "shopspList",
                    "remark",
                    "id_gys",
                    "id_jbr",
                    "rq",
                    "je_sf",
                    "dh_origin",
                    "bm_djlx_origin",
                    "id_bill_origin"
                });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion

                #region 验证数据操作

                List <Td_Jh_2> shopspList = new List <Td_Jh_2>();

                try
                {
                    shopspList = JSON.Deserialize <List <Td_Jh_2> >(param["shopspList"].ToString()) ?? new List <Td_Jh_2>();
                }
                catch (Exception ex)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "操作失败 shopspList不符合要求!";
                    return(res);
                }

                if (shopspList == null || shopspList.Count() <= 0)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "操作失败 shopspList不能为空!";
                    return(res);
                }

                var digitHashtable = GetParm(param["id_masteruser"].ToString());

                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()))
                        {
                            res.State   = ServiceState.Fail;
                            res.Message = "商品[" + item.barcode + "]数量不允许为0!";
                            return(res);
                        }
                        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
                    {
                        res.State   = ServiceState.Fail;
                        res.Message = "商品中存在 单价*数量不等于金额的数据!";
                        return(res);
                    }
                }

                param.Remove("shopspList");
                param.Add("shopspList", shopspList);
                param.Add("DigitHashtable", digitHashtable);
                param.Add("autoAudit", true);

                #endregion

                #region 执行业务保存操作
                var dh = GetNewDH(Enums.FlagDJLX.DHJH, param["id_masteruser"].ToString(), param["id_shop"].ToString());
                param.Add("dh", dh);
                var br = BusinessFactory.Td_Jh_1.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));
        }
Пример #3
0
        public ActionResult QuickInventory()
        {
            var sr = RequestResult(res =>
            {
                #region 获取参数
                Hashtable param = base.GetParameters();
                ParamVessel pv  = new ParamVessel();
                pv.Add("id_shop", string.Empty, HandleType.ReturnMsg);       //id_shop
                pv.Add("id_masteruser", string.Empty, HandleType.ReturnMsg); //id_masteruser
                pv.Add("json_param", string.Empty, HandleType.ReturnMsg);    //jsonParam
                pv.Add("id_jbr", string.Empty, HandleType.ReturnMsg);        //id_jbr
                pv.Add("id_create", string.Empty, HandleType.ReturnMsg);     //id_create
                pv.Add("bz", string.Empty, HandleType.DefaultValue);         //bz
                pv.Add("rq", string.Empty, HandleType.ReturnMsg);            //rq
                pv.Add("sign", string.Empty, HandleType.ReturnMsg);          //sign
                #endregion
                #region 验证参数
                try
                {
                    param = param.Trim(pv);
                }
                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 = 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", "json_param", "id_jbr", "id_create", "bz", "rq" });
                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 读取数据
                var br = BusinessFactory.Td_Kc_Kspd_1.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));
        }
Пример #4
0
        public ActionResult JhddNoFinish()
        {
            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("rq_begin", string.Empty, HandleType.DefaultValue);   //rq_begin
                p.Add("rq_end", string.Empty, HandleType.DefaultValue);     //rq_end
                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);
                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", "rq_begin", "rq_end" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion

                #region 读取数据
                ht.Clear();

                ht.Clear();
                ht.Add("id_masteruser", param["id_masteruser"].ToString());
                ht.Add("flag_delete", (int)Enums.FlagDelete.NoDelete);
                ht.Add("id_shop", param["id_shop"].ToString());
                ht.Add("no_th", 1);

                DateTime now = DateTime.Now;

                if (!string.IsNullOrEmpty(param["rq_begin"].ToString()) && DateTime.TryParse(param["rq_begin"].ToString(), out now))
                {
                    ht.Add("start_rq", DateTime.Parse(param["rq_begin"].ToString()));
                }
                if (!string.IsNullOrEmpty(param["rq_end"].ToString()) && DateTime.TryParse(param["rq_end"].ToString(), out now))
                {
                    ht.Add("end_rq", DateTime.Parse(param["rq_end"].ToString()));
                }

                var br = BusinessFactory.Business.ShydhQuery(ht);

                #endregion

                #region 返回

                res.State   = br.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = br.Message.FirstOrDefault();
                res.Data    = br.Data;

                return(res);

                #endregion
            });

            #region 数据处理
            var            jsonString     = JSON.Serialize(sr);;
            string         p1             = @"\\/Date\((\d+)\)\\/";
            MatchEvaluator matchEvaluator = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg            = new Regex(p1);
            jsonString = reg.Replace(jsonString, matchEvaluator);

            string         p2 = @"\\/Date\(([/+/-]\d+)\)\\/";
            MatchEvaluator matchEvaluator2 = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg2            = new Regex(p2);
            jsonString = reg2.Replace(jsonString, matchEvaluator2);
            #endregion

            return(Content(jsonString));
        }
Пример #5
0
        public ActionResult ProcedureOutQuery()
        {
            var sr = RequestResult(res =>
            {
                #region 获取参数
                Hashtable param = base.GetParameters();
                ParamVessel pv  = new ParamVessel();
                pv.Add("id_shop", string.Empty, HandleType.ReturnMsg);       //id_shop
                pv.Add("id_masteruser", string.Empty, HandleType.ReturnMsg); //id_masteruser
                pv.Add("json_param", string.Empty, HandleType.ReturnMsg);    //jsonParam
                pv.Add("sign", string.Empty, HandleType.ReturnMsg);          //sign
                #endregion
                #region 验证参数
                try
                {
                    param = param.Trim(pv);
                }
                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 = 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", "json_param" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 读取数据
                var br = BusinessFactory.Business.ProcedureOutQuery(param);
                #endregion
                #region 返回
                res.State   = br.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = br.Message.FirstOrDefault();
                res.Data    = br.Data;
                return(res);

                #endregion
            });

            #region 数据处理
            var            jsonString     = JSON.Serialize(sr);;
            string         p              = @"\\/Date\((\d+)\)\\/";
            MatchEvaluator matchEvaluator = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg            = new Regex(p);
            jsonString = reg.Replace(jsonString, matchEvaluator);

            string         p2 = @"\\/Date\(([/+/-]\d+)\)\\/";
            MatchEvaluator matchEvaluator2 = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg2            = new Regex(p2);
            jsonString = reg2.Replace(jsonString, matchEvaluator2);
            #endregion

            return(Content(jsonString));
        }
Пример #6
0
        public ActionResult GetServiceShopspByBarcodeDB()
        {
            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("barcode", string.Empty, HandleType.ReturnMsg);       //barcode
                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 = 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", "barcode" });
                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 调用接口获取数据

                var paramters = new Dictionary <string, string>();
                paramters.Add("barCode", param["barcode"].ToString());
                paramters.Add("sign", SignUtils.SignRequestForCyUserSys(paramters, PublicSign.shopspMD5Key));
                var webutils  = new CySoft.Utility.WebUtils();
                var respStr   = webutils.DoPost(PublicSign.shopspUrl, paramters, 30000);
                var respModel = JSON.Deserialize <ServiceResult>(respStr);

                if (respModel != null)
                {
                    if (respModel.State != ServiceState.Done)
                    {
                        res.State   = ServiceState.Fail;
                        res.Message = "操作失败,调用商品服务接口失败,Message:" + respModel.Message;
                        res.Data    = respModel;
                        return(res);
                    }
                    else
                    {
                        if (respModel.Data != null)
                        {
                            if (!string.IsNullOrEmpty(respModel.Data.ToString()))
                            {
                                var dbModel = JSON.Deserialize <Tb_Shopsp_Service>(respModel.Data.ToString());
                                if (dbModel.BarCode != null)
                                {
                                    dbModel.BarCode = dbModel.BarCode.Trim();
                                }
                                if (dbModel.ProductName != null)
                                {
                                    dbModel.ProductName = dbModel.ProductName.Trim();
                                }
                                if (dbModel.Unit != null)
                                {
                                    dbModel.Unit = dbModel.Unit.Trim();
                                }
                                if (dbModel.Picture != null)
                                {
                                    dbModel.Picture = dbModel.Picture.Trim();
                                }
                                res.Data = dbModel;
                            }
                        }
                    }
                }

                #endregion
                #region 返回
                res.State   = ServiceState.Done;
                res.Message = "操作成功";

                return(res);

                #endregion
            });

            #region 数据处理
            var            jsonString     = JSON.Serialize(sr);;
            string         rp             = @"\\/Date\((\d+)\)\\/";
            MatchEvaluator matchEvaluator = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg            = new Regex(rp);
            jsonString = reg.Replace(jsonString, matchEvaluator);

            string         p2 = @"\\/Date\(([/+/-]\d+)\)\\/";
            MatchEvaluator matchEvaluator2 = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg2            = new Regex(p2);
            jsonString = reg2.Replace(jsonString, matchEvaluator2);
            #endregion

            return(Content(jsonString));
        }
Пример #7
0
        public ActionResult JfQuery()
        {
            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("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);
                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" });

                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");
                var br = BusinessFactory.Tz_Hy_Jf.Get(param);
                #endregion
                #region 返回

                res.State   = br.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = br.Message.FirstOrDefault();
                res.Data    = "";

                if (br.Success)
                {
                    var tz_Hy_Jf = (Tz_Hy_Jf)br.Data;
                    res.Data     = new { jf_qm = tz_Hy_Jf.jf_qm };
                    return(res);
                }

                return(res);

                #endregion
            });

            return(JsonString(sr));
        }
Пример #8
0
        /// <summary>
        /// 主用户登录
        /// 2016-9-14 修改LD
        /// </summary>
        /// <returns></returns>
        //[HttpPost]
        public ActionResult ShopRegister()
        {
            var sr = RequestResult(res =>
            {
                if (CheckParamNull(res).State == ServiceState.Fail)
                {
                    return(res);
                }
                Hashtable ht = new Hashtable();
                ht.Add("username", base.GetParameter("username"));
                ht.Add("id_masteruser", "0");
                IDictionary <string, string> param = base.GetParameters(new string[] { "username", "yzm" });
                //WriteDBLog(LogFlag.Bill, new List<string>() { "接口SystemService/ShopRegister,username:"******"username"] });
                var userModel = BusinessFactory.Account.ShopRegister(ht).Data as Tb_User;
                if (userModel == null)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "主帐号或企业号错误!";
                    return(res);
                }

                var validSign = SignUtils.SignRequest(param, "CY2016");
                var sign      = base.GetParameter("sign");
                //WriteDBLog(LogFlag.Bill, new List<string>() { "接口SystemService/ShopRegister,sign:" + sign + ";服务器生成sign:" + validSign + ";username:"******"username"] });
                if (sign != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "数据签名验证失败!";
                    return(res);
                }
                ht.Clear();
                ht.Add("username", base.GetParameter("username"));
                ht.Add("yzm", base.GetParameter("yzm"));
                var br = BusinessFactory.Tb_Shop.GetPosShopInfo(ht);
                var posShopInfoModel = br.Data as PosShopInfoModel;
                if (posShopInfoModel == null)
                {
                    res.State = ServiceState.Fail;
                    if (userModel.version == 10)
                    {
                        res.Message = "密码错误!";
                    }
                    else
                    {
                        res.Message = "门店验证码错误!";
                    }
                    return(res);
                }
                var key    = userModel.id_masteruser + "_" + posShopInfoModel.id_shop;
                var ticket = Guid.NewGuid().ToString();
                posShopInfoModel.ticket = ticket;
                Tb_Ticket ticketModel   = new Tb_Ticket()
                {
                    ticket = ticket,
                    key_y  = key,
                    id     = Guid.NewGuid().ToString()
                };
                var ticketRes = BusinessFactory.Tb_Ticket.Add(ticketModel);
                if (!string.IsNullOrEmpty(ticketRes.Data + ""))
                {
                    posShopInfoModel.ticket = ticketRes.Data.ToString();
                }
                res.State = br.Success ? ServiceState.Done : ServiceState.Fail;
                posShopInfoModel.version = userModel.version;
                res.Data    = posShopInfoModel;
                res.Message = br.Message.FirstOrDefault();
                return(res);
            });

            return(JsonString(sr));
        }
Пример #9
0
        /// <summary>
        /// 新增商品
        /// lz
        /// 2016-09-26
        /// </summary>
        //[HttpPost]
        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 *
                p.Add("id_masteruser", string.Empty, HandleType.ReturnMsg); //主用户id *
                p.Add("id_user", string.Empty, HandleType.ReturnMsg);       //用户id *
                p.Add("barcode", string.Empty, HandleType.ReturnMsg);       //条码 *
                p.Add("bm", string.Empty, HandleType.ReturnMsg);            //编码 *
                p.Add("mc", string.Empty, HandleType.ReturnMsg);            //名称 *
                p.Add("dj_jh", 0m, HandleType.DefaultValue);                //进货价
                p.Add("dj_ls", 0m, HandleType.DefaultValue);                //零售价
                p.Add("dj_hy", 0m, HandleType.DefaultValue);                //会员价
                p.Add("dj_ps", 0m, HandleType.DefaultValue);                //配送价
                p.Add("dw", string.Empty, HandleType.ReturnMsg);            //单位 *
                p.Add("sl_kc_min", 0m, HandleType.DefaultValue);            //最底库存量 *
                p.Add("sl_kc_max", 0m, HandleType.DefaultValue);            //最高库存量 *
                p.Add("flag_czfs", string.Empty, HandleType.ReturnMsg);     //计价方式 *
                p.Add("id_spfl", string.Empty, HandleType.ReturnMsg);       //分类ID *
                p.Add("yxq", 0, HandleType.DefaultValue);                   //保质期 天

                p.Add("cd", string.Empty, HandleType.DefaultValue);         //产地
                p.Add("pic_path", string.Empty, HandleType.DefaultValue);   //图片路径
                p.Add("id_gys", string.Empty, HandleType.DefaultValue);     //默认供应商
                p.Add("bz", string.Empty, HandleType.DefaultValue);         //备注
                p.Add("dj_pf", 0m, HandleType.DefaultValue);                //批发价  目前此字段没用

                p.Add("je_qc", 0m, HandleType.DefaultValue);                //期初金额
                p.Add("sl_qc", 0m, HandleType.DefaultValue);                //期初数量

                p.Add("dbzList", string.Empty, HandleType.DefaultValue);    //多包装

                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 = 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", "id_user", "barcode", "bm", "mc", "dj_jh", "dj_ls", "dj_hy", "dj_ps", "dw", "sl_kc_min", "sl_kc_max", "flag_czfs", "id_spfl", "yxq", "cd", "pic_path", "id_gys", "bz", "je_qc", "sl_qc", "dbzList" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 验证参数是否符合

                #region 多包装
                //多包装
                var dbzList = new List <Tb_Shopsp_DBZ>();
                try
                {
                    dbzList = JSON.Deserialize <List <Tb_Shopsp_DBZ> >(param["dbzList"].ToString()) ?? new List <Tb_Shopsp_DBZ>();
                    foreach (var item in dbzList)
                    {
                        item.id        = Guid.NewGuid().ToString();
                        item.info_type = "add";
                    }
                }
                catch (Exception ex)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "操作失败 多包装不符合要求!";
                    return(res);
                }
                #endregion

                #region 期初
                //期初
                var qcModel = new Td_Sp_Qc()
                {
                    sl_qc = decimal.Parse(param["sl_qc"].ToString()), je_qc = decimal.Parse(param["je_qc"].ToString())
                };
                #endregion

                #region 验证数据
                //控制层验证数据
                var brCheck = this.CheckParam(param, qcModel, dbzList);
                if (!brCheck.Success)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = string.Join(";", brCheck.Message);
                    return(res);
                }
                #endregion

                #region 数据处理

                #region 图片
                // 图片
                if (param["pic_path"] != null && !string.IsNullOrEmpty(param["pic_path"].ToString()))
                {
                    CheckImgPath();
                    string[] url_img = param["pic_path"].ToString().Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    string guid      = Guid.NewGuid().ToString();
                    string extension = Path.GetExtension(url_img[url_img.Length - 1]);
                    string fileName  = guid + extension;
                    ImgExtension.MakeThumbnail(param["pic_path"].ToString(), "/UpLoad/Goods/thumb/_480x480_" + fileName, 480, 480, ImgCreateWay.Cut, false);
                    string newPath = string.Format("/UpLoad/Goods/thumb/_480x480_{0}", fileName);
                    ;
                    ; //480x480
                    param.Remove("pic_path");
                    param.Add("pic_path", newPath);
                }
                #endregion

                #region 多包装
                if (param.ContainsKey("dbzList"))
                {
                    param.Remove("dbzList");
                }
                param.Add("dbzList", dbzList);
                #endregion

                #region 期初
                if (param.ContainsKey("sp_qc"))
                {
                    param.Remove("sp_qc");
                }
                param.Add("sp_qc", qcModel);
                #endregion

                #region 用户管理门店
                var brShopShop = this.GetUserShopShop(param["id_masteruser"].ToString(), param["id_shop"].ToString(), param["id_user"].ToString());
                if (!brShopShop.Success)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = string.Join(";", brShopShop.Message);
                    return(res);
                }
                var shopShopList = (List <Tb_User_ShopWithShopMc>)brShopShop.Data;
                param.Add("shop_shop", shopShopList);
                #endregion

                #region 获取小数点位数
                var DigitHashtable = BusinessFactory.Account.GetParm(param["id_masteruser"].ToString());
                if (!param.ContainsKey("DigitHashtable"))
                {
                    param.Add("DigitHashtable", DigitHashtable);
                }
                #endregion

                #endregion

                #endregion
                #region 保存至本地图片
                if (param.ContainsKey("pic_path") && !string.IsNullOrEmpty(param["pic_path"].ToString()))
                {
                    var pic_path = BusinessFactory.Tb_Shopsp.GetBarcodePic(new Tb_Shopsp_Service()
                    {
                        BarCode = param["barcode"].ToString(), Picture = param["pic_path"].ToString()
                    });
                    param["pic_path"] = pic_path;
                }
                #endregion
                #region 新增
                var br = BusinessFactory.Tb_Shopsp.Add(param);
                #endregion
                #region 返回
                res.State   = br.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = br.Message.FirstOrDefault();
                if (br.Success)
                {
                    res.Data = br.Data;
                }
                return(res);

                #endregion
            });

            return(JsonString(sr));
        }
Пример #10
0
        public ActionResult ChangePwd()
        {
            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_user", string.Empty, HandleType.ReturnMsg);       //id
                p.Add("old_pwd", string.Empty, HandleType.ReturnMsg);       //old_pwd
                p.Add("new_pwd", string.Empty, HandleType.ReturnMsg);       //new_pwd
                p.Add("sign", string.Empty, HandleType.ReturnMsg);          //sign
                #endregion
                #region 验证参数
                try
                {
                    param = param.Trim(p);
                }
                catch (Exception ex)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "部份必要参数缺失!";
                    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 = "主用户或门店ID缺失!";
                    return(res);
                }
                var ticketModel = (Tb_Ticket)ticketBr.Data;
                if (ticketModel == null)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "登录票据已不存在,请重新登录!";
                    return(res);
                }
                var ticket = ticketModel.ticket;
                #endregion
                #region 验证签名
                IDictionary <string, string> dic = base.GetParameters(new string[] { "id_shop", "id_masteruser", "id_user", "old_pwd", "new_pwd" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "数据签名验证失败!";
                    return(res);
                }
                #endregion

                #region 更新密码
                param.Remove("sign");
                param.Add("id", param["id_user"]);
                param.Remove("id_user");
                var br = BusinessFactory.Account.ChangeUserPwd(param);
                #endregion

                #region 返回
                res.State   = br.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = br.Message.FirstOrDefault();
                res.Data    = "";
                return(res);

                #endregion
            });

            return(JsonString(sr));
        }
Пример #11
0
        public ActionResult Add()
        {
            ServiceResult res = new ServiceResult()
            {
                State = ServiceState.Done
            };

            try
            {
                #region 编码类型
                Encoding encoding = null;
                //编码类型
                string charset = System.Configuration.ConfigurationManager.AppSettings["Charset"];
                try
                {
                    encoding = Encoding.GetEncoding(charset);
                }
                catch
                {
                    encoding = Encoding.GetEncoding("UTF-8");
                }
                #endregion

                #region 获取参数
                Hashtable param     = base.GetParameters();
                string    id_user   = Request["id_user"] == null ? "" : HttpUtility.UrlDecode(Request["id_user"], encoding);     //id_user
                string    flag_from = Request["flag_from"] == null ? "" : HttpUtility.UrlDecode(Request["flag_from"], encoding); //flag_from
                string    flag_lx   = Request["flag_lx"] == null ? "" : HttpUtility.UrlDecode(Request["flag_lx"], encoding);     //flag_lx
                string    content   = Request["content"] == null ? "" : HttpUtility.UrlDecode(Request["content"], encoding);     //content
                string    sign      = Request["sign"] == null ? "" : HttpUtility.UrlDecode(Request["sign"], encoding);           //sign
                string    ip        = Request["ip"] == null ? "" : HttpUtility.UrlDecode(Request["ip"], encoding);               //ip

                #endregion
                #region 验证参数
                if (string.IsNullOrEmpty(content) || string.IsNullOrEmpty(sign))
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0001;
                    return(JsonString(res));
                }
                #endregion
                #region 验证签名
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("id_user", HttpUtility.UrlEncode(id_user, Encoding.UTF8));
                dic.Add("flag_from", HttpUtility.UrlEncode(flag_from, Encoding.UTF8));
                dic.Add("flag_lx", HttpUtility.UrlEncode(flag_lx, Encoding.UTF8));
                //dic.Add("content", HttpUtility.UrlEncode(content, Encoding.UTF8)  );
                var validSign = SignUtils.SignRequest(dic, "CY2016");
                //验证签名
                if (sign != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(JsonString(res));
                }
                #endregion
                #region 读取数据
                Hashtable loginInfo = new Hashtable();
                loginInfo.Add("id_user", id_user);
                loginInfo.Add("flag_from", flag_from);

                if (!string.IsNullOrEmpty(ip))
                {
                    loginInfo.Add("ip", ip);
                }

                BusinessFactory.Log.Add(loginInfo, flag_lx.ToString(), content.ToString());

                #endregion
                #region 返回
                res.State   = ServiceState.Done;
                res.Message = "操作成功!";
                res.Data    = "";
                return(JsonString(res));

                #endregion
            }
            catch (Exception ex)
            {
                res.State   = ServiceState.Fail;
                res.Message = ServiceFailCode.S0001;
                return(JsonString(res));
            }
        }
Пример #12
0
        public ActionResult OutOrderPay()
        {
            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("dh", string.Empty, HandleType.ReturnMsg);            //dh
                p.Add("json_param", string.Empty, HandleType.ReturnMsg);    //json_param
                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 转换payList
                try
                {
                    var payList = Utility.JSON.Deserialize <List <Money_OrderPayList> >(param["json_param"].ToString());
                    param.Add("payList", payList);
                }
                catch (Exception ex)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "json_param参数格式不正确.";
                    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", "json_param", "dh" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 执行操作
                var br = BusinessFactory.Pay.OutOrderPay(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));
        }
Пример #13
0
        public ActionResult WXPayQuery()
        {
            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("out_trade_no", string.Empty, HandleType.ReturnMsg);  //out_trade_no
                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);
                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", "out_trade_no" });

                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["out_trade_no"].ToString()))
                {
                    res.State   = ServiceState.Fail;
                    res.Message = "商户订单号不能为空.";
                    return(res);
                }
                #endregion
                #region 执行操作
                var br = BusinessFactory.Pay.WXPayQuery(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));
        }
Пример #14
0
        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));
        }
Пример #15
0
        public ActionResult GetSystemTime(string phone)
        {
            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("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);
                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" });

                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 返回

                res.State   = ServiceState.Done;
                res.Message = "操作成功!!";
                res.Data    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                return(res);

                #endregion
            });

            return(JsonString(sr));

            #region 注释
            //#region 获取参数
            //ServiceResult res = new ServiceResult();
            //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("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 JsonString(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 JsonString(res);
            //}

            //var ticketModel = (Tb_Ticket)ticketBr.Data;
            //if (ticketModel == null)
            //{
            //    res.State = ServiceState.Fail;
            //    res.Message = ServiceFailCode.A0003;
            //    return JsonString(res);
            //}

            //var ticket = ticketModel.ticket;
            //#endregion
            //#region 验证签名
            //IDictionary<string, string> dic = base.GetParameters(new string[] { "id_shop", "id_masteruser" });

            //var validSign = SignUtils.SignRequest(dic, ticket);
            ////验证签名
            //if (param["sign"].ToString() != validSign)
            //{
            //    res.State = ServiceState.Fail;
            //    res.Message = ServiceFailCode.A0002;
            //    return JsonString(res);
            //}
            //#endregion
            //#region 返回

            //res.State = ServiceState.Done;
            //res.Message = "操作成功!!";
            //res.Data = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            //return JsonString(res);
            //#endregion

            #endregion
        }
Пример #16
0
        public ActionResult CheckCYService()
        {
            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("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 = 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" });
                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 获取商品信息
                var brCheck = CheckUserServiceWork(param);
                #endregion
                #region 返回
                res.State   = brCheck.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = brCheck.Message.FirstOrDefault();
                res.Data    = brCheck.Data;

                return(res);

                #endregion
            });

            return(JsonString(sr));
        }
Пример #17
0
        public ActionResult CreateBarcode()
        {
            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("flag_czfs", string.Empty, HandleType.ReturnMsg);     //flag_czfs
                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 = 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", "flag_czfs" });
                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion

                #region 获取单号
                string barcode = string.Empty;
                if (param != null && param.ContainsKey("flag_czfs") && (param["flag_czfs"].ToString() == "1" || param["flag_czfs"].ToString() == "2"))
                {
                    barcode = GetNewDH(Enums.FlagDJLX.BMShopspCZFS, param["id_masteruser"].ToString(), param["id_shop"].ToString());
                }
                else
                {
                    barcode = GetNewDH(Enums.FlagDJLX.BMShopsp, param["id_masteruser"].ToString(), param["id_shop"].ToString());
                }
                #endregion
                #region 返回
                res.State   = (!string.IsNullOrEmpty(barcode)) ? ServiceState.Done : ServiceState.Fail;
                res.Message = "";
                res.Data    = new { barcode = barcode };
                return(res);

                #endregion
            });

            return(JsonString(sr));
        }
Пример #18
0
        //[HttpPost]
        public ActionResult GetShopspByBarcode()
        {
            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("barcode", string.Empty, HandleType.ReturnMsg);       //barcode
                p.Add("query_type", string.Empty, HandleType.DefaultValue); //query_type  0:查询所有 1:只查询本地2:只查询条码库 如果此字段不传 则只查询本地库
                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 = 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", "barcode", "query_type" });
                var validSign = SignUtils.SignRequest(dic, ticket);
                //验证签名
                if (param["sign"].ToString() != validSign)
                {
                    res.State   = ServiceState.Fail;
                    res.Message = ServiceFailCode.A0002;
                    return(res);
                }
                #endregion
                #region 获取商品信息



                BaseResult br = new BaseResult();
                if (param.ContainsKey("query_type") && (param["query_type"].ToString() == "1"))
                {
                    br = GetShopSpByLocal(param);
                }
                else if (param.ContainsKey("query_type") && param["query_type"].ToString() == "2")
                {
                    br = GetShopSpByTMK(param);
                }
                else if (param.ContainsKey("query_type") && param["query_type"].ToString() == "0" || string.IsNullOrEmpty(param["query_type"].ToString()))
                {
                    br = GetShopSpByLocal(param);
                    if (br.Success)
                    {
                        if (br.Data == null)
                        {
                            //本地无数据 调用条码库接口查询
                            br = GetShopSpByTMK(param);
                        }
                    }
                }


                #region 注释
                //ht.Clear();
                //ht.Add("barcode", param["barcode"].ToString());
                //ht.Add("flag_delete", (byte)Enums.FlagDelete.NoDelete);
                //ht.Add("id_masteruser", param["id_masteruser"].ToString());
                //var br = BusinessFactory.Tb_Shopsp.GetShopspList(ht);
                //if (br.Success)
                //{
                //    List<ShopspList_Query> shopspList = (List<ShopspList_Query>)br.Data;
                //    if (shopspList.Count() > 0)
                //    {
                //        var ShopSp = shopspList.FirstOrDefault();
                //        br.Success = true;
                //        br.Data = ShopSp;
                //        br.Level = ErrorLevel.Alert;
                //    }
                //    else
                //    {
                //        br.Level = ErrorLevel.Alert;
                //        br.Success = true;
                //        br.Data = new { };

                //        if (param.ContainsKey("query_type") && param["query_type"].ToString() == "0")
                //        {
                //        }
                //    }
                //}
                #endregion

                #endregion
                #region 返回
                if (br.Data == null)
                {
                    br.Data = new { }
                }
                ;
                res.State   = br.Success ? ServiceState.Done : ServiceState.Fail;
                res.Message = "";
                res.Data    = br.Data;
                res.Number  = ((int)br.Level).ToString();
                return(res);

                #endregion
            });


            #region 数据处理
            var            jsonString     = JSON.Serialize(sr);;
            string         rp             = @"\\/Date\((\d+)\)\\/";
            MatchEvaluator matchEvaluator = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg            = new Regex(rp);
            jsonString = reg.Replace(jsonString, matchEvaluator);

            string         p2 = @"\\/Date\(([/+/-]\d+)\)\\/";
            MatchEvaluator matchEvaluator2 = new MatchEvaluator(this.ConvertJsonDateToDateString);
            Regex          reg2            = new Regex(p2);
            jsonString = reg2.Replace(jsonString, matchEvaluator2);
            #endregion

            return(Content(jsonString));
        }
Пример #19
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));
        }