676 lines
33 KiB
C#
676 lines
33 KiB
C#
using StoreHub.KJDWebService.Models;
|
|
using StoreHub.Framework.Repositorys;
|
|
using Microsoft.Extensions.Configuration;
|
|
using StoreHub.KJDWebService.Commons;
|
|
using NaiBa.Util.Extension;
|
|
using NaiBa.Util.Helper;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
|
|
namespace StoreHub.KJDWebService.Services
|
|
{
|
|
public class OrderService : ServiceBase
|
|
{
|
|
public OrderService(SqlRepository sqlRepository, IConfiguration configuration) : base(sqlRepository, configuration)
|
|
{
|
|
}
|
|
public List<string> year_mounth_lst = new List<string>() { "202510", "202511", "202512",
|
|
"202601", "202602", "202603", "202604", "202605", "202606", "202607", "202608", "202609", "202610", "202611", "202612",
|
|
"202701", "202702", "202703", "202704", "202705", "202706", "202707", "202708", "202709", "202710", "202711", "202712",
|
|
"202801", "202802", "202803", "202804", "202805", "202806", "202807", "202808", "202809", "202810", "202811", "202812",
|
|
"202901", "202902", "202903", "202904", "202905", "202906", "202907", "202908", "202909", "202910", "202911", "202912",
|
|
"203001", "203002", "203003", "203004", "203005", "203006", "203007", "203008", "203009", "203010", "203011", "203012",
|
|
"203101", "203102", "203103", "203104", "203105", "203106", "203107", "203108", "203109", "203110", "203111", "203112",
|
|
"203201", "203202", "203203", "203204", "203205", "203206", "203207", "203208", "203209", "203210", "203211", "203212",
|
|
"203301", "203302", "203303", "203304", "203305", "203306", "203307", "203308", "203309", "203310", "203311", "203312" };
|
|
public string AddOrder(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
|
|
|
|
string order_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_data"))?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(order_data))
|
|
return "{\"code\":500,\"msg\":\"请输入订单参数\"}";
|
|
|
|
//string orderPurchaseTime = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "order_data"))?.Replace("'", "\\'");
|
|
//if (string.IsNullOrEmpty(order_data))
|
|
// return "{\"code\":500,\"msg\":\"请输入订单创建时间\"}";
|
|
|
|
JObject jObj = null;
|
|
try
|
|
{
|
|
jObj = JObject.Parse(order_data);
|
|
}
|
|
catch
|
|
{
|
|
return "{\"code\":500,\"msg\":\"数据格式错误\"}";
|
|
}
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
string table_id = "999999";
|
|
try
|
|
{
|
|
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(jObj["purchaseTime"].ToString())).ToString("yyyyMM");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + ex.Message + "\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
|
|
sql = "insert into kjd_order.order_" + table_id + " (";
|
|
foreach (var item in jObj)
|
|
{
|
|
if (item.Key.ParseToString() != "id" && JsonConvert.SerializeObject(item.Value) != "null" &&
|
|
item.Key.ParseToString() != "add_time" && item.Key.ParseToString() != "mdy_time")
|
|
sql += item.Key + ",";
|
|
}
|
|
sql = sql.Trim(',');
|
|
sql += ")";
|
|
sql += "values (";
|
|
foreach (var item in jObj)
|
|
{
|
|
if (item.Key.ParseToString() != "id" && JsonConvert.SerializeObject(item.Value) != "null" &&
|
|
item.Key.ParseToString() != "add_time" && item.Key.ParseToString() != "mdy_time")
|
|
sql += "'" + item.Value.ParseToString().Replace("\\'", "'").Replace("'", "\\'") + "',";
|
|
}
|
|
sql = sql.Trim(',');
|
|
sql += ");";
|
|
var rst = mySql.ExecuteInsertId(sql);
|
|
mySql.Close();
|
|
if (rst > 0)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string GetOrderList(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
//if (string.IsNullOrEmpty(shop_id))
|
|
// return "{\"code\":500,\"msg\":\"请输入查询店铺\",\"data\":[],\"count\":" + 0 + "}";
|
|
|
|
var upload_order_status = RegexUtils.GetStringQuery(ref inputData, "upload_order_status")?.Replace("'", "\\'");
|
|
//var start_time = RegexUtils.GetStringQuery(ref inputData, "start_time")?.Replace("'", "\\'");
|
|
var start_time = TimeUtils.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddDays(-30));
|
|
|
|
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
|
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
|
|
|
string startTimeStr = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "startTime"))?.Replace("'", "\\'");
|
|
string endTimeStr = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "endTime"))?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(endTimeStr))
|
|
{
|
|
var datetime = DateTime.Now;
|
|
startTimeStr = datetime.AddMonths(-1).ToString("yyyyMM");
|
|
endTimeStr = datetime.ToString("yyyyMM");
|
|
}
|
|
var startIndex = year_mounth_lst.IndexOf(startTimeStr);
|
|
var endIndex = year_mounth_lst.IndexOf(endTimeStr);
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
//sql = "select count(id) from kjd_order.order_" + table_id + " o where 1=1";
|
|
string sql = "";
|
|
sql += " SELECT count(*) FROM ( ";
|
|
for (int i = startIndex; i<=endIndex; i++)
|
|
{
|
|
if (i > startIndex)
|
|
sql += " UNION ALL ";
|
|
sql += " SELECT id,purchaseTime,supplierId,upLoadStatus FROM kjd_order.order_" + year_mounth_lst[i];
|
|
}
|
|
sql += " ) AS o WHERE 1=1";
|
|
|
|
string where = "";
|
|
if (start_time > 0)
|
|
where += " and o.purchaseTime > " + start_time;
|
|
if (!string.IsNullOrWhiteSpace(shop_id))
|
|
where += " and o.supplierId = '" + shop_id + "'";
|
|
if (!string.IsNullOrEmpty(upload_order_status))
|
|
where += " and upLoadStatus >= " + upload_order_status;
|
|
sql += where;
|
|
|
|
var count = mySql.ExecuteRowCount(sql);
|
|
|
|
DataTable dt;
|
|
if (count == 0)
|
|
{
|
|
dt = new DataTable();
|
|
}
|
|
else
|
|
{
|
|
//sql = "SELECT * FROM kjd_order.order_" + table_id + " o where 1=1"; // p.is_del=0
|
|
sql = " SELECT * FROM ( ";
|
|
for (int i = startIndex; i <= endIndex; i++)
|
|
{
|
|
if (i > startIndex)
|
|
sql += " UNION ALL ";
|
|
sql += " SELECT * FROM kjd_order.order_" + year_mounth_lst[i];
|
|
}
|
|
sql += " ) AS o WHERE 1=1";
|
|
|
|
//where子句
|
|
sql += where;
|
|
|
|
sql += " ORDER BY o.purchaseTime desc";
|
|
//sql += " ORDER BY o.select_total_count desc, p.id desc";
|
|
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
|
dt = mySql.ExecuteDataTable(sql);
|
|
}
|
|
|
|
mySql.Close();
|
|
if (dt != null)
|
|
{
|
|
try
|
|
{
|
|
List<TemuDBOrderInfo> orderLst = new List<TemuDBOrderInfo>();
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
TemuDBOrderInfo prod = new TemuDBOrderInfo
|
|
{
|
|
id = Convert.ToInt32(row["id"]),
|
|
add_time = Convert.ToDateTime(row["add_time"]),
|
|
mdy_time = Convert.ToDateTime(row["mdy_time"]),
|
|
notes = row["notes"].ParseToString(),
|
|
availableSaleDays = row["availableSaleDays"].ParseToNullableDecimal(),
|
|
barCodeMd5 = row["barCodeMd5"].ParseToString(),
|
|
category = row["category"].ParseToString(),
|
|
className = row["className"].ParseToString(),
|
|
costPrice = row["costPrice"].ParseToNullableInt(),
|
|
currencyType = row["currencyType"].ParseToString(),
|
|
deliverQuantity = row["deliverQuantity"].ParseToInt(),
|
|
deliverTime = row["deliverTime"].ParseToNullableLong(),
|
|
deliveryFee = row["deliveryFee"].ParseToNullableInt(),
|
|
deliveryOrderSn = row["deliveryOrderSn"].ParseToString(),
|
|
expectLatestArrivalTimeOrDefault = row["expectLatestArrivalTimeOrDefault"].ParseToLong(),
|
|
expectLatestDeliverTimeOrDefault = row["expectLatestDeliverTimeOrDefault"].ParseToLong(),
|
|
extCode = row["extCode"].ParseToString(),
|
|
jiaTongCode = row["jiaTongCode"].ParseToString(),
|
|
markFee = row["markFee"].ParseToNullableInt(),
|
|
originalPurchaseOrderSn = row["originalPurchaseOrderSn"].ParseToString(),
|
|
productId = row["productId"].ParseToString(),
|
|
productName = row["productName"].ParseToString(),
|
|
productSkcPicture = row["productSkcPicture"].ParseToString(),
|
|
productSkcId = row["productSkcId"].ParseToString(),
|
|
productSkuId = row["productSkuId"].ParseToString(),
|
|
productSn = row["productSn"].ParseToString(),
|
|
purchaseQuantity = row["purchaseQuantity"].ParseToInt(),
|
|
purchaseTime = row["purchaseTime"].ParseToLong(),
|
|
qcResult = row["qcResult"].ParseToNullableInt(),
|
|
realReceiveAuthenticQuantity = row["realReceiveAuthenticQuantity"].ParseToInt(),
|
|
receiveTime = row["receiveTime"].ParseToNullableLong(),
|
|
receiveWarehouseId = row["receiveWarehouseId"].ParseToString(),
|
|
receiveWarehouseName = row["receiveWarehouseName"].ParseToString(),
|
|
shippingMarkMd5 = row["shippingMarkMd5"].ParseToString(),
|
|
status = row["status"].ParseToInt(),
|
|
subPurchaseOrderSn = row["subPurchaseOrderSn"].ParseToString(),
|
|
supplierId = row["supplierId"].ParseToString(),
|
|
supplierName = row["supplierName"].ParseToString(),
|
|
supplierPrice = row["supplierPrice"].ParseToInt(),
|
|
thumbUrlList = row["thumbUrlList"].ParseToString(),
|
|
upLoadStatus = row["upLoadStatus"].ParseToInt(),
|
|
upProductId = row["upProductId"].ParseToString(),
|
|
warehouseGroupId = row["warehouseGroupId"].ParseToString(),
|
|
};
|
|
orderLst.Add(prod);
|
|
}
|
|
var data = JsonUtils.SerializeObjectToString(orderLst);
|
|
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 UpdateOrderStatus1(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 user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
// var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
|
|
|
|
// var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
// if (string.IsNullOrEmpty(shop_id))
|
|
// return "{\"code\":500,\"msg\":\"请输入查询店铺\"}";
|
|
// var product_id = RegexUtils.GetStringQuery(ref inputData, "product_id")?.Replace("'", "\\'");
|
|
// if (string.IsNullOrEmpty(product_id))
|
|
// return "{\"code\":500,\"msg\":\"请输入商品编号\"}";
|
|
|
|
// int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
|
// int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
|
|
|
// string conn = "ConnKJD";
|
|
// MysqlUtils mySql = new MysqlUtils(conn);
|
|
|
|
// long table_id = shop_id.ParseToLong() % 128;
|
|
// string sql = "update kjd_order.order_" + table_id + " o set o.upLoadStatus=1";
|
|
|
|
// string where = "";
|
|
// where += " and o.supplierId = '" + shop_id + "'";
|
|
// where += " and o.productId = '" + product_id + "'";
|
|
// where += " and o.upLoadStatus < 1";
|
|
// sql += where;
|
|
|
|
// var rst = mySql.ExecuteNonQuery(sql);
|
|
// mySql.Close();
|
|
|
|
// if (rst)
|
|
// {
|
|
// return "{\"code\":200,\"msg\":\"success\"}";
|
|
// }
|
|
// else
|
|
// {
|
|
// return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
// }
|
|
//}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
|
|
public string AddOrderCodeFile(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
|
|
|
|
string file_md5 = RegexUtils.GetStringQuery(ref inputData, "file_md5")?.Replace("'", "\\'");
|
|
string file_base64 = RegexUtils.GetStringQuery(ref inputData, "file_base64")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(file_md5) || string.IsNullOrEmpty(file_base64))
|
|
return "{\"code\":500,\"msg\":\"请输入文件信息\"}";
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
|
|
string table_id = "999999";
|
|
try
|
|
{
|
|
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
|
|
sql = "select count(fileCodeMd5) from kjd_order.order_code_" + table_id + " where fileCodeMd5='" + file_md5 + "';";
|
|
var rowCount = mySql.ExecuteRowCount(sql);
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
else if (rowCount > 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
|
|
sql = "insert into kjd_order.order_code_" + table_id + " (supplierId,fileCodeMd5,fileCodeBase64)";
|
|
sql += " values ('" + shop_id + "','" + file_md5 + "','" + file_base64 + "')";
|
|
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (!rst)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string SaveOrderCodeFileLink(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
|
|
var sub_order_sn = RegexUtils.GetStringQuery(ref inputData, "sub_order_sn")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(sub_order_sn))
|
|
return "{\"code\":500,\"msg\":\"请输入子单号\"}";
|
|
|
|
string jia_tong_code = RegexUtils.GetStringQuery(ref inputData, "jia_tong_code")?.Replace("'", "\\'"); // 佳同码
|
|
string bar_code_md5 = RegexUtils.GetStringQuery(ref inputData, "bar_code_md5")?.Replace("'", "\\'"); // 商品条码md5
|
|
string shipping_mark_md5 = RegexUtils.GetStringQuery(ref inputData, "shipping_mark_md5")?.Replace("'", "\\'"); // 箱唛md5
|
|
if (string.IsNullOrEmpty(jia_tong_code) && string.IsNullOrEmpty(bar_code_md5) && string.IsNullOrEmpty(shipping_mark_md5))
|
|
return "{\"code\":500,\"msg\":\"请输入文件信息\"}";
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'"); // 佳同码
|
|
string table_id = "999999";
|
|
try
|
|
{
|
|
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
|
|
}
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
|
|
sql = "update kjd_order.order_" + table_id;
|
|
sql += " set";
|
|
if (jia_tong_code != null)
|
|
sql += " jiaTongCode='" + jia_tong_code + "',";
|
|
if (bar_code_md5 != null)
|
|
sql += " barCodeMd5='" + bar_code_md5 + "',";
|
|
if (shipping_mark_md5 != null)
|
|
sql += " shippingMarkMd5='" + shipping_mark_md5 + "',";
|
|
sql = sql.TrimEnd(',');
|
|
sql += " where subPurchaseOrderSn='" + sub_order_sn + "';";
|
|
var rst = mySql.ExecuteNonQuery(sql);
|
|
mySql.Close();
|
|
if (rst)
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string getOrderCodeFile(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
|
|
|
|
string file_md5 = RegexUtils.GetStringQuery(ref inputData, "file_md5")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(file_md5))
|
|
return "{\"code\":500,\"msg\":\"请输入文件信息\"}";
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
|
|
string table_id = "999999";
|
|
try
|
|
{
|
|
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
|
|
sql = "select fileCodeMd5,fileCodeBase64 from kjd_order.order_code_" + table_id + " where fileCodeMd5='" + file_md5 + "';";
|
|
|
|
var dt = mySql.ExecuteDataTable(sql);
|
|
mySql.Close();
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
else
|
|
{
|
|
string file_md5_rst = "";
|
|
string file_base64_rst = "";
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
file_md5_rst = dt.Rows[0]["fileCodeMd5"].ParseToString();
|
|
file_base64_rst = dt.Rows[0]["fileCodeBase64"].ParseToString();
|
|
}
|
|
return "{\"code\":200,\"msg\":\"success\",\"data\":\"{\"file_md5\":\"" + file_md5_rst + "\",\"file_base64\":\"" + file_base64_rst + "\"}\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string UploadOrder(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
|
|
|
|
string subPurchaseOrderSn = RegexUtils.GetStringQuery(ref inputData, "subPurchaseOrderSn")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(subPurchaseOrderSn))
|
|
return "{\"code\":500,\"msg\":\"请输入订单编号\"}";
|
|
|
|
string feeStr = RegexUtils.GetStringQuery(ref inputData, "fee")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(feeStr))
|
|
return "{\"code\":500,\"msg\":\"请输入费用\"}";
|
|
decimal fee = feeStr.ParseToDecimal();
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
|
|
string table_id = "999999";
|
|
try
|
|
{
|
|
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
|
|
sql = "select authorized_amount from kjd.user where user_name='" + user_name + "'";
|
|
var value = mySql.ExecuteFirst(sql);
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
if (value.IsNullOrEmpty())
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"用户不存\"}";
|
|
}
|
|
if (value.ParseToDecimal() < fee)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"授权金不足\"}";
|
|
}
|
|
|
|
sql = "update kjd_order.order_" + table_id + " set upLoadStatus=2 where upLoadStatus < 2 and subPurchaseOrderSn in('" + subPurchaseOrderSn + "');";
|
|
var rst = mySql.ExecuteAffectedRows(sql);
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
if (rst == 0)
|
|
{
|
|
mySql.Close();
|
|
return "{\"code\":500,\"msg\":\"订单不存在或已上传\"}";
|
|
}
|
|
|
|
sql = "update kjd.user set authorized_amount=authorized_amount-" + fee + " where user_name='" + user_name + "';";
|
|
rst = mySql.ExecuteAffectedRows(sql);
|
|
mySql.Close();
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
if(rst == 0)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"订单已提交但扣费失败\"}";
|
|
}
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
|
|
public string UpdateOrderStatus(string inputData)
|
|
{
|
|
if (!string.IsNullOrEmpty(inputData))
|
|
{
|
|
var time = 0;
|
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
|
if (time1 != EncrypUtil.Encryption(time))
|
|
return "{\"code\":50000,\"msg\":\"校验失败\"}";
|
|
|
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
|
if (string.IsNullOrEmpty(user_name))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
|
}
|
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(shop_id))
|
|
return "{\"code\":500,\"msg\":\"请输入店铺\"}";
|
|
|
|
string subPurchaseOrderSn = RegexUtils.GetStringQuery(ref inputData, "subPurchaseOrderSn")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(subPurchaseOrderSn))
|
|
return "{\"code\":500,\"msg\":\"请输入订单编号\"}";
|
|
|
|
string new_status = RegexUtils.GetStringQuery(ref inputData, "new_status")?.Replace("'", "\\'");
|
|
string old_status = RegexUtils.GetStringQuery(ref inputData, "old_status")?.Replace("'", "\\'");
|
|
if (string.IsNullOrEmpty(new_status))
|
|
return "{\"code\":500,\"msg\":\"请输入订单状态\"}";
|
|
|
|
//long table_id = shop_id.ParseToLong() % 128;
|
|
string purchaseTime = RegexUtils.GetStringQuery(ref inputData, "purchaseTime")?.Replace("'", "\\'");
|
|
string table_id = "999999";
|
|
try
|
|
{
|
|
table_id = TimeUtils.StampMillisecondsToDateTime(long.Parse(purchaseTime)).ToString("yyyyMM");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "{\"code\":500,\"msg\":\"请输入正确的时间:" + ex.Message + "\"}";
|
|
}
|
|
|
|
string conn = "ConnKJD";
|
|
MysqlUtils mySql = new MysqlUtils(conn);
|
|
string sql = "";
|
|
|
|
sql = "update kjd_order.order_" + table_id + " set upLoadStatus=" + new_status + " where 1=1";
|
|
if (!string.IsNullOrEmpty(old_status))
|
|
sql += " and upLoadStatus=" + old_status;
|
|
sql += " and subPurchaseOrderSn in('" + subPurchaseOrderSn + "');";
|
|
var rst = mySql.ExecuteAffectedRows(sql);
|
|
mySql.Close();
|
|
if (!string.IsNullOrEmpty(mySql.Message))
|
|
{
|
|
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":200,\"msg\":\"success\"}";
|
|
}
|
|
}
|
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|