This commit is contained in:
chfei committed 2026-10-14 14:08:33 +08:00
commit 3b85f00d88
3 files changed
+272 -17

No files matched your search

+244 -16
View File
@@ -601,7 +601,11 @@ namespace KJD_Web.BLL.WXXD
SELECT t.*,ROW_NUMBER() OVER (PARTITION BY spu_code ORDER BY mdy_time DESC) AS rn
FROM `bxx`.`product_buy_map_skus` t
) AS ranked
WHERE rn <= 5" + where;
WHERE rn <= 3" + where;
sql = @"
SELECT t.* FROM `bxx`.`product_buy_map_skus` t
WHERE 1=1 " + where;
sql += " ORDER BY mdy_time DESC";
dt = mySql.ExecuteDataTable(sql);
}
mySql.Close();
@@ -613,21 +617,22 @@ namespace KJD_Web.BLL.WXXD
List<WXBuyMapSkusInfo> WXBuyMapInfoLst = new List<WXBuyMapSkusInfo>();
foreach (DataRow row in dt.Rows)
{
WXBuyMapInfoLst.Add(new WXBuyMapSkusInfo()
{
id = row["id"].ParseToInt(),
user_name = row["user_name"].ParseToNullableString(),
spu_code = row["spu_code"].ParseToNullableString(),
map_url = row["map_url"].ParseToNullableString(),
map_goods_name = row["map_goods_name"].ParseToNullableString(),
map_goods_id = row["map_goods_id"].ParseToNullableString(),
map_skus = row["map_skus"].ParseToNullableString(),
map_send_address = row["map_send_address"].ParseToNullableString(),
transit_warehouse_id = row["transit_warehouse_id"].ParseToNullableString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
platform = row["platform"].ParseToNullableString(),
});
if (WXBuyMapInfoLst.Where(b => b.spu_code == row["spu_code"].ParseToNullableString()).ToList().Count < 5)
WXBuyMapInfoLst.Add(new WXBuyMapSkusInfo()
{
id = row["id"].ParseToInt(),
user_name = row["user_name"].ParseToNullableString(),
spu_code = row["spu_code"].ParseToNullableString(),
map_url = row["map_url"].ParseToNullableString(),
map_goods_name = row["map_goods_name"].ParseToNullableString(),
map_goods_id = row["map_goods_id"].ParseToNullableString(),
map_skus = row["map_skus"].ParseToNullableString(),
map_send_address = row["map_send_address"].ParseToNullableString(),
transit_warehouse_id = row["transit_warehouse_id"].ParseToNullableString(),
add_time = Convert.ToDateTime(row["add_time"]),
mdy_time = Convert.ToDateTime(row["mdy_time"]),
platform = row["platform"].ParseToNullableString(),
});
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(WXBuyMapInfoLst, jsonSetting);
@@ -2295,6 +2300,229 @@ namespace KJD_Web.BLL.WXXD
}
public string WXAddMdyTbBuyerAfterSale(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 wx_send_type = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "wx_send_type"))?.Replace("'", "\\'");
if (wx_send_type.IsNullOrEmpty())
wx_send_type = "0";
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 orderSn = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "orderSn"))?.Replace("'", "\\'");
string afterSalesId = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "afterSalesId"))?.Replace("'", "\\'");
string orderAmount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "orderAmount"))?.Replace("'", "\\'");
string orderDate = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "orderDate"))?.Replace("'", "\\'");
string order_detail = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_detail"))?.Replace("'", "\\'");
string refundAmount = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "refundAmount"))?.Replace("'", "\\'");
string statusText = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "statusText"))?.Replace("'", "\\'");
string afterSaleAddress = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "afterSaleAddress"))?.Replace("'", "\\'");
string is_mdy = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "is_mdy"))?.Replace("'", "\\'");
if (string.IsNullOrEmpty(wx_order_id) || string.IsNullOrEmpty(orderSn) || string.IsNullOrEmpty(afterSalesId))
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_tb_buyer_after_sale where afterSalesId='" + afterSalesId + "'";
var id = mySql.ExecuteFirstInt(sql);
if (!string.IsNullOrEmpty(mySql.Message))
{
mySql.Close();
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
if (id == 0 && is_mdy != "true")
{
sql = "INSERT INTO wxxd.order_tb_buyer_after_sale (wx_order_id,wx_sku_id,wx_send_type,TransitCreateTime,pre_allocated_order_no,buyerId,buyerName,orderSn,afterSalesId,orderAmount,orderDate," +
"refundAmount,statusText,afterSaleAddress,order_detail)";
sql += "VALUES(@wx_order_id,@wx_sku_id,@wx_send_type,@TransitCreateTime,@pre_allocated_order_no,@buyerId,@buyerName,@orderSn,@afterSalesId,@orderAmount,@orderDate," +
"@refundAmount,@statusText,@afterSaleAddress,@order_detail);";
}
else
{
sql = "UPDATE wxxd.order_tb_buyer_after_sale 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(wx_send_type))
sql += " wx_send_type=@wx_send_type,";
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(orderSn))
sql += " orderSn=@orderSn,";
if (!string.IsNullOrEmpty(orderAmount))
sql += " orderAmount=@orderAmount,";
if (!string.IsNullOrEmpty(refundAmount))
sql += " refundAmount=@refundAmount,";
if (!string.IsNullOrEmpty(statusText))
sql += " statusText=@statusText,";
if (!string.IsNullOrEmpty(orderDate))
sql += " orderDate=@orderDate,";
if (!string.IsNullOrEmpty(afterSaleAddress))
sql += " afterSaleAddress=@afterSaleAddress,";
if (!string.IsNullOrEmpty(order_detail))
sql += " order_detail=@order_detail,";
sql = sql.TrimEnd(',');
sql += " where afterSalesId=@afterSalesId";
}
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.Int32, ParameterName = "wx_send_type", Value = wx_send_type.ParseToInt(), });
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 = "statusText", Value = statusText, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "orderSn", Value = orderSn, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "afterSalesId", Value = afterSalesId, });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "refundAmount", Value = refundAmount.ParseToNullableInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int32, ParameterName = "orderAmount", Value = orderAmount.ParseToNullableInt(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.Int64, ParameterName = "orderDate", Value = orderDate.ParseToLong(), });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "afterSaleAddress", Value = afterSaleAddress, });
paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "order_detail", Value = order_detail, });
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 WXGetTbBuyerAfterSaleList(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_tb_buyer_after_sale 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_tb_buyer_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<order_tb_buyer_after_sale> buyerAfterSaleLst = new List<order_tb_buyer_after_sale>();
foreach (DataRow row in dt.Rows)
{
order_tb_buyer_after_sale afterSale = new order_tb_buyer_after_sale
{
id = row["id"].ParseToLong(),
add_time = row["add_time"].ParseToString().ParseToDateTime(),
afterSalesId = row["afterSalesId"].ParseToString(),
buyerId = row["buyerId"].ParseToString(),
buyerName = row["buyerName"].ParseToString(),
mdy_time = row["mdy_time"].ParseToString().ParseToDateTime(),
orderAmount = row["orderAmount"].ParseToNullableInt(),
order_detail = row["order_detail"].ParseToString(),
orderSn = row["orderSn"].ParseToString(),
orderDate = row["orderDate"].ParseToNullableInt(),
refundAmount = row["refundAmount"].ParseToNullableInt(),
statusText = row["statusText"].ParseToString(),
afterSaleAddress = row["afterSaleAddress"].ParseToString(),
pre_allocated_order_no = row["pre_allocated_order_no"].ParseToNullableInt(),
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(),
};
buyerAfterSaleLst.Add(afterSale);
}
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
var data = JsonUtils.SerializeObjectToString(buyerAfterSaleLst, 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))
@@ -278,6 +278,28 @@ namespace KJD_Web.Controllers.WX
return JsonString(result);
}
public IHttpActionResult wx_add_mdy_tb_buyer_after_sale()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXOrderManage().WXAddMdyTbBuyerAfterSale(jsontext);
return JsonString(result);
}
public IHttpActionResult wx_get_tb_buyer_after_sale_list()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new WXOrderManage().WXGetTbBuyerAfterSaleList(jsontext);
return JsonString(result);
}
public IHttpActionResult wx_get_transit_warehouse_aftersale_list()
{
string jsontext = GetRequestJsonString();
@@ -5,7 +5,12 @@ using System.Web;
namespace KJD_Web.Model.WxModel
{
public class order_pdd_buyer_after_sale
public class order_tb_buyer_after_sale : order_pdd_buyer_after_sale
{
}
public class order_pdd_buyer_after_sale
{
public long? id { get; set; }
public string wx_order_id { get; set; }