Files
KJD/KJDService/KJD_WebService/BLL/WXXD/WXOrderManage.cs
T

1295 lines
75 KiB
C#

using KJD_Web.Model.WxModel;
using KJD_Web.Utils;
using MySql.Data.MySqlClient;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
namespace KJD_Web.BLL.WXXD
{
public class WXOrderManage
{
public string WXGetErpOrderList(string inputData, bool isDetail = false)
{
if (!string.IsNullOrEmpty(inputData))
{
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 erp_shop_id_in = RegexUtils.GetStringQuery(ref inputData, "erp_shop_id_in")?.Replace("'", "\\'");
var erp_order_id_in = RegexUtils.GetStringQuery(ref inputData, "erp_order_id_in")?.Replace("'", "\\'");
if (erp_shop_id_in.IsNullOrEmpty() && erp_order_id_in.IsNullOrEmpty())
{
return "{\"code\":500,\"msg\":\"未指定店铺和订单\"}";
}
var query_status = RegexUtils.GetStringQuery(ref inputData, "query_status")?.Replace("'", "\\'");
var purchase_status = RegexUtils.GetStringQuery(ref inputData, "purchase_status")?.Replace("'", "\\'");
var sort_type = RegexUtils.GetStringQuery(ref inputData, "sort_type")?.Replace("'", "\\'");
var start_time = RegexUtils.GetStringQuery(ref inputData, "start_time").ParseToInt();
var end_time = RegexUtils.GetStringQuery(ref inputData, "end_time").ParseToInt();
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(50);
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT COUNT(id) FROM erp.oms_wei_order o WHERE 1=1 ";
string where = "";
if (!string.IsNullOrWhiteSpace(erp_shop_id_in))
where += " and o.shop_id in (" + erp_shop_id_in + ")";
if (!string.IsNullOrWhiteSpace(erp_order_id_in))
where += " and o.order_id in ('" + erp_order_id_in.Replace(",", "','") + "')";
if (!string.IsNullOrWhiteSpace(query_status))
where += " and o.status = " + query_status;
if (!string.IsNullOrWhiteSpace(purchase_status))
where += " and o.purchase_status = " + purchase_status;
if (start_time > 0)
where += " and o.create_time >= " + start_time;
if (end_time > 0)
where += " and o.create_time <= " + end_time;
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.oms_wei_order o " +
" WHERE 1=1";
//where子句
sql += where;
if (sort_type == "asc")
//sql += " ORDER BY o.create_time ASC, o.id desc";
sql += " ORDER BY o.create_time ASC";
else
sql += " ORDER BY o.create_time DESC";
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<oms_wei_order> orderList = new List<oms_wei_order>();
foreach (DataRow row in dt.Rows)
{
oms_wei_order order = new oms_wei_order
{
id = row["id"].ParseToLong(),
aftersale_detail = row["aftersale_detail"].ParseToString(),
audit_status = row["audit_status"].ParseToNullableInt(),
audit_time = row["audit_time"].ParseToString().ParseToDateTime(),
city_name = row["city_name"].ParseToString(),
colour_flag = row["colour_flag"].ParseToNullableInt(),
colour_flag_update_time = row["colour_flag_update_time"].ParseToString().ParseToDateTime(),
commission_amount = row["commission_amount"].ParseToNullableInt(),
county_name = row["county_name"].ParseToString(),
create_time = row["create_time"].ParseToInt(),
delivery_deadline = row["delivery_deadline"].ParseToNullableInt(),
delivery_product_info = row["delivery_product_info"].ParseToString(),
delivery_time = row["delivery_time"].ParseToNullableInt(),
detail_info = row["detail_info"].ParseToString(),
discounted_price = row["discounted_price"].ParseToNullableInt(),
erp_send_code = row["erp_send_code"].ParseToString(),
erp_send_company = row["erp_send_company"].ParseToString(),
erp_send_status = row["erp_send_status"].ParseToNullableInt(),
erp_send_time = row["erp_send_time"].ParseToString().ParseToDateTime(),
ewaybill_order_code = row["ewaybill_order_code"].ParseToString(),
external_gift = row["external_gift"].ParseToNullableInt(),
ext_info = row["ext_info"].ParseToString(),
freight = row["freight"].ParseToNullableInt(),
freight_insurance_amount = row["freight_insurance_amount"].ParseToNullableInt(),
gift_order_status = row["gift_order_status"].ParseToNullableInt(),
hash_code = row["hash_code"].ParseToString(),
has_freight_insurance = row["has_freight_insurance"].ParseToNullableInt(),
house_number = row["house_number"].ParseToString(),
is_express_no_used = row["is_express_no_used"].ParseToNullableInt(),
is_shipment_optimized = row["is_shipment_optimized"].ParseToNullableInt(),
merchant_id = row["merchant_id"].ParseToLong(),
openid = row["openid"].ParseToString(),
order_id = row["order_id"].ParseToString(),
order_price = row["order_price"].ParseToNullableInt(),
out_account = row["out_account"].ParseToString(),
out_after_sale_status = row["out_after_sale_status"].ParseToString(),
out_amount = row["out_amount"].ParseToNullableInt(),
out_express_company = row["out_express_company"].ParseToString(),
out_express_no = row["out_express_no"].ParseToString(),
out_order_no = row["out_order_no"].ParseToString(),
out_shipped = row["out_shipped"].ParseToNullableInt(),
pay_info = row["pay_info"].ParseToString(),
postal_code = row["postal_code"].ParseToString(),
predict_commission_fee = row["predict_commission_fee"].ParseToNullableInt(),
product_price = row["product_price"].ParseToNullableInt(),
profit = row["profit"].ParseToNullableInt(),
province_name = row["province_name"].ParseToString(),
purchase_price = row["purchase_price"].ParseToNullableInt(),
purchase_status = row["purchase_status"].ParseToNullableInt(),
purchase_time = row["purchase_time"].ParseToNullableInt(),
settle_info = row["settle_info"].ParseToString(),
ship_done_time = row["ship_done_time"].ParseToNullableInt(),
shop_id = row["shop_id"].ParseToLong(),
shop_name = row["shop_name"].ParseToString(),
shop_remark = row["shop_remark"].ParseToString(),
soft_remark = row["soft_remark"].ParseToString(),
status = row["status"].ParseToNullableInt(),
supplier_remark_exception = row["supplier_remark_exception"].ParseToString(),
tel_number = row["tel_number"].ParseToString(),
tel_number_ext_info = row["tel_number_ext_info"].ParseToString(),
transfer_warehouse_status = row["transfer_warehouse_status"].ParseToNullableInt(),
unionid = row["unionid"].ParseToString(),
update_time = row["update_time"].ParseToInt(),
user_name = row["user_name"].ParseToString(),
use_tel_number = row["use_tel_number"].ParseToNullableInt(),
virtual_order_tel_number = row["virtual_order_tel_number"].ParseToString(),
};
orderList.Add(order);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(orderList, jsonSetting);
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
}
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\":\"输入为空\"}";
}
public string WXGetErpOrderItemList(string inputData, bool isDetail = false)
{
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 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") != "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 erp.oms_wei_order_item o WHERE 1=1 ";
string where = "";
if (!string.IsNullOrWhiteSpace(erp_order_id_in))
where += " and o.order_id 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.oms_wei_order_item 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<oms_wei_order_item> orderItemList = new List<oms_wei_order_item>();
foreach (DataRow row in dt.Rows)
{
oms_wei_order_item order = new oms_wei_order_item
{
id = row["id"].ParseToLong(),
commission_amount = row["commission_amount"].ParseToNullableInt(),
freight = row["freight"].ParseToNullableInt(),
merchant_id = row["merchant_id"].ParseToLong(),
order_id = row["order_id"].ParseToString(),
predict_commission_fee = row["predict_commission_fee"].ParseToNullableInt(),
purchase_price = row["purchase_price"].ParseToNullableInt(),
shop_id = row["shop_id"].ParseToLong(),
cash_coupon_discounted_price = row["cash_coupon_discounted_price"].ParseToNullableInt(),
change_price = row["change_price"].ParseToNullableInt(),
deduction_price = row["deduction_price"].ParseToNullableInt(),
erp_goods_id = row["erp_goods_id"].ParseToNullableLong(),
erp_goods_sku_id = row["erp_goods_sku_id"].ParseToNullableLong(),
estimate_price = row["estimate_price"].ParseToNullableInt(),
extra_service = row["extra_service"].ParseToString(),
finish_aftersale_sku_cnt = row["finish_aftersale_sku_cnt"].ParseToNullableInt(),
is_change_price = row["is_change_price"].ParseToString(),
is_discounted = row["is_discounted"].ParseToString(),
market_price = row["market_price"].ParseToNullableInt(),
on_aftersale_sku_cnt = row["on_aftersale_sku_cnt"].ParseToNullableInt(),
order_product_coupon_info_list = row["order_product_coupon_info_list"].ParseToString(),
out_product_id = row["out_product_id"].ParseToString(),
out_sku_id = row["out_sku_id"].ParseToString(),
out_warehouse_id = row["out_warehouse_id"].ParseToString(),
product_id = row["product_id"].ParseToString(),
real_price = row["real_price"].ParseToNullableInt(),
refund_status = row["refund_status"].ParseToNullableInt(),
return_address = row["return_address"].ParseToString(),
sale_price = row["sale_price"].ParseToNullableInt(),
sku_attrs = row["sku_attrs"].ParseToString(),
sku_cnt = row["sku_cnt"].ParseToNullableInt(),
sku_code = row["sku_code"].ParseToString(),
sku_deliver_info = row["sku_deliver_info"].ParseToString(),
sku_id = row["sku_id"].ParseToString(),
thumb_img = row["thumb_img"].ParseToString(),
title = row["title"].ParseToString(),
use_deduction = row["use_deduction"].ParseToString(),
};
orderItemList.Add(order);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(orderItemList, 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\":\"输入为空\"}";
}
public string WXGetErpRefundList(string inputData, bool isDetail = false)
{
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 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") != "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 erp.oms_wei_refund o WHERE 1=1 ";
string where = "";
if (!string.IsNullOrWhiteSpace(erp_order_id_in))
where += " and o.order_id 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.oms_wei_refund 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<oms_wei_refund> refundItemList = new List<oms_wei_refund>();
foreach (DataRow row in dt.Rows)
{
oms_wei_refund order = new oms_wei_refund
{
id = row["id"].ParseToLong(),
merchant_id = row["merchant_id"].ParseToLong(),
order_id = row["order_id"].ParseToString(),
shop_id = row["shop_id"].ParseToLong(),
erp_goods_id = row["erp_goods_id"].ParseToNullableLong(),
erp_goods_sku_id = row["erp_goods_sku_id"].ParseToNullableLong(),
product_id = row["product_id"].ParseToString(),
sku_id = row["sku_id"].ParseToString(),
after_sale_order_id = row["after_sale_order_id"].ParseToString(),
complaint_id = row["complaint_id"].ParseToString(),
count = row["count"].ParseToNullableInt(),
create_time = row["create_time"].ParseToNullableInt(),
details = row["details"].ParseToString(),
fast_refund = row["fast_refund"].ParseToString(),
merchant_upload_info = row["merchant_upload_info"].ParseToString(),
openid = row["openid"].ParseToString(),
pull_status = row["pull_status"].ParseToNullableInt(),
pull_time = row["pull_time"].ParseToString().ParseToDateTime(),
reason = row["reason"].ParseToString(),
reason_text = row["reason_text"].ParseToString(),
refund_amount = row["refund_amount"].ParseToNullableInt(),
refund_reason = row["refund_reason"].ParseToNullableInt(),
refund_resp = row["refund_resp"].ParseToString(),
return_delivery_id = row["return_delivery_id"].ParseToString(),
return_delivery_name = row["return_delivery_name"].ParseToString(),
return_waybill_id = row["return_waybill_id"].ParseToString(),
status = row["status"].ParseToString(),
type = row["type"].ParseToString(),
unionid = row["unionid"].ParseToString(),
update_time = row["update_time"].ParseToNullableInt(),
warehouse_status = row["warehouse_status"].ParseToNullableInt(),
};
refundItemList.Add(order);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(refundItemList, 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\":\"输入为空\"}";
}
/// <summary>
/// 微信添加修改采购映射商品(含sku映射和)
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXAddMdyBuyProdMap(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
// 软件用户名
string spu_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_code"))?.Replace("'", "\\'");
string sku_code = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_code"))?.Replace("'", "\\'");
string user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_user_name"))?.Replace("'", "\\'");
string map_url = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_url"))?.Replace("'", "\\'");
string map_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_goods_name"))?.Replace("'", "\\'");
string map_spec_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "map_spec_name"))?.Replace("'", "\\'");
string map_goods_id = RegexUtils.GetStringQuery(ref inputData, "map_goods_id")?.Replace("'", "\\'");
string map_sku_id = RegexUtils.GetStringQuery(ref inputData, "map_sku_id")?.Replace("'", "\\'");
string map_send_address = RegexUtils.GetStringQuery(ref inputData, "map_send_address")?.Replace("'", "\\'");
string transit_warehouse_id = RegexUtils.GetStringQuery(ref inputData, "transit_warehouse_id")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(spu_code) || string.IsNullOrEmpty(sku_code))
return "{\"code\":500,\"msg\":\"缺少系统商品或SKU编号\"}";
if (string.IsNullOrEmpty(user_name))
return "{\"code\":500,\"msg\":\"缺少用户名\"}";
if (string.IsNullOrEmpty(map_url) && (string.IsNullOrEmpty(map_goods_id) || string.IsNullOrEmpty(map_sku_id)))
return "{\"code\":500,\"msg\":\"缺少采购商品信息\"}";
if (string.IsNullOrEmpty(transit_warehouse_id))
return "{\"code\":500,\"msg\":\"缺少中转仓信息\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT 1 FROM `bxx`.`product_buy_map` where user_name='" + user_name + "' AND spu_code='" + spu_code + "' AND sku_code='" + sku_code + "'";
string where = "";
sql += where;
var exist = mySql.ExecuteFirstInt(sql);
if (!mySql.Message.IsNullOrEmpty())
{
mySql.Close();
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
}
if (exist == 0)
{
sql = " INSERT INTO `bxx`.`product_buy_map` (user_name,spu_code,sku_code,map_url,map_goods_name,map_spec_name,map_goods_id,map_sku_id,map_send_address,transit_warehouse_id)" +
" VALUES (@user_name,@spu_code,@sku_code,@map_url,@map_goods_name,@map_spec_name,@map_goods_id,@map_sku_id,@map_send_address,@transit_warehouse_id);";
}
else
{
sql = "UPDATE `bxx`.`product_buy_map` SET ";
if (map_url != null)
sql += " map_url=@map_url,";
if (map_goods_name != null)
sql += " map_goods_name=@map_goods_name,";
if (map_spec_name != null)
sql += " map_spec_name=@map_spec_name,";
if (map_goods_id != null)
sql += " map_goods_id=@map_goods_id,";
if (map_sku_id != null)
sql += " map_sku_id=@map_sku_id,";
if (map_send_address != null)
sql += " map_send_address=@map_send_address,";
if (transit_warehouse_id != null)
sql += " transit_warehouse_id=@transit_warehouse_id,";
sql = sql.TrimEnd(',');
sql += " WHERE user_name=@user_name and spu_code=@spu_code and sku_code=@sku_code;";
}
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "user_name", Value = user_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "spu_code", Value = spu_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "sku_code", Value = sku_code, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_url", Value = map_url, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_goods_name", Value = map_goods_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_spec_name", Value = map_spec_name, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_goods_id", Value = map_goods_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_sku_id", Value = map_sku_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "map_send_address", Value = map_send_address, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "transit_warehouse_id", Value = transit_warehouse_id, });
mySql.ExecuteNonQuery(sql, paramLst.ToArray());
mySql.Close();
if (string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":200,\"msg\":\"success\",\"data\":\"\"}";
}
else
{
return "{\"code\":50003,\"msg\":\"" + mySql.Message + "\",\"data\":\"\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
/// <summary>
/// 微信获取采购映射商品
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXGetBuyPordMap(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
string spu_codes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "spu_codes"))?.Replace("'", "\\'");
string sku_codes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sku_codes"))?.Replace("'", "\\'");
string user_name = RegexUtils.GetStringQuery(ref inputData, "main_user_name")?.Replace("'", "\\'");
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(spu_codes))
return "{\"code\":500,\"msg\":\"商品编码不能为空\"}";
if (string.IsNullOrEmpty(user_name))
return "{\"code\":500,\"msg\":\"用户名不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = "SELECT COUNT(*) FROM `bxx`.`product_buy_map` WHERE 1=1";
string where = "";
if (spu_codes != null)
where += " and spu_code IN ('" + spu_codes.Replace(",", "','") + "')";
if (sku_codes != null)
where += " and sku_code IN ('" + sku_codes.Replace(",", "','") + "')";
if (user_name != null)
where += " and user_name='" + user_name + "'";
sql += where;
sql += ";";
if (not_count == "false")
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT * FROM `bxx`.`product_buy_map` WHERE 1=1";
sql += where;
sql += " order by id desc limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<WXBuyMapInfo> WXBuyMapInfoLst = new List<WXBuyMapInfo>();
foreach (DataRow row in dt.Rows)
{
WXBuyMapInfoLst.Add(new WXBuyMapInfo()
{
id = row["id"].ParseToInt(),
user_name = row["user_name"].ParseToString(),
spu_code = row["spu_code"].ParseToString(),
sku_code = row["sku_code"].ParseToString(),
map_url = row["map_url"].ParseToString(),
map_goods_name = row["map_goods_name"].ParseToString(),
map_spec_name = row["map_spec_name"].ParseToString(),
map_goods_id = row["map_goods_id"].ParseToString(),
map_sku_id = row["map_sku_id"].ParseToString(),
map_send_address = row["map_send_address"].ParseToString(),
transit_warehouse_id = row["transit_warehouse_id"].ParseToString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WXBuyMapInfoLst, 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\":\"输入为空\"}";
}
/// <summary>
/// 获取中转仓订单信息
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXGetTransitOrder(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
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_no"))?.Replace("'", "\\'");
string order_sku_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_sku_id"))?.Replace("'", "\\'");
string out_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_order_no"))?.Replace("'", "\\'");
string pre_allocated_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pre_allocated_order_no"))?.Replace("'", "\\'");
string transfer_warehouse_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "transfer_warehouse_status"))?.Replace("'", "\\'");
string not_count = RegexUtils.GetStringQuery(ref inputData, "not_count")?.Replace("'", "\\'");
string is_admin = RegexUtils.GetStringQuery(ref inputData, "is_admin")?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_no) && string.IsNullOrEmpty(out_order_no) && string.IsNullOrEmpty(order_sku_id) && is_admin != "true")
return "{\"code\":500,\"msg\":\"中转订单查询信息不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = "SELECT COUNT(*) FROM `erp`.`oms_wei_external_procurement_log` WHERE 1=1";
string where = "";
if (order_no != null)
where += " and order_no IN ('" + order_no.Replace(",", "','") + "')";
if (order_sku_id != null)
where += " and order_sku_id IN ('" + order_sku_id.Replace(",", "','") + "')";
if (out_order_no != null)
where += " and out_order_no IN ('" + out_order_no.Replace(",", "','") + "')";
// 取号状态
if (pre_allocated_order_no != null)
where += " and pre_allocated_order_no IN (" + pre_allocated_order_no + ")";
// 仓库状态
if (transfer_warehouse_status != null)
where += " and transfer_warehouse_status IN (" + transfer_warehouse_status + ")";
sql += where;
sql += ";";
if (not_count == "false")
count = mySql.ExecuteRowCount(sql);
DataTable dt;
if (count == 0)
{
dt = new DataTable();
}
else
{
sql = "SELECT * FROM `erp`.`oms_wei_external_procurement_log` WHERE 1=1";
sql += where;
sql += " order by id desc limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
// 客戶端查兩次
//if (is_admin == "true")
//{
// sql = "SELECT e.*,o.create_time as order_create_time FROM `erp`.`oms_wei_external_procurement_log` e LEFT JOIN `erp`.`oms_wei_order` ON e.order_no = o.order_id WHERE 1=1";
// sql += where;
// sql += " order by id desc limit " + Math.Max(0, page - 1) * page_size + "," + page_size + ";";
//}
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
if (dt != null)
{
try
{
List<oms_wei_external_procurement_log> oms_wei_external_procurement_log_list = new List<oms_wei_external_procurement_log>();
foreach (DataRow row in dt.Rows)
{
oms_wei_external_procurement_log_list.Add(new oms_wei_external_procurement_log()
{
id = row["id"].ParseToInt(),
buyer_account = row["buyer_account"].ParseToString(),
order_no = row["order_no"].ParseToString(),
order_sku_id = row["order_sku_id"].ParseToString(),
out_amount = row["out_amount"].ParseToNullableInt(),
out_order_no = row["out_order_no"].ParseToString(),
purchaser_note = row["purchaser_note"].ParseToString(),
created_time = row["created_time"].ParseToString().ParseToDateTime(),
express_1_company = row["express_1_company"].ParseToString(),
express_1_waybill = row["express_1_waybill"].ParseToString(),
express_2_company = row["express_2_company"].ParseToString(),
express_2_waybill = row["express_2_waybill"].ParseToString(),
order_code = row["order_code"].ParseToString(),
order_platform_code = row["order_platform_code"].ParseToString(),
pickup_time = row["pickup_time"].ParseToString().ParseToDateTime(),
platform = row["platform"].ParseToString(),
pre_allocated_order_no = row["pre_allocated_order_no"].ParseToNullableInt(),
raw_message = row["raw_message"].ParseToString(),
refund_status = row["refund_status"].ParseToString(),
transfer_warehouse_status = row["transfer_warehouse_status"].ParseToNullableInt(),
updated_time = row["updated_time"].ParseToString().ParseToDateTime(),
is_transfer_ship = row["is_transfer_ship"].ParseToNullableInt(),
random_code = row["random_code"].ParseToString(),
transfer_refund_status = row["transfer_refund_status"].ParseToNullableInt(),
order_void_status = row["order_void_status"].ParseToNullableInt(),
warehouse_status = row["warehouse_status"].ParseToNullableInt(),
inbound_time = row["inbound_time"].ParseToString().ParseToDateTimeNullable(),
outbound_time = row["outbound_time"].ParseToString().ParseToDateTimeNullable(),
});
}
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 + "}";
}
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"data\":[],\"count\":" + 0 + "}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
/// <summary>
/// 修改中转仓订单信息(真实物流),临时补救
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXUpdateErpOrderExpress(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
string out_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_order_no"))?.Replace("'", "\\'");
string express_1_company = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "express_1_company"))?.Replace("'", "\\'");
string express_1_waybill = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "express_1_waybil"))?.Replace("'", "\\'");
string refund_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "refund_status"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(out_order_no))
return "{\"code\":500,\"msg\":\"订单外部ID信息不能为空\"}";
//if (string.IsNullOrEmpty(express_1_company))
// return "{\"code\":500,\"msg\":\"物流公司不能为空\"}";
//if (string.IsNullOrEmpty(express_1_waybill))
// return "{\"code\":500,\"msg\":\"物流单号不能为空\"}";
if (string.IsNullOrEmpty(express_1_company) && string.IsNullOrEmpty(express_1_waybill) && string.IsNullOrEmpty(refund_status))
return "{\"code\":500,\"msg\":\"修改信息不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = " update `erp`.`oms_wei_external_procurement_log` set ";
if (!string.IsNullOrEmpty(express_1_company))
sql += " express_1_company='" + express_1_company + "',";
if (!string.IsNullOrEmpty(express_1_waybill))
sql += " express_1_waybill='" + express_1_waybill + "',";
if (!string.IsNullOrEmpty(refund_status))
sql += " refund_status='" + refund_status + "',";
sql = sql.TrimEnd(',');
sql += " where out_order_no = '" + out_order_no + "';";
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\":\"输入为空\"}";
}
/// <summary>
/// 修改中转仓订单信息(取号状态),临时补救
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXUpdateErpAllocatedOrderNo(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(200);
string out_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_order_no"))?.Replace("'", "\\'");
string pre_allocated_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pre_allocated_order_no"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(out_order_no))
return "{\"code\":500,\"msg\":\"订单外部ID信息不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = " update `erp`.`oms_wei_external_procurement_log` set ";
if (!string.IsNullOrEmpty(pre_allocated_order_no))
sql += " pre_allocated_order_no=" + pre_allocated_order_no + ",";
sql = sql.TrimEnd(',');
sql += " where out_order_no = '" + out_order_no + "';";
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\":\"输入为空\"}";
}
/// <summary>
/// 删除中转仓订单 临时补救,慎用
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXDelErpTransitWarehouseOrder(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
string out_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "out_order_no"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(out_order_no))
return "{\"code\":500,\"msg\":\"订单外部ID信息不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = " DELETE FROM `erp`.`oms_wei_external_procurement_log` WHERE out_order_no in ('" + out_order_no.Replace(",", "','") + "')";
count = mySql.ExecuteAffectedRows(sql);
mySql.Close();
if (!string.IsNullOrEmpty(mySql.Message))
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\",\"affected_rows\":" + count + "}";
}
if (count == 0)
{
return "{\"code\":500,\"msg\":\"删除失败,订单不存在\",\"affected_rows\":" + count + "}";
}
return "{\"code\":200,\"msg\":\"success\",\"affected_rows\":" + count + "}";
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
}
/// <summary>
/// 修改订单软件备注
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public string WXUpdateErpSoftRemark(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("'", "\\'");
string soft_remark = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "soft_remark"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(order_id))
return "{\"code\":500,\"msg\":\"订单ID不能为空\"}";
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 (soft_remark != null)
sql += " soft_remark='" + soft_remark + "',";
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))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
string wx_order_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_order_id"))?.Replace("'", "\\'");
string wx_sku_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_sku_id"))?.Replace("'", "\\'");
string TransitCreateTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "TransitCreateTime"))?.Replace("'", "\\'");
string pre_allocated_order_no = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pre_allocated_order_no"))?.Replace("'", "\\'");
string buyerId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "buyerId"))?.Replace("'", "\\'");
string buyerName = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "buyerName"))?.Replace("'", "\\'");
string pdd_order_sn = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "pdd_order_sn"))?.Replace("'", "\\'");
string order_amount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_amount"))?.Replace("'", "\\'");
string order_time = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_time"))?.Replace("'", "\\'");
string outExpressCompanyCode = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "outExpressCompanyCode"))?.Replace("'", "\\'");
string tracking_number = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "tracking_number"))?.Replace("'", "\\'");
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("'", "\\'");
if (string.IsNullOrEmpty(wx_order_id) || string.IsNullOrEmpty(pdd_order_sn))
return "{\"code\":500,\"msg\":\"订单ID不能为空\"}";
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
var count = -1;
sql = "select id from wxxd.order_pdd_buyer_order where order_sn='" + pdd_order_sn + "'";
var id = mySql.ExecuteFirstInt(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.Close();
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
//sql = "INSERT INTO wxxd.order_pdd_buyer_order (wx_order_id,wx_sku_id,TransitCreateTime,pre_allocated_order_no,buyerId,buyerName,order_sn,order_amount,order_time," +
// "outExpressCompanyCode,tracking_number,order_status_prompt,after_sales_status,order_detail)";
//sql += "VALUES(@wx_order_id,@wx_sku_id,@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)";
//sql += " ON DUPLICATE KEY UPDATE wx_order_id=VALUES(@wx_order_id),wx_sku_id=VALUES(@wx_sku_id),TransitCreateTime=VALUES(@TransitCreateTime)," +
// "pre_allocated_order_no=VALUES(@pre_allocated_order_no),buyerId=VALUES(@buyerId),buyerName=VALUES(@buyerName),order_amount=VALUES(@order_amount)," +
// "order_time=VALUES(@order_time),outExpressCompanyCode=VALUES(@outExpressCompanyCode),tracking_number=VALUES(@tracking_number),order_status_prompt=VALUES(@order_status_prompt)," +
// "after_sales_status=VALUES(@after_sales_status),order_detail=VALUES(@order_detail)";
if (id == 0)
{
sql = "INSERT INTO wxxd.order_pdd_buyer_order (wx_order_id,wx_sku_id,TransitCreateTime,pre_allocated_order_no,buyerId,buyerName,order_sn,order_amount,order_time," +
"outExpressCompanyCode,tracking_number,order_status_prompt,after_sales_status,order_detail)";
sql += "VALUES(@wx_order_id,@wx_sku_id,@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);";
}
else
{
sql = "UPDATE wxxd.order_pdd_buyer_order SET ";
if (!string.IsNullOrEmpty(wx_order_id))
sql += " wx_order_id=@wx_order_id,";
if (!string.IsNullOrEmpty(wx_sku_id))
sql += " wx_sku_id=@wx_sku_id,";
if (!string.IsNullOrEmpty(TransitCreateTime))
sql += " TransitCreateTime=@TransitCreateTime,";
if (!string.IsNullOrEmpty(pre_allocated_order_no))
sql += " pre_allocated_order_no=@pre_allocated_order_no,";
if (!string.IsNullOrEmpty(buyerId))
sql += " buyerId=@buyerId,";
if (!string.IsNullOrEmpty(buyerName))
sql += " buyerName=@buyerName,";
if (!string.IsNullOrEmpty(order_amount))
sql += " order_amount=@order_amount,";
if (!string.IsNullOrEmpty(order_time))
sql += " order_time=@order_time,";
if (!string.IsNullOrEmpty(outExpressCompanyCode))
sql += " outExpressCompanyCode=@outExpressCompanyCode,";
if (!string.IsNullOrEmpty(tracking_number))
sql += " tracking_number=@tracking_number,";
if (!string.IsNullOrEmpty(order_status_prompt))
sql += " order_status_prompt=@order_status_prompt,";
if (!string.IsNullOrEmpty(after_sales_status))
sql += " after_sales_status=@after_sales_status,";
if (!string.IsNullOrEmpty(order_detail))
sql += " order_detail=@order_detail,";
sql = sql.TrimEnd(',');
sql += " where order_sn=@pdd_order_sn";
}
//260705-105706954352823
List<MySqlParameter> paramLst = new List<MySqlParameter>();
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "wx_order_id", Value = wx_order_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "wx_sku_id", Value = wx_sku_id, });
paramLst.Add(new MySqlParameter() { DbType = DbType.DateTime, ParameterName = "TransitCreateTime", Value = TransitCreateTime.ParseToDateTime(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "pre_allocated_order_no", Value = pre_allocated_order_no.ParseToInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "buyerId", Value = buyerId, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "buyerName", Value = buyerName, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "pdd_order_sn", Value = pdd_order_sn, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "order_amount", Value = order_amount, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int64, ParameterName = "order_time", Value = order_time.ParseToLong(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "outExpressCompanyCode", Value = outExpressCompanyCode, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "tracking_number", Value = tracking_number, });
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, });
//sql = " update `wxxd`.`order_pdd_buyer_order` set ";
//if (!string.IsNullOrEmpty(soft_remark))
// sql += " soft_remark=" + soft_remark + ",";
//sql = sql.TrimEnd(',');
//sql += " where order_id = '" + wx_order_id + "';";
count = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
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 WXGetBuyerOrderList(string inputData, bool isDetail = false)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
var wx_order_id_in = RegexUtils.GetStringQuery(ref inputData, "wx_order_id_in")?.Replace("'", "\\'");
var buyer_order_sn_in = RegexUtils.GetStringQuery(ref inputData, "buyer_order_sn_in")?.Replace("'", "\\'");
if (wx_order_id_in.IsNullOrEmpty() && string.IsNullOrEmpty(buyer_order_sn_in))
{
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.order_pdd_buyer_order o WHERE 1=1 ";
string where = "";
if (!string.IsNullOrWhiteSpace(wx_order_id_in))
where += " and o.wx_order_id in ('" + wx_order_id_in.Replace(",", "','") + "')";
if (!string.IsNullOrWhiteSpace(buyer_order_sn_in))
where += " and o.order_sn in ('" + buyer_order_sn_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" +
" wxxd.order_pdd_buyer_order 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<order_pdd_buyer_order> refundItemList = new List<order_pdd_buyer_order>();
foreach (DataRow row in dt.Rows)
{
order_pdd_buyer_order order = new 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(),
};
refundItemList.Add(order);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(refundItemList, 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\":\"输入为空\"}";
}
public string WXGetTransitWarehouseAfterSaleList(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
if (!WXUserManage.GetSign(inputData))
return "{\"code\":999,\"msg\":\"校验失败\"}";
var timeCalc = DateTime.Now;
var wx_order_id_in = RegexUtils.GetStringQuery(ref inputData, "wx_order_id_in")?.Replace("'", "\\'");
var buyer_order_sn_in = RegexUtils.GetStringQuery(ref inputData, "buyer_order_sn_in")?.Replace("'", "\\'");
if (wx_order_id_in.IsNullOrEmpty() && string.IsNullOrEmpty(buyer_order_sn_in))
{
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(1000);
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "SELECT COUNT(id) FROM erp.oms_wei_external_procurement_after_sale o WHERE 1=1 ";
string where = "";
if (!string.IsNullOrWhiteSpace(wx_order_id_in))
where += " and o.order_no in ('" + wx_order_id_in.Replace(",", "','") + "')";
if (!string.IsNullOrWhiteSpace(buyer_order_sn_in))
where += " and o.order_code in ('" + buyer_order_sn_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.oms_wei_external_procurement_after_sale 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<oms_wei_external_procurement_after_sale_info> refundItemList = new List<oms_wei_external_procurement_after_sale_info>();
foreach (DataRow row in dt.Rows)
{
oms_wei_external_procurement_after_sale_info order = new oms_wei_external_procurement_after_sale_info
{
id = row["id"].ParseToLong(),
order_no = row["order_no"].ParseToString(),
order_code = row["order_code"].ParseToString(),
inbound_time = row["inbound_time"].ParseToString().ParseToDateTimeNullable(),
outbound_time = row["outbound_time"].ParseToString().ParseToDateTimeNullable(),
account_user = row["account_user"].ParseToString(),
after_sale_no = row["after_sale_no"].ParseToString(),
created_time = row["created_time"].ParseToString().ParseToDateTimeNullable(),
create_user = row["create_user"].ParseToString(),
downstream_express_code = row["downstream_express_code"].ParseToString(),
downstream_waybill = row["downstream_waybill"].ParseToString(),
external_order_no = row["external_order_no"].ParseToString(),
raw_message = row["raw_message"].ParseToString(),
recipient_name = row["recipient_name"].ParseToString(),
recipient_phone = row["recipient_phone"].ParseToString(),
refund_city = row["refund_city"].ParseToString(),
refund_county = row["refund_county"].ParseToString(),
refund_detail_address = row["refund_detail_address"].ParseToString(),
refund_province = row["refund_province"].ParseToString(),
refund_waybill = row["refund_waybill"].ParseToString(),
return_express_company = row["return_express_company"].ParseToString(),
return_or_exchange = row["return_or_exchange"].ParseToNullableInt(),
status = row["status"].ParseToNullableInt(),
updated_time = row["updated_time"].ParseToString().ParseToDateTimeNullable(),
update_user = row["update_user"].ParseToString(),
warehouse_status = row["warehouse_status"].ParseToNullableInt(),
};
refundItemList.Add(order);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(refundItemList, 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\":\"输入为空\"}";
}
}
}