594 lines
22 KiB
C#
594 lines
22 KiB
C#
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;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Services;
|
|
|
|
namespace KJD_Web
|
|
{
|
|
/// <summary>
|
|
/// OrderService 的摘要说明
|
|
/// </summary>
|
|
[WebService(Namespace = "http://tempuri.org/")]
|
|
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
|
[System.ComponentModel.ToolboxItem(false)]
|
|
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
|
// [System.Web.Script.Services.ScriptService]
|
|
public class WXOrderService : System.Web.Services.WebService
|
|
{
|
|
private string GetRequestJsonString()
|
|
{
|
|
Context.Response.ContentType = "text/html;charset=utf-8";
|
|
Context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
|
|
|
|
using (Stream s = HttpContext.Current.Request.InputStream) // 获得json 字符流
|
|
{
|
|
// 还原数据流
|
|
byte[] b = new byte[s.Length];
|
|
s.Read(b, 0, (int)s.Length);
|
|
string jsonText = Encoding.UTF8.GetString(b); // JSON字符串
|
|
if (string.IsNullOrEmpty(jsonText))
|
|
{
|
|
var qs = HttpContext.Current.Request.QueryString;
|
|
if (qs != null && qs.Keys.Count > 0)
|
|
{
|
|
jsonText = "{";
|
|
foreach (var key in qs.Keys)
|
|
{
|
|
jsonText += "\"" + key + "\":" + "\"" + qs[key.ToString()] + "\";";
|
|
}
|
|
jsonText = jsonText.TrimEnd(';') + "}";
|
|
}
|
|
}
|
|
return jsonText;
|
|
}
|
|
}
|
|
|
|
//[WebMethod]
|
|
public void repair_miss_direct_order()
|
|
{
|
|
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-13 15:30' AND 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-12 15:30' And buy_type = '直发'";
|
|
//var s = "SELECT order_id,out_order_id FROM `wxxd`.`order_item_ext` WHERE add_time > '2026-08-08 15:30' AND add_time < '2026-08-10 15:30' And buy_type = '直发'";
|
|
var s = "SELECT order_id,out_order_id FROM `wxxd`.`order_item_ext` WHERE add_time > '2026-7-15 15:30' AND add_time < '2026-08-15 15:30' And 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);
|
|
//out_order_no //out_express_no //out_shipped=0
|
|
//s = " Select order_id FROM erp.oms_wei_order WHERE order_id in ('" + string.Join("','", dt1.Rows.Cast<System.Data.DataRow>().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<System.Data.DataRow>().Select(r => r["order_id"].ParseToLong())) + "') And wx_send_type=1";
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
List<Model.WxModel.order_pdd_buyer_order> buyerOrderList = new List<Model.WxModel.order_pdd_buyer_order>();
|
|
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);
|
|
}
|
|
|
|
foreach (var bo in buyerOrderList.ToList())
|
|
{
|
|
var buyerOrders = buyerOrderList.Where(r => r.wx_order_id == bo.wx_order_id).ToList();
|
|
if (buyerOrders.Count > 1)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
buyerOrderList.Remove(buyerOrders.FirstOrDefault());
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
string err = "";
|
|
|
|
buyerOrderList = buyerOrderList.OrderByDescending(b => b.add_time).ToList();
|
|
|
|
var buyerOrderListTmp = new List<Model.WxModel.order_pdd_buyer_order>();
|
|
foreach(var od in buyerOrderList)
|
|
{
|
|
if (buyerOrderListTmp.Any(o => o.wx_order_id == od.wx_order_id))
|
|
continue;
|
|
buyerOrderListTmp.Add(od);
|
|
}
|
|
buyerOrderList = buyerOrderListTmp;
|
|
|
|
//46
|
|
foreach (var pddOrder in buyerOrderList)
|
|
{
|
|
//if (!pddOrder.outExpressCompanyCode.IsNullOrEmpty() && !pddOrder.tracking_number.IsNullOrEmpty())
|
|
// continue;
|
|
|
|
bool isSend = false;
|
|
var pddOrderSn = "";
|
|
|
|
mySql = new MysqlUtils(conn);
|
|
string sqlStr;
|
|
sqlStr = " Select out_order_no FROM erp.oms_wei_order WHERE order_id in ('" + pddOrder.wx_order_id + "')";
|
|
pddOrderSn = mySql.ExecuteFirst(sqlStr);
|
|
|
|
if (!pddOrder.outExpressCompanyCode.IsNullOrEmpty() && !pddOrder.tracking_number.IsNullOrEmpty())
|
|
{
|
|
sqlStr = " Select status FROM erp.oms_wei_order WHERE order_id in ('" + pddOrder.wx_order_id + "')";
|
|
var status = mySql.ExecuteFirstInt(sqlStr);
|
|
if (status > 20)
|
|
{
|
|
isSend = true;
|
|
//sqlStr = "update `erp`.`oms_wei_order` set out_express_company='" + pddOrder.outExpressCompanyCode + "',out_express_no='" + pddOrder.tracking_number +
|
|
// "' WHERE order_id = '" + pddOrder.wx_order_id + "'";
|
|
}
|
|
|
|
sqlStr = "update `erp`.`oms_wei_order` set out_express_company='" + pddOrder.outExpressCompanyCode + "',out_express_no='" + pddOrder.tracking_number +
|
|
"' WHERE order_id = '" + pddOrder.wx_order_id + "'";
|
|
var rows = mySql.ExecuteAffectedRows(sqlStr);
|
|
}
|
|
mySql.Close();
|
|
if (!mySql.Message.IsNullOrEmpty())
|
|
continue;
|
|
|
|
if (pddOrderSn == pddOrder.order_sn)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
|
|
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 (!isSend && !pddOrder.outExpressCompanyCode.IsNullOrEmpty() && !pddOrder.tracking_number.IsNullOrEmpty())
|
|
{
|
|
obj["outExpressCompany"] = pddOrder.outExpressCompanyCode;
|
|
obj["outExpressNo"] = pddOrder.tracking_number;
|
|
}
|
|
|
|
|
|
var dataStr = JsonUtils.SerializeObject(obj);
|
|
var url = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/bind/v2";
|
|
//成功 "<ResultVo><code>0</code><msg>SUCCESS</msg><data/><totalRecords/></ResultVo>"
|
|
//<AjaxResult><msg>更新微信外采订单状态成功</msg><code>1</code></AjaxResult>
|
|
//失败 已存在 <ResultVo><code>1505</code><msg>调用微信接口更新物流信息失败: 非法参数, 同运单号拦截 rid: 69d8ab9c-22baa3b1-67de0d95</msg><data/><totalRecords/></ResultVo>
|
|
var exportRst = HttpUtils.e57PostResponse(url, dataStr, "");
|
|
if (!exportRst.Contains("<code>1</code>") && !exportRst.Contains("<code>0</code>"))
|
|
{
|
|
err += "\r\n" + pddOrder.order_sn + " " + exportRst;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//[WebMethod]
|
|
public void repair_miss_order_software_remark()
|
|
{
|
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
//var s1 = "SELECT order_id,soft_remark FROM `erp`.`oms_wei_order_bak_2608151610` WHERE create_time > '2026-7-15 15:30' AND create_time < '2026-08-15 15:30' and soft_remark is not null";
|
|
var startTime = TimeUtils.DateTimeToTimestampSeconds("2026-6-25 16:10".ParseToDateTime()).ToString();
|
|
var EndTime = TimeUtils.DateTimeToTimestampSeconds("2026-7-1 16:10".ParseToDateTime()).ToString();
|
|
var s1 = "SELECT order_id,soft_remark FROM `erp`.`oms_wei_order_bak_2608151612` WHERE create_time > " + startTime + " AND create_time < " + EndTime + " and soft_remark is not null";
|
|
var dt = mySql.ExecuteDataTable(s1);
|
|
|
|
mySql.Close();
|
|
|
|
string err = "";
|
|
if (dt != null)
|
|
{
|
|
int id = 0;
|
|
int cnt = 0;
|
|
|
|
var orderStr = "'" + string.Join("','", dt.Rows.Cast<System.Data.DataRow>().Select(rw => rw["order_id"].ParseToString())) + "'";
|
|
var orderStr2 = "'" + string.Join("','", dt.Rows.Cast<System.Data.DataRow>().Select(rw => rw["order_id"].ParseToString() + "|" + rw["soft_remark"].ParseToString())) + "'";
|
|
|
|
foreach (System.Data.DataRow row in dt.Rows)
|
|
{
|
|
id++;
|
|
var orderId = row["order_id"].ParseToString();
|
|
var softwareRemark = row["soft_remark"].ParseToString();
|
|
try
|
|
{
|
|
|
|
mySql = new MysqlUtils(conn);
|
|
string sqlStr;
|
|
sqlStr = "SELECT soft_remark FROM `erp`.`oms_wei_order` WHERE order_id='" + orderId + "'";
|
|
var remark = mySql.ExecuteFirst(sqlStr);
|
|
if (remark.IsNullOrEmpty() && !string.IsNullOrEmpty(softwareRemark))
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
mySql.Close();
|
|
continue;
|
|
}
|
|
|
|
sqlStr = " UPDATE erp.oms_wei_order set soft_remark='" + softwareRemark + "' WHERE order_id='" + orderId + "' AND (soft_remark IS NULL or soft_remark='')";
|
|
var rows = mySql.ExecuteAffectedRows(sqlStr);
|
|
cnt += rows;
|
|
if (!mySql.Message.IsNullOrEmpty())
|
|
{
|
|
err += "\r\n" + orderId + " " + softwareRemark + " " + mySql.Message;
|
|
}
|
|
mySql.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
err += "\r\n" + orderId + " " + softwareRemark + " " + mySql.Message;
|
|
}
|
|
}
|
|
} //30 //59 //6 //5 //1 //1 //1
|
|
}
|
|
|
|
[WebMethod]
|
|
public void get_erp_order_list()
|
|
{
|
|
get_order_list();
|
|
}
|
|
[WebMethod]
|
|
public void get_order_list()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetErpOrderList(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void get_erp_order_item_list()
|
|
{
|
|
get_order_item_list();
|
|
}
|
|
[WebMethod]
|
|
public void get_order_item_list()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetErpOrderItemList(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void get_erp_refund_list()
|
|
{
|
|
get_refund_list();
|
|
}
|
|
[WebMethod]
|
|
public void get_refund_list()
|
|
{
|
|
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetErpRefundList(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_add_mdy_buy_prod_map()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXAddMdyBuyProdMap(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
[WebMethod]
|
|
public void wx_get_buy_prod_map()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetBuyPordMap(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取中转仓订单信息
|
|
/// </summary>
|
|
[WebMethod]
|
|
public void wx_get_transit_order()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetTransitOrder(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改中转仓物流信息
|
|
/// </summary>
|
|
[WebMethod]
|
|
public void wx_update_erp_order_express()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateErpOrderExpress(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
/// <summary>
|
|
/// 修改中转仓取号状态 临时补救
|
|
/// </summary>
|
|
[WebMethod]
|
|
public void wx_update_erp_allocated_order_no()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateErpAllocatedOrderNo(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除中转仓指定订单 临时补救,慎用
|
|
/// </summary>
|
|
[WebMethod]
|
|
public void wx_del_erp_transit_warehouse_order()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXDelErpTransitWarehouseOrder(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_update_erp_soft_remark()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateErpSoftRemark(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_update_erp_color_flag()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateErpColorFlag(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_update_erp_out_after_sale_status()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateErpOutAfterSaleStatus(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_add_mdy_buyer_order()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXAddMdyBuyerOrder(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_get_buyer_order_list()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetBuyerOrderList(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_add_mdy_buyer_after_sale()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXAddMdyBuyerAfterSale(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_get_buyer_after_sale_list()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetBuyerAfterSaleList(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_get_transit_warehouse_aftersale_list()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetTransitWarehouseAfterSaleList(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_update_abnormal_transit_order()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateAbnormalTransitOrder(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_update_transit_order_reject_status()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXUpdateTransitOrderRejectStatus(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_add_order_item_ext_info()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXAddOrderItemExtInfo(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_mdy_order_item_ext_info()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXMdyOrderItemExtInfo(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
|
|
[WebMethod]
|
|
public void wx_get_order_item_ext_info()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().WXGetOrderItemExtInfoList(jsontext);
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
[WebMethod]
|
|
public void wx_get_task_status_list()
|
|
{
|
|
string jsontext = GetRequestJsonString();
|
|
|
|
var result = jsontext;
|
|
result = new WXOrderManage().GetWxTaskStatus(jsontext);
|
|
|
|
Context.Response.Write(result);
|
|
Context.Response.End();
|
|
}
|
|
}
|
|
}
|