private void button2_Click(object sender, EventArgs e) { String youHuiQuanJson = Share.getPage("http://chongzhi.jd.com/json/order/searchp_searchDxqInfo.action", "ISP=" + 2 + "&jdPrice=" + 98.00, ""); MessageBox.Show(youHuiQuanJson); }
private void timer1_Tick(object sender, EventArgs e) { String result = Share.getPage_GET("http://order.jd.com/center/list.action?r=" + new Random().Next(1, 999999999)); log.Debug("保持连接结果:" + result); }
private void loop(HttpListener httpListenner) { while (startMark) { HttpListenerRequest request = null; HttpListenerResponse response = null; StreamWriter writer = null; try { HttpListenerContext context = httpListenner.GetContext(); request = context.Request; //分析插入订单 StateHandle handle = new StateHandle(); OrderInfo phoneInfo = new OrderInfo(); phoneInfo.vender_id = request.QueryString["venderId"]; phoneInfo.order_id = request.QueryString["orderId"]; phoneInfo.face_price = request.QueryString["facePrice"]; phoneInfo.phone_no = request.QueryString["phoneNo"]; phoneInfo.provider = request.QueryString["provider"]; phoneInfo.province_code = request.QueryString["provinceCode"]; phoneInfo.city_code = request.QueryString["cityCode"]; phoneInfo.order_status = "0"; String inTime = request.QueryString["inTime"]; String sign = request.QueryString["sign"]; StringBuilder sb = new StringBuilder(); sb.Append("venderId=").Append(phoneInfo.vender_id) .Append("&orderId=").Append(phoneInfo.order_id) .Append("&phoneNo=").Append(phoneInfo.phone_no) .Append("&facePrice=").Append(phoneInfo.face_price) .Append("&provider=").Append(phoneInfo.provider) .Append("&provinceCode=").Append(phoneInfo.province_code) .Append("&cityCode=").Append(phoneInfo.city_code) .Append("&inTime=").Append(inTime) .Append("&key=").Append(Config.md5Key); String _sign = Share.MD5(sb.ToString()).ToLower(); String res = ""; if (phoneInfo.vender_id == null || "".Equals(phoneInfo.vender_id) || phoneInfo.order_id == null || "".Equals(phoneInfo.order_id) || phoneInfo.face_price == null || "".Equals(phoneInfo.face_price) || phoneInfo.phone_no == null || "".Equals(phoneInfo.phone_no) || inTime == null || "".Equals(inTime) || sign == null || "".Equals(sign) ) { res = "000001"; } else if (!_sign.Equals(sign)) { res = "000005"; } else { //验证时间戳(略) //验证订单号 int count = handle.selectCountByOrderId(phoneInfo); if (count <= 0) { int insertCount = handle.insertOrderService(phoneInfo); if (insertCount > 0) { res = "000000"; } else { res = "000003"; } } else { res = "000004"; } } response = context.Response; response.StatusCode = 200; writer = new StreamWriter(response.OutputStream); writer.Write(res); writer.Close(); response.Close(); View.write("收单接口orderId:" + phoneInfo.order_id + ",录入结果:" + res); log.Debug("收单接口orderId:" + phoneInfo.order_id + ",录入结果:" + res); } catch (Exception ex) { log.Debug("收单接口异常:" + ex); } finally { try { if (writer != null) { writer.Close(); } if (response != null) { response.Close(); } } catch (Exception ex) { log.Debug("收单接口异常:" + ex); View.write("收单接口异常:" + ex); } } } }
public OrderInfo submitOrderService(MainForm frm) { OrderInfoDao dao = new OrderInfoDao(); OrderInfo phoneInfo = dao.getSubmitOrderDao(); if (phoneInfo != null) { try { String jdOrderId = ""; String jdOrderInTime = ""; String orderId = phoneInfo.order_id.Trim(); String facePrice = phoneInfo.face_price.Trim(); String telephone = phoneInfo.phone_no.Trim(); View.write("实立单号:" + orderId + ",号码:" + telephone + ",面值:" + facePrice + ",开始充值提交..."); log.Debug("实立单号:" + orderId + ",号码:" + telephone + ",面值:" + facePrice + ",开始充值提交..."); if (!String.IsNullOrEmpty(orderId) && !String.IsNullOrEmpty(facePrice) && !String.IsNullOrEmpty(telephone)) { log.Debug("searchSkuIdResult:http://chongzhi.jd.com/json/order/search_searchPhone.action?mobile=" + telephone); String telephoneInfo = Share.getPage("http://chongzhi.jd.com/json/order/search_searchPhone.action", "mobile=" + telephone, ""); log.Debug("telephoneInfo:" + telephoneInfo); if (String.IsNullOrEmpty(telephoneInfo) || telephoneInfo.Contains("System.Net.WebException")) { log.Debug("searchSkuIdResult:http://chongzhi.jd.com/json/order/search_searchPhone.action?mobile=" + telephone); telephoneInfo = Share.getPage("http://chongzhi.jd.com/json/order/search_searchPhone.action", "mobile=" + telephone, ""); log.Debug("telephoneInfo:" + telephoneInfo); } JObject telephoneInfoJson = (JObject)JsonConvert.DeserializeObject(telephoneInfo); String area = telephoneInfoJson["area"].ToString().Trim(); String ISP = telephoneInfoJson["provider"].ToString().Trim(); log.Debug("searchSkuIdResult:http://chongzhi.jd.com/json/order/search_searchSkuId.action?ISP=" + ISP + "&area=" + area + "&filltype=0&faceValue=" + facePrice); String searchSkuIdResult = Share.getPage("http://chongzhi.jd.com/json/order/search_searchSkuId.action", "ISP=" + ISP + "&area=" + area + "&filltype=0&faceValue=" + facePrice, ""); log.Debug("searchSkuIdResult:" + searchSkuIdResult); if (String.IsNullOrEmpty(searchSkuIdResult) || searchSkuIdResult.Contains("System.Net.WebException")) { log.Debug("searchSkuIdResult:http://chongzhi.jd.com/json/order/search_searchSkuId.action?ISP=" + ISP + "&area=" + area + "&filltype=0&faceValue=" + facePrice); searchSkuIdResult = Share.getPage("http://chongzhi.jd.com/json/order/search_searchSkuId.action", "ISP=" + ISP + "&area=" + area + "&filltype=0&faceValue=" + facePrice, ""); log.Debug("searchSkuIdResult:" + searchSkuIdResult); } JObject searchSkuIdResultJson = (JObject)JsonConvert.DeserializeObject(searchSkuIdResult); String skuId = searchSkuIdResultJson["skuId"].ToString(); log.Debug("jdPrice:http://chongzhi.jd.com/json/order/searchp_searchJdPrice.action?skuId=" + skuId); String jdPrice = Share.getPage("http://chongzhi.jd.com/json/order/searchp_searchJdPrice.action", "skuId=" + skuId, "").Trim().Replace("\"", ""); log.Debug("jdPrice:" + jdPrice); if (String.IsNullOrEmpty(jdPrice) || jdPrice.Contains("System.Net.WebException") || jdPrice.Length > 100) { log.Debug("jdPrice:http://chongzhi.jd.com/json/order/searchp_searchJdPrice.action?skuId=" + skuId); jdPrice = Share.getPage("http://chongzhi.jd.com/json/order/searchp_searchJdPrice.action", "skuId=" + skuId, "").Trim().Replace("\"", ""); log.Debug("jdPrice:" + jdPrice); } log.Debug("获取到京东价格:" + jdPrice + ",区域ID:" + area + ",产品ID:" + skuId + ",开始匹配优惠券..."); View.write("获取到京东价格:" + ((jdPrice.Length > 100) ? "异常" : jdPrice) + ",区域ID:" + area + ",产品ID:" + skuId + ",开始匹配优惠券..."); log.Debug("youHuiQuanJson:http://chongzhi.jd.com/json/order/searchp_searchDxqInfo.action?ISP=" + ISP + "&jdPrice=" + jdPrice); String youHuiQuanJson = Share.getPage("http://chongzhi.jd.com/json/order/searchp_searchDxqInfo.action", "ISP=" + ISP + "&jdPrice=" + jdPrice, ""); log.Debug("youHuiQuanJson:" + youHuiQuanJson); if (String.IsNullOrEmpty(youHuiQuanJson) || youHuiQuanJson.Contains("System.Net.WebException")) { log.Debug("youHuiQuanJson:http://chongzhi.jd.com/json/order/searchp_searchDxqInfo.action?ISP=" + ISP + "&jdPrice=" + jdPrice); youHuiQuanJson = Share.getPage("http://chongzhi.jd.com/json/order/searchp_searchDxqInfo.action", "ISP=" + ISP + "&jdPrice=" + jdPrice, ""); log.Debug("youHuiQuanJson:" + youHuiQuanJson); } String dxqidsStr = getdxqidsString(youHuiQuanJson, jdPrice); if (!String.IsNullOrEmpty(dxqidsStr)) { log.Debug("查找到过期最快的优惠券 dxqidsStr:" + dxqidsStr + ",开始验证是否可以提交充值等信息..."); View.write("查找到过期最快的优惠券 dxqidsStr:" + dxqidsStr + ",开始验证是否可以提交充值等信息..."); phoneInfo.features = "优惠券编号:" + dxqidsStr; log.Debug("hideKeyResult:http://chongzhi.jd.com/order/order_place.action?skuId=" + skuId + "&mobile=" + telephone + "&entry=4"); String hideKeyResult = Share.getPage("http://chongzhi.jd.com/order/order_place.action", "skuId=" + skuId + "&mobile=" + telephone + "&entry=4", ""); log.Debug("hideKeyResult:" + hideKeyResult); if (String.IsNullOrEmpty(hideKeyResult) || hideKeyResult.Contains("System.Net.WebException")) { log.Debug("hideKeyResult:http://chongzhi.jd.com/order/order_place.action?skuId=" + skuId + "&mobile=" + telephone + "&entry=4"); hideKeyResult = Share.getPage("http://chongzhi.jd.com/order/order_place.action", "skuId=" + skuId + "&mobile=" + telephone + "&entry=4", ""); log.Debug("hideKeyResult:" + hideKeyResult); } String hideKey = Share.getValue("<input type=\"hidden\" id=\"hideKey\" name=\"hideKey\" value=\"", "\"/>", hideKeyResult); log.Debug("checkRechargeResult:http://chongzhi.jd.com/json/order/searchp_checkRecharge.action?mobile=" + telephone + "&skuId=" + skuId); String checkRechargeResult = Share.getPage("http://chongzhi.jd.com/json/order/searchp_checkRecharge.action", "mobile=" + telephone + "&skuId=" + skuId, ""); log.Debug("checkRechargeResult:" + checkRechargeResult); if (String.IsNullOrEmpty(checkRechargeResult) || checkRechargeResult.Contains("System.Net.WebException")) { log.Debug("checkRechargeResult:http://chongzhi.jd.com/json/order/searchp_checkRecharge.action?mobile=" + telephone + "&skuId=" + skuId); checkRechargeResult = Share.getPage("http://chongzhi.jd.com/json/order/searchp_checkRecharge.action", "mobile=" + telephone + "&skuId=" + skuId, ""); log.Debug("checkRechargeResult:" + checkRechargeResult); } JObject checkRechargeResultJson = (JObject)JsonConvert.DeserializeObject(checkRechargeResult); String flag = checkRechargeResultJson["flag"].ToString().Trim().ToLower(); log.Debug("获取到是否可以提交充值:" + flag + ",hideKey:" + hideKey + ",开始提交充值..."); View.write("获取到是否可以提交充值:" + flag + ",hideKey:" + hideKey + ",开始提交充值..."); if (flag == "true") { try { String mobileFor = telephone.Substring(0, 3) + "+" + telephone.Substring(3, 4) + "+" + telephone.Substring(7, 4); log.Debug("submitOrderResult:http://chongzhi.jd.com/order/order_submitOrder.action?mobile=" + telephone + "&mobileFor=" + mobileFor + "&placeOrderVo.fillType=0&radiobutton=" + facePrice + dxqidsStr + "&paymentPassword="******"&skuId=" + skuId + "&entry=4&price=" + jdPrice + "&hideKey=" + hideKey + "&areaCodeU=7&rechargeTypeU=2&messageId=&initFlag=&payType=3&canUseJingdou=&usedJingdouNum="); String submitOrderResult = Share.getPage("http://chongzhi.jd.com/order/order_submitOrder.action", "mobile=" + telephone + "&mobileFor=" + mobileFor + "&placeOrderVo.fillType=0&radiobutton=" + facePrice + dxqidsStr + "&paymentPassword="******"&skuId=" + skuId + "&entry=4&price=" + jdPrice + "&hideKey=" + hideKey + "&areaCodeU=7&rechargeTypeU=2&messageId=&initFlag=&payType=3&canUseJingdou=&usedJingdouNum=", "http://chongzhi.jd.com/order/order_place.action?skuId=" + skuId + "&mobile=" + telephone + "&entry=4"); log.Debug("submitOrderResult:" + submitOrderResult); if (String.IsNullOrEmpty(submitOrderResult) || submitOrderResult.Contains("System.Net.WebException")) { phoneInfo.fail_reason = "状态未知"; phoneInfo.order_new_status = "3"; log.Debug("状态未知,需要人工核实"); View.write("状态未知,需要人工核实"); } else { if (submitOrderResult.Contains("您已付款成功!正在为您充值")) { phoneInfo.order_new_status = "2"; phoneInfo.fail_reason = "付款成功,正在充值"; log.Debug("您已付款成功!正在为您充值,开始获取京东订单号..."); View.write("您已付款成功!正在为您充值,开始获取京东订单号..."); try { log.Debug("orderListResult:http://order.jd.com/center/list.action?t=37&d=0&s=4096"); String orderListResult = Share.getPageOrder("http://order.jd.com/center/list.action", "t=37&d=0&s=4096", ""); log.Debug("orderListResult:" + orderListResult); if (String.IsNullOrEmpty(orderListResult) || orderListResult.Contains("System.Net.WebException")) { log.Debug("orderListResult:http://order.jd.com/center/list.action?t=37&d=0&s=4096"); orderListResult = Share.getPageOrder("http://order.jd.com/center/list.action", "t=37&d=0&s=4096", ""); log.Debug("orderListResult:" + orderListResult); } String firstOrderId = Share.getValue("<span id=\"pop_sign\" style=\"display:none;\">[{\"orderType\":37,\"orderIds\":[\"", "\"", orderListResult); log.Debug("firstOrderIdResult:http://chongzhi.jd.com/order/order_autoDetail.action?orderId=" + firstOrderId); String firstOrderIdResult = Share.getPage("http://chongzhi.jd.com/order/order_autoDetail.action", "orderId=" + firstOrderId, ""); log.Debug("firstOrderIdResult:" + firstOrderIdResult); if (String.IsNullOrEmpty(firstOrderIdResult) || firstOrderIdResult.Contains("System.Net.WebException")) { log.Debug("firstOrderIdResult:http://chongzhi.jd.com/order/order_autoDetail.action?orderId=" + firstOrderId); firstOrderIdResult = Share.getPage("http://chongzhi.jd.com/order/order_autoDetail.action", "orderId=" + firstOrderId, ""); log.Debug("firstOrderIdResult:" + firstOrderIdResult); } String orderTelephone = Share.getValue("<li>手机号码:", "</li>", firstOrderIdResult); String orderFacePrice = Share.getValue("<li>充值面额:", "元</li>", firstOrderIdResult); String orderInTime = Share.getValue("<li>下单时间:", "</li>", firstOrderIdResult); if (float.Parse(orderFacePrice) == float.Parse(facePrice) && Share.getMacherStr(telephone, orderTelephone)) { jdOrderId = firstOrderId; jdOrderInTime = orderInTime; phoneInfo.vender_order_no = jdOrderId; log.Debug("获取到京东订单号:" + jdOrderId + ",京东下单时间:" + jdOrderInTime); View.write("获取到京东订单号:" + jdOrderId + ",京东下单时间:" + jdOrderInTime); } else { log.Debug("获取京东订单信息失败,请人工核实!"); View.write("获取京东订单信息失败,请人工核实!"); } } catch (Exception exc) { log.Debug("获取京东订单信息异常,请人工核实!" + exc); View.write("获取京东订单信息异常,请人工核实!"); } } else { phoneInfo.order_new_status = "4"; String failReason = Share.getValue("<div class=\"success\"><s></s>", "</h4>", submitOrderResult); phoneInfo.fail_reason = failReason; log.Debug("付款失败,失败原因:" + failReason); View.write("付款失败,失败原因:" + failReason); } } } catch (Exception exc) { phoneInfo.fail_reason = "状态未知"; phoneInfo.order_new_status = "3"; log.Debug("状态未知,需要人工核实"); View.write("状态未知,需要人工核实"); } } else { phoneInfo.order_new_status = "4"; phoneInfo.fail_reason = "未付款,原因:付款前检查是否可以充值返回" + checkRechargeResult + " is false"; log.Debug("未付款,原因:付款前检查是否可以充值返回" + checkRechargeResult + " is false"); View.write("未付款,原因:付款前检查是否可以充值" + checkRechargeResult + " is false"); } } else { phoneInfo.order_new_status = "4"; phoneInfo.fail_reason = "未查找到优惠券,付款失败"; log.Debug("未查找到优惠券,付款失败"); View.write("未查找到优惠券,付款失败"); } } else { phoneInfo.order_new_status = "4"; phoneInfo.fail_reason = "该行面值、号码、单号参数为空,提交失败"; log.Debug("该行面值、号码、单号参数为空,提交失败"); View.write("该行面值、号码、单号参数为空,提交失败"); } } catch (Exception ex) { phoneInfo.order_new_status = "4"; phoneInfo.fail_reason = "程序异常提交失败"; log.Debug("程序异常,提交失败!" + ex); View.write("异常提交失败!"); } int updateCount = dao.updateOrderStatusDao(phoneInfo); log.Debug("updateOrderStatusDao orderId:" + phoneInfo.order_id + ",更新结果:" + updateCount); View.write("orderId:" + phoneInfo.order_id + ",更新结果:" + updateCount); } return(phoneInfo); }