public HttpResponseMessage GetCondition(string type) { if (type.Contains(",") == true) { if (type.Split(',')[1] != "") { string strLocalpathother = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Config/" + type.Split(',')[1] + ".json");//配置的json文件地址 strLocalpath = strLocalpathother; } } string returntxt = ""; try { string getjson = rule.GetJson(strLocalpath);//json配置文件转换 JArray jsonObj = JArray.Parse(getjson); for (int i = 0; i < jsonObj.Count; i++) { string typemodel = jsonObj[i]["type"].ToString(); if (type.Split(',')[0] == typemodel) { JArray jsonObjs = JArray.Parse(jsonObj[i]["condition"].ToString()); JArray jsonend = JArray.Parse(jsonObjs[0]["one"].ToString());//配置每次的第一个,索引为0 returntxt = rule.JsonStr("ok", "", jsonend); } } } catch (Exception e) { returntxt = rule.JsonStr("error", e.Message, ""); } return(new HttpResponseMessage { Content = new StringContent(returntxt, System.Text.Encoding.UTF8, "application/json") }); }
/// <summary> /// 功能描述:处理参数 /// 创建 人:周文卿 /// 创建时间:2018-11-17 /// </summary> /// <param name="tblSubroutes">路由表</param> /// <param name="payparameter">请求参数表</param> /// <param name="sing">签名的字段</param> /// <param name="orderid">订单号</param> /// /// <returns></returns> public Dictionary <string, string> HandleParm(List <tblSubroute> tblSubroutes, Dictionary <string, string> payparameter, ref string sing, ref string orderid) { //读取参数配置Json 文件 RuleCommon rule = new RuleCommon(); string getjson = rule.GetJson(strLocalpath); JArray jsonObj = JArray.Parse(getjson); Dictionary <string, string> keyValuePairs = new Dictionary <string, string>(); JToken array = new JArray(); //根据路由表判断 取哪个对象 for (int i = 0; i < jsonObj.Count; i++) { //网关编号和支付方式一样 if (tblSubroutes[0].fldGatewaynumber == jsonObj[i]["fldGatewaynumber"].ToString() && tblSubroutes[0].fldPayType == jsonObj[i]["fldPayType"].ToString()) { array = jsonObj[i]; sing = jsonObj[i]["sign"].ToString(); } } JArray childrenarray = new JArray(); //得到参数列表 childrenarray = JArray.Parse(array["parameter"].ToString()); //分别获取Key和value foreach (JToken item in childrenarray[0].Children()) { var JP = item as JProperty; string key = JP.Name; string value = JP.Value.ToString(); //如果value分别是num time 则为系统分配 switch (value) { //自己发往商户的订单号 case "num": value = ram(); orderid = value; break; //自己发往商户的时间 case "time": value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); break; default: if (payparameter.Keys.Contains(value)) { value = payparameter[value]; } break; } keyValuePairs.Add(key, value); } return(keyValuePairs); }
/// <summary> /// 功能描述:代付查询 /// </summary> /// <param name="MerchantId">商户ID</param> /// <param name="order_no">订单号</param> /// <param name="key">key值</param> /// <param name="cheanlname">渠道名称</param> public static void QueryAgentThend(string MerchantId, string order_no, string key, string cheanlname) { //读取参数配置Json 文件 RuleCommon rule = new RuleCommon(); string strLocalpath = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Config/QueryAgent.json");//配置的json文件地址; string getjson = rule.GetJson(strLocalpath); //转换成JSON对象 JArray jsonObj = JArray.Parse(getjson); JToken array = new JArray(); //循环JSON 根据渠道名称 匹配对象 for (int i = 0; i < jsonObj.Count; i++) { if (jsonObj[i]["fldGatewaynumber"].ToString() == cheanlname) { array = jsonObj[i]; } } //得到参数列表 JToken childrenarray = JArray.Parse(array["parameter"].ToString()); Dictionary <string, string> directory = new Dictionary <string, string>(); foreach (JToken item in childrenarray[0].Children()) { var JP = item as JProperty; string keyname = JP.Name; string value = JP.Value.ToString(); //如果value分别是order_no switch (value) { case "order_no": value = order_no; break; } directory.Add(keyname, value); } //根据各个渠道不同的要求 处理参数 Processingparameter processingparameter = new Processingparameter(); string por = ""; switch (cheanlname) { case "HT_006": por = processingparameter.ProcessingHT(directory, key, "1"); break; case "QJ_004": por = processingparameter.ProcessingQJ(directory, key, 0); break; case "YD_010": por = processingparameter.ProcessingYDSelect(directory, key); break; case "ZC_008": por = processingparameter.ProcessingZCselect(directory, key); break; case "HF_011": por = processingparameter.ProcessingHFselect(directory, key); break; } //根据requesttype 判断请求的方式 1是application/x-www-form-urlencoded 0是application/json TimerExampleState s = new TimerExampleState(); //QueryRequest rulePayRequest = new QueryRequest(); //string rest = "err"; //rest = rulePayRequest.HttpPostZF(array["payurl"].ToString(), por, cheanlname, order_no); s.type = array["requesttype"].ToString(); s.fldNotice = array["payurl"].ToString(); s.cheanlname = cheanlname; s.pram = por; //创建代理对象TimerCallback,该代理将被定时调用 TimerCallback timerDelegate = new TimerCallback(Request); //创建一个时间间隔为5m的定时器 Timer timer = new Timer(timerDelegate, s, 5 * 60 * 1000, 5 * 60 * 1000); s.tmr = timer; //主线程停下来等待Timer对象的终止 while (s.tmr != null) { Thread.Sleep(1000); } }
/// <summary> /// 功能描述:手工执行代付查询 /// 创建 人:周文卿 /// 创建时间:2019-03-21 /// </summary> /// <param name="MerchantId"></param> /// <param name="order_no"></param> /// <param name="key"></param> /// <param name="cheanlname"></param> /// <returns></returns> public string manualQuery(string MerchantId, string order_no, string key, string cheanlname) { RuleCommon rule = new RuleCommon(); string strLocalpath = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Config/QueryAgent.json");//配置的json文件地址; string getjson = rule.GetJson(strLocalpath); //转换成JSON对象 JArray jsonObj = JArray.Parse(getjson); JToken array = new JArray(); //循环JSON 根据渠道名称 匹配对象 for (int i = 0; i < jsonObj.Count; i++) { if (jsonObj[i]["fldGatewaynumber"].ToString() == cheanlname) { array = jsonObj[i]; } } //得到参数列表 JToken childrenarray = JArray.Parse(array["parameter"].ToString()); Dictionary <string, string> directory = new Dictionary <string, string>(); foreach (JToken item in childrenarray[0].Children()) { var JP = item as JProperty; string keyname = JP.Name; string value = JP.Value.ToString(); //如果value分别是order_no switch (value) { case "order_no": value = order_no; break; } directory.Add(keyname, value); } //根据各个渠道不同的要求 处理参数 Processingparameter processingparameter = new Processingparameter(); string por = ""; switch (cheanlname) { case "HT_006": por = processingparameter.ProcessingHT(directory, key, "1"); break; case "QJ_004": por = processingparameter.ProcessingQJ(directory, key, 0); break; } QueryRequest rulePayRequest = new QueryRequest(); string rest = "err"; switch (array["requesttype"].ToString()) { case "1": //rest = rulePayRequest.HttpPostZF(array["payurl"].ToString(), por, cheanlname); break; case "0": rest = rulePayRequest.HttpPostJSON(array["payurl"].ToString(), por, cheanlname); break; } return(rest); }
//[SupportFilter] public HttpResponseMessage UpdateItem(dynamic obj) { string result = string.Empty; try { string getjson = rule.GetJson(strLocalpath); long index = 0; JArray jsonObj = JArray.Parse(getjson); var tablename = (from x in jsonObj where x["type"].ToString() == obj.type.ToString() select x).FirstOrDefault(); RuletblItem_Recording it = new RuletblItem_Recording(); tblItem_Recording item_Recording = new tblItem_Recording(); string itemcode = "101^141^106^108^105^107"; // 如果是大气业务,并且在上述因子中,那么做除以1000的操作 if (obj.type == "eqia_r") { if (itemcode.Contains(obj.flditemcode.ToString())) { obj.fldItemValue = (double.Parse(obj.fldItemValue.ToString()) / 1000).ToString(); } } bool result2 = false; if (obj.fldRSInfo != null) { result2 = rule.UpdateitemAndRemark(obj.fldAutoid.ToString(), obj.flditemcode.ToString(), obj.fldItemValue.ToString(), tablename["tablenamepre"].ToString(), obj.fldSource.ToString(), obj.fldRSInfo.ToString(), obj.fldDate.ToString(), obj.fldRemark.ToString(), obj.fldObject.ToString()); } else { result2 = rule.Updateitem(obj.fldAutoid.ToString(), obj.flditemcode.ToString(), obj.fldItemValue.ToString(), tablename["tablenamepre"].ToString()); } if (result2) { if (obj.isitem == "y") { item_Recording.fldRange = obj.fldRSInfo + "|" + obj.flditemcode; item_Recording.fldType = obj.type.ToString(); item_Recording.fldDate = obj.fldDate.ToString(); index = it.Insert(item_Recording); } if (index > 0) { result = rule.JsonStr("ok", "", "修改成功"); } else { result = rule.JsonStr("ok", "", "记录因子值记录失败!"); } } else { result = rule.JsonStr("nodata", "无数据", ""); } } catch (Exception e) { result = rule.JsonStr("error", e.Message, ""); } return(new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }