diff --git a/KJD_WebService/BLL/WXXD/WXOrderManage.cs b/KJD_WebService/BLL/WXXD/WXOrderManage.cs index c9adcda..690b3ff 100644 --- a/KJD_WebService/BLL/WXXD/WXOrderManage.cs +++ b/KJD_WebService/BLL/WXXD/WXOrderManage.cs @@ -1139,6 +1139,153 @@ namespace KJD_Web.BLL.WXXD return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + /// + /// 中转仓额外包裹 + /// + /// + /// + public string WXGetTransferExtraPackage(string inputData) + { + if (!string.IsNullOrEmpty(inputData)) + { + if (!WXUserManage.GetSign(inputData)) + return "{\"code\":999,\"msg\":\"校验失败\"}"; + + var timeCalc = DateTime.Now; + + var count = -1; + int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt(); + int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200); + string order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_do"))?.Replace("'", "\\'"); + string order_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_code"))?.Replace("'", "\\'"); + string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'"); + if (string.IsNullOrEmpty(order_no) && string.IsNullOrEmpty(order_code)) + return "{\"code\":500,\"msg\":\"中转额外包裹查询信息不能为空\"}"; + + try + { + var oms_wei_external_procurement_log_list = GetTransitOrderTable(page, page_size, order_no, null, null, null, null, not_count, out count); + if (oms_wei_external_procurement_log_list != null) + { + JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; + var data = JsonUtils.SerializeObjectToString(oms_wei_external_procurement_log_list, 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 + "}"; + } + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } + + /// + /// 同步单 + /// + /// + /// + public string WXGetSyncWaybill(string inputData) + { + if (!string.IsNullOrEmpty(inputData)) + { + var timeCalc = DateTime.Now; + + var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt(); + string time1 = RegexUtils.GetStringQuery(ref inputData, "code"); + if (time1 != EncrypUtil.Encryption(time)) + return "{\"code\":50000,\"msg\":\"校验失败\"}"; + + // 买手订单号 + var order_id = RegexUtils.GetStringQuery(ref inputData, "order_id")?.Replace("'", "\\'"); + if (order_id.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") != "false"; + + 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 wxxd.yh_sync_logistics o WHERE 1=1 "; + + string where = ""; + if (!string.IsNullOrWhiteSpace(order_id)) + where += " and o.order_id in ('" + order_id.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" + + " wxxd.yh_sync_logistics o " + + " WHERE 1=1"; + + //where子句 + sql += where; + + if (sort_type == "asc") + sql += " ORDER BY o.id ASC"; + else + sql += " ORDER BY o.id DESC"; + sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size; + dt = mySql.ExecuteDataTable(sql); + } + + mySql.Close(); + if (dt != null) + { + try + { + List yhSyncLogisticsList = new List(); + foreach (DataRow row in dt.Rows) + { + yh_sync_logistics order = new yh_sync_logistics + { + id = row["id"].ParseToLong(), + order_id = row["order_id"].ParseToNullableString(), + create_time = row["create_time"].ParseToNullableString().ParseToDateTimeNullable(), + pickup_code = row["pickup_code"].ParseToNullableString(), + remark = row["remark"].ParseToNullableString(), + source_tracking_number = row["source_tracking_number"].ParseToNullableString(), + tracking_number = row["tracking_number"].ParseToNullableString(), + upload_pickup_status = row["id"].ParseToNullableInt(), + upload_pickup_Time = row["create_time"].ParseToNullableString().ParseToDateTimeNullable(), + }; + yhSyncLogisticsList.Add(order); + } + JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; + var data = JsonUtils.SerializeObjectToString(yhSyncLogisticsList, 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\":\"输入为空\"}"; + } + /// /// 修改订单软件备注 /// @@ -1265,6 +1412,59 @@ namespace KJD_Web.BLL.WXXD return "{\"code\":19999,\"msg\":\"输入为空\"}"; } + public string WXUpdateErpOutWaybillStatus(string inputData) + { + if (!string.IsNullOrEmpty(inputData)) + { + if (!WXUserManage.GetSign(inputData)) + return "{\"code\":999,\"msg\":\"校验失败\"}"; + var timeCalc = DateTime.Now; + + string order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_id"))?.Replace("'", "\\'"); + if (string.IsNullOrEmpty(order_id)) + return "{\"code\":500,\"msg\":\"订单ID不能为空\"}"; + + string out_express_company = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_express_company"))?.Replace("'", "\\'"); + string out_express_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_express_no"))?.Replace("'", "\\'"); + + // 外采是否发货(0 未发货,1 已发货) + string out_shipped = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_shipped"))?.Replace("'", "\\'"); + + string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + + string sql = ""; + var count = -1; + + sql = " update erp.oms_wei_order set "; + if (out_express_company != null) + { + sql += " out_express_company='" + out_express_company + "',"; + } + if (out_express_no != null) + { + sql += " out_express_no='" + out_express_no + "',"; + } + if (out_shipped != null) + { + sql += " out_shipped=" + out_shipped + ","; + } + + sql = sql.TrimEnd(','); + sql += " where order_id='" + order_id + "';"; + + count = mySql.ExecuteAffectedRows(sql); + mySql.Close(); + + if (!string.IsNullOrEmpty(mySql.Message)) + { + return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"affected_rows\":" + count + "}"; + } + return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + count + "}"; + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } + public string WXAddMdyBuyerOrder(string inputData) { if (!string.IsNullOrEmpty(inputData)) @@ -1290,6 +1490,7 @@ namespace KJD_Web.BLL.WXXD string order_status_prompt = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_status_prompt"))?.Replace("'", "\\'"); string after_sales_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "after_sales_status"))?.Replace("'", "\\'"); string order_detail = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_detail"))?.Replace("'", "\\'"); + string sync_logistics_msg = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sync_logistics_msg"))?.Replace("'", "\\'"); //string wx_order_send_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_order_send_type"))?.Replace("'", "\\'"); //if (string.IsNullOrEmpty(wx_order_send_type)) // wx_order_send_type = "1"; @@ -1322,9 +1523,9 @@ namespace KJD_Web.BLL.WXXD if (id == 0) { sql = "INSERT INTO wxxd.order_pdd_buyer_order (wx_order_id,wx_sku_id,wx_send_type,TransitCreateTime,pre_allocated_order_no,buyerId,buyerName,order_sn,order_amount,order_time," + - "outExpressCompanyCode,tracking_number,order_status_prompt,after_sales_status,order_detail)"; + "outExpressCompanyCode,tracking_number,order_status_prompt,after_sales_status,order_detail,sync_logistics_msg)"; sql += "VALUES(@wx_order_id,@wx_sku_id,@wx_send_type,@TransitCreateTime,@pre_allocated_order_no,@buyerId,@buyerName,@pdd_order_sn,@order_amount,@order_time," + - "@outExpressCompanyCode,@tracking_number,@order_status_prompt,@after_sales_status,@order_detail);"; + "@outExpressCompanyCode,@tracking_number,@order_status_prompt,@after_sales_status,@order_detail,@sync_logistics_msg);"; } else { @@ -1357,6 +1558,8 @@ namespace KJD_Web.BLL.WXXD sql += " after_sales_status=@after_sales_status,"; if (!string.IsNullOrEmpty(order_detail)) sql += " order_detail=@order_detail,"; + if (!string.IsNullOrEmpty(sync_logistics_msg)) + sql += " sync_logistics_msg=@sync_logistics_msg,"; sql = sql.TrimEnd(','); sql += " where order_sn=@pdd_order_sn"; } @@ -1379,6 +1582,7 @@ namespace KJD_Web.BLL.WXXD paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "order_status_prompt", Value = order_status_prompt, }); paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "after_sales_status", Value = after_sales_status.ParseToInt(), }); paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "order_detail", Value = order_detail, }); + paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "sync_logistics_msg", Value = sync_logistics_msg, }); //sql = " update `wxxd`.`order_pdd_buyer_order` set "; //if (!string.IsNullOrEmpty(soft_remark)) // sql += " soft_remark=" + soft_remark + ","; @@ -1483,6 +1687,7 @@ namespace KJD_Web.BLL.WXXD wx_order_id = row["wx_order_id"].ParseToString(), wx_sku_id = row["wx_sku_id"].ParseToString(), wx_send_type = row["wx_send_type"].ParseToInt(), + sync_logistics_msg = row["sync_logistics_msg"].ParseToString(), }; buyerOrderList.Add(order); } diff --git a/KJD_WebService/Controllers/WX/WXOrderController.cs b/KJD_WebService/Controllers/WX/WXOrderController.cs index 71d697a..203acbd 100644 --- a/KJD_WebService/Controllers/WX/WXOrderController.cs +++ b/KJD_WebService/Controllers/WX/WXOrderController.cs @@ -156,6 +156,20 @@ namespace KJD_Web.Controllers.WX return JsonString(result); } + /// + /// 查询同步单列表 + /// + /// + public IHttpActionResult wx_get_sync_waybill() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXOrderManage().WXGetSyncWaybill(jsontext); + + return JsonString(result); + } + public IHttpActionResult wx_update_erp_soft_remark() { string jsontext = GetRequestJsonString(); @@ -185,6 +199,15 @@ namespace KJD_Web.Controllers.WX return JsonString(result); } + public IHttpActionResult wx_update_erp_out_waybill_status() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXOrderManage().WXUpdateErpOutWaybillStatus(jsontext); + + return JsonString(result); + } public IHttpActionResult wx_add_mdy_buyer_order() { diff --git a/KJD_WebService/KJD_WebService.csproj b/KJD_WebService/KJD_WebService.csproj index b481898..5286328 100644 --- a/KJD_WebService/KJD_WebService.csproj +++ b/KJD_WebService/KJD_WebService.csproj @@ -215,6 +215,7 @@ + diff --git a/KJD_WebService/Model/WxModel/order_pdd_buyer_order.cs b/KJD_WebService/Model/WxModel/order_pdd_buyer_order.cs index 5633509..c325db7 100644 --- a/KJD_WebService/Model/WxModel/order_pdd_buyer_order.cs +++ b/KJD_WebService/Model/WxModel/order_pdd_buyer_order.cs @@ -31,5 +31,6 @@ namespace KJD_Web.Model.WxModel public string order_detail { get; set; } public DateTime add_time { get; set; } public DateTime mdy_time { get; set; } - } + public string sync_logistics_msg { get; internal set; } + } } \ No newline at end of file