From 456b0534e3b48e935ee19dae53a9911758d872d2 Mon Sep 17 00:00:00 2001 From: wule Date: Mon, 17 Aug 2026 01:41:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=20=20=E4=BA=91=E4=BB=93=E9=80=80=E8=B4=A7?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=9C=8D=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KJD_WebService/BLL/WXXD/WXOrderManage.cs | 112 ++++++++++++++++++ .../KJD_WebService/KJD_WebService.csproj | 1 + .../KJD_WebService/WXOrderService.asmx.cs | 101 ++++++++++++++++ 3 files changed, 214 insertions(+) diff --git a/KJDService/KJD_WebService/BLL/WXXD/WXOrderManage.cs b/KJDService/KJD_WebService/BLL/WXXD/WXOrderManage.cs index 15fba7a..855eb1b 100644 --- a/KJDService/KJD_WebService/BLL/WXXD/WXOrderManage.cs +++ b/KJDService/KJD_WebService/BLL/WXXD/WXOrderManage.cs @@ -2040,5 +2040,117 @@ namespace KJD_Web.BLL.WXXD } return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + + public string WXGetErpReturnOrderList(string inputData, bool isDetail = false) + { + if (!string.IsNullOrEmpty(inputData)) + { + if (!WXUserManage.GetSign(inputData)) + return "{\"code\":999,\"msg\":\"校验失败\"}"; + var timeCalc = DateTime.Now; + + var erp_order_id_in = RegexUtils.GetStringQuery(ref inputData, "erp_order_id_in")?.Replace("'", "\\'"); + if (erp_order_id_in.IsNullOrEmpty()) + { + return "{\"code\":500,\"msg\":\"未指定订单\"}"; + } + var sort_type = RegexUtils.GetStringQuery(ref inputData, "sort_type")?.Replace("'", "\\'"); + var is_not_count = RegexUtils.GetStringQuery(ref inputData, "is_not_count") == "true"; + + int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); + int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(500); + + string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + + string sql = "SELECT COUNT(id) FROM erp.distrib_return_order o WHERE 1=1 "; + + string where = ""; + if (!string.IsNullOrWhiteSpace(erp_order_id_in)) + where += " and o.order_code_source in ('" + erp_order_id_in.Replace(",", "','") + "')"; + sql += where; + + var count = 0; + if (!is_not_count) + count = mySql.ExecuteRowCount(sql); + + DataTable dt; + if (count == 0 && !is_not_count) + { + dt = new DataTable(); + } + else + { + sql = "SELECT o.* FROM erp.distrib_return_order o WHERE 1=1"; + + //where子句 + sql += where; + + if (sort_type == "asc") + sql += " ORDER BY o.created_at ASC"; + else + sql += " ORDER BY o.created_at DESC"; + sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size; + dt = mySql.ExecuteDataTable(sql); + } + + mySql.Close(); + if (dt != null) + { + try + { + List orderList = new List(); + foreach (DataRow row in dt.Rows) + { + distrib_return_order_info order = new distrib_return_order_info + { + id = row["id"].ParseToLong(), + additional_weight_fee = row["additional_weight_fee"].ParseToNullableInt(), + after_sale_no = row["after_sale_no"].ParseToNullableString(), + created_at = row["created_at"].ParseToString().ParseToDateTime(), + ext_field1 = row["ext_field1"].ParseToNullableString(), + ext_field2 = row["ext_field2"].ParseToNullableString(), + first_weight_fee = row["first_weight_fee"].ParseToNullableInt(), + logistics_code = row["logistics_code"].ParseToNullableString(), + logistics_express_no = row["logistics_express_no"].ParseToNullableString(), + order_code = row["order_code"].ParseToNullableString(), + order_code_source = row["order_code_source"].ParseToNullableString(), + order_void_status = row["order_void_status"].ParseToNullableInt(), + platform = row["platform"].ParseToNullableString(), + platform_code = row["platform_code"].ParseToNullableString(), + platform_order_no = row["platform_order_no"].ParseToNullableString(), + postage = row["postage"].ParseToNullableInt(), + real_logistics_code = row["real_logistics_code"].ParseToNullableString(), + real_logistics_express_code = row["real_logistics_express_code"].ParseToNullableString(), + receiver_address = row["receiver_address"].ParseToNullableString(), + receiver_area = row["receiver_area"].ParseToNullableString(), + receiver_city = row["receiver_city"].ParseToNullableString(), + receiver_name= row["receiver_name"].ParseToNullableString(), + receiver_phone = row["receiver_phone"].ParseToNullableString(), + receiver_province = row["receiver_province"].ParseToNullableString(), + response_msg = row["response_msg"].ParseToNullableString(), + return_order_status = row["return_order_status"].ParseToNullableInt(), + sender_info = row["sender_info"].ParseToNullableString(), + sender_name = row["sender_name"].ParseToNullableString(), + }; + orderList.Add(order); + } + JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; + var data = JsonUtils.SerializeObjectToString(orderList, jsonSetting); + var seconds = (DateTime.Now - timeCalc).TotalSeconds.ToString("0.000"); + return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + ",\"seconds\":" + seconds + "}"; + } + catch (Exception ex) + { + return "{\"code\":500,\"msg\":\"" + ex.Message + "\",\"data\":[],\"count\":" + 0 + "}"; + } + } + else + { + return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}"; + } + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } } } \ No newline at end of file diff --git a/KJDService/KJD_WebService/KJD_WebService.csproj b/KJDService/KJD_WebService/KJD_WebService.csproj index a7caf23..f29db9d 100644 --- a/KJDService/KJD_WebService/KJD_WebService.csproj +++ b/KJDService/KJD_WebService/KJD_WebService.csproj @@ -135,6 +135,7 @@ + diff --git a/KJDService/KJD_WebService/WXOrderService.asmx.cs b/KJDService/KJD_WebService/WXOrderService.asmx.cs index 382e56f..d9c180d 100644 --- a/KJDService/KJD_WebService/WXOrderService.asmx.cs +++ b/KJDService/KJD_WebService/WXOrderService.asmx.cs @@ -1,6 +1,7 @@ using KJD_Web.BLL; using KJD_Web.BLL.WXXD; using KJD_Web.Utils; +using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.IO; @@ -49,6 +50,93 @@ namespace KJD_Web } } + [WebMethod] + public void repair_miss_direct_order() + { + return; + string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + + //var s = "SELECT order_id,out_order_id FROM `wxxd`.`order_item_ext` WHERE add_time > '2026-08-15 15:30' AND buy_type = '直发'"; + + //var s = "SELECT order_id,out_order_id FROM `wxxd`.`order_item_ext` WHERE add_time > '2026-08-10 15:30' AND add_time < '2026-08-15 15:30' buy_type = '直发'"; + var s = "SELECT order_id,out_order_id FROM `wxxd`.`order_item_ext` WHERE order_id in ('3738460213351447040') AND buy_type = '直发'"; + var dt1 = mySql.ExecuteDataTable(s); + s = "Select order_id FROM erp.oms_wei_order WHERE order_id in ('" + string.Join("','", dt1.Rows.Cast().Select(r => r["order_id"].ParseToLong()))+ "') and out_order_no is null"; + dt1 = mySql.ExecuteDataTable(s); + + mySql.Close(); + + conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + mySql = new MysqlUtils(conn); + string sql = "Select * FROM wxxd.order_pdd_buyer_order WHERE wx_order_id in ('" + string.Join("','", dt1.Rows.Cast().Select(r => r["order_id"].ParseToLong())) + "')"; + var dt = mySql.ExecuteDataTable(sql); + List buyerOrderList = new List(); + mySql.Close(); + if (dt != null) + { + try + { + foreach (System.Data.DataRow row in dt.Rows) + { + Model.WxModel.order_pdd_buyer_order order = new Model.WxModel.order_pdd_buyer_order + { + id = row["id"].ParseToLong(), + add_time = row["add_time"].ParseToString().ParseToDateTime(), + after_sales_status = row["after_sales_status"].ParseToNullableInt(), + buyerId = row["buyerId"].ParseToString(), + buyerName = row["buyerName"].ParseToString(), + mdy_time = row["mdy_time"].ParseToString().ParseToDateTime(), + order_amount = row["order_amount"].ParseToNullableInt(), + order_detail = row["order_detail"].ParseToString(), + order_sn = row["order_sn"].ParseToString(), + order_status_prompt = row["order_status_prompt"].ParseToString(), + order_time = row["order_time"].ParseToNullableLong(), + outExpressCompanyCode = row["outExpressCompanyCode"].ParseToString(), + pre_allocated_order_no = row["pre_allocated_order_no"].ParseToNullableInt(), + tracking_number = row["tracking_number"].ParseToString(), + TransitCreateTime = row["TransitCreateTime"].ParseToString().ParseToDateTime(), + wx_order_id = row["wx_order_id"].ParseToString(), + wx_sku_id = row["wx_sku_id"].ParseToString(), + wx_send_type = row["wx_send_type"].ParseToInt(), + }; + buyerOrderList.Add(order); + } + } + catch (Exception ex) + { + } + } + string err = ""; + + buyerOrderList = buyerOrderList.OrderBy(b => b.add_time).ToList(); + //46 + foreach (var pddOrder in buyerOrderList) + { + Newtonsoft.Json.Linq.JObject obj = new Newtonsoft.Json.Linq.JObject(); + obj["platform"] = "WEISHOP"; + obj["outAmount"] = (pddOrder.order_amount.ParseToDecimal()).ParseToInt() + ""; + obj["outAccount"] = pddOrder.buyerName; + obj["orderId"] = pddOrder.wx_order_id; + obj["outOrderNo"] = pddOrder.order_sn; + //if (!order.outExpressCompanyCode.IsNullOrEmpty() && !order.tracking_number.IsNullOrEmpty()) + //{ + // obj["outExpressCompany"] = order.outExpressCompanyCode; + // obj["outExpressNo"] = order.tracking_number; + //} + var dataStr = JsonUtils.SerializeObject(obj); + var url = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/bind/v2"; + //成功 "0SUCCESS" + //更新微信外采订单状态成功1 + //失败 已存在 1505调用微信接口更新物流信息失败: 非法参数, 同运单号拦截 rid: 69d8ab9c-22baa3b1-67de0d95 + var exportRst = HttpUtils.e57PostResponse(url, dataStr, ""); + if (!exportRst.Contains("1") && !exportRst.Contains("0")) + { + err += "\r\n" + pddOrder.order_sn + " " + exportRst; + } + } + } + [WebMethod] public void get_erp_order_list() { @@ -345,5 +433,18 @@ namespace KJD_Web Context.Response.Write(result); Context.Response.End(); } + + //WXGetErpReturnOrderList + [WebMethod] + public void wx_get_erp_return_order_list() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXOrderManage().WXGetErpReturnOrderList(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } } }