private string SendSMS(string vaildphone, string content) { var webutils = new CySoft.Utility.WebUtils(); var reqUrl = string.Format("{0}", System.Configuration.ConfigurationManager.AppSettings["CyUserMsgUrl"]); var Md5Key = string.Format("{0}", System.Configuration.ConfigurationManager.AppSettings["Md5KeySMS"]); IDictionary <string, string> ps = new Dictionary <string, string>(); Random random = new Random(); var code = random.Next(1000, 9999); ps.Add("phone", vaildphone); ps.Add("content", content); ps.Add("client", "window"); ps.Add("client_ver", "7"); ps.Add("flag_from", "YUNPOS"); ps.Add("sign", SignUtils.SignRequestForCyUserSys(ps, Md5Key)); return(webutils.DoPost(reqUrl, ps, 30000)); }
public BaseResult GetShopSpByTMK(Hashtable param) { BaseResult br = new BaseResult(); br.Level = ErrorLevel.Question; #region 调用接口获取数据 try { if (PublicSign.shopspCheckAPI == "1") { #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) { br.Success = false; br.Message.Clear(); br.Message.Add(string.Format("查询接口失败")); br.Data = null; return(br); } else { br.Success = true; br.Message.Clear(); br.Message.Add(string.Format("查询接口成功")); br.Data = null; if (respModel.Data != null) { if (!string.IsNullOrEmpty(respModel.Data.ToString())) { var dbModel = JSON.Deserialize <Tb_Shopsp_Service>(respModel.Data.ToString()); var rModel = new ShopspList_Query() { bm = dbModel.BarCode, barcode = dbModel.BarCode, mc = dbModel.ProductName, dw = dbModel.Unit, dj_ls = dbModel.SellingPrice, pic_path = dbModel.Picture, source = "barcodedb" }; if (rModel.bm != null) { rModel.bm = rModel.bm.Trim(); } if (rModel.barcode != null) { rModel.barcode = rModel.barcode.Trim(); } if (rModel.mc != null) { rModel.mc = rModel.mc.Trim(); } if (rModel.dw != null) { rModel.dw = rModel.dw.Trim(); } if (rModel.pic_path != null) { rModel.pic_path = rModel.pic_path.Trim(); } br.Data = rModel; return(br); } } } } else { br.Success = false; br.Message.Clear(); br.Message.Add(string.Format("查询接口数据出现异常 请重试")); br.Data = null; return(br); } #endregion } else { #region 需要调用接口直接返回成功 br.Success = true; br.Message.Clear(); br.Message.Add(string.Format("查询接口成功")); br.Data = null; return(br); #endregion } } catch (Exception ex) { br.Success = false; br.Message.Clear(); br.Message.Add(string.Format("查询接口出现异常 请重试")); br.Data = null; return(br); } #endregion return(br); }
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)); }