Compare commits
32
Commits
79dfefaceb
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69b39196f5 | ||
|
|
2de3d0dc92 | ||
|
|
ea0cbd6b92 | ||
|
|
75ec004e16 | ||
|
|
96de35a454 | ||
|
|
e971db92ad | ||
|
|
6f54b8a63f | ||
|
|
7d9114482e | ||
|
|
8d6c4ebb84 | ||
|
|
60d96db5ee | ||
|
|
572c8e19f1 | ||
|
|
ac3be37e66 | ||
|
|
5ddad5bceb | ||
|
|
0e38a1e31f | ||
|
|
08f8e2009f | ||
|
|
34b1d39108 | ||
|
|
2153e881f3 | ||
|
|
af15492130 | ||
|
|
94bc729ea3 | ||
|
|
b5ab6ef8d2 | ||
|
|
6e4f44bbe6 | ||
|
|
28a90b135c | ||
|
|
bbb7d19dc1 | ||
|
|
a34b49d1a0 | ||
|
|
132b9932db | ||
|
|
f836cf6e3a | ||
|
|
dc4fca1b9b | ||
|
|
dc51a3729e | ||
|
|
1142c6f05a | ||
|
|
c714bbea64 | ||
|
|
d4051474e3 | ||
|
|
827c103099 |
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
using KJD_Web.BLL.WXXD;
|
using KJD_Web.BLL.WXXD;
|
||||||
using KJD_Web.Model;
|
using KJD_Web.Model;
|
||||||
using KJD_Web.Model.ShopModel;
|
using KJD_Web.Model.ShopModel;
|
||||||
|
using KJD_Web.Upload.Prod;
|
||||||
using KJD_Web.Utils;
|
using KJD_Web.Utils;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
@@ -672,6 +673,8 @@ namespace KJD_Web.BLL.BXX
|
|||||||
var max_sale_count_num = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "max_sale_count_num"))?.Replace("'", "\\'");
|
var max_sale_count_num = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "max_sale_count_num"))?.Replace("'", "\\'");
|
||||||
var min_sale_count_num = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "min_sale_count_num"))?.Replace("'", "\\'");
|
var min_sale_count_num = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "min_sale_count_num"))?.Replace("'", "\\'");
|
||||||
var is_del = RegexUtils.GetStringQuery(ref inputData, "is_del").ParseToInt();
|
var is_del = RegexUtils.GetStringQuery(ref inputData, "is_del").ParseToInt();
|
||||||
|
//安全状态:0 全部(默认),1 安全,2 违规,3 未检测。
|
||||||
|
var safeStatus = RegexUtils.GetStringQuery(ref inputData, "safe_status").ParseToInt(0);
|
||||||
|
|
||||||
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
int page = RegexUtils.GetStringQuery(ref inputData, "page").ParseToInt();
|
||||||
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
int page_size = RegexUtils.GetStringQuery(ref inputData, "page_size").ParseToInt(50);
|
||||||
@@ -903,6 +906,10 @@ namespace KJD_Web.BLL.BXX
|
|||||||
{
|
{
|
||||||
where += " and p.sale_count_num>=" + min_sale_count_num;
|
where += " and p.sale_count_num>=" + min_sale_count_num;
|
||||||
}
|
}
|
||||||
|
if (safeStatus > 0)
|
||||||
|
{
|
||||||
|
where += (" and p.is_safe " + (safeStatus == 1 ? "=1" : safeStatus == 2 ? "=0" : " is NULL"));
|
||||||
|
}
|
||||||
sql += where;
|
sql += where;
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
@@ -957,7 +964,7 @@ namespace KJD_Web.BLL.BXX
|
|||||||
sql = "SELECT p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name," +
|
sql = "SELECT p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name," +
|
||||||
" p.main_img,p.notes,p.add_time,p.mdy_time,p.fission_words,p.head_words,p.end_words,p.group," +
|
" p.main_img,p.notes,p.add_time,p.mdy_time,p.fission_words,p.head_words,p.end_words,p.group," +
|
||||||
" p.product_get_type,p.wx_safe_status,p.sale_count_num,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
|
" p.product_get_type,p.wx_safe_status,p.sale_count_num,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," +
|
||||||
" p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation,p.view_uv,p.add_user_name,p.is_del" +
|
" p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id,p.real_coid,p.real_spu_id,p.is_relation,p.view_uv,p.add_user_name,p.is_del,p.is_safe" +
|
||||||
" FROM " + tableName + " p" +
|
" FROM " + tableName + " p" +
|
||||||
" WHERE p.is_del=" + is_del;
|
" WHERE p.is_del=" + is_del;
|
||||||
|
|
||||||
@@ -1019,6 +1026,7 @@ namespace KJD_Web.BLL.BXX
|
|||||||
is_relation = row["is_relation"].ParseToInt(),
|
is_relation = row["is_relation"].ParseToInt(),
|
||||||
add_user_name = row["add_user_name"].ParseToString(),
|
add_user_name = row["add_user_name"].ParseToString(),
|
||||||
is_del = row["is_del"].ParseToNullableInt(),
|
is_del = row["is_del"].ParseToNullableInt(),
|
||||||
|
is_safe = row["is_safe"].ParseToNullableBool(),
|
||||||
};
|
};
|
||||||
if (isDetail)
|
if (isDetail)
|
||||||
{
|
{
|
||||||
@@ -3349,6 +3357,28 @@ namespace KJD_Web.BLL.BXX
|
|||||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取提审限额
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string WxApiGetAuditQuota(string inputData)
|
||||||
|
{
|
||||||
|
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\":\"校验失败\"}";
|
||||||
|
|
||||||
|
string post_data = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "post_data"));
|
||||||
|
string token = RegexUtils.GetStringQuery(ref inputData, "token");
|
||||||
|
|
||||||
|
return HttpUtils.WxApiPostResponse("https://api.weixin.qq.com/channels/ec/product/getauditquota?access_token= " + token, post_data, "");
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||||
|
}
|
||||||
|
|
||||||
public string WxApiUploadImage(string inputData)
|
public string WxApiUploadImage(string inputData)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(inputData))
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
@@ -3913,8 +3943,9 @@ namespace KJD_Web.BLL.BXX
|
|||||||
return "{\"code\":500,\"msg\":\"缺少上家编号\"}";
|
return "{\"code\":500,\"msg\":\"缺少上家编号\"}";
|
||||||
}
|
}
|
||||||
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
||||||
if (index == null)
|
index = Convert.ToInt32(EncrypUtil.GetMd5(up_spu_id).Substring(EncrypUtil.GetMd5(up_spu_id).Length - 4), 16) % 128;
|
||||||
index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
//if (index == null)
|
||||||
|
// index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||||||
var up_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "up_goods_name"));
|
var up_goods_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "up_goods_name"));
|
||||||
if (string.IsNullOrEmpty(up_goods_name))
|
if (string.IsNullOrEmpty(up_goods_name))
|
||||||
{
|
{
|
||||||
@@ -3949,7 +3980,7 @@ namespace KJD_Web.BLL.BXX
|
|||||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
MysqlUtils mySql = new MysqlUtils(conn);
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
string sql = "insert into bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
|
string sql = "insert into bxx_relation.out_prod_relation_t" + index.ParseToString().PadLeft(4, '0') +
|
||||||
" (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max) " +
|
" (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max) " +
|
||||||
" values ('" + up_spu_id + "',@up_goods_name,'" + from_site + "','" +
|
" values ('" + up_spu_id + "',@up_goods_name,'" + from_site + "','" +
|
||||||
goods_id + "'," + shop_id + "," + price_min + "," + price_max + ");";
|
goods_id + "'," + shop_id + "," + price_min + "," + price_max + ");";
|
||||||
@@ -3984,16 +4015,89 @@ namespace KJD_Web.BLL.BXX
|
|||||||
return "{\"code\":500,\"msg\":\"缺少来源商品编号\"}";
|
return "{\"code\":500,\"msg\":\"缺少来源商品编号\"}";
|
||||||
}
|
}
|
||||||
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong();
|
||||||
if (index == null)
|
index = Convert.ToInt32(EncrypUtil.GetMd5(up_spu_id).Substring(EncrypUtil.GetMd5(up_spu_id).Length - 4), 16) % 128;
|
||||||
index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
//if (index == null)
|
||||||
|
// index = Math.Abs(up_spu_id.GetHashCode()) % 128;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
MysqlUtils mySql = new MysqlUtils(conn);
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
string sql = "select * from bxx_relation.out_prod_relation_" + index.ParseToString().PadLeft(4, '0') +
|
string sql = "select * from bxx_relation.out_prod_relation_t" + index.ParseToString().PadLeft(4, '0') +
|
||||||
" where up_spu_id='" + up_spu_id + "' limit 20;";
|
" where up_spu_id='" + up_spu_id + "' limit 20;";
|
||||||
var dt = mySql.ExecuteDataTable(sql);
|
var dt = mySql.ExecuteDataTable(sql);
|
||||||
|
|
||||||
mySql.Close();
|
mySql.Close();
|
||||||
|
|
||||||
|
//int uniqCount = 0; //95 个重复的(可能中间少记录一个)
|
||||||
|
//var totalCount = 0; //30224 //30320
|
||||||
|
//for (int i = 0; i < 128; i++)
|
||||||
|
//{
|
||||||
|
// sql = "";
|
||||||
|
// mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
|
// //sql = @"drop table if exists bxx_relation.out_prod_relation_t" + i.ParseToString().PadLeft(4, '0') + ";\r\n";
|
||||||
|
// //sql += @"CREATE TABLE bxx_relation.out_prod_relation_t" + i.ParseToString().PadLeft(4, '0') + @" (
|
||||||
|
// // `id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
// // `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息,此字段为分表依据',
|
||||||
|
// // `up_goods_name` varchar(255) NOT NULL COMMENT '源商品标题',
|
||||||
|
// // `from_site` varchar(10) NOT NULL COMMENT '商品来源平台如pdd,tb,1688,vd(微店)等',
|
||||||
|
// // `goods_id` varchar(50) NOT NULL COMMENT '映射商品id信息',
|
||||||
|
// // `shop_id` varchar(50) NOT NULL COMMENT '上传到的店铺id',
|
||||||
|
// // `price_min` int NOT NULL COMMENT '最低价,单位分',
|
||||||
|
// // `price_max` int NOT NULL COMMENT '最高价,单位分',
|
||||||
|
// // `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
// // PRIMARY KEY(`id`),
|
||||||
|
// // UNIQUE KEY `index_up_spu_id` (`up_spu_id`) USING BTREE,
|
||||||
|
// // KEY `index_add_time` (`add_time`) USING BTREE,
|
||||||
|
// // KEY `index_shop_id` (`shop_id`) USING BTREE,
|
||||||
|
// // KEY `index_price_min` (`price_min`) USING BTREE,
|
||||||
|
// // KEY `index_price_max` (`price_max`) USING BTREE
|
||||||
|
// // ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '记录拼多多关联数据信息'";
|
||||||
|
// //var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
|
||||||
|
// sql = "select * from bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0');
|
||||||
|
// dt = mySql.ExecuteDataTable(sql);
|
||||||
|
// totalCount += dt.Rows.Count;
|
||||||
|
|
||||||
|
// //sql = "select count(*) from bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0');
|
||||||
|
// //totalCount += mySql.ExecuteFirstInt(sql);
|
||||||
|
// foreach (DataRow row in dt.Rows)
|
||||||
|
// {
|
||||||
|
// var indexCount = dt.Rows.IndexOf(row);
|
||||||
|
// JObject jObj = new JObject();
|
||||||
|
// //jObj["id"] = row["id"].ParseToInt();
|
||||||
|
// var up_spu_id1 = row["up_spu_id"].ToString();
|
||||||
|
// var up_goods_name = row["up_goods_name"].ToString();
|
||||||
|
// var from_site = row["from_site"].ToString();
|
||||||
|
// var goods_id = row["goods_id"].ToString();
|
||||||
|
// var shop_id = row["shop_id"].ToString();
|
||||||
|
// var price_min = row["price_min"].ParseToInt();
|
||||||
|
// var price_max = row["price_max"].ParseToInt();
|
||||||
|
// var add_time = row["add_time"].ParseToString().ParseToDateTime();
|
||||||
|
|
||||||
|
|
||||||
|
// index = Convert.ToInt32(EncrypUtil.GetMd5(up_spu_id1).Substring(EncrypUtil.GetMd5(up_spu_id1).Length - 4), 16) % 128;
|
||||||
|
|
||||||
|
// sql = "insert into bxx_relation.out_prod_relation_t" + index.ParseToString().PadLeft(4, '0') +
|
||||||
|
// " (up_spu_id,up_goods_name,from_site,goods_id,shop_id,price_min,price_max,add_time) " +
|
||||||
|
// " values ('" + up_spu_id1 + "',@up_goods_name,'" + from_site + "','" +
|
||||||
|
// goods_id + "'," + shop_id + "," + price_min + "," + price_max + ",'" + add_time.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
||||||
|
// List<MySqlParameter> paramLst = new List<MySqlParameter>();
|
||||||
|
// paramLst.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "@up_goods_name", Value = up_goods_name, });
|
||||||
|
// var rs = mySql.ExecuteAffectedRows(sql, paramLst.ToArray());
|
||||||
|
// if (rs != 1)
|
||||||
|
// {
|
||||||
|
// uniqCount++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// mySql.Close();
|
||||||
|
//}
|
||||||
|
|
||||||
if (mySql.Message.IsNullOrEmpty())
|
if (mySql.Message.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
JArray jArr = new JArray();
|
JArray jArr = new JArray();
|
||||||
@@ -4283,6 +4387,33 @@ namespace KJD_Web.BLL.BXX
|
|||||||
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string SaveProductSafety(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var timeCalc = DateTime.Now;
|
||||||
|
if (!WXUserManage.GetSign(inputData))
|
||||||
|
return "{\"code\":999,\"msg\":\"校验失败\"}";
|
||||||
|
|
||||||
|
int id = RegexUtils.GetStringQuery(ref inputData, "id").ParseToInt();
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
|
string sql = "";
|
||||||
|
var count = -1;
|
||||||
|
|
||||||
|
sql = "UPDATE bxx.product set is_safe=1 WHERE id=" + id;
|
||||||
|
|
||||||
|
count = mySql.ExecuteAffectedRows(sql);
|
||||||
|
|
||||||
|
mySql.Close();
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"输入为空\"}";
|
||||||
|
}
|
||||||
|
|
||||||
//public string XJGetAiImage(string inputData)
|
//public string XJGetAiImage(string inputData)
|
||||||
//{
|
//{
|
||||||
// if (string.IsNullOrEmpty(inputData))
|
// if (string.IsNullOrEmpty(inputData))
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ namespace KJD_Web.BLL
|
|||||||
//string sql = "";
|
//string sql = "";
|
||||||
//for (int i = 0; i < 128; i++)
|
//for (int i = 0; i < 128; i++)
|
||||||
//{
|
//{
|
||||||
// sql = @"drop table if exists bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0') + ";\r\n";
|
// sql = @"drop table if exists bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(6, '0') + ";\r\n";
|
||||||
// sql += @"CREATE TABLE bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(4, '0') + @" (
|
// sql += @"CREATE TABLE bxx_relation.out_prod_relation_" + i.ParseToString().PadLeft(6, '0') + @" (
|
||||||
// `id` int NOT NULL AUTO_INCREMENT,
|
// `id` int NOT NULL AUTO_INCREMENT,
|
||||||
// `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息,此字段为分表依据',
|
// `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息,此字段为分表依据',
|
||||||
// `up_goods_name` varchar(255) NOT NULL COMMENT '源商品标题',
|
// `up_goods_name` varchar(255) NOT NULL COMMENT '源商品标题',
|
||||||
|
|||||||
@@ -37,12 +37,13 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
var oem_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'"));
|
var oem_id = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'"));
|
||||||
var oem_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_name")?.Replace("'", "\\'"));
|
var oem_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_name")?.Replace("'", "\\'"));
|
||||||
var oem_owner = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_owner")?.Replace("'", "\\'"));
|
var oem_owner = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "oem_owner")?.Replace("'", "\\'"));
|
||||||
|
var parent_oemid = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "parent_oemid")?.Replace("'", "\\'"));
|
||||||
if (oem_id.IsNullOrEmpty() || oem_name.IsNullOrEmpty())
|
if (oem_id.IsNullOrEmpty() || oem_name.IsNullOrEmpty())
|
||||||
return "{\"code\":500,\"msg\":\"oem信息不能为空\"}";
|
return "{\"code\":500,\"msg\":\"oem信息不能为空\"}";
|
||||||
|
|
||||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
MysqlUtils mySql = new MysqlUtils(conn);
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
string sql = "INSERT INTO wxxd.oem (oem_id,oem_name,oem_owner) VALUES('" + oem_id + "','" + oem_name + "','" + oem_owner + "')" +
|
string sql = "INSERT INTO wxxd.oem (oem_id,oem_name,oem_owner,parent_oem_id) VALUES('" + oem_id + "','" + oem_name + "','" + oem_owner + "','" + parent_oemid + "')" +
|
||||||
"ON DUPLICATE KEY UPDATE oem_name=VALUES(oem_name),oem_owner=VALUES(oem_owner);";
|
"ON DUPLICATE KEY UPDATE oem_name=VALUES(oem_name),oem_owner=VALUES(oem_owner);";
|
||||||
|
|
||||||
var rst = mySql.ExecuteAffectedRows(sql);
|
var rst = mySql.ExecuteAffectedRows(sql);
|
||||||
@@ -135,6 +136,7 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
oem_img = null,
|
oem_img = null,
|
||||||
oem_name = row["oem_name"].ParseToString(),
|
oem_name = row["oem_name"].ParseToString(),
|
||||||
oem_owner = row["oem_owner"].ParseToString(),
|
oem_owner = row["oem_owner"].ParseToString(),
|
||||||
|
parent_oem_id = row["parent_oem_id"].ParseToString(),
|
||||||
available_balance = row.Table.Columns.Contains("available_balance") ? row["available_balance"].ParseToLong() : 0,
|
available_balance = row.Table.Columns.Contains("available_balance") ? row["available_balance"].ParseToLong() : 0,
|
||||||
frozen_balance = row.Table.Columns.Contains("frozen_balance") ? row["frozen_balance"].ParseToLong() : 0,
|
frozen_balance = row.Table.Columns.Contains("frozen_balance") ? row["frozen_balance"].ParseToLong() : 0,
|
||||||
total_rebate_amount = row.Table.Columns.Contains("total_rebate_amount") ? row["total_rebate_amount"].ParseToLong() : 0,
|
total_rebate_amount = row.Table.Columns.Contains("total_rebate_amount") ? row["total_rebate_amount"].ParseToLong() : 0,
|
||||||
@@ -360,6 +362,10 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
{
|
{
|
||||||
throw new Exception("错误的账号");
|
throw new Exception("错误的账号");
|
||||||
}
|
}
|
||||||
|
else if (oems.Count != 1)
|
||||||
|
{
|
||||||
|
throw new Exception($"错误的OEM数据{oems.Count}");
|
||||||
|
}
|
||||||
|
|
||||||
oem oemInfo = null;
|
oem oemInfo = null;
|
||||||
if (!request.oem_id.IsNullOrEmpty())
|
if (!request.oem_id.IsNullOrEmpty())
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using KJD_Web.Model;
|
using KJD_Web.Model;
|
||||||
|
using KJD_Web.Model.PddModel;
|
||||||
using KJD_Web.Model.WxModel;
|
using KJD_Web.Model.WxModel;
|
||||||
using KJD_Web.Utils;
|
using KJD_Web.Utils;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using MySqlX.XDevAPI;
|
using MySqlX.XDevAPI;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
|
using NaiBa.Util.Helper;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using System;
|
using System;
|
||||||
@@ -83,6 +85,9 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
//2.查询 tinyint(1) 的sql 字段时,转为(status + 0) as status
|
//2.查询 tinyint(1) 的sql 字段时,转为(status + 0) as status
|
||||||
//3.避免使用 tinyint(1) 作为字段的数据类型
|
//3.避免使用 tinyint(1) 作为字段的数据类型
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(erp_order_id_in))
|
||||||
|
{
|
||||||
|
|
||||||
sql = "SELECT o.*,(out_shipped+0) as out_shipped_int FROM erp.oms_wei_order o WHERE 1=1";
|
sql = "SELECT o.*,(out_shipped+0) as out_shipped_int FROM erp.oms_wei_order o WHERE 1=1";
|
||||||
|
|
||||||
//where子句
|
//where子句
|
||||||
@@ -95,6 +100,35 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
sql += " ORDER BY o.create_time DESC, o.id DESC";
|
sql += " ORDER BY o.create_time DESC, o.id DESC";
|
||||||
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||||||
dt = mySql.ExecuteDataTable(sql);
|
dt = mySql.ExecuteDataTable(sql);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql = "SELECT id FROM erp.oms_wei_order o WHERE 1=1";
|
||||||
|
//where子句
|
||||||
|
sql += where;
|
||||||
|
dt = mySql.ExecuteDataTable(sql);
|
||||||
|
if (sort_type == "asc")
|
||||||
|
//sql += " ORDER BY o.create_time ASC, o.id desc";
|
||||||
|
sql += " ORDER BY o.create_time ASC, o.id ASC";
|
||||||
|
else
|
||||||
|
sql += " ORDER BY o.create_time DESC, o.id DESC";
|
||||||
|
sql += " LIMIT " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||||||
|
dt = mySql.ExecuteDataTable(sql);
|
||||||
|
|
||||||
|
if (dt != null && string.IsNullOrEmpty(mySql.Message))
|
||||||
|
{
|
||||||
|
var ids = string.Join(",", dt.Rows.Cast<DataRow>().Select(r => r["id"]).ToList());
|
||||||
|
sql = "SELECT o.*,(out_shipped+0) as out_shipped_int FROM erp.oms_wei_order o WHERE id in (" + ids + ")";
|
||||||
|
|
||||||
|
if (sort_type == "asc")
|
||||||
|
//sql += " ORDER BY o.create_time ASC, o.id desc";
|
||||||
|
sql += " ORDER BY o.create_time ASC, o.id ASC";
|
||||||
|
else
|
||||||
|
sql += " ORDER BY o.create_time DESC, o.id DESC";
|
||||||
|
dt = mySql.ExecuteDataTable(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mySql.Close();
|
mySql.Close();
|
||||||
@@ -617,6 +651,7 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
List<WXBuyMapSkusInfo> WXBuyMapInfoLst = new List<WXBuyMapSkusInfo>();
|
List<WXBuyMapSkusInfo> WXBuyMapInfoLst = new List<WXBuyMapSkusInfo>();
|
||||||
foreach (DataRow row in dt.Rows)
|
foreach (DataRow row in dt.Rows)
|
||||||
{
|
{
|
||||||
|
var map_skus = JsonUtils.SerializeObject(JsonUtils.DeserializeJsonToObject<pddFrontGoods3Lite>(row["map_skus"].ParseToNullableString()));
|
||||||
if (WXBuyMapInfoLst.Where(b => b.spu_code == row["spu_code"].ParseToNullableString()).ToList().Count < 5)
|
if (WXBuyMapInfoLst.Where(b => b.spu_code == row["spu_code"].ParseToNullableString()).ToList().Count < 5)
|
||||||
WXBuyMapInfoLst.Add(new WXBuyMapSkusInfo()
|
WXBuyMapInfoLst.Add(new WXBuyMapSkusInfo()
|
||||||
{
|
{
|
||||||
@@ -626,7 +661,7 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
map_url = row["map_url"].ParseToNullableString(),
|
map_url = row["map_url"].ParseToNullableString(),
|
||||||
map_goods_name = row["map_goods_name"].ParseToNullableString(),
|
map_goods_name = row["map_goods_name"].ParseToNullableString(),
|
||||||
map_goods_id = row["map_goods_id"].ParseToNullableString(),
|
map_goods_id = row["map_goods_id"].ParseToNullableString(),
|
||||||
map_skus = row["map_skus"].ParseToNullableString(),
|
map_skus = map_skus,
|
||||||
map_send_address = row["map_send_address"].ParseToNullableString(),
|
map_send_address = row["map_send_address"].ParseToNullableString(),
|
||||||
transit_warehouse_id = row["transit_warehouse_id"].ParseToNullableString(),
|
transit_warehouse_id = row["transit_warehouse_id"].ParseToNullableString(),
|
||||||
add_time = Convert.ToDateTime(row["add_time"]),
|
add_time = Convert.ToDateTime(row["add_time"]),
|
||||||
@@ -1003,6 +1038,12 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
intercept_return_info = row["intercept_return_info"].ParseToNullableString(),
|
intercept_return_info = row["intercept_return_info"].ParseToNullableString(),
|
||||||
intercept_return_status = row["intercept_return_status"].ParseToNullableInt(),
|
intercept_return_status = row["intercept_return_status"].ParseToNullableInt(),
|
||||||
intercept_return_time = row["intercept_return_status"].ParseToNullableString().ParseToDateTimeNullable(),
|
intercept_return_time = row["intercept_return_status"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
|
is_manual_shipment = row["is_manual_shipment"].ParseToInt(),
|
||||||
|
manual_shipment_status = row["manual_shipment_status"].ParseToNullableInt(),
|
||||||
|
location_code = row["location_code"].ParseToNullableString(),
|
||||||
|
location_write_time = row["location_write_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
|
virtual_express_company = row["virtual_express_company"].ParseToNullableString(),
|
||||||
|
virtual_waybill_no = row["virtual_waybill_no"].ParseToNullableString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return oms_wei_external_procurement_log_list;
|
return oms_wei_external_procurement_log_list;
|
||||||
@@ -1103,6 +1144,17 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
real_logistics_code = row["real_logistics_code"].ParseToNullableString(),
|
real_logistics_code = row["real_logistics_code"].ParseToNullableString(),
|
||||||
real_logistics_express_code = row["real_logistics_express_code"].ParseToNullableString(),
|
real_logistics_express_code = row["real_logistics_express_code"].ParseToNullableString(),
|
||||||
retry_acquire_success = row["retry_acquire_success"].ParseToNullableInt(),
|
retry_acquire_success = row["retry_acquire_success"].ParseToNullableInt(),
|
||||||
|
location_code = row["location_code"].ParseToNullableString(),
|
||||||
|
location_write_time = row["location_write_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
|
has_return = row["has_return"].ParseToNullableInt(),
|
||||||
|
intercept_address_info = row["intercept_address_info"].ParseToNullableString(),
|
||||||
|
intercept_address_status = row["intercept_address_status"].ParseToNullableInt(),
|
||||||
|
intercept_address_time = row["intercept_address_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
|
intercept_return_info = row["intercept_return_info"].ParseToNullableString(),
|
||||||
|
intercept_return_status = row["intercept_return_status"].ParseToNullableInt(),
|
||||||
|
intercept_return_time = row["intercept_address_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
|
out_order_no = row["out_order_no"].ParseToNullableString(),
|
||||||
|
out_sku_id = row["out_sku_id"].ParseToNullableString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return oms_wei_transfer_extra_package_list;
|
return oms_wei_transfer_extra_package_list;
|
||||||
@@ -2594,11 +2646,11 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
id = row["id"].ParseToLong(),
|
id = row["id"].ParseToLong(),
|
||||||
order_no = row["order_no"].ParseToString(),
|
order_no = row["order_no"].ParseToString(),
|
||||||
order_code = row["order_code"].ParseToString(),
|
order_code = row["order_code"].ParseToString(),
|
||||||
inbound_time = row["inbound_time"].ParseToString().ParseToDateTimeNullable(),
|
inbound_time = row["inbound_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
outbound_time = row["outbound_time"].ParseToString().ParseToDateTimeNullable(),
|
outbound_time = row["outbound_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
account_user = row["account_user"].ParseToString(),
|
account_user = row["account_user"].ParseToString(),
|
||||||
after_sale_no = row["after_sale_no"].ParseToString(),
|
after_sale_no = row["after_sale_no"].ParseToString(),
|
||||||
created_time = row["created_time"].ParseToString().ParseToDateTimeNullable(),
|
created_time = row["created_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
create_user = row["create_user"].ParseToString(),
|
create_user = row["create_user"].ParseToString(),
|
||||||
downstream_express_code = row["downstream_express_code"].ParseToString(),
|
downstream_express_code = row["downstream_express_code"].ParseToString(),
|
||||||
downstream_waybill = row["downstream_waybill"].ParseToString(),
|
downstream_waybill = row["downstream_waybill"].ParseToString(),
|
||||||
@@ -2614,10 +2666,19 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
return_express_company = row["return_express_company"].ParseToString(),
|
return_express_company = row["return_express_company"].ParseToString(),
|
||||||
return_or_exchange = row["return_or_exchange"].ParseToNullableInt(),
|
return_or_exchange = row["return_or_exchange"].ParseToNullableInt(),
|
||||||
status = row["status"].ParseToNullableInt(),
|
status = row["status"].ParseToNullableInt(),
|
||||||
updated_time = row["updated_time"].ParseToString().ParseToDateTimeNullable(),
|
updated_time = row["updated_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
update_user = row["update_user"].ParseToString(),
|
update_user = row["update_user"].ParseToString(),
|
||||||
warehouse_status = row["warehouse_status"].ParseToNullableInt(),
|
warehouse_status = row["warehouse_status"].ParseToNullableInt(),
|
||||||
|
postage = row["postage"].ParseToNullableInt(),
|
||||||
|
location_code = row["location_code"].ParseToNullableString(),
|
||||||
|
location_write_time = row["location_write_time"].ParseToNullableString().ParseToDateTimeNullable(),
|
||||||
|
pack_type = row["pack_type"].ParseToNullableInt(),
|
||||||
|
order_void_status = row["order_void_status"].ParseToNullableInt(),
|
||||||
};
|
};
|
||||||
|
if(order.order_no == "3739776364860294912")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
refundItemList.Add(order);
|
refundItemList.Add(order);
|
||||||
}
|
}
|
||||||
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||||||
|
|||||||
@@ -70,9 +70,11 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
MysqlUtils mySql = new MysqlUtils(conn);
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
string sql;
|
string sql;
|
||||||
bool isPayUser = false;
|
bool isPayUser = false;
|
||||||
|
int userGroup = 4;
|
||||||
|
string parentUserName = "";
|
||||||
if (!isAdmin)
|
if (!isAdmin)
|
||||||
{
|
{
|
||||||
sql = "select u.authority,uu.authority as main_authority " +
|
sql = "select u.parent_user_name,u.group_id,u.authority,uu.authority as main_authority " +
|
||||||
"FROM wxxd.user u LEFT JOIN wxxd.user uu ON uu.user_name=u.parent_user_name where u.user_name='"
|
"FROM wxxd.user u LEFT JOIN wxxd.user uu ON uu.user_name=u.parent_user_name where u.user_name='"
|
||||||
+ user_name + "'";
|
+ user_name + "'";
|
||||||
|
|
||||||
@@ -88,6 +90,12 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\",\"data\":null}";
|
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\",\"data\":null}";
|
||||||
}
|
}
|
||||||
isPayUser = dtRow["authority"].ToString().Contains("充值用户") || dtRow["main_authority"].ToString().Contains("充值用户");
|
isPayUser = dtRow["authority"].ToString().Contains("充值用户") || dtRow["main_authority"].ToString().Contains("充值用户");
|
||||||
|
userGroup = dtRow["group_id"].ParseToInt();
|
||||||
|
parentUserName = dtRow["parent_user_name"].ParseToString();
|
||||||
|
if (userGroup != 3 && parentUserName.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return "{\"code\":501,\"msg\":\"用户名错误\",\"data\":null}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "SELECT COUNT(*) FROM wxxd.shop s WHERE 1=1";
|
sql = "SELECT COUNT(*) FROM wxxd.shop s WHERE 1=1";
|
||||||
@@ -97,7 +105,12 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
if (isAdmin)
|
if (isAdmin)
|
||||||
where += " and (s.cookie='' or s.shop_id!='')";
|
where += " and (s.cookie='' or s.shop_id!='')";
|
||||||
if (!isAdmin)
|
if (!isAdmin)
|
||||||
where += " and (s.user_name='" + user_name + "' or s.sub_user_name like '%" + user_name + "%')";
|
{
|
||||||
|
if (userGroup != 3)
|
||||||
|
where += " and (s.user_name='" + parentUserName + "' and s.sub_user_name like '%" + user_name + "%')";
|
||||||
|
else
|
||||||
|
where += " and (s.user_name='" + user_name + "')";
|
||||||
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
|
if (!string.IsNullOrWhiteSpace(operate_sub_sa_name))
|
||||||
where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
|
where += " and s.operate_sub_sa_name='" + operate_sub_sa_name + "'";
|
||||||
if (!string.IsNullOrWhiteSpace(search_user_name))
|
if (!string.IsNullOrWhiteSpace(search_user_name))
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
using KJD_Web.Model;
|
using KJD_Web.Model;
|
||||||
using KJD_Web.Model.PddModel;
|
using KJD_Web.Model.PddModel;
|
||||||
using KJD_Web.Model.WxModel;
|
using KJD_Web.Model.WxModel;
|
||||||
|
using KJD_Web.Services.Users;
|
||||||
using KJD_Web.Utils;
|
using KJD_Web.Utils;
|
||||||
|
using MAX.Core.DependencyInjection;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Mysqlx.Crud;
|
using Mysqlx.Crud;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -14,13 +18,18 @@ using System.Reflection;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.ApplicationServices;
|
using System.Web.ApplicationServices;
|
||||||
|
using System.Web.Http;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
using System.Web.UI.WebControls;
|
using System.Web.UI.WebControls;
|
||||||
|
|
||||||
namespace KJD_Web.BLL.WXXD
|
namespace KJD_Web.BLL.WXXD
|
||||||
{
|
{
|
||||||
public class WXUserManage
|
public class WXUserManage : ITransientDependency
|
||||||
{
|
{
|
||||||
|
public WXUserManage()
|
||||||
|
{
|
||||||
|
_userService =(UserService) GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(UserService));
|
||||||
|
}
|
||||||
public static bool GetSign(string signData, bool isUserLogin = false)
|
public static bool GetSign(string signData, bool isUserLogin = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(signData)) { return false; }
|
if (string.IsNullOrEmpty(signData)) { return false; }
|
||||||
@@ -45,6 +54,8 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
|
|
||||||
public static DateTime dtAuthorizationExpireTime = DateTime.Now;
|
public static DateTime dtAuthorizationExpireTime = DateTime.Now;
|
||||||
public static string e57Authorization = "";
|
public static string e57Authorization = "";
|
||||||
|
private readonly UserService _userService;
|
||||||
|
|
||||||
public string GetE57Authorization(string inputData)
|
public string GetE57Authorization(string inputData)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(inputData))
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
@@ -138,6 +149,7 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
postage_per_order = row.Table.Columns.Contains("postage_per_order") ? row["postage_per_order"].ParseToNullableDecimal() : null,
|
postage_per_order = row.Table.Columns.Contains("postage_per_order") ? row["postage_per_order"].ParseToNullableDecimal() : null,
|
||||||
refund_postage_per_order = row.Table.Columns.Contains("refund_postage_per_order") ? row["refund_postage_per_order"].ParseToNullableDecimal() : null,
|
refund_postage_per_order = row.Table.Columns.Contains("refund_postage_per_order") ? row["refund_postage_per_order"].ParseToNullableDecimal() : null,
|
||||||
gift_oem_amount_per_order = row.Table.Columns.Contains("gift_oem_amount_per_order") ? row["gift_oem_amount_per_order"].ParseToNullableDecimal() : null,
|
gift_oem_amount_per_order = row.Table.Columns.Contains("gift_oem_amount_per_order") ? row["gift_oem_amount_per_order"].ParseToNullableDecimal() : null,
|
||||||
|
image_analysis_quota = row.Table.Columns.Contains("image_analysis_quota") ? row["image_analysis_quota"].ParseToInt() : 0,
|
||||||
};
|
};
|
||||||
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
|
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
|
||||||
var main_oem_id = row.Table.Columns.Contains("main_oem_id") ? row["main_oem_id"].ParseToString() : "";
|
var main_oem_id = row.Table.Columns.Contains("main_oem_id") ? row["main_oem_id"].ParseToString() : "";
|
||||||
@@ -191,7 +203,12 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
var data = JsonUtils.SerializeObjectToString(user);
|
var data = JsonUtils.SerializeObjectToString(user);
|
||||||
|
|
||||||
mySql.Close();
|
mySql.Close();
|
||||||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
var prodApiUrl = (System.Configuration.ConfigurationManager.ConnectionStrings["ProdApiUrl"]?.ConnectionString).ParseToString();
|
||||||
|
var orderApiUrl = (System.Configuration.ConfigurationManager.ConnectionStrings["OrderApiUrl"]?.ConnectionString).ParseToString();
|
||||||
|
var AllowTraditionalBuyAddress = (System.Configuration.ConfigurationManager.ConnectionStrings["AllowTraditionalBuyAddress"]?.ConnectionString).ParseToString();
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"prod_api_url\":\"" + prodApiUrl + "\",\"order_api_url\":\"" + orderApiUrl +
|
||||||
|
"\",\"allow_traditional_buy_address\":\"" + AllowTraditionalBuyAddress +
|
||||||
|
"\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
}
|
}
|
||||||
mySql.Close();
|
mySql.Close();
|
||||||
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
|
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
|
||||||
@@ -548,6 +565,7 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
refund_postage_per_order = row.Table.Columns.Contains("refund_postage_per_order") ? row["refund_postage_per_order"].ParseToNullableDecimal() : null,
|
refund_postage_per_order = row.Table.Columns.Contains("refund_postage_per_order") ? row["refund_postage_per_order"].ParseToNullableDecimal() : null,
|
||||||
gift_oem_amount_per_order = row.Table.Columns.Contains("gift_oem_amount_per_order") ? row["gift_oem_amount_per_order"].ParseToNullableDecimal() : null,
|
gift_oem_amount_per_order = row.Table.Columns.Contains("gift_oem_amount_per_order") ? row["gift_oem_amount_per_order"].ParseToNullableDecimal() : null,
|
||||||
sync_logistics_per_order = row.Table.Columns.Contains("sync_logistics_per_order") ? row["sync_logistics_per_order"].ParseToNullableDecimal() : null,
|
sync_logistics_per_order = row.Table.Columns.Contains("sync_logistics_per_order") ? row["sync_logistics_per_order"].ParseToNullableDecimal() : null,
|
||||||
|
shop_renewal_platform_floor_fee = row.Table.Columns.Contains("shop_renewal_platform_floor_fee") ? row["shop_renewal_platform_floor_fee"].ParseToNullableDecimal() : null,
|
||||||
};
|
};
|
||||||
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
|
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
|
||||||
var main_oem_id = row.Table.Columns.Contains("main_oem_id") ? row["main_oem_id"].ParseToString() : "";
|
var main_oem_id = row.Table.Columns.Contains("main_oem_id") ? row["main_oem_id"].ParseToString() : "";
|
||||||
@@ -583,6 +601,24 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
}
|
}
|
||||||
userList.Add(user);
|
userList.Add(user);
|
||||||
}
|
}
|
||||||
|
#region 返回新的OEM加价
|
||||||
|
var mainUsers = userList.Where(a => a.group_id == "3").ToList();
|
||||||
|
var prices = _userService.GetUserFinalPrices(mainUsers.Select(a => new UserEntity
|
||||||
|
{
|
||||||
|
UserName = a.user_name,
|
||||||
|
OemId = a.oem_id
|
||||||
|
}));
|
||||||
|
foreach (var user in mainUsers)
|
||||||
|
{
|
||||||
|
var userPrices = prices[user.user_name];
|
||||||
|
// 批量价格单位为分,旧版列表字段单位为元。
|
||||||
|
user.postage_per_order = userPrices[UserPaymentTypes.中转仓扣费支出] / 100m;
|
||||||
|
user.refund_postage_per_order = userPrices[UserPaymentTypes.退货包裹扣费支出] / 100m;
|
||||||
|
user.gift_oem_amount_per_order = userPrices[UserPaymentTypes.礼物单支出] / 100m;
|
||||||
|
user.sync_logistics_per_order = userPrices[UserPaymentTypes.同步物流] / 100m;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
var data = JsonUtils.SerializeObjectToString(userList);
|
var data = JsonUtils.SerializeObjectToString(userList);
|
||||||
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
||||||
}
|
}
|
||||||
@@ -768,7 +804,7 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
var gift_oem_amount_per_order = RegexUtils.GetStringQuery(ref inputData, "gift_oem_amount_per_order")?.Replace("'", "\\'");
|
var gift_oem_amount_per_order = RegexUtils.GetStringQuery(ref inputData, "gift_oem_amount_per_order")?.Replace("'", "\\'");
|
||||||
var sync_logistics_per_order = RegexUtils.GetStringQuery(ref inputData, "sync_logistics_per_order")?.Replace("'", "\\'");
|
var sync_logistics_per_order = RegexUtils.GetStringQuery(ref inputData, "sync_logistics_per_order")?.Replace("'", "\\'");
|
||||||
var oem_id = RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'");
|
var oem_id = RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'");
|
||||||
|
var shop_renewal_platform_floor_fee = RegexUtils.GetStringQuery(ref inputData, "shop_renewal_platform_floor_fee")?.Replace("'", "\\'");
|
||||||
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
MysqlUtils mySql = new MysqlUtils(conn);
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
string sql = "";
|
string sql = "";
|
||||||
@@ -798,7 +834,13 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
if (forbidden_page != null)
|
if (forbidden_page != null)
|
||||||
sql += " forbidden_page='" + forbidden_page + "',";
|
sql += " forbidden_page='" + forbidden_page + "',";
|
||||||
if (shop_points_per_month != null)
|
if (shop_points_per_month != null)
|
||||||
sql += " shop_points_per_month=" + shop_points_per_month + ",";
|
{
|
||||||
|
sql += " shop_points_per_month=" + Math.Max(10, shop_points_per_month.ParseToDecimal(10)) + ",";
|
||||||
|
}
|
||||||
|
if (shop_renewal_platform_floor_fee != null)
|
||||||
|
{
|
||||||
|
sql += " shop_renewal_platform_floor_fee=" + Math.Max(5, shop_renewal_platform_floor_fee.ParseToDecimal(15)) + ",";
|
||||||
|
}
|
||||||
if (postage_per_order != null)
|
if (postage_per_order != null)
|
||||||
sql += " postage_per_order=" + postage_per_order + ",";
|
sql += " postage_per_order=" + postage_per_order + ",";
|
||||||
if (refund_postage_per_order != null)
|
if (refund_postage_per_order != null)
|
||||||
@@ -1098,14 +1140,14 @@ namespace KJD_Web.BLL.WXXD
|
|||||||
if (option_type == "续费")
|
if (option_type == "续费")
|
||||||
{
|
{
|
||||||
sql = "SELECT shop_points_per_month FROM `wxxd`.`user` WHERE user_name='" + user_name + "'";
|
sql = "SELECT shop_points_per_month FROM `wxxd`.`user` WHERE user_name='" + user_name + "'";
|
||||||
shopPointsPerMonth = mySql.ExecuteFirstDecimal(sql); // 店铺续费一个月的点数,默认30,可以设置为其他值
|
shopPointsPerMonth = mySql.ExecuteFirstDecimal(sql); // 店铺续费一个月的点数,默认30,最低10,可以设置为其他值
|
||||||
if (!string.IsNullOrEmpty(mySql.Message))
|
if (!string.IsNullOrEmpty(mySql.Message))
|
||||||
{
|
{
|
||||||
mySql.RollBack();
|
mySql.RollBack();
|
||||||
mySql.Close();
|
mySql.Close();
|
||||||
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||||
}
|
}
|
||||||
shopPointsPerMonth = Math.Max(30, shopPointsPerMonth);
|
shopPointsPerMonth = Math.Max(10, shopPointsPerMonth);
|
||||||
|
|
||||||
if (delta_points <= 0 || delta_points.ParseToInt().ParseToDecimal() != delta_points || delta_points.ParseToInt() % shopPointsPerMonth.ParseToInt() > 0)
|
if (delta_points <= 0 || delta_points.ParseToInt().ParseToDecimal() != delta_points || delta_points.ParseToInt() % shopPointsPerMonth.ParseToInt() > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -444,5 +444,17 @@ namespace KJD_Web.Controllers.BXX
|
|||||||
|
|
||||||
return JsonString(result);
|
return JsonString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IHttpActionResult SaveProductSafety()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new BXXProductManage().SaveProductSafety(jsontext);
|
||||||
|
|
||||||
|
return JsonString(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,6 +403,14 @@ namespace KJD_Web.Controllers.WX
|
|||||||
return JsonString(result);
|
return JsonString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IHttpActionResult wx_api_get_audit_quota()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
var result = new BXXProductManage().WxApiGetAuditQuota(jsontext);
|
||||||
|
|
||||||
|
return JsonString(result);
|
||||||
|
}
|
||||||
|
|
||||||
public IHttpActionResult wx_api_category_classify()
|
public IHttpActionResult wx_api_category_classify()
|
||||||
{
|
{
|
||||||
string jsontext = GetRequestJsonString();
|
string jsontext = GetRequestJsonString();
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ namespace KJD_Web.Controllers.WX
|
|||||||
ret = _statsService.GetShopOrderDetails(request.StartDate, request.EndDate, request.OrderType, "", request.ShopIds);
|
ret = _statsService.GetShopOrderDetails(request.StartDate, request.EndDate, request.OrderType, "", request.ShopIds);
|
||||||
return Ok(ApiResult.Success(ret));
|
return Ok(ApiResult.Success(ret));
|
||||||
}
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.ServerError));
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return Ok(ApiResult.Fail("查询失败", ResultCode.ServerError));
|
return Ok(ApiResult.Fail("查询失败", ResultCode.ServerError));
|
||||||
@@ -197,7 +201,7 @@ namespace KJD_Web.Controllers.WX
|
|||||||
|
|
||||||
foreach (var item in ret)
|
foreach (var item in ret)
|
||||||
{
|
{
|
||||||
item.ShopId= dict[item.ShopId];
|
item.ShopId = dict[item.ShopId];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(ApiResult.Success(ret));
|
return Ok(ApiResult.Success(ret));
|
||||||
|
|||||||
@@ -18,7 +18,18 @@ public partial class WXShopController : AsmxApiController
|
|||||||
{
|
{
|
||||||
_shopService = shopService;
|
_shopService = shopService;
|
||||||
}
|
}
|
||||||
|
public IHttpActionResult GetShopKey(string ordersn)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var appkey = _shopService.GetShopKey(ordersn);
|
||||||
|
return Ok(ApiResult.Success(appkey, "操作成功"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新商铺永久续费
|
/// 更新商铺永久续费
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using KJD_Web.BLL.WXXD;
|
|||||||
using KJD_Web.Requests.Users;
|
using KJD_Web.Requests.Users;
|
||||||
using KJD_Web.Utils;
|
using KJD_Web.Utils;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
|
using Org.BouncyCastle.Asn1.Ocsp;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
using Store.Framework.Dtos;
|
using Store.Framework.Dtos;
|
||||||
using Store.Framework.Models;
|
using Store.Framework.Models;
|
||||||
using System;
|
using System;
|
||||||
@@ -24,7 +26,12 @@ namespace KJD_Web.Controllers
|
|||||||
[Route("{action}")]
|
[Route("{action}")]
|
||||||
public partial class WXUserController : AsmxApiController
|
public partial class WXUserController : AsmxApiController
|
||||||
{
|
{
|
||||||
|
private readonly WXUserManage _wxUserManage;
|
||||||
|
|
||||||
|
public WXUserController(WXUserManage wxUserManage)
|
||||||
|
{
|
||||||
|
_wxUserManage = wxUserManage;
|
||||||
|
}
|
||||||
//GetE57Authorization
|
//GetE57Authorization
|
||||||
public IHttpActionResult get_e57_authorization()
|
public IHttpActionResult get_e57_authorization()
|
||||||
{
|
{
|
||||||
@@ -133,10 +140,20 @@ namespace KJD_Web.Controllers
|
|||||||
var uu = RegexUtils.GetStringQuery(ref inputData, "uu")?.Replace("'", "\\'").ParseToBool();
|
var uu = RegexUtils.GetStringQuery(ref inputData, "uu")?.Replace("'", "\\'").ParseToBool();
|
||||||
|
|
||||||
if (uu != true)
|
if (uu != true)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var result = new WXUserManage().UpdateUser(inputData);
|
var result = new WXUserManage().UpdateUser(inputData);
|
||||||
|
|
||||||
|
|
||||||
|
_userService.SetMarkupRule(inputData);
|
||||||
return JsonString(result);
|
return JsonString(result);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ using KJD_Web.Services.Users;
|
|||||||
using MAX.Core.Logger;
|
using MAX.Core.Logger;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
using Org.BouncyCastle.Ocsp;
|
using Org.BouncyCastle.Ocsp;
|
||||||
|
using Store.Framework.DependencyInjection;
|
||||||
using Store.Framework.Dtos;
|
using Store.Framework.Dtos;
|
||||||
using Store.Framework.Models;
|
using Store.Framework.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
using Ubiety.Dns.Core;
|
||||||
|
|
||||||
namespace KJD_Web.Controllers
|
namespace KJD_Web.Controllers
|
||||||
{
|
{
|
||||||
@@ -15,12 +17,106 @@ namespace KJD_Web.Controllers
|
|||||||
{
|
{
|
||||||
private readonly UserService _userService;
|
private readonly UserService _userService;
|
||||||
private readonly ILoggerFacade _logger;
|
private readonly ILoggerFacade _logger;
|
||||||
|
private readonly string OpenApiKey;
|
||||||
public WXUserController(UserService userService, ILoggerFacade logger)
|
public WXUserController(UserService userService, ILoggerFacade logger)
|
||||||
{
|
{
|
||||||
|
OpenApiKey = System.Configuration.ConfigurationManager.AppSettings["OpenApiKey"].ParseToString();
|
||||||
|
|
||||||
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
|
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IHttpActionResult SetMarkupRule(SetMarkupRuleRequest request)
|
||||||
|
{
|
||||||
|
if (!ValidateSign(request)) return Ok(ApiResult.Fail("校验失败", 999));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (request.TargetType == Store.Contracts.User.Enums.OEMMarkupTargetType.OEM)
|
||||||
|
{
|
||||||
|
request.PaymentType = Store.Contracts.User.Enums.UserPaymentTypes.中转仓扣费支出;
|
||||||
|
_userService.SetMarkupRule(request);
|
||||||
|
request.PaymentType = Store.Contracts.User.Enums.UserPaymentTypes.退货包裹扣费支出;
|
||||||
|
_userService.SetMarkupRule(request);
|
||||||
|
request.PaymentType = Store.Contracts.User.Enums.UserPaymentTypes.礼物单支出;
|
||||||
|
_userService.SetMarkupRule(request);
|
||||||
|
request.PaymentType = Store.Contracts.User.Enums.UserPaymentTypes.同步物流;
|
||||||
|
_userService.SetMarkupRule(request);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_userService.SetMarkupRule(request);
|
||||||
|
}
|
||||||
|
return Ok(ApiResult.Success("加价规则设置成功"));
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.Forbidden));
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.ValidationError));
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.BusinessError));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "设置加价规则失败, UserName=" + request.UserName + ", TargetId=" + request.TargetId);
|
||||||
|
return Ok(ApiResult.Fail("设置加价规则失败,请稍后重试", ResultCode.ServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IHttpActionResult GetUserMarkups( GetUserMarkupsRequest request)
|
||||||
|
{
|
||||||
|
//if (!ValidateSign(request)) return Ok(ApiResult.Fail("校验失败", 999));
|
||||||
|
//if (!ModelState.IsValid) return Ok(ApiResult.Fail("请求参数格式错误", ResultCode.ValidationError));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Success(data: _userService.GetUserMarkups(request.UserName, request.PaymentType)));
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.ValidationError));
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.BusinessError));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "查询代理加价失败, UserName=" + request.UserName);
|
||||||
|
return Ok(ApiResult.Fail("查询代理加价失败,请稍后重试", ResultCode.ServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IHttpActionResult GetUserConfig(SignRequestBase request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var config = _userService.GetUserConfig(request.UserName);
|
||||||
|
return Ok(ApiResult.Success(data: config));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IHttpActionResult SaveUserConfig(UserConfigRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var config = _userService.SaveUserConfig(request.UserName, request.Config);
|
||||||
|
return Ok(ApiResult.Success(config));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询
|
/// 查询
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -121,5 +217,86 @@ namespace KJD_Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 购买图片检测配额
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IHttpActionResult BuyImageAnalysisQuota(ImageAnalysisRequest request)
|
||||||
|
{
|
||||||
|
if (!ValidateSign(request))
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail("校验失败", 999));
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = _userService.BuyImageAnalysisQuota(request);
|
||||||
|
return Ok(ApiResult.Success(response, "兑换成功"));
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.ValidationError));
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail(ex.Message, ResultCode.BusinessError));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "积分购买图片检测, UserName=" + (request == null ? null : request.UserName) + ", ShopId=" + (request == null ? null : request.Amount));
|
||||||
|
return Ok(ApiResult.Fail("购买图片检测失败,请稍后重试", ResultCode.ServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部调用 图片检测配额消费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IHttpActionResult UseImageAnalysisQuota(string token, string userName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (token != OpenApiKey)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail("调用失败"));
|
||||||
|
}
|
||||||
|
if (userName == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("不存在的用户");
|
||||||
|
}
|
||||||
|
var ret = _userService.UseImageAnalysisQuota(userName);
|
||||||
|
return Ok(ApiResult.Success(ret, "兑换成功"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "外部调用失败");
|
||||||
|
return Ok(ApiResult.Fail("消耗检图失败,请稍后重试", ResultCode.ServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHttpActionResult GetUserImageAnalysisQuota(string token,string userName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (token != OpenApiKey)
|
||||||
|
{
|
||||||
|
return Ok(ApiResult.Fail("调用失败"));
|
||||||
|
}
|
||||||
|
if (userName == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("不存在的用户");
|
||||||
|
}
|
||||||
|
var ret = _userService.GetUserImageAnalysisQuota(userName);
|
||||||
|
return Ok(ApiResult.Success(ret, "查询成功"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "外部调用失败");
|
||||||
|
return Ok(ApiResult.Fail("查询失败,请稍后重试", ResultCode.ServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ using MAX.Core.DependencyInjection;
|
|||||||
using MAX.Core.Logger;
|
using MAX.Core.Logger;
|
||||||
using MAX.Framework.Logger;
|
using MAX.Framework.Logger;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
using NaiBa.Util.Extension;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Store.Framework.DependencyInjection;
|
using Store.Framework.DependencyInjection;
|
||||||
@@ -36,7 +37,11 @@ namespace KJD_Web
|
|||||||
GlobalConfiguration.Configuration.DependencyResolver =
|
GlobalConfiguration.Configuration.DependencyResolver =
|
||||||
new AutofacWebApiDependencyResolver(container);
|
new AutofacWebApiDependencyResolver(container);
|
||||||
|
|
||||||
|
bool BackgroundJobs = System.Configuration.ConfigurationManager.AppSettings["BackgroundJobs"].ParseToBool();
|
||||||
|
if (BackgroundJobs)
|
||||||
|
{
|
||||||
ContainerConfig.BuildHangfire(GlobalConfiguration.Configuration.DependencyResolver);
|
ContainerConfig.BuildHangfire(GlobalConfiguration.Configuration.DependencyResolver);
|
||||||
|
}
|
||||||
|
|
||||||
GlobalConfiguration.Configure(WebApiConfig.Register);
|
GlobalConfiguration.Configure(WebApiConfig.Register);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,6 +216,7 @@
|
|||||||
<Compile Include="Controllers\ShopController.cs" />
|
<Compile Include="Controllers\ShopController.cs" />
|
||||||
<Compile Include="Controllers\UserController.cs" />
|
<Compile Include="Controllers\UserController.cs" />
|
||||||
<Compile Include="Mappers\WeOrderMapper.cs" />
|
<Compile Include="Mappers\WeOrderMapper.cs" />
|
||||||
|
<Compile Include="Model\PddModel\PddFrontGoods3Lite.cs" />
|
||||||
<Compile Include="Model\WxModel\oms_wei_ewaybill_path.cs" />
|
<Compile Include="Model\WxModel\oms_wei_ewaybill_path.cs" />
|
||||||
<Compile Include="Model\WxModel\oms_wei_transfer_extra_package.cs" />
|
<Compile Include="Model\WxModel\oms_wei_transfer_extra_package.cs" />
|
||||||
<Compile Include="Model\WxModel\ShopRevenueStatistics.cs" />
|
<Compile Include="Model\WxModel\ShopRevenueStatistics.cs" />
|
||||||
@@ -227,7 +228,12 @@
|
|||||||
<Compile Include="Requests\Shops\ShopStatsGroupType.cs" />
|
<Compile Include="Requests\Shops\ShopStatsGroupType.cs" />
|
||||||
<Compile Include="Requests\Shops\ShopStatsRequest.cs" />
|
<Compile Include="Requests\Shops\ShopStatsRequest.cs" />
|
||||||
<Compile Include="Requests\Users\CUUserInfoRequest.cs" />
|
<Compile Include="Requests\Users\CUUserInfoRequest.cs" />
|
||||||
|
<Compile Include="Requests\Users\PurchaseImageQuotaRequest.cs" />
|
||||||
<Compile Include="Requests\Users\RebateRecordRequest.cs" />
|
<Compile Include="Requests\Users\RebateRecordRequest.cs" />
|
||||||
|
<Compile Include="Requests\Users\UserConfigRequest.cs" />
|
||||||
|
<Compile Include="Requests\Users\SetMarkupRuleRequest.cs" />
|
||||||
|
<Compile Include="Requests\Users\GetUserMarkupsRequest.cs" />
|
||||||
|
<Compile Include="Responses\Users\UserMarkupResponse.cs" />
|
||||||
<Compile Include="Responses\Shops\ShopOrderDetailResponse.cs" />
|
<Compile Include="Responses\Shops\ShopOrderDetailResponse.cs" />
|
||||||
<Compile Include="Responses\Shops\ShopStatsResponse.cs" />
|
<Compile Include="Responses\Shops\ShopStatsResponse.cs" />
|
||||||
<Compile Include="Responses\Shops\ShopStatsTrendResponse.cs" />
|
<Compile Include="Responses\Shops\ShopStatsTrendResponse.cs" />
|
||||||
@@ -276,10 +282,12 @@
|
|||||||
<Compile Include="Requests\Users\ShopRenewRequest.cs" />
|
<Compile Include="Requests\Users\ShopRenewRequest.cs" />
|
||||||
<Compile Include="Services\ImageCacheService.cs" />
|
<Compile Include="Services\ImageCacheService.cs" />
|
||||||
<Compile Include="Services\Buyer\BuyerService.cs" />
|
<Compile Include="Services\Buyer\BuyerService.cs" />
|
||||||
|
<Compile Include="Services\Products\ProductService.cs" />
|
||||||
<Compile Include="Services\Shops\ShopRevenueStatisticsService.cs" />
|
<Compile Include="Services\Shops\ShopRevenueStatisticsService.cs" />
|
||||||
<Compile Include="Services\Shops\ShopService.cs" />
|
<Compile Include="Services\Shops\ShopService.cs" />
|
||||||
<Compile Include="Services\Shops\ShopStatsJob.cs" />
|
<Compile Include="Services\Shops\ShopStatsJob.cs" />
|
||||||
<Compile Include="Services\Users\UserService.FeeRecord.cs" />
|
<Compile Include="Services\Users\UserService.FeeRecord.cs" />
|
||||||
|
<Compile Include="Services\Users\OEMMarkupBaseFeeSettings.cs" />
|
||||||
<Compile Include="Services\Users\UserService.OEM.cs" />
|
<Compile Include="Services\Users\UserService.OEM.cs" />
|
||||||
<Compile Include="Services\Users\UserService.cs" />
|
<Compile Include="Services\Users\UserService.cs" />
|
||||||
<Compile Include="SignValidateFilterAttribute.cs" />
|
<Compile Include="SignValidateFilterAttribute.cs" />
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ namespace KJD_Web.Model
|
|||||||
public int is_relation { get; set; }
|
public int is_relation { get; set; }
|
||||||
public string add_user_name { get; set; }
|
public string add_user_name { get; set; }
|
||||||
public int? is_del { get; set; }
|
public int? is_del { get; set; }
|
||||||
|
public bool? is_safe { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class KJDDBProduct : DBProductResultParam
|
public class KJDDBProduct : DBProductResultParam
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Model.PddModel;
|
||||||
|
public class pddFrontGoods3Lite
|
||||||
|
{
|
||||||
|
public long? goodsId { get; set; } // 1661424397,
|
||||||
|
public string goodsName { get; set; } // "红薏仁5斤装 红薏仁米小薏米仁农家自产新红薏米1斤2斤苡仁糙薏米",
|
||||||
|
public long? mallId { get; set; } // 525159017
|
||||||
|
public string mallName { get; set; }
|
||||||
|
public List<frontSkuInfo3Lite> skus { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class frontSkuInfo3Lite
|
||||||
|
{
|
||||||
|
public long? skuId { get; set; } // 28790184768,
|
||||||
|
public long? goodsId { get; set; } // 1661424397,
|
||||||
|
public string thumbUrl { get; set; } /* "https://t00img.yangkeduo.com/t10img/images/2018-06-09/5c7746a3608e75a2b65926f4ed0f34cb.jpeg", */
|
||||||
|
//public int? initQuantity { get; set; } // 0,
|
||||||
|
//public int? quantity { get; set; } // 1000,
|
||||||
|
//public int? limitQuantity { get; set; } // 999999,
|
||||||
|
//public int? soldQuantity { get; set; } // 0,
|
||||||
|
//public int? hotSale { get; set; } // 1,
|
||||||
|
//public int? defaultQuantity { get; set; } // 100,
|
||||||
|
//public int? isOnsale { get; set; } // 1,
|
||||||
|
public string spec { get; set; } // "677094835",
|
||||||
|
public List<frontSpecInfo3> specs { get; set; }
|
||||||
|
public int? price { get; set; } // 0,
|
||||||
|
public string normalPrice { get; set; } // "14.5",
|
||||||
|
public string groupPrice { get; set; } // "13.5",
|
||||||
|
public int? oldGroupPrice { get; set; } /* 1350, */
|
||||||
|
//public int? marketPrice { get; set; } // 0,
|
||||||
|
//public int? weight { get; set; } // 2500,
|
||||||
|
//public List<yellowLabelListInfo> yellowLabelList { get; set; }
|
||||||
|
//public int? previewPriority { get; set; } // 0,
|
||||||
|
//public int? startTime { get; set; } // 0,
|
||||||
|
//public int? endTime { get; set; } // 0,
|
||||||
|
//public int? staticLimitQuantity { get; set; } // 999999,
|
||||||
|
//public string attribute { get; set; } // "{\"skuPreSaleTime\":0}",
|
||||||
|
//public string normalSavePrice { get; set; } // "1",
|
||||||
|
public long? skuID { get; set; } // 28790184768,
|
||||||
|
//public string skuExpansionPrice { get; set; } // "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
public class frontSpecInfo3
|
||||||
|
{
|
||||||
|
public string spec_key { get; set; } // "重量",
|
||||||
|
public string spec_value { get; set; } // "红薏仁米1斤装",
|
||||||
|
public long? spec_key_id { get; set; } // 1253,
|
||||||
|
public long? spec_value_id { get; set; } // 677094835,
|
||||||
|
public bool? custom { get; set; } // false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,6 +108,10 @@ namespace KJD_Web.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? gift_oem_amount_per_order { get; set; }
|
public decimal? gift_oem_amount_per_order { get; set; }
|
||||||
public decimal? sync_logistics_per_order { get; set; }
|
public decimal? sync_logistics_per_order { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 店铺续租平台保底金额 有OEM 平台默认抽成15
|
||||||
|
/// </summary>
|
||||||
|
public decimal? shop_renewal_platform_floor_fee { get; set; }
|
||||||
|
public int image_analysis_quota { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,11 @@ public class ShopRevenueStatistics
|
|||||||
/// 利润
|
/// 利润
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Profit { get; set; }
|
public int Profit { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 快递包裹费用
|
||||||
|
/// </summary>
|
||||||
|
public int PackageAmount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 采购类型
|
/// 采购类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace KJD_Web.Model.WxModel
|
|||||||
public string oem_id { get; set; }
|
public string oem_id { get; set; }
|
||||||
public string oem_name { get; set; }
|
public string oem_name { get; set; }
|
||||||
public string oem_owner { get; set; }
|
public string oem_owner { get; set; }
|
||||||
|
public string parent_oem_id { get; set; }
|
||||||
public string oem_icon { get; set; }
|
public string oem_icon { get; set; }
|
||||||
public string oem_img { get; set; }
|
public string oem_img { get; set; }
|
||||||
public DateTime add_time { get; set; }
|
public DateTime add_time { get; set; }
|
||||||
|
|||||||
@@ -96,5 +96,25 @@ namespace KJD_Web.Model.WxModel
|
|||||||
/// 下游快递公司编码
|
/// 下游快递公司编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string downstream_express_code { get; set; }
|
public string downstream_express_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 订单初始费用(分)
|
||||||
|
/// </summary>
|
||||||
|
public int? postage { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 货架号
|
||||||
|
/// </summary>
|
||||||
|
public string location_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 货架写入时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? location_write_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 1商品退货包裹2额外退货包裹
|
||||||
|
/// </summary>
|
||||||
|
public int? pack_type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 作废状态 1作废成功 2作废失败
|
||||||
|
/// </summary>
|
||||||
|
public int? order_void_status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,5 +83,29 @@ namespace KJD_Web.Model.WxModel
|
|||||||
/// 拦截退回操作信息/回调信息
|
/// 拦截退回操作信息/回调信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string intercept_return_info { get; set; }
|
public string intercept_return_info { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否手动发货:0自动发货,1手动发货
|
||||||
|
/// </summary>
|
||||||
|
public int is_manual_shipment { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 手动发货处理状态:0未处理,1成功,2失败
|
||||||
|
/// </summary>
|
||||||
|
public int? manual_shipment_status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 货架号
|
||||||
|
/// </summary>
|
||||||
|
public string location_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 货架写入时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? location_write_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 虚拟快递单号
|
||||||
|
/// </summary>
|
||||||
|
public string virtual_waybill_no { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 虚拟快递公司
|
||||||
|
/// </summary>
|
||||||
|
public string virtual_express_company { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,51 @@ namespace KJD_Web.Model.WxModel
|
|||||||
public DateTime? rejected_time { get; set; } // '拒收时间',
|
public DateTime? rejected_time { get; set; } // '拒收时间',
|
||||||
public int? has_reject { get; set; } // DEFAULT NULL,
|
public int? has_reject { get; set; } // DEFAULT NULL,
|
||||||
public DateTime? blocked_arrival_time { get; set; }
|
public DateTime? blocked_arrival_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 货架号
|
||||||
|
/// </summary>
|
||||||
|
public string location_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 货架写入时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? location_write_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外采单号
|
||||||
|
/// </summary>
|
||||||
|
public string out_order_no { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 商品skuId
|
||||||
|
/// </summary>
|
||||||
|
public string out_sku_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拦截退回状态:0未处理,1已退回成功,2退回失败(或其它业务码)
|
||||||
|
/// </summary>
|
||||||
|
public int? intercept_return_status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拦截退回时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? intercept_return_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拦截退回操作信息(回调/失败信息/备注等)
|
||||||
|
/// </summary>
|
||||||
|
public string intercept_return_info { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拦截改地址状态:0未处理,1修改成功,2修改失败(或其它业务码)
|
||||||
|
/// </summary>
|
||||||
|
public int? intercept_address_status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拦截改地址时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? intercept_address_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 拦截改地址操作信息(回调/失败信息/备注等)
|
||||||
|
/// </summary>
|
||||||
|
public string intercept_address_info { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有退货:0 无退货,1 有退货
|
||||||
|
/// </summary>
|
||||||
|
public int? has_return { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using Store.Framework.Dtos;
|
||||||
|
|
||||||
|
namespace KJD_Web.Requests.Users;
|
||||||
|
|
||||||
|
/// <summary>按 user_name 和消费类型查询两级代理加价。</summary>
|
||||||
|
public class GetUserMarkupsRequest : SignRequestBase
|
||||||
|
{
|
||||||
|
public UserPaymentTypes PaymentType { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Store.Framework.Dtos;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Requests.Users;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买图片检测配额
|
||||||
|
/// </summary>
|
||||||
|
public class ImageAnalysisRequest : SignRequestBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 购买金额
|
||||||
|
/// </summary>
|
||||||
|
public int Amount { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using Store.Framework.Dtos;
|
||||||
|
|
||||||
|
namespace KJD_Web.Requests.Users;
|
||||||
|
|
||||||
|
public class SetMarkupRuleRequest : SignRequestBase
|
||||||
|
{
|
||||||
|
public OEMMarkupTargetType TargetType { get; set; }
|
||||||
|
/// <summary>用户规则传主账号用户名,OEM 规则传目标 OEM ID。</summary>
|
||||||
|
public string TargetId { get; set; }
|
||||||
|
public UserPaymentTypes PaymentType { get; set; }
|
||||||
|
/// <summary>加价金额,单位:分;必须传入,0 表示不加价。</summary>
|
||||||
|
public int? Markup { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using Store.Framework.Dtos;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Requests.Users;
|
||||||
|
|
||||||
|
public class UserConfigRequest:SignRequestBase
|
||||||
|
{
|
||||||
|
public string Config { get; set; }
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
@@ -59,6 +59,9 @@ public class ShopOrderDetailResponse
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int OutAmount { get; set; }
|
public int OutAmount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>快递包裹净费用(分)</summary>
|
||||||
|
public int PackageAmount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 买手未退回金额(分),即买手订单中退款未成功的退款金额之和;无售后时为 0
|
/// 买手未退回金额(分),即买手订单中退款未成功的退款金额之和;无售后时为 0
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ public class ShopStatsResponse
|
|||||||
/// 退款处理中金额
|
/// 退款处理中金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long RefundPending { get; set; }
|
public long RefundPending { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹金额
|
||||||
|
/// </summary>
|
||||||
|
public long PackageAmount { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace KJD_Web.Responses.Users;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RebateRecordResponse
|
public class RebateRecordResponse
|
||||||
{
|
{
|
||||||
|
public string OrderId { get; set; }
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public long Amount { get; set; }
|
public long Amount { get; set; }
|
||||||
public long Rebate { get; set; }
|
public long Rebate { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace KJD_Web.Responses.Users;
|
||||||
|
|
||||||
|
public class UserMarkupResponse
|
||||||
|
{
|
||||||
|
/// <summary>1:上级代理对所属 OEM 的加价;2:所属 OEM 对用户的加价。</summary>
|
||||||
|
public int Level { get; set; }
|
||||||
|
/// <summary>该级代理的 OEM ID;不存在对应代理时为 null。</summary>
|
||||||
|
public string OemId { get; set; }
|
||||||
|
/// <summary>加价金额,单位:分;未设置时为 0。</summary>
|
||||||
|
public int Markup { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Services.Products;
|
||||||
|
|
||||||
|
public class ProductService
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using KJD_Web.Model.WxModel;
|
using KJD_Web.Model.WxModel;
|
||||||
using KJD_Web.Requests.Shops;
|
using KJD_Web.Requests.Shops;
|
||||||
using KJD_Web.Responses.Shops;
|
using KJD_Web.Responses.Shops;
|
||||||
using KJD_Web.Services.Users;
|
using KJD_Web.Services.Users;
|
||||||
@@ -8,6 +8,7 @@ using MAX.Core.Logger;
|
|||||||
using MySqlX.XDevAPI.Relational;
|
using MySqlX.XDevAPI.Relational;
|
||||||
using Store.Contracts.Order.Entitys;
|
using Store.Contracts.Order.Entitys;
|
||||||
using Store.Contracts.Shops;
|
using Store.Contracts.Shops;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
using Store.Contracts.User.Interfaces;
|
using Store.Contracts.User.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -93,6 +94,7 @@ public class ShopRevenueStatisticsService : ITransientDependency
|
|||||||
resp.RefundOrderCount = ss.Sum(x => x.RefundOrderCount);
|
resp.RefundOrderCount = ss.Sum(x => x.RefundOrderCount);
|
||||||
resp.RefundDone = ss.Sum(x => x.RefundDone);
|
resp.RefundDone = ss.Sum(x => x.RefundDone);
|
||||||
resp.RefundPending = ss.Sum(x => x.RefundPending);
|
resp.RefundPending = ss.Sum(x => x.RefundPending);
|
||||||
|
resp.PackageAmount = ss.Sum(a => a.PackageAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bDict.TryGetValue(key, out var bb))
|
if (bDict.TryGetValue(key, out var bb))
|
||||||
@@ -196,6 +198,7 @@ public class ShopRevenueStatisticsService : ITransientDependency
|
|||||||
if (orders.Count == 0) return result;
|
if (orders.Count == 0) return result;
|
||||||
|
|
||||||
// 加载买手订单(直拍和中转仓都要查),并回填商铺订单的退款金额
|
// 加载买手订单(直拍和中转仓都要查),并回填商铺订单的退款金额
|
||||||
|
FillPackageAmount(orders);
|
||||||
FillRefunds(orders);
|
FillRefunds(orders);
|
||||||
LoadBuyerOrder(orders);
|
LoadBuyerOrder(orders);
|
||||||
CalcProfit(orders);
|
CalcProfit(orders);
|
||||||
@@ -240,6 +243,7 @@ public class ShopRevenueStatisticsService : ITransientDependency
|
|||||||
ProfitAmount = order.Profit,
|
ProfitAmount = order.Profit,
|
||||||
PlatformFee = order.HasRefund ? 0 : order.PredictCommissionFee,
|
PlatformFee = order.HasRefund ? 0 : order.PredictCommissionFee,
|
||||||
OutAmount = order.OutAmount,
|
OutAmount = order.OutAmount,
|
||||||
|
PackageAmount = order.PackageAmount,
|
||||||
UnrefundedAmount = unrefundedAmount,
|
UnrefundedAmount = unrefundedAmount,
|
||||||
BuyerOrders = buyerOrders,
|
BuyerOrders = buyerOrders,
|
||||||
});
|
});
|
||||||
@@ -337,6 +341,7 @@ public class ShopRevenueStatisticsService : ITransientDependency
|
|||||||
{
|
{
|
||||||
|
|
||||||
var orders = LoadOrders(date, shopId);
|
var orders = LoadOrders(date, shopId);
|
||||||
|
FillPackageAmount(orders);
|
||||||
FillRefunds(orders);
|
FillRefunds(orders);
|
||||||
LoadBuyerOrder(orders);
|
LoadBuyerOrder(orders);
|
||||||
CalcProfit(orders);
|
CalcProfit(orders);
|
||||||
@@ -667,7 +672,39 @@ public class ShopRevenueStatisticsService : ITransientDependency
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 填充快递费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orders"></param>
|
||||||
|
private void FillPackageAmount(List<OrderInfo> orders)
|
||||||
|
{
|
||||||
|
int[] types = { 20, 23, 24, 26, 28, 38, 31, 32, 33, 35, 36, 37, 39, 40, 41 };
|
||||||
|
var amounts = orders.Select(o => o.OrderId).Distinct().ToDictionary(id => id, id => 0m);
|
||||||
|
foreach (var batch in Batch(amounts.Keys.ToList(), BatchSize))
|
||||||
|
{
|
||||||
|
var ids = new HashSet<string>(batch);
|
||||||
|
var search = string.Join(" ", batch.Select(id => "\"" + id + "\""));
|
||||||
|
var payments = _freeSql.Select<UserPaymentRecordEntity>()
|
||||||
|
.Where(p => p.IsDeleted == 0 && types.Contains(p.Type))
|
||||||
|
.Where("MATCH(remark) AGAINST(?search IN BOOLEAN MODE)", new { search })
|
||||||
|
.ToList(p => new { p.Remark, p.Type, p.Amount });
|
||||||
|
|
||||||
|
foreach (var payment in payments)
|
||||||
|
{
|
||||||
|
// 全文索引只筛候选流水,按完整单号核对,同一备注重复提及只计一次。
|
||||||
|
var matches = Regex.Matches(payment.Remark, @"[A-Za-z0-9_-]+").Cast<Match>()
|
||||||
|
.Select(m => m.Value).Where(ids.Contains).Distinct();
|
||||||
|
var amount = payment.Amount ?? 0m;
|
||||||
|
if (payment.Type == 23 || payment.Type == 32 || payment.Type == 38 || payment.Type == 36 || payment.Type == 40)
|
||||||
|
amount = -amount;
|
||||||
|
foreach (var id in matches)
|
||||||
|
amounts[id] += amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var order in orders)
|
||||||
|
order.PackageAmount = decimal.ToInt32(decimal.Round(amounts[order.OrderId] * 100m, 0, MidpointRounding.AwayFromZero));
|
||||||
|
}
|
||||||
/// <summary>回填商铺订单的退款信息</summary>
|
/// <summary>回填商铺订单的退款信息</summary>
|
||||||
private void FillRefunds(List<OrderInfo> orders)
|
private void FillRefunds(List<OrderInfo> orders)
|
||||||
{
|
{
|
||||||
@@ -761,6 +798,7 @@ public class ShopRevenueStatisticsService : ITransientDependency
|
|||||||
.Sum(i => (long)i.RefundAmount),
|
.Sum(i => (long)i.RefundAmount),
|
||||||
RefundPending = afterSaleItems.Where(i => !i.IsRefundSuccessed && i.IsAfterSale)
|
RefundPending = afterSaleItems.Where(i => !i.IsRefundSuccessed && i.IsAfterSale)
|
||||||
.Sum(i => (long)i.RefundAmount),
|
.Sum(i => (long)i.RefundAmount),
|
||||||
|
PackageAmount = shopGroup.Sum(a => a.PackageAmount)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using MAX.Core.DependencyInjection;
|
using MAX.Core.DependencyInjection;
|
||||||
using MAX.Core.Logger;
|
using MAX.Core.Logger;
|
||||||
using Org.BouncyCastle.Utilities;
|
using Org.BouncyCastle.Utilities;
|
||||||
|
using Store.Contracts.Order.Entitys;
|
||||||
using Store.Contracts.Shops;
|
using Store.Contracts.Shops;
|
||||||
using Store.Contracts.User.Interfaces;
|
using Store.Contracts.User.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
@@ -70,4 +71,19 @@ public class ShopService : ITransientDependency
|
|||||||
.Where(a => shopAppkeys.Contains(a.AppKey))
|
.Where(a => shopAppkeys.Contains(a.AppKey))
|
||||||
.ToList(a => a.Id);
|
.ToList(a => a.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetShopKey(string orderSn)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(orderSn)) return "";
|
||||||
|
var appKey = _freeSql.Select<WeiOrderEntity, WXShopEntity>()
|
||||||
|
.InnerJoin((a, b) => a.ShopId == b.Id)
|
||||||
|
.Where((a, b) => a.OrderId == orderSn)
|
||||||
|
.First((a, b) => b.AppKey);
|
||||||
|
return appKey;
|
||||||
|
|
||||||
|
// SELECT B.app_key from erp.oms_wei_order AS A
|
||||||
|
//JOIN erp.o_shop as B on A.shop_id = B.id
|
||||||
|
// WHERE A.order_id = '3739958894823388160'
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,9 @@ using System.Web;
|
|||||||
namespace KJD_Web.Services.Shops;
|
namespace KJD_Web.Services.Shops;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新商铺统计
|
/// 更新商铺统计 每天0:5分 统计
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Job("ShopStats", "0 2 * * *")]
|
[Job("ShopStats", "5 0 * * *")]
|
||||||
public class ShopStatsJob : IScheduledJobs, ITransientDependency
|
public class ShopStatsJob : IScheduledJobs, ITransientDependency
|
||||||
{
|
{
|
||||||
private readonly ShopRevenueStatisticsService _shopRevenueStatisticsService;
|
private readonly ShopRevenueStatisticsService _shopRevenueStatisticsService;
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace KJD_Web.Services.Users;
|
||||||
|
|
||||||
|
/// <summary>从 appSettings 读取每单基础费用,单位:分。</summary>
|
||||||
|
public static class OEMMarkupBaseFeeSettings
|
||||||
|
{
|
||||||
|
public static int PostagePerOrder => ReadFee("postage_per_order");
|
||||||
|
public static int RefundPostagePerOrder => ReadFee("refund_postage_per_order");
|
||||||
|
public static int GiftOemAmountPerOrder => ReadFee("gift_oem_amount_per_order");
|
||||||
|
public static int SyncLogisticsPerOrder => ReadFee("sync_logistics_per_order");
|
||||||
|
|
||||||
|
public static int GetBaseFee(UserPaymentTypes paymentType) => paymentType switch
|
||||||
|
{
|
||||||
|
UserPaymentTypes.中转仓扣费支出 => PostagePerOrder,
|
||||||
|
UserPaymentTypes.退货包裹扣费支出 => RefundPostagePerOrder,
|
||||||
|
UserPaymentTypes.礼物单支出 => GiftOemAmountPerOrder,
|
||||||
|
UserPaymentTypes.同步物流 => SyncLogisticsPerOrder,
|
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(paymentType), "不支持的加价交易类型")
|
||||||
|
};
|
||||||
|
|
||||||
|
private static int ReadFee(string key)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(ConfigurationManager.AppSettings[key], NumberStyles.Integer,
|
||||||
|
CultureInfo.InvariantCulture, out int fee) || fee < 0)
|
||||||
|
throw new ConfigurationErrorsException($"appSettings 配置项 '{key}' 必须为非负整数,单位:分。");
|
||||||
|
return fee;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using MySqlX.XDevAPI;
|
using MySqlX.XDevAPI;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Store.Contracts.User.Entitys;
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
@@ -40,13 +41,9 @@ namespace KJD_Web.Services.Users
|
|||||||
// 获取OEM下面的所有用户
|
// 获取OEM下面的所有用户
|
||||||
var users = GetOEMUsers(oem.OemId, true);
|
var users = GetOEMUsers(oem.OemId, true);
|
||||||
|
|
||||||
var userNames = users
|
|
||||||
.Select(a => a.UserName)
|
|
||||||
.Where(a => !string.IsNullOrEmpty(a))
|
|
||||||
.Distinct()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (userNames.Count == 0)
|
|
||||||
|
if (users.Count == 0)
|
||||||
{//todo
|
{//todo
|
||||||
throw new Exception("没有用户");
|
throw new Exception("没有用户");
|
||||||
}
|
}
|
||||||
@@ -60,7 +57,7 @@ namespace KJD_Web.Services.Users
|
|||||||
*/
|
*/
|
||||||
long totalFen = SettleFlowsInternal(
|
long totalFen = SettleFlowsInternal(
|
||||||
trFreeSql,
|
trFreeSql,
|
||||||
userNames,
|
users,
|
||||||
oem.AddTime);
|
oem.AddTime);
|
||||||
|
|
||||||
long rebateFen = totalFen;
|
long rebateFen = totalFen;
|
||||||
@@ -99,16 +96,15 @@ namespace KJD_Web.Services.Users
|
|||||||
/// <param name="userName"></param>
|
/// <param name="userName"></param>
|
||||||
public long SettleUserFlows(string userName, DbTransaction tarn = null)
|
public long SettleUserFlows(string userName, DbTransaction tarn = null)
|
||||||
{
|
{
|
||||||
var user = GetUserAndSubUser(userName);
|
var users = GetUserAndSubUser(userName);
|
||||||
if (user == null)
|
if (users == null)
|
||||||
{
|
{
|
||||||
throw new Exception("错误的账号");
|
throw new Exception("错误的账号");
|
||||||
}
|
}
|
||||||
using var work = tarn != null ? _freeSql.CreateUnitOfWork(tarn) : _freeSql.CreateUnitOfWork();
|
using var work = tarn != null ? _freeSql.CreateUnitOfWork(tarn) : _freeSql.CreateUnitOfWork();
|
||||||
var trFreeSql = work.Orm;
|
var trFreeSql = work.Orm;
|
||||||
var userNames = user.Select(a => a.UserName).ToList();
|
|
||||||
/* * 普通用户没有OEM创建时间限制。 * * 所以这里传null。 */
|
/* * 普通用户没有OEM创建时间限制。 * * 所以这里传null。 */
|
||||||
long totalAmount = SettleFlowsInternal(trFreeSql, userNames, null);
|
long totalAmount = SettleFlowsInternal(trFreeSql, users, null);
|
||||||
/* * 普通用户没有余额, * 所以不做任何金额更新。 */
|
/* * 普通用户没有余额, * 所以不做任何金额更新。 */
|
||||||
Debug.WriteLine($"用户流水结算:{totalAmount}");
|
Debug.WriteLine($"用户流水结算:{totalAmount}");
|
||||||
work.Commit();
|
work.Commit();
|
||||||
@@ -124,17 +120,20 @@ namespace KJD_Web.Services.Users
|
|||||||
/// <param name="orm">当前事务ORM</param>
|
/// <param name="orm">当前事务ORM</param>
|
||||||
/// <param name="userNames">需要结算的用户</param>
|
/// <param name="userNames">需要结算的用户</param>
|
||||||
/// <param name="oemAddTime">
|
/// <param name="oemAddTime">
|
||||||
private long SettleFlowsInternal(IFreeSql tr_freeSql, ICollection<string> userNames, DateTime? oemAddTime)
|
private long SettleFlowsInternal(IFreeSql tr_freeSql, ICollection<UserEntity> users, DateTime? oemAddTime)
|
||||||
{
|
{
|
||||||
if (userNames == null || userNames.Count == 0) { throw new Exception("没有用户"); }
|
if (users == null || users.Count == 0) { throw new Exception("没有用户"); }
|
||||||
|
|
||||||
|
IEnumerable<string> userNames = users.Select(a => a.UserName);
|
||||||
decimal total_amount = 0m; // 总金额(元)
|
decimal total_amount = 0m; // 总金额(元)
|
||||||
decimal rebate_amount = 0m; // 正数部分(累计返利)
|
decimal rebate_amount = 0m; // 正数部分(累计返利)
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
|
int[] positiveTypes = [16, 20, 26, 31, 35, 39, 55];
|
||||||
List<int> UserPaymentTypeFiltert = [16, 20, 23, 26, 31, 34, 55];
|
int[] negativeTypes = [34, 23, 38, 32, 36, 40];
|
||||||
|
var paymentTypes = positiveTypes.Concat(negativeTypes).ToArray();
|
||||||
var paymentQuery = tr_freeSql.Select<UserPaymentRecordEntity>()
|
var paymentQuery = tr_freeSql.Select<UserPaymentRecordEntity>()
|
||||||
.Where(a => userNames.Contains(a.UserName))
|
.Where(a => userNames.Contains(a.UserName))
|
||||||
.Where(a => UserPaymentTypeFiltert.Contains(a.Type))
|
.Where(a => paymentTypes.Contains(a.Type))
|
||||||
.Where(a => a.Settlement == 0)
|
.Where(a => a.Settlement == 0)
|
||||||
.Where(a => a.IsDeleted == 0);
|
.Where(a => a.IsDeleted == 0);
|
||||||
//只有OEM结算才限制OEM创建时间。
|
//只有OEM结算才限制OEM创建时间。
|
||||||
@@ -142,58 +141,18 @@ namespace KJD_Web.Services.Users
|
|||||||
{
|
{
|
||||||
paymentQuery = paymentQuery.Where(a => a.CreateTime > oemAddTime.Value);
|
paymentQuery = paymentQuery.Where(a => a.CreateTime > oemAddTime.Value);
|
||||||
}
|
}
|
||||||
paymentQuery.OrderBy(a => a.Id);
|
var userPayments = paymentQuery.OrderBy(a => a.Id).ToList();
|
||||||
var userPayments = paymentQuery.ToList();
|
|
||||||
if (userPayments.Count > 0)
|
if (userPayments.Count > 0)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(userPayments.Where(a => a.Type == 20).Sum(a => a.OemAmount));
|
var ids = userPayments.Select(a => a.Id).ToList();
|
||||||
///原始流水ID。
|
var userPaymentAmount = userPayments
|
||||||
List<long> ids = userPayments.Select(a => a.Id).ToList();
|
.GroupBy(a => new { a.Type, a.OrderId })
|
||||||
|
.Select(group => group.First())
|
||||||
var userPaymentUnique = userPayments.GroupBy(a => //去重
|
.Sum(a =>
|
||||||
new
|
|
||||||
{
|
{
|
||||||
a.Type,
|
var amount = Math.Abs(a.OemAmount ?? 0m);
|
||||||
a.OrderId
|
return positiveTypes.Contains(a.Type) ? amount : -amount;
|
||||||
}).Select(a => a.First()).ToList();
|
});
|
||||||
|
|
||||||
//经过计算过滤后的列表
|
|
||||||
List<UserPaymentRecordEntity> userPaymentCalculated = new List<UserPaymentRecordEntity>();
|
|
||||||
|
|
||||||
foreach (var item in userPaymentUnique)
|
|
||||||
{
|
|
||||||
if (item.Type == 20)
|
|
||||||
{
|
|
||||||
//item.OemAmount = item.Amount - 2.2m;
|
|
||||||
item.OemAmount = item.OemAmount;
|
|
||||||
}
|
|
||||||
else if (item.Type == 26)
|
|
||||||
{
|
|
||||||
//item.OemAmount = item.Amount - 2.5m;
|
|
||||||
item.OemAmount = item.OemAmount;
|
|
||||||
}
|
|
||||||
if (item.Type == 23)
|
|
||||||
{
|
|
||||||
var temp = userPaymentCalculated.FirstOrDefault(a => a.Type == 20 && a.OrderId == item.OrderId);
|
|
||||||
if (temp != null)
|
|
||||||
{
|
|
||||||
userPaymentCalculated.Remove(temp);//23 移除 20
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (item.Type == 34)
|
|
||||||
{
|
|
||||||
item.OemAmount = item.OemAmount * -1;
|
|
||||||
}
|
|
||||||
userPaymentCalculated.Add(item);
|
|
||||||
}
|
|
||||||
decimal userPaymentAmount = userPaymentCalculated.Sum(x => x.OemAmount ?? 0);//累计返利
|
|
||||||
//StringBuilder sb = new StringBuilder();
|
|
||||||
//sb.AppendLine("id,order_id,type,amount,oem_amount,time");
|
|
||||||
//foreach (var item in userPayments)
|
|
||||||
//{
|
|
||||||
// sb.AppendLine($"{item.Id},{item.OrderId},{item.Type},{item.Amount},{item.OemAmount},{item.CreateTime}");
|
|
||||||
//}
|
|
||||||
total_amount += userPaymentAmount;
|
total_amount += userPaymentAmount;
|
||||||
rebate_amount += userPaymentAmount;
|
rebate_amount += userPaymentAmount;
|
||||||
|
|
||||||
@@ -217,11 +176,23 @@ namespace KJD_Web.Services.Users
|
|||||||
.ToList();
|
.ToList();
|
||||||
if (userPoints.Count > 0)
|
if (userPoints.Count > 0)
|
||||||
{
|
{
|
||||||
List<long> ids = userPoints.Select(a => a.Id).ToList();
|
var feeMap = users
|
||||||
|
.GroupBy(a => a.UserName)
|
||||||
|
.ToDictionary(g => g.Key, g => g.First().ShopRenewalPlatformFloorFee);
|
||||||
|
|
||||||
|
List<long> ids = userPoints.Select(a => a.Id).ToList();
|
||||||
decimal userPointsAmount = userPoints.Sum(x =>
|
decimal userPointsAmount = userPoints.Sum(x =>
|
||||||
{
|
{
|
||||||
return x.DeltaPoints * 1 - ShopRenewFee; //比例1:1 减去固定收取费用
|
var fee = feeMap.TryGetValue(x.UserName, out var f) ? f : (decimal?)null;
|
||||||
|
var net = x.DeltaPoints - (fee ?? ShopRenewFee); // 允许为负
|
||||||
|
|
||||||
|
if (net < 0m)
|
||||||
|
{
|
||||||
|
_logger.Warn(
|
||||||
|
$"续费返利出现负数:UserName={x.UserName}, DeltaPoints={x.DeltaPoints}, Fee={fee ?? ShopRenewFee}, Net={net}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return net; // 允许出现负数
|
||||||
});//累计返利
|
});//累计返利
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
using FreeSql.Internal.Model;
|
using FreeSql.Internal.Model;
|
||||||
|
using KJD_Web.Model.WxModel;
|
||||||
using KJD_Web.Requests.Users;
|
using KJD_Web.Requests.Users;
|
||||||
using KJD_Web.Responses.Users;
|
using KJD_Web.Responses.Users;
|
||||||
using MAX.Core.DependencyInjection;
|
using MAX.Core.DependencyInjection;
|
||||||
using Store.Contracts.User.Entitys;
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|
||||||
@@ -89,15 +92,21 @@ public partial class UserService
|
|||||||
var oem = GetOEMByUserName(request.UserName);
|
var oem = GetOEMByUserName(request.UserName);
|
||||||
if (oem == null)
|
if (oem == null)
|
||||||
throw new Exception("无权限");
|
throw new Exception("无权限");
|
||||||
|
|
||||||
if (request.Type == 0) //运费流水
|
if (request.Type == 0) //运费流水
|
||||||
{
|
{
|
||||||
var users = GetOEMUsers(oem.OemId);
|
var users = GetOEMUsers(oem.OemId);
|
||||||
|
request.StartTime = oem.AddTime;
|
||||||
|
if (request.StartTime > request.EndTime)
|
||||||
|
request.EndTime = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
var userNames = users.Select(u => u.UserName).ToList();
|
var userNames = users.Select(u => u.UserName).ToList();
|
||||||
List<int> types = [20, 23, 26, 16, 31, 34, 55];
|
int[] positiveTypes = [16, 20, 26, 31, 35, 39, 55];
|
||||||
|
int[] negativeTypes = [34, 23, 38, 32, 36, 40];
|
||||||
|
var paymentTypes = positiveTypes.Concat(negativeTypes).ToArray();
|
||||||
|
|
||||||
var query = _freeSql.Select<UserPaymentRecordEntity>()
|
var query = _freeSql.Select<UserPaymentRecordEntity>()
|
||||||
.Where(a => types.Contains(a.Type))
|
.Where(a => paymentTypes.Contains(a.Type))
|
||||||
.Where(a => userNames.Contains(a.UserName))
|
.Where(a => userNames.Contains(a.UserName))
|
||||||
.Where(a => a.CreateTime >= request.StartTime && a.CreateTime <= request.EndTime)
|
.Where(a => a.CreateTime >= request.StartTime && a.CreateTime <= request.EndTime)
|
||||||
.OrderByDescending(a => a.CreateTime)
|
.OrderByDescending(a => a.CreateTime)
|
||||||
@@ -105,10 +114,16 @@ public partial class UserService
|
|||||||
.Page(request.PageIndex, request.PageSize);
|
.Page(request.PageIndex, request.PageSize);
|
||||||
string sq = query.ToSql();
|
string sq = query.ToSql();
|
||||||
var data = query.ToList();
|
var data = query.ToList();
|
||||||
|
// shortcut: 仅按当前页退款流水移除订单;需要准确总数和跨页匹配时改为分页前过滤。
|
||||||
|
var refundedOrders = data.Where(a => negativeTypes.Contains(a.Type))
|
||||||
|
.Select(a => new { a.UserName, a.OrderId }).ToHashSet();
|
||||||
|
data.RemoveAll(a => negativeTypes.Contains(a.Type) ||
|
||||||
|
refundedOrders.Contains(new { a.UserName, a.OrderId }));
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
list.Add(new RebateRecordResponse
|
list.Add(new RebateRecordResponse
|
||||||
{
|
{
|
||||||
|
OrderId = item.OrderId,
|
||||||
UserName = item.UserName,
|
UserName = item.UserName,
|
||||||
Amount = (long)Math.Round((item.Amount ?? 0) * 100m),
|
Amount = (long)Math.Round((item.Amount ?? 0) * 100m),
|
||||||
Rebate = (long)Math.Round((item.OemAmount ?? 0) * 100m),
|
Rebate = (long)Math.Round((item.OemAmount ?? 0) * 100m),
|
||||||
@@ -144,4 +159,393 @@ public partial class UserService
|
|||||||
}
|
}
|
||||||
return (list, total);
|
return (list, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取父代理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="oemId"></param>
|
||||||
|
/// <param name="isCache"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
public OEMEntity GetParentOem(string oemId, bool isCache = true)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(oemId)) throw new ArgumentNullException(nameof(oemId));
|
||||||
|
var oem = GetOEMByOemId(oemId, isCache);
|
||||||
|
if (oem == null) throw new Exception("错误的OEM");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(oem.ParentOemId)) return oem;
|
||||||
|
|
||||||
|
return GetOEMByOemId(oem.ParentOemId, isCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有子代理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="oemId"></param>
|
||||||
|
/// <param name="isCache"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
public List<OEMEntity> GetSubOems(string oemId, bool isCache = true)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(oemId)) throw new ArgumentNullException(nameof(oemId));
|
||||||
|
|
||||||
|
return OEMData.Where(a => a.ParentOemId == oemId).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 加价规则
|
||||||
|
|
||||||
|
private const string DefaultMarkupOemId = "00000000";
|
||||||
|
|
||||||
|
private static string GetMarkupOemId(string oemId) =>
|
||||||
|
string.IsNullOrWhiteSpace(oemId) ? DefaultMarkupOemId : oemId;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容旧版查询字符串:id 为目标用户ID,user_name 为操作人,费用单位为元。
|
||||||
|
/// 四个费用字段依次对应交易类型 20、26、16、55;二级加价为费用转分后减去基础费及一级 OEM 加价,未传字段不修改。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputData">旧版表单字符串;调用方须先完成签名和身份校验。</param>
|
||||||
|
public void SetMarkupRule(string inputData)
|
||||||
|
{
|
||||||
|
var (userId, actorUserName, fees) = ParseLegacyMarkupInput(inputData);
|
||||||
|
var requests = new List<SetMarkupRuleRequest>();
|
||||||
|
foreach (var (paymentType, amount) in fees)
|
||||||
|
{
|
||||||
|
int markup = amount - GetDefaultFloorPrice(paymentType);
|
||||||
|
if (markup < 0) throw new ArgumentException($"交易类型 {(int)paymentType} 的费用不能低于基础费");
|
||||||
|
requests.Add(new SetMarkupRuleRequest
|
||||||
|
{
|
||||||
|
UserName = actorUserName,
|
||||||
|
TargetType = OEMMarkupTargetType.User,
|
||||||
|
PaymentType = paymentType,
|
||||||
|
Markup = markup
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (requests.Count == 0) return;
|
||||||
|
_freeSql.Transaction(() =>
|
||||||
|
{
|
||||||
|
var user = _freeSql.Select<UserEntity>().Where(a => a.Id == userId).ForUpdate().First()
|
||||||
|
?? throw new InvalidOperationException("目标用户不存在");
|
||||||
|
var oemId = GetMarkupOemId(user.OemId);
|
||||||
|
var paymentTypes = requests.Select(a => a.PaymentType).ToArray();
|
||||||
|
var oemRules = _freeSql.Select<OEMMarkupRuleEntity>()
|
||||||
|
.Where(a => a.TargetType == OEMMarkupTargetType.OEM && a.TargetId == oemId
|
||||||
|
&& paymentTypes.Contains(a.PaymentType)).ForUpdate().ToList();
|
||||||
|
// 先校验所有消费类型,避免后面的金额不足时已保存前面的规则。
|
||||||
|
DeductOemMarkup(requests, oemRules, oemId);
|
||||||
|
foreach (var request in requests)
|
||||||
|
{
|
||||||
|
request.TargetId = user.UserName;
|
||||||
|
SetMarkupRule(request);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>从已扣除基础费的金额中扣除一级 OEM 加价,得到要保存的二级用户加价。</summary>
|
||||||
|
private static void DeductOemMarkup(List<SetMarkupRuleRequest> requests, List<OEMMarkupRuleEntity> oemRules, string oemId)
|
||||||
|
{
|
||||||
|
foreach (var request in requests)
|
||||||
|
{
|
||||||
|
int oemMarkup = GetMarkup(oemRules, null, OEMMarkupTargetType.OEM, oemId, request.PaymentType);
|
||||||
|
int markup = checked(request.Markup.Value - oemMarkup);
|
||||||
|
if (markup < 0)
|
||||||
|
throw new ArgumentException($"交易类型 {request.PaymentType} 的费用不能低于基础费用");
|
||||||
|
request.Markup = markup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (int UserId, string ActorUserName, List<(UserPaymentTypes PaymentType, int Amount)> Fees) ParseLegacyMarkupInput(string inputData)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(inputData)) throw new ArgumentException("输入不能为空", nameof(inputData));
|
||||||
|
var values = HttpUtility.ParseQueryString(inputData);
|
||||||
|
if (!int.TryParse(values["id"], NumberStyles.None, CultureInfo.InvariantCulture, out int userId) || userId <= 0)
|
||||||
|
throw new ArgumentException("id 必须为有效的用户ID");
|
||||||
|
var actorUserName = values["user_name"];
|
||||||
|
if (string.IsNullOrWhiteSpace(actorUserName) || values.GetValues("user_name")?.Length != 1)
|
||||||
|
throw new ArgumentException("操作人 user_name 必须传入且只能传入一次");
|
||||||
|
var fields = new[]
|
||||||
|
{
|
||||||
|
("postage_per_order", UserPaymentTypes.中转仓扣费支出),
|
||||||
|
("refund_postage_per_order", UserPaymentTypes.退货包裹扣费支出),
|
||||||
|
("gift_oem_amount_per_order", UserPaymentTypes.礼物单支出),
|
||||||
|
("sync_logistics_per_order", UserPaymentTypes.同步物流)
|
||||||
|
};
|
||||||
|
var fees = new List<(UserPaymentTypes PaymentType, int Amount)>();
|
||||||
|
foreach (var (key, paymentType) in fields)
|
||||||
|
{
|
||||||
|
var value = values[key];
|
||||||
|
if (value == null) continue;
|
||||||
|
if (!decimal.TryParse(value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out decimal amount)
|
||||||
|
|| amount < 0 || amount > int.MaxValue / 100m || decimal.Truncate(amount * 100m) != amount * 100m)
|
||||||
|
throw new ArgumentException($"{key} 必须为非负金额,单位:元,精确到分且不能超出范围");
|
||||||
|
fees.Add((paymentType, (int)(amount * 100m)));
|
||||||
|
}
|
||||||
|
return (userId, actorUserName, fees);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 校验操作权限,并新增或更新指定主用户、下级 OEM 的加价规则。
|
||||||
|
/// OEM 管理人只能设置自己直属主用户的规则;管理员可以设置指定主用户或下级 OEM 的规则。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">
|
||||||
|
/// UserName 为操作人用户名,调用方须先完成身份认证;TargetId 为目标主用户的用户名或目标 OEM ID。
|
||||||
|
/// PaymentType 为交易类型,Markup 为加价金额(分),必须传入非负整数,0 表示不加价。
|
||||||
|
/// </param>
|
||||||
|
/// <remarks>
|
||||||
|
/// setter_oem_id 根据目标归属关系确定,不使用管理员身份作为设置者。
|
||||||
|
/// 保存时会在事务中再次检查目标与设置者的直属关系。
|
||||||
|
/// </remarks>
|
||||||
|
/// <exception cref="ArgumentException">请求为空、必填参数缺失、类型不支持或金额不合法。</exception>
|
||||||
|
/// <exception cref="UnauthorizedAccessException">操作人不存在或无权设置目标规则。</exception>
|
||||||
|
/// <exception cref="InvalidOperationException">目标或所属 OEM 无效、目标不是主用户、直属关系不符或保存失败。</exception>
|
||||||
|
public void SetMarkupRule(SetMarkupRuleRequest request)
|
||||||
|
{
|
||||||
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
||||||
|
if (string.IsNullOrWhiteSpace(request.UserName)) throw new ArgumentException("操作人不能为空");
|
||||||
|
if (string.IsNullOrWhiteSpace(request.TargetId)) throw new ArgumentException("设置目标不能为空");
|
||||||
|
if (request.TargetType != OEMMarkupTargetType.User && request.TargetType != OEMMarkupTargetType.OEM)
|
||||||
|
throw new ArgumentException("不支持的加价目标类型");
|
||||||
|
if (!request.Markup.HasValue || request.Markup < 0) throw new ArgumentException("加价金额必须为非负整数,单位:分");
|
||||||
|
GetDefaultFloorPrice(request.PaymentType);
|
||||||
|
var actor = _freeSql.Select<UserEntity>().Where(a => a.UserName == request.UserName).First()
|
||||||
|
?? throw new UnauthorizedAccessException("操作人不存在");
|
||||||
|
var actorOem = actor.SaLevel == 1 ? null : GetOEMByUserName(actor.UserName, false);
|
||||||
|
var targetUser = request.TargetType == OEMMarkupTargetType.User
|
||||||
|
? _freeSql.Select<UserEntity>().Where(a => a.UserName == request.TargetId).First() : null;
|
||||||
|
var targetOem = request.TargetType == OEMMarkupTargetType.OEM ? GetOEMByOemId(request.TargetId, false) : null;
|
||||||
|
var setterOemId = ResolveMarkupSetter(request.TargetType, actor, actorOem, targetUser, targetOem);
|
||||||
|
if (request.TargetType == OEMMarkupTargetType.User)
|
||||||
|
SetUserMarkup(setterOemId, request.TargetId, request.PaymentType, request.Markup.Value);
|
||||||
|
else
|
||||||
|
SetOEMMarkup(setterOemId, request.TargetId, request.PaymentType, request.Markup.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据操作人权限和目标归属,确定加价规则的收益方 OEM(setter_oem_id)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetType">目标类型:主用户或下级 OEM。</param>
|
||||||
|
/// <param name="actor">已查询到的操作人;SaLevel 为 1 时按管理员处理,不能为空。</param>
|
||||||
|
/// <param name="actorOem">操作人作为管理人拥有的 OEM;管理员场景可为空。</param>
|
||||||
|
/// <param name="targetUser">用户规则的目标主用户;OEM 规则场景可为空。</param>
|
||||||
|
/// <param name="targetOem">OEM 规则的目标 OEM;用户规则场景可为空。</param>
|
||||||
|
/// <returns>
|
||||||
|
/// 用户规则返回目标用户的 OemId,未挂载时返回 00000000;OEM 规则仅允许管理员设置,返回目标 OEM 的 ParentOemId。
|
||||||
|
/// </returns>
|
||||||
|
/// <exception cref="ArgumentException">目标类型不支持。</exception>
|
||||||
|
/// <exception cref="UnauthorizedAccessException">非管理员设置其他 OEM 的用户,或尝试设置 OEM 规则。</exception>
|
||||||
|
/// <exception cref="InvalidOperationException">目标用户不存在、不是主用户;目标 OEM 不存在、已删除或没有上级。</exception>
|
||||||
|
private static string ResolveMarkupSetter(OEMMarkupTargetType targetType, UserEntity actor,
|
||||||
|
OEMEntity actorOem, UserEntity targetUser, OEMEntity targetOem)
|
||||||
|
{
|
||||||
|
if (targetType == OEMMarkupTargetType.User)
|
||||||
|
{
|
||||||
|
if (targetUser == null) throw new InvalidOperationException("目标用户不存在");
|
||||||
|
if (!targetUser.IsMainUser) throw new InvalidOperationException("只能设置主用户的加价规则");
|
||||||
|
var setterOemId = GetMarkupOemId(targetUser.OemId);
|
||||||
|
if (actor.SaLevel != 1 && (actorOem == null || actorOem.IsDel != 0
|
||||||
|
|| actorOem.OemOwner != actor.UserName || actorOem.OemId != setterOemId))
|
||||||
|
throw new UnauthorizedAccessException("只能设置自己OEM下主用户的加价规则");
|
||||||
|
return setterOemId;
|
||||||
|
}
|
||||||
|
if (targetType != OEMMarkupTargetType.OEM) throw new ArgumentException("不支持的加价目标类型");
|
||||||
|
if (actor.SaLevel != 1) throw new UnauthorizedAccessException("只有管理员可以设置OEM加价规则");
|
||||||
|
if (targetOem == null || targetOem.IsDel != 0) throw new InvalidOperationException("目标OEM不存在或已删除");
|
||||||
|
if (string.IsNullOrWhiteSpace(targetOem.ParentOemId)) throw new InvalidOperationException("目标OEM没有上级OEM");
|
||||||
|
return targetOem.ParentOemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>获取交易类型的默认地板价,单位:分。</summary>
|
||||||
|
public int GetDefaultFloorPrice(UserPaymentTypes paymentType) => OEMMarkupBaseFeeSettings.GetBaseFee(paymentType);
|
||||||
|
|
||||||
|
/// <summary>设置直属主用户的加价(分),0 表示不加价,不允许传入子账号。</summary>
|
||||||
|
public void SetUserMarkup(string setterOemId, string userName, UserPaymentTypes paymentType, int markup)
|
||||||
|
{
|
||||||
|
ValidateMarkup(setterOemId, paymentType, markup);
|
||||||
|
if (string.IsNullOrWhiteSpace(userName)) throw new ArgumentException("用户名不能为空", nameof(userName));
|
||||||
|
var user = _freeSql.Select<UserEntity>().Where(a => a.UserName == userName).First()
|
||||||
|
?? throw new InvalidOperationException("用户不存在");
|
||||||
|
if (!user.IsMainUser) throw new InvalidOperationException("只能设置主用户的加价规则");
|
||||||
|
SaveMarkup(setterOemId, OEMMarkupTargetType.User, user.UserName, paymentType, markup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>设置直属下级 OEM 的加价,单位:分,0 表示不加价。</summary>
|
||||||
|
public void SetOEMMarkup(string setterOemId, string oemId, UserPaymentTypes paymentType, int markup)
|
||||||
|
{
|
||||||
|
ValidateMarkup(setterOemId, paymentType, markup);
|
||||||
|
if (string.IsNullOrWhiteSpace(oemId)) throw new ArgumentException("OEM不能为空", nameof(oemId));
|
||||||
|
if (setterOemId == oemId) throw new ArgumentException("不能设置自身的OEM加价", nameof(oemId));
|
||||||
|
SaveMarkup(setterOemId, OEMMarkupTargetType.OEM, oemId, paymentType, markup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ValidateMarkup(string setterOemId, UserPaymentTypes paymentType, int markup)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(setterOemId)) throw new ArgumentException("设置者OEM不能为空", nameof(setterOemId));
|
||||||
|
GetDefaultFloorPrice(paymentType);
|
||||||
|
if (markup < 0) throw new ArgumentOutOfRangeException(nameof(markup), "加价金额不能为负数");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveMarkup(string setterOemId, OEMMarkupTargetType targetType, string targetId, UserPaymentTypes paymentType, int markup)
|
||||||
|
{
|
||||||
|
_freeSql.Transaction(() =>
|
||||||
|
{
|
||||||
|
// 无归属用户使用平台默认标识,不要求存在对应的 OEM 记录。
|
||||||
|
if (!(targetType == OEMMarkupTargetType.User && setterOemId == DefaultMarkupOemId)
|
||||||
|
&& !_freeSql.Select<OEMEntity>().Where(a => a.OemId == setterOemId && a.IsDel == 0).Any())
|
||||||
|
throw new InvalidOperationException("设置者OEM不存在或已删除");
|
||||||
|
|
||||||
|
// 锁定目标行,使不同进程首次设置同一目标时也不会重复插入规则。
|
||||||
|
if (targetType == OEMMarkupTargetType.User)
|
||||||
|
{
|
||||||
|
var user = _freeSql.Select<UserEntity>().Where(a => a.UserName == targetId).ForUpdate().First();
|
||||||
|
if (user == null || !user.IsMainUser || GetMarkupOemId(user.OemId) != setterOemId)
|
||||||
|
throw new InvalidOperationException("只能设置直属主账号的加价");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var oem = _freeSql.Select<OEMEntity>().Where(a => a.OemId == targetId).ForUpdate().First();
|
||||||
|
if (oem == null || oem.IsDel != 0 || oem.ParentOemId != setterOemId)
|
||||||
|
throw new InvalidOperationException("只能设置直属下级OEM的加价");
|
||||||
|
}
|
||||||
|
|
||||||
|
var rule = _freeSql.Select<OEMMarkupRuleEntity>()
|
||||||
|
.Where(a => a.SetterOemId == setterOemId && a.TargetType == targetType
|
||||||
|
&& a.TargetId == targetId && a.PaymentType == paymentType).First();
|
||||||
|
if (rule != null && rule.Markup == markup) return;
|
||||||
|
var now = DateTime.Now;
|
||||||
|
int affected = rule == null
|
||||||
|
? _freeSql.Insert(new OEMMarkupRuleEntity
|
||||||
|
{
|
||||||
|
SetterOemId = setterOemId,
|
||||||
|
TargetType = targetType,
|
||||||
|
TargetId = targetId,
|
||||||
|
PaymentType = paymentType,
|
||||||
|
Markup = markup,
|
||||||
|
UpdatedAt = now
|
||||||
|
}).ExecuteAffrows()
|
||||||
|
: _freeSql.Update<OEMMarkupRuleEntity>().Where(a => a.Id == rule.Id)
|
||||||
|
.Set(a => a.Markup, markup).Set(a => a.UpdatedAt, now).ExecuteAffrows();
|
||||||
|
if (affected != 1) throw new InvalidOperationException("保存加价规则失败");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>查询用户最终价格(分):地板价 + A对B的加价 + B对主账号的加价。</summary>
|
||||||
|
public int GetUserFinalPrice(string userName, UserPaymentTypes paymentType)
|
||||||
|
{
|
||||||
|
int price = GetDefaultFloorPrice(paymentType);
|
||||||
|
if (string.IsNullOrWhiteSpace(userName)) throw new ArgumentException("用户名不能为空", nameof(userName));
|
||||||
|
var user = GetUserByUserName(userName) ?? throw new InvalidOperationException("用户不存在");
|
||||||
|
return CalculateUserPrice(GetUserMarkupRules(user, paymentType), user, paymentType, price);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量计算用户四种最终价格(分),返回用户名到消费类型、价格的映射。
|
||||||
|
/// 复用已查询的用户列表;加价规则只查一次,子账号的主账号归属另作一次批量查询,不使用缓存。
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, Dictionary<UserPaymentTypes, int>> GetUserFinalPrices(IEnumerable<UserEntity> users)
|
||||||
|
{
|
||||||
|
if (users == null) throw new ArgumentNullException(nameof(users));
|
||||||
|
var userList = users.ToList();
|
||||||
|
if (userList.Any(a => a == null || string.IsNullOrWhiteSpace(a.UserName)))
|
||||||
|
throw new ArgumentException("用户及用户名不能为空", nameof(users));
|
||||||
|
if (userList.Select(a => a.UserName).Distinct().Count() != userList.Count)
|
||||||
|
throw new ArgumentException("用户列表中存在重复用户名", nameof(users));
|
||||||
|
if (userList.Count == 0) return new();
|
||||||
|
|
||||||
|
var parentNames = userList.Where(a => !a.IsMainUser).Select(a => a.ParentUserName).Distinct().ToList();
|
||||||
|
if (parentNames.Count > 0)
|
||||||
|
{
|
||||||
|
var parents = _freeSql.Select<UserEntity>().Where(a => parentNames.Contains(a.UserName))
|
||||||
|
.ToList().ToDictionary(a => a.UserName);
|
||||||
|
// 与单用户查询一致:子账号继承主账号的 OEM,但仍按自己的用户名匹配规则。
|
||||||
|
userList = userList.Select(a => new UserEntity
|
||||||
|
{
|
||||||
|
UserName = a.UserName,
|
||||||
|
OemId = !a.IsMainUser && parents.TryGetValue(a.ParentUserName, out var parent) ? parent.OemId : a.OemId
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
userList = userList.Select(a => new UserEntity { UserName = a.UserName, OemId = GetMarkupOemId(a.OemId) }).ToList();
|
||||||
|
UserPaymentTypes[] paymentTypes = [UserPaymentTypes.中转仓扣费支出, UserPaymentTypes.退货包裹扣费支出,
|
||||||
|
UserPaymentTypes.礼物单支出, UserPaymentTypes.同步物流];
|
||||||
|
var floorPrices = paymentTypes.ToDictionary(a => a, GetDefaultFloorPrice);
|
||||||
|
var oemIds = userList.Select(a => a.OemId).Where(a => !string.IsNullOrWhiteSpace(a)).Distinct().ToList();
|
||||||
|
var userNames = userList.Where(a => !string.IsNullOrWhiteSpace(a.OemId)).Select(a => a.UserName).ToList();
|
||||||
|
var rules = oemIds.Count == 0 ? new List<OEMMarkupRuleEntity>() : _freeSql.Select<OEMMarkupRuleEntity>()
|
||||||
|
.Where(a => paymentTypes.Contains(a.PaymentType) &&
|
||||||
|
((a.TargetType == OEMMarkupTargetType.User && userNames.Contains(a.TargetId) && oemIds.Contains(a.SetterOemId))
|
||||||
|
|| (a.TargetType == OEMMarkupTargetType.OEM && oemIds.Contains(a.TargetId))))
|
||||||
|
.ToList();
|
||||||
|
return CalculateUserPrices(userList, rules, floorPrices);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<string, Dictionary<UserPaymentTypes, int>> CalculateUserPrices(List<UserEntity> users,
|
||||||
|
List<OEMMarkupRuleEntity> rules, Dictionary<UserPaymentTypes, int> floorPrices)
|
||||||
|
{
|
||||||
|
var rulesByTarget = rules.ToLookup(a => (a.TargetType, a.TargetId));
|
||||||
|
var result = new Dictionary<string, Dictionary<UserPaymentTypes, int>>();
|
||||||
|
foreach (var user in users)
|
||||||
|
{
|
||||||
|
var userRules = rulesByTarget[(OEMMarkupTargetType.User, user.UserName)]
|
||||||
|
.Concat(rulesByTarget[(OEMMarkupTargetType.OEM, GetMarkupOemId(user.OemId))]).ToList();
|
||||||
|
result.Add(user.UserName, floorPrices.ToDictionary(a => a.Key,
|
||||||
|
a => CalculateUserPrice(userRules, user, a.Key, a.Value)));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>实时查询用户两级代理加价(分),按一级、二级返回,未设置的级别金额为 0。</summary>
|
||||||
|
public UserMarkupResponse[] GetUserMarkups(string userName, UserPaymentTypes paymentType)
|
||||||
|
{
|
||||||
|
GetDefaultFloorPrice(paymentType);
|
||||||
|
if (string.IsNullOrWhiteSpace(userName)) throw new ArgumentException("用户名不能为空", nameof(userName));
|
||||||
|
var user = GetUserByUserName(userName) ?? throw new InvalidOperationException("用户不存在");
|
||||||
|
var rules = GetUserMarkupRules(user, paymentType);
|
||||||
|
var parentOemId = string.IsNullOrWhiteSpace(user.OemId)
|
||||||
|
? null : GetOEMByOemId(user.OemId, false)?.ParentOemId;
|
||||||
|
return BuildUserMarkups(rules, user, paymentType, parentOemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OEMMarkupRuleEntity> GetUserMarkupRules(UserEntity user, UserPaymentTypes paymentType)
|
||||||
|
{
|
||||||
|
var oemId = GetMarkupOemId(user.OemId);
|
||||||
|
return _freeSql.Select<OEMMarkupRuleEntity>()
|
||||||
|
.Where(a => a.PaymentType == paymentType &&
|
||||||
|
((a.TargetType == OEMMarkupTargetType.User && a.SetterOemId == oemId && a.TargetId == user.UserName)
|
||||||
|
|| (a.TargetType == OEMMarkupTargetType.OEM && a.TargetId == oemId))).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UserMarkupResponse[] BuildUserMarkups(List<OEMMarkupRuleEntity> rules, UserEntity user, UserPaymentTypes paymentType, string parentOemId)
|
||||||
|
{
|
||||||
|
int oemMarkup = GetMarkup(rules, null, OEMMarkupTargetType.OEM, GetMarkupOemId(user.OemId), paymentType);
|
||||||
|
var oemRule = rules.FirstOrDefault(a => a.TargetType == OEMMarkupTargetType.OEM
|
||||||
|
&& a.TargetId == GetMarkupOemId(user.OemId) && a.PaymentType == paymentType);
|
||||||
|
// 已有规则时,代理 ID 与金额必须来自同一条规则。
|
||||||
|
var oemId = oemRule == null ? parentOemId : oemRule.SetterOemId;
|
||||||
|
return
|
||||||
|
[
|
||||||
|
new() { Level = 1, OemId = string.IsNullOrWhiteSpace(oemId) ? null : oemId, Markup = oemMarkup },
|
||||||
|
new() { Level = 2, OemId = GetMarkupOemId(user.OemId),
|
||||||
|
Markup = GetMarkup(rules, GetMarkupOemId(user.OemId), OEMMarkupTargetType.User, user.UserName, paymentType) }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int CalculateUserPrice(List<OEMMarkupRuleEntity> rules, UserEntity user, UserPaymentTypes paymentType, int floorPrice)
|
||||||
|
{
|
||||||
|
// 按当前OEM筛选用户规则,避免用户换OEM后使用旧设置者的加价。
|
||||||
|
int userMarkup = GetMarkup(rules, GetMarkupOemId(user.OemId), OEMMarkupTargetType.User, user.UserName, paymentType);
|
||||||
|
int oemMarkup = GetMarkup(rules, null, OEMMarkupTargetType.OEM, GetMarkupOemId(user.OemId), paymentType);
|
||||||
|
return checked(floorPrice + userMarkup + oemMarkup);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GetMarkup(List<OEMMarkupRuleEntity> rules, string setterOemId, OEMMarkupTargetType targetType, string targetId, UserPaymentTypes paymentType)
|
||||||
|
{
|
||||||
|
var matches = rules.Where(a => (setterOemId == null || a.SetterOemId == setterOemId) && a.TargetType == targetType
|
||||||
|
&& a.TargetId == targetId && a.PaymentType == paymentType).ToList();
|
||||||
|
if (matches.Count > 1) throw new InvalidOperationException("存在重复的加价规则,请检查数据");
|
||||||
|
int markup = matches.FirstOrDefault()?.Markup ?? 0;
|
||||||
|
if (markup < 0) throw new InvalidOperationException("加价规则金额不能为负数");
|
||||||
|
return markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ using KJD_Web.Requests.Users;
|
|||||||
using KJD_Web.Utils;
|
using KJD_Web.Utils;
|
||||||
using MAX.Core.DependencyInjection;
|
using MAX.Core.DependencyInjection;
|
||||||
using MAX.Core.Logger;
|
using MAX.Core.Logger;
|
||||||
|
using MySqlX.XDevAPI.Relational;
|
||||||
using NaiBa.Util.Extension;
|
using NaiBa.Util.Extension;
|
||||||
using Store.Contracts.Order.Entitys;
|
using Store.Contracts.Order.Entitys;
|
||||||
using Store.Contracts.User.Entitys;
|
using Store.Contracts.User.Entitys;
|
||||||
@@ -15,6 +16,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Ubiety.Dns.Core;
|
using Ubiety.Dns.Core;
|
||||||
using YourNamespace;
|
using YourNamespace;
|
||||||
|
|
||||||
@@ -25,12 +27,15 @@ namespace KJD_Web.Services.Users
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 商铺续费每月30
|
/// 商铺续费每月30
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int MinShopPointsPerMonth = 30;
|
private const int MinShopPointsPerMonth = 10;
|
||||||
private const int UserNameMaxLength = 20;
|
private const int UserNameMaxLength = 20;
|
||||||
private const int ShopIdMaxLength = 50;
|
private const int ShopIdMaxLength = 50;
|
||||||
private const int RemarkMaxLength = 255;
|
private const int RemarkMaxLength = 255;
|
||||||
private const int MaxRenewDuration = 120;
|
private const int MaxRenewDuration = 120;
|
||||||
|
/// <summary>
|
||||||
|
/// AI图片包 1张 价格 分
|
||||||
|
/// </summary>
|
||||||
|
private const int AIImageAmount = 1;
|
||||||
private readonly IFreeSql _freeSql;
|
private readonly IFreeSql _freeSql;
|
||||||
private readonly ILoggerFacade _logger;
|
private readonly ILoggerFacade _logger;
|
||||||
|
|
||||||
@@ -44,7 +49,19 @@ namespace KJD_Web.Services.Users
|
|||||||
{
|
{
|
||||||
return GetOEMByUserName(userName) != null;
|
return GetOEMByUserName(userName) != null;
|
||||||
}
|
}
|
||||||
|
public UserEntity GetMainUser(string userName)
|
||||||
|
{
|
||||||
|
var user = _freeSql.Select<UserEntity>().Where(u => u.UserName == userName).First();
|
||||||
|
return user == null ? null : GetMainUser(user);
|
||||||
|
}
|
||||||
|
private UserEntity GetMainUser(UserEntity user)
|
||||||
|
{
|
||||||
|
if (user.IsMainUser) return user;
|
||||||
|
var parent = _freeSql.Select<UserEntity>().Where(u => u.UserName == user.ParentUserName).First();
|
||||||
|
if (parent == null || !parent.IsMainUser)
|
||||||
|
throw new Exception("主账号不存在或账号关系无效,请联系管理员");
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
public UserEntity GetUserByUserName(string userName)
|
public UserEntity GetUserByUserName(string userName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(userName)) return null;
|
if (string.IsNullOrEmpty(userName)) return null;
|
||||||
@@ -59,10 +76,12 @@ namespace KJD_Web.Services.Users
|
|||||||
if (mainUser != null)
|
if (mainUser != null)
|
||||||
{
|
{
|
||||||
user.OemId = mainUser.OemId;
|
user.OemId = mainUser.OemId;
|
||||||
|
user.ShopPointsPerMonth = mainUser.ShopPointsPerMonth;
|
||||||
user.PostagePerOrder = mainUser.PostagePerOrder;
|
user.PostagePerOrder = mainUser.PostagePerOrder;
|
||||||
user.RefundPostagePerOrder = mainUser.RefundPostagePerOrder;
|
user.RefundPostagePerOrder = mainUser.RefundPostagePerOrder;
|
||||||
user.GiftOemAmountPerOrder = mainUser.GiftOemAmountPerOrder;
|
user.GiftOemAmountPerOrder = mainUser.GiftOemAmountPerOrder;
|
||||||
user.SyncLogisticsPerOrder = mainUser.SyncLogisticsPerOrder;
|
user.SyncLogisticsPerOrder = mainUser.SyncLogisticsPerOrder;
|
||||||
|
user.ShopRenewalPlatformFloorFee = mainUser.ShopRenewalPlatformFloorFee;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,6 +247,59 @@ namespace KJD_Web.Services.Users
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买图片检测购买份额
|
||||||
|
/// 最少1块钱
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
public int BuyImageAnalysisQuota(ImageAnalysisRequest request)
|
||||||
|
{
|
||||||
|
if (request == null) throw new ArgumentException("请求参数不能为空", nameof(request));
|
||||||
|
if (string.IsNullOrWhiteSpace(request.UserName)) throw new ArgumentException("用户名不能为空", nameof(request.UserName));
|
||||||
|
if (request.Amount == 0) throw new ArgumentException("购买金额不能小于1积分");
|
||||||
|
|
||||||
|
int ImageQuota = request.Amount * (AIImageAmount * 100);//检测图片配额数量
|
||||||
|
using var work = _freeSql.CreateUnitOfWork();
|
||||||
|
var trFreeSql = work.Orm;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UserPointsPayment(request.UserName, request.Amount, PointsTypes.AI识图包, work.GetOrBeginTransaction());
|
||||||
|
var affrows = trFreeSql.Update<UserEntity>()
|
||||||
|
.Set(a => a.ImageAnalysisQuota + ImageQuota)
|
||||||
|
.Where(a => a.UserName == request.UserName)
|
||||||
|
.ExecuteAffrows();
|
||||||
|
if (affrows != 1)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("账户已发生改变,请刷新账户后重新操作");
|
||||||
|
}
|
||||||
|
work.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
work.Rollback();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
return ImageQuota;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UseImageAnalysisQuota(string userName)
|
||||||
|
{
|
||||||
|
var affrows = _freeSql.Update<UserEntity>()
|
||||||
|
.Set(a => a.ImageAnalysisQuota - 1)
|
||||||
|
.Where(a => a.UserName == userName)
|
||||||
|
.ExecuteAffrows();
|
||||||
|
return affrows == 1;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户当前的图片配额
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int GetUserImageAnalysisQuota(string userName)
|
||||||
|
{
|
||||||
|
var user = GetUserByUserName(userName);
|
||||||
|
return user.ImageAnalysisQuota;
|
||||||
|
}
|
||||||
private static void ValidateRequest(ShopRenewRequest request)
|
private static void ValidateRequest(ShopRenewRequest request)
|
||||||
{
|
{
|
||||||
if (request == null)
|
if (request == null)
|
||||||
@@ -405,7 +477,7 @@ namespace KJD_Web.Services.Users
|
|||||||
if (user == null) return false;
|
if (user == null) return false;
|
||||||
// 消费金额必须大于 0
|
// 消费金额必须大于 0
|
||||||
if (user.Balance <= 0) return false;
|
if (user.Balance <= 0) return false;
|
||||||
if (type != UserPaymentTypes.同步单号) return false;
|
if (type != UserPaymentTypes.同步物流) return false;
|
||||||
consumeAmount = (user.SyncLogisticsPerOrder ?? 0m) + consumeAmount;
|
consumeAmount = (user.SyncLogisticsPerOrder ?? 0m) + consumeAmount;
|
||||||
return user.Balance >= consumeAmount;
|
return user.Balance >= consumeAmount;
|
||||||
}
|
}
|
||||||
@@ -427,7 +499,7 @@ namespace KJD_Web.Services.Users
|
|||||||
{
|
{
|
||||||
throw new Exception("用户不存在");
|
throw new Exception("用户不存在");
|
||||||
}
|
}
|
||||||
if (type != UserPaymentTypes.同步单号) throw new Exception("不支持的类型");
|
if (type != UserPaymentTypes.同步物流) throw new Exception("不支持的类型");
|
||||||
var payItem = new UserPaymentRecordEntity
|
var payItem = new UserPaymentRecordEntity
|
||||||
{
|
{
|
||||||
Type = (int)type,
|
Type = (int)type,
|
||||||
@@ -465,6 +537,79 @@ namespace KJD_Web.Services.Users
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 积分消费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
private void UserPointsPayment(string userName, int pointsCost, PointsTypes type, DbTransaction tarn = null)
|
||||||
|
{
|
||||||
|
using var work = tarn != null ? _freeSql.CreateUnitOfWork(tarn) : _freeSql.CreateUnitOfWork();
|
||||||
|
var trFreeSql = work.Orm;
|
||||||
|
if (pointsCost <= 0) throw new Exception("积分消耗不能小于1");
|
||||||
|
var user = GetUserByUserName(userName);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
throw new Exception("用户不存在");
|
||||||
|
}
|
||||||
|
if (user.Points < pointsCost) throw new Exception("余额不足");
|
||||||
|
if (type != PointsTypes.AI识图包) throw new Exception("不支持的类型");
|
||||||
|
var payItem = new UserPointsRecordEntity
|
||||||
|
{
|
||||||
|
UserName = userName,
|
||||||
|
UserNick = user.NickName,
|
||||||
|
DeltaPoints = pointsCost,
|
||||||
|
OptionType = type.ToString(),
|
||||||
|
OperatorType = "用户",
|
||||||
|
OperatorName = userName,
|
||||||
|
Remark = type.ToString(),
|
||||||
|
AddTime = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
payItem.NewPoints = user.Points - payItem.DeltaPoints;
|
||||||
|
var affrows = trFreeSql.Insert<UserPointsRecordEntity>(payItem).ExecuteAffrows();
|
||||||
|
if (affrows != 1)
|
||||||
|
{
|
||||||
|
_logger.Error($"积分消费失败:{userName},{type}");
|
||||||
|
throw new Exception("积分消费失败");
|
||||||
|
}
|
||||||
|
affrows = trFreeSql.Update<UserEntity>()
|
||||||
|
.Set(a => a.Points, payItem.NewPoints)
|
||||||
|
.Where(a => a.UserName == user.UserName)
|
||||||
|
.Where(a => a.Points >= payItem.DeltaPoints)
|
||||||
|
.ExecuteAffrows();
|
||||||
|
if (affrows != 1)
|
||||||
|
{
|
||||||
|
_logger.Error($"积分消费失败,余额不足:{userName},{type}");
|
||||||
|
throw new Exception("余额不足");
|
||||||
|
}
|
||||||
|
if (tarn == null)
|
||||||
|
work.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetUserConfig(string userName)
|
||||||
|
{
|
||||||
|
var user = GetMainUser(userName);
|
||||||
|
var item = _freeSql.Select<UserConfig>()
|
||||||
|
.Where(a => a.UserName == user.UserName)
|
||||||
|
.First();
|
||||||
|
if (item != null && !string.IsNullOrEmpty(item.UserName))
|
||||||
|
{
|
||||||
|
return item.Config;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
public bool SaveUserConfig(string userName, string config)
|
||||||
|
{
|
||||||
|
var affrows = _freeSql.InsertOrUpdate<UserConfig>()
|
||||||
|
.SetSource(new UserConfig { UserName = userName, Config = config })
|
||||||
|
.ExecuteAffrows();
|
||||||
|
return affrows == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,12 +25,29 @@
|
|||||||
<add name="UpdateWxFindOrderUrl" connectionString="http://weidian.e57.cn/find_order_update/" />
|
<add name="UpdateWxFindOrderUrl" connectionString="http://weidian.e57.cn/find_order_update/" />
|
||||||
<add name="WxFindOrderLimitVersion" connectionString="172" />
|
<add name="WxFindOrderLimitVersion" connectionString="172" />
|
||||||
<add name="WxFindOrderLowVersion" connectionString="99" />
|
<add name="WxFindOrderLowVersion" connectionString="99" />
|
||||||
|
<add name="OrderApiUrl" connectionString="http://119.45.29.75:9000" />
|
||||||
|
<add name="ProdApiUrl" connectionString="http://1.13.195.131:9000" />
|
||||||
|
|
||||||
|
<add name="AllowTraditionalBuyAddress" connectionString="1" />
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<!-- 禁用 OWIN 启动类的自动发现,避免与现有项目结构冲突 -->
|
<!-- 禁用 OWIN 启动类的自动发现,避免与现有项目结构冲突 -->
|
||||||
<add key="owin:AutomaticAppStartup" value="true" />
|
<add key="owin:AutomaticAppStartup" value="false" />
|
||||||
<add key="Hangfire:User" value="admin" />
|
<!--<add key="Hangfire:User" value="admin" />
|
||||||
<add key="Hangfire:Password" value="hangadmin" />
|
<add key="Hangfire:Password" value="hangadmin" />-->
|
||||||
|
<!--是否启用后台任务-->
|
||||||
|
<add key="BackgroundJobs" value="false"/>
|
||||||
|
<!--第三方调用API 直接走token-->
|
||||||
|
<add key="OpenApiKey" value="e3b0c44298fc1c149afbf4c8996fb924"/>
|
||||||
|
|
||||||
|
<!--每单中转仓快递费-->
|
||||||
|
<add key="postage_per_order" value="220"/>
|
||||||
|
<!--每单中转仓退货快递费用-->
|
||||||
|
<add key="refund_postage_per_order" value="250"/>
|
||||||
|
<!--礼物每单额外收取费用-->
|
||||||
|
<add key="gift_oem_amount_per_order" value="160"/>
|
||||||
|
<!--同步订单额外收取费用-->
|
||||||
|
<add key="sync_logistics_per_order" value="190"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<!--
|
<!--
|
||||||
有关 web.config 更改的说明,请参见 http://go.microsoft.com/fwlink/?LinkId=235367。
|
有关 web.config 更改的说明,请参见 http://go.microsoft.com/fwlink/?LinkId=235367。
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//using MAX.Core.Autofac;
|
//using MAX.Core.Interfaces;
|
||||||
//using MAX.Core.Infrastructure;
|
|
||||||
//using System;
|
//using System;
|
||||||
//using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,11 @@ public class ShopDailyStatsEntity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(Name = "refund_pending")]
|
[Column(Name = "refund_pending")]
|
||||||
public long RefundPending { get; set; }
|
public long RefundPending { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹费用
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "package_amount")]
|
||||||
|
public long PackageAmount { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -90,4 +90,10 @@ public class OEMEntity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(Name = "total_withdraw_amount")]
|
[Column(Name = "total_withdraw_amount")]
|
||||||
public long TotalWithdrawAmount { get; set; }
|
public long TotalWithdrawAmount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 父级OEMid
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "parent_oem_id")]
|
||||||
|
public string ParentOemId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Store.Contracts.User.Entitys;
|
||||||
|
|
||||||
|
[Table(Name = "wxxd.oem_markup_rule")]
|
||||||
|
public class OEMMarkupRuleEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自增主键
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置者(上级),也是该笔加价的收益方
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "setter_oem_id")]
|
||||||
|
public string SetterOemId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标类型 1=下级OEM 2=用户
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "target_type", MapType = typeof(sbyte))]
|
||||||
|
public OEMMarkupTargetType TargetType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标ID:type=1 是oem_id, type=2 是user_name
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "target_id")]
|
||||||
|
public string TargetId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 交易类型
|
||||||
|
/// 20 快递
|
||||||
|
/// 26 退货快递
|
||||||
|
/// 16 礼物单
|
||||||
|
/// 55 同步物流
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "payment_type", MapType = typeof(sbyte))]
|
||||||
|
public UserPaymentTypes PaymentType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加价金额,单位:分
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "markup")]
|
||||||
|
public int Markup { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新时间
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "updated_at")]
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Store.Contracts.User.Entitys;
|
||||||
|
|
||||||
|
[Table(Name = "wxxd.user_config")]
|
||||||
|
|
||||||
|
public class UserConfig
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true, Name = "user_name")]
|
||||||
|
public string UserName { get; set; }
|
||||||
|
[Column(Name = "config")]
|
||||||
|
|
||||||
|
public string Config { get; set; }
|
||||||
|
}
|
||||||
@@ -160,6 +160,18 @@ namespace Store.Contracts.User.Entitys
|
|||||||
[Column(Name = "sync_logistics_per_order")]
|
[Column(Name = "sync_logistics_per_order")]
|
||||||
public decimal? SyncLogisticsPerOrder { get; set; }
|
public decimal? SyncLogisticsPerOrder { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 店铺续租平台保底金额 默认15
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "shop_renewal_platform_floor_fee")]
|
||||||
|
public decimal ShopRenewalPlatformFloorFee { get; set; } = 15;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 图片检测份额
|
||||||
|
/// </summary>
|
||||||
|
[Column(Name = "image_analysis_quota")]
|
||||||
|
public int ImageAnalysisQuota { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否主账户
|
/// 是否主账户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Store.Contracts.User.Enums;
|
||||||
|
|
||||||
|
/// <summary>OEM 加价规则的目标类型。</summary>
|
||||||
|
public enum OEMMarkupTargetType : sbyte
|
||||||
|
{
|
||||||
|
OEM = 1,
|
||||||
|
User = 2,
|
||||||
|
}
|
||||||
@@ -19,12 +19,18 @@ public enum UserPaymentTypes
|
|||||||
//运费退款扣除 = 7,
|
//运费退款扣除 = 7,
|
||||||
礼物单支出 = 16,
|
礼物单支出 = 16,
|
||||||
中转仓扣费支出 = 20,
|
中转仓扣费支出 = 20,
|
||||||
中转仓作废返还收入 = 23,
|
中转仓作废收入 = 23,
|
||||||
中转仓超重支出 = 24,
|
中转仓超重支出 = 24,
|
||||||
退货包裹扣费支出 = 26,
|
退货包裹扣费支出 = 26,
|
||||||
中转仓快递超重费用 = 28,
|
|
||||||
支付宝在线充值 = 30,
|
支付宝在线充值 = 30,
|
||||||
云仓退货支出 = 31,
|
云仓退货支出 = 31,
|
||||||
礼物单退费 = 34,
|
礼物单退费 = 34,
|
||||||
同步单号 = 55,
|
额外订单创建 = 35,
|
||||||
|
额外订单作废 = 36,
|
||||||
|
额外订单超重支出 = 37,
|
||||||
|
退货包裹作废返还 = 38,
|
||||||
|
同步物流 = 55,
|
||||||
|
额外包裹退货拦截花费 = 39,
|
||||||
|
额外包裹退货拦截花费退款 = 40,
|
||||||
|
额外包裹退货拦截超重花费 = 41,
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Store.Contracts.User.Enums;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 积分类型
|
||||||
|
/// </summary>
|
||||||
|
public enum PointsTypes
|
||||||
|
{
|
||||||
|
充值,
|
||||||
|
续费,
|
||||||
|
转入,
|
||||||
|
转出,
|
||||||
|
支付宝充值,
|
||||||
|
AI识图包,
|
||||||
|
}
|
||||||
@@ -11,6 +11,16 @@ namespace Store.Contracts.User.Interfaces;
|
|||||||
|
|
||||||
public interface IUserService
|
public interface IUserService
|
||||||
{
|
{
|
||||||
|
/// <summary>交易类型默认地板价,单位:分。</summary>
|
||||||
|
int GetDefaultFloorPrice(UserPaymentTypes paymentType);
|
||||||
|
/// <summary>设置直属主用户加价,单位:分,不允许传入子账号。</summary>
|
||||||
|
void SetUserMarkup(string setterOemId, string userName, UserPaymentTypes paymentType, int markup);
|
||||||
|
/// <summary>设置直属下级OEM加价,单位:分。</summary>
|
||||||
|
void SetOEMMarkup(string setterOemId, string oemId, UserPaymentTypes paymentType, int markup);
|
||||||
|
/// <summary>地板价加上A对B的加价、B对用户的加价,缺失规则按0计算,单位:分。</summary>
|
||||||
|
int GetUserFinalPrice(string userName, UserPaymentTypes paymentType);
|
||||||
|
/// <summary>批量查询四种最终价格,返回用户名到消费类型、价格(分)的映射。</summary>
|
||||||
|
Dictionary<string, Dictionary<UserPaymentTypes, int>> GetUserFinalPrices(IEnumerable<UserEntity> users);
|
||||||
bool CanAfford(string userName, UserPaymentTypes type, decimal consumeAmount);
|
bool CanAfford(string userName, UserPaymentTypes type, decimal consumeAmount);
|
||||||
OEMEntity GetOEMByOemId(string oemId, bool isCache = true);
|
OEMEntity GetOEMByOemId(string oemId, bool isCache = true);
|
||||||
OEMEntity GetOEMByUserName(string userName, bool isCache = true);
|
OEMEntity GetOEMByUserName(string userName, bool isCache = true);
|
||||||
|
|||||||
@@ -303,6 +303,20 @@ namespace NaiBa.Util.Extension
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static bool? ParseToNullableBool(this object str)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 1. 快速判断:如果为 null 或 DBNull,直接返回
|
||||||
|
if (str == null || str == DBNull.Value)
|
||||||
|
return null;
|
||||||
|
return bool.Parse(str.ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 转换为float
|
#region 转换为float
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class VirtualLogisticsService : ITransientDependency
|
|||||||
}
|
}
|
||||||
var user = _userService.GetUserByUserName(userName);
|
var user = _userService.GetUserByUserName(userName);
|
||||||
if (user == null) throw new Exception("错误的账号");
|
if (user == null) throw new Exception("错误的账号");
|
||||||
if (_userService.CanAfford(userName, Contracts.User.Enums.UserPaymentTypes.同步单号, FIXEDFEES) == false)
|
if (_userService.CanAfford(userName, Contracts.User.Enums.UserPaymentTypes.同步物流, FIXEDFEES) == false)
|
||||||
{
|
{
|
||||||
throw new Exception("余额不足");
|
throw new Exception("余额不足");
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ public class VirtualLogisticsService : ITransientDependency
|
|||||||
throw new Exception("记录同步单失败");
|
throw new Exception("记录同步单失败");
|
||||||
}
|
}
|
||||||
//todo 更新UserBlance
|
//todo 更新UserBlance
|
||||||
_userService.UserPayment(user.UserName, orderId, type: Contracts.User.Enums.UserPaymentTypes.同步单号);
|
_userService.UserPayment(user.UserName, orderId, type: Contracts.User.Enums.UserPaymentTypes.同步物流);
|
||||||
return yhSyncs;
|
return yhSyncs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,16 @@
|
|||||||
https://go.microsoft.com/fwlink/?LinkId=169433
|
https://go.microsoft.com/fwlink/?LinkId=169433
|
||||||
-->
|
-->
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="postage_per_order" value="220"/>
|
||||||
|
<add key="refund_postage_per_order" value="250"/>
|
||||||
|
<add key="gift_oem_amount_per_order" value="160"/>
|
||||||
|
<add key="sync_logistics_per_order" value="190"/>
|
||||||
|
</appSettings>
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<add name="ConnKJD" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-hl51pkfr.sql.tencentcdb.com';Port=27660;User Id='kjd';Password='Temukjd0625';Charset=utf8mb4;"/>
|
<!--<add name="ConnKJD" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-hl51pkfr.sql.tencentcdb.com';Port=27660;User Id='kjd';Password='Temukjd0625';Charset=utf8mb4;"/>-->
|
||||||
|
|
||||||
<!--<add name="ConnKJD" connectionString="Server=192.168.0.200;Port=3306;Database=mysql;Uid=root;Pwd=123456;"/>-->
|
<add name="ConnKJD" connectionString="Server=192.168.0.200;Port=3306;Database=mysql;Uid=root;Pwd=123456;"/>
|
||||||
|
|
||||||
<add name="ConnKJDBAK" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-9s7x16mt.sql.tencentcdb.com';Port=24049;User Id='kjdbak';Password='Temukjd0126';Charset=utf8mb4;"/>
|
<add name="ConnKJDBAK" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-9s7x16mt.sql.tencentcdb.com';Port=24049;User Id='kjdbak';Password='Temukjd0126';Charset=utf8mb4;"/>
|
||||||
<add name="UpdateVersion" connectionString="525"/>
|
<add name="UpdateVersion" connectionString="525"/>
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using KJD_Web.Services.Users;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WebServiceTest;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class BatchMarkupPriceTest
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<UserPaymentTypes, int> Floors = new()
|
||||||
|
{
|
||||||
|
[UserPaymentTypes.中转仓扣费支出] = 220,
|
||||||
|
[UserPaymentTypes.退货包裹扣费支出] = 250,
|
||||||
|
[UserPaymentTypes.礼物单支出] = 160,
|
||||||
|
[UserPaymentTypes.同步物流] = 190
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Dictionary<string, Dictionary<UserPaymentTypes, int>> Calculate(List<UserEntity> users, List<OEMMarkupRuleEntity> rules)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (Dictionary<string, Dictionary<UserPaymentTypes, int>>)typeof(UserService)
|
||||||
|
.GetMethod("CalculateUserPrices", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { users, rules, Floors })!;
|
||||||
|
}
|
||||||
|
catch (TargetInvocationException ex) { throw ex.InnerException!; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FourPricesMatchSingleCalculationAndDoNotMixUsersOrOems()
|
||||||
|
{
|
||||||
|
var users = new List<UserEntity>
|
||||||
|
{
|
||||||
|
new() { UserName = "user1", OemId = "B" },
|
||||||
|
new() { UserName = "user2", OemId = "C" },
|
||||||
|
new() { UserName = "plain" }
|
||||||
|
};
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>();
|
||||||
|
foreach (var type in Floors.Keys)
|
||||||
|
{
|
||||||
|
rules.Add(new() { TargetType = OEMMarkupTargetType.OEM, TargetId = "B", SetterOemId = "A", PaymentType = type, Markup = 10 });
|
||||||
|
rules.Add(new() { TargetType = OEMMarkupTargetType.User, TargetId = "user1", SetterOemId = "B", PaymentType = type, Markup = 20 });
|
||||||
|
rules.Add(new() { TargetType = OEMMarkupTargetType.User, TargetId = "user1", SetterOemId = "C", PaymentType = type, Markup = 99 });
|
||||||
|
}
|
||||||
|
var result = Calculate(users, rules);
|
||||||
|
Assert.That(result.Count, Is.EqualTo(3));
|
||||||
|
foreach (var user in users)
|
||||||
|
{
|
||||||
|
Assert.That(result[user.UserName].Count, Is.EqualTo(4));
|
||||||
|
foreach (var floor in Floors)
|
||||||
|
{
|
||||||
|
Assert.That(result[user.UserName][floor.Key], Is.EqualTo(floor.Value + (user.UserName == "user1" ? 30 : 0)));
|
||||||
|
var single = typeof(UserService).GetMethod("CalculateUserPrice", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { rules, user, floor.Key, floor.Value });
|
||||||
|
Assert.That(result[user.UserName][floor.Key], Is.EqualTo(single));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(-1, 1, typeof(InvalidOperationException))]
|
||||||
|
[TestCase(10, 2, typeof(InvalidOperationException))]
|
||||||
|
[TestCase(int.MaxValue, 1, typeof(OverflowException))]
|
||||||
|
public void InvalidRuleDataStillFails(int markup, int copies, Type exceptionType)
|
||||||
|
{
|
||||||
|
var rule = new OEMMarkupRuleEntity { TargetType = OEMMarkupTargetType.User, TargetId = "user",
|
||||||
|
SetterOemId = "B", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = markup };
|
||||||
|
Assert.Throws(exceptionType, () => Calculate(new() { new() { UserName = "user", OemId = "B" } },
|
||||||
|
Enumerable.Repeat(rule, copies).ToList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmptyAndInvalidUserListsDoNotAccessDatabase()
|
||||||
|
{
|
||||||
|
using var sql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Server=127.0.0.1;Database=unused;User Id=unused;Password=unused;").Build();
|
||||||
|
var service = new UserService(sql, null!);
|
||||||
|
Assert.That(service.GetUserFinalPrices(Array.Empty<UserEntity>()), Is.Empty);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => service.GetUserFinalPrices(null!));
|
||||||
|
Assert.Throws<ArgumentException>(() => service.GetUserFinalPrices(new[] { new UserEntity() }));
|
||||||
|
Assert.Throws<ArgumentException>(() => service.GetUserFinalPrices(new[] { new UserEntity { UserName = "same" }, new UserEntity { UserName = "same" } }));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using KJD_Web.Services.Users;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WebServiceTest;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class DefaultMarkupOemTest
|
||||||
|
{
|
||||||
|
[TestCase(null)]
|
||||||
|
[TestCase("")]
|
||||||
|
[TestCase(" ")]
|
||||||
|
public void AdminCanSetUnassignedUserAndOrdinaryOemCannot(string? oemId)
|
||||||
|
{
|
||||||
|
var method = typeof(UserService).GetMethod("ResolveMarkupSetter", BindingFlags.NonPublic | BindingFlags.Static)!;
|
||||||
|
var actor = new UserEntity { UserName = "admin", SaLevel = 1 };
|
||||||
|
var user = new UserEntity { UserName = "user", OemId = oemId };
|
||||||
|
Assert.That(method.Invoke(null, new object?[] { OEMMarkupTargetType.User, actor, null, user, null }), Is.EqualTo("00000000"));
|
||||||
|
actor.SaLevel = 0;
|
||||||
|
var error = Assert.Throws<TargetInvocationException>(() => method.Invoke(null, new object?[]
|
||||||
|
{
|
||||||
|
OEMMarkupTargetType.User, actor, new OEMEntity { OemId = "other", OemOwner = "admin" }, user, null
|
||||||
|
}));
|
||||||
|
Assert.That(error!.InnerException, Is.TypeOf<UnauthorizedAccessException>());
|
||||||
|
Assert.That(user.OemId, Is.EqualTo(oemId), "不修改用户原始归属");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(null)]
|
||||||
|
[TestCase("")]
|
||||||
|
[TestCase(" ")]
|
||||||
|
public void SingleAndBatchPricesIncludeDefaultOemUserMarkup(string? oemId)
|
||||||
|
{
|
||||||
|
var user = new UserEntity { UserName = "user", OemId = oemId };
|
||||||
|
var type = UserPaymentTypes.中转仓扣费支出;
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>
|
||||||
|
{
|
||||||
|
new() { SetterOemId = "00000000", TargetType = OEMMarkupTargetType.User, TargetId = "user", PaymentType = type, Markup = 12 },
|
||||||
|
new() { SetterOemId = "old", TargetType = OEMMarkupTargetType.User, TargetId = "user", PaymentType = type, Markup = 99 }
|
||||||
|
};
|
||||||
|
var single = typeof(UserService).GetMethod("CalculateUserPrice", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { rules, user, type, 220 });
|
||||||
|
Assert.That(single, Is.EqualTo(232));
|
||||||
|
var batch = (Dictionary<string, Dictionary<UserPaymentTypes, int>>)typeof(UserService)
|
||||||
|
.GetMethod("CalculateUserPrices", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { new List<UserEntity> { user }, rules, new Dictionary<UserPaymentTypes, int> { [type] = 220 } })!;
|
||||||
|
Assert.That(batch["user"][type], Is.EqualTo(232));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using KJD_Web.Services.Users;
|
||||||
|
using KJD_Web.Requests.Users;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WebServiceTest;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class LegacyMarkupInputTest
|
||||||
|
{
|
||||||
|
[TestCase(250, 220, 12, 18)]
|
||||||
|
[TestCase(232, 220, 12, 0)]
|
||||||
|
[TestCase(250, 220, 0, 30)]
|
||||||
|
public void FinalPriceDeductsFloorAndUpstreamMarkup(int amount, int floor, int upstream, int expected)
|
||||||
|
{
|
||||||
|
var request = new SetMarkupRuleRequest { PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = amount - floor };
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>();
|
||||||
|
if (upstream != 0) rules.Add(new() { TargetType = OEMMarkupTargetType.OEM, TargetId = "B",
|
||||||
|
SetterOemId = "A", PaymentType = request.PaymentType, Markup = upstream });
|
||||||
|
// 其他类型、目标及已有二级加价不应参与扣除。
|
||||||
|
rules.Add(new() { TargetType = OEMMarkupTargetType.OEM, TargetId = "B", PaymentType = UserPaymentTypes.同步物流, Markup = 99 });
|
||||||
|
rules.Add(new() { TargetType = OEMMarkupTargetType.User, TargetId = "B", PaymentType = request.PaymentType, Markup = 99 });
|
||||||
|
rules.Add(new() { TargetType = OEMMarkupTargetType.OEM, TargetId = "other", PaymentType = request.PaymentType, Markup = 99 });
|
||||||
|
typeof(UserService).GetMethod("DeductOemMarkup", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { new List<SetMarkupRuleRequest> { request }, rules, "B" });
|
||||||
|
Assert.That(request.Markup, Is.EqualTo(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(11, 12, 1, typeof(ArgumentException))]
|
||||||
|
[TestCase(30, -1, 1, typeof(InvalidOperationException))]
|
||||||
|
[TestCase(30, 12, 2, typeof(InvalidOperationException))]
|
||||||
|
public void InsufficientAmountAndCorruptUpstreamRulesAreRejected(int afterFloor, int upstream, int count, Type errorType)
|
||||||
|
{
|
||||||
|
var request = new SetMarkupRuleRequest { PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = afterFloor };
|
||||||
|
var rule = new OEMMarkupRuleEntity { TargetType = OEMMarkupTargetType.OEM, TargetId = "00000000",
|
||||||
|
PaymentType = request.PaymentType, Markup = upstream };
|
||||||
|
var error = Assert.Throws<TargetInvocationException>(() => typeof(UserService)
|
||||||
|
.GetMethod("DeductOemMarkup", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { new List<SetMarkupRuleRequest> { request }, Enumerable.Repeat(rule, count).ToList(), "00000000" }));
|
||||||
|
Assert.That(error!.InnerException, Is.TypeOf(errorType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (int UserId, string ActorUserName, List<(UserPaymentTypes PaymentType, int Amount)> Fees) Parse(string input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ((int, string, List<(UserPaymentTypes, int)>))typeof(UserService)
|
||||||
|
.GetMethod("ParseLegacyMarkupInput", BindingFlags.NonPublic | BindingFlags.Static)!.Invoke(null, new object[] { input })!;
|
||||||
|
}
|
||||||
|
catch (TargetInvocationException ex) { throw ex.InnerException!; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapsAllFourTypesAndConvertsYuanToCents()
|
||||||
|
{
|
||||||
|
var result = Parse("id=739&user_name=operator%2Bname&postage_per_order=2.2&refund_postage_per_order=2.50&gift_oem_amount_per_order=1.60&sync_logistics_per_order=1.90");
|
||||||
|
Assert.That(result.UserId, Is.EqualTo(739));
|
||||||
|
Assert.That(result.ActorUserName, Is.EqualTo("operator+name"));
|
||||||
|
Assert.That(result.Fees.Select(a => (int)a.PaymentType), Is.EqualTo(new[] { 20, 26, 16, 55 }));
|
||||||
|
Assert.That(result.Fees.Select(a => a.Amount), Is.EqualTo(new[] { 220, 250, 160, 190 }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MissingFieldsAreNotOverwrittenAndZeroIsPreserved()
|
||||||
|
{
|
||||||
|
Assert.That(Parse("id=739&user_name=operator").Fees, Is.Empty);
|
||||||
|
Assert.That(Parse("id=739&user_name=operator&postage_per_order=0").Fees,
|
||||||
|
Is.EqualTo(new[] { (UserPaymentTypes.中转仓扣费支出, 0) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("")]
|
||||||
|
[TestCase("-1")]
|
||||||
|
[TestCase("abc")]
|
||||||
|
[TestCase("2.201")]
|
||||||
|
[TestCase("21474836.48")]
|
||||||
|
[TestCase("2%2C2")]
|
||||||
|
[TestCase("2.2&postage_per_order=3")]
|
||||||
|
public void InvalidAmountsAreRejected(string value) =>
|
||||||
|
Assert.Throws<ArgumentException>(() => Parse("id=739&user_name=operator&postage_per_order=" + value));
|
||||||
|
|
||||||
|
[TestCase("")]
|
||||||
|
[TestCase("id=0&user_name=operator")]
|
||||||
|
[TestCase("id=739")]
|
||||||
|
[TestCase("id=739&user_name=operator&user_name=admin")]
|
||||||
|
[TestCase("id=739&id=740&user_name=operator")]
|
||||||
|
public void InvalidIdentityFieldsAreRejected(string input) =>
|
||||||
|
Assert.Throws<ArgumentException>(() => Parse(input));
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FeeBelowFloorIsRejectedBeforeDatabaseAccess()
|
||||||
|
{
|
||||||
|
using var sql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Server=127.0.0.1;Database=unused;User Id=unused;Password=unused;").Build();
|
||||||
|
var service = new UserService(sql, null!);
|
||||||
|
Assert.Throws<ArgumentException>(() => service.SetMarkupRule("id=739&user_name=operator&postage_per_order=0"));
|
||||||
|
Assert.DoesNotThrow(() => service.SetMarkupRule("id=739&user_name=operator"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using KJD_Web.Requests.Users;
|
||||||
|
using KJD_Web.Services.Users;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WebServiceTest;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class MarkupRulePermissionTest
|
||||||
|
{
|
||||||
|
private static string Resolve(OEMMarkupTargetType type, UserEntity actor, OEMEntity? owner,
|
||||||
|
UserEntity? user = null, OEMEntity? oem = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (string)typeof(UserService).GetMethod("ResolveMarkupSetter", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object?[] { type, actor, owner, user, oem })!;
|
||||||
|
}
|
||||||
|
catch (TargetInvocationException ex) { throw ex.InnerException!; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0)]
|
||||||
|
[TestCase(1)]
|
||||||
|
public void UserRuleSetterIsTargetUsersOem(int adminLevel)
|
||||||
|
{
|
||||||
|
var actor = new UserEntity { UserName = "operator", SaLevel = (short)adminLevel, OemId = "operator-oem" };
|
||||||
|
var owner = new OEMEntity { OemId = "target-oem", OemOwner = "operator" };
|
||||||
|
var user = new UserEntity { UserName = "main-user", OemId = "target-oem" };
|
||||||
|
Assert.That(Resolve(OEMMarkupTargetType.User, actor, adminLevel == 1 ? null : owner, user), Is.EqualTo("target-oem"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(null)]
|
||||||
|
[TestCase("another-oem")]
|
||||||
|
public void OrdinaryUserAndUnrelatedOemCannotSetUserRule(string? ownerOemId)
|
||||||
|
{
|
||||||
|
var actor = new UserEntity { UserName = "operator", SaLevel = 0 };
|
||||||
|
var owner = ownerOemId == null ? null : new OEMEntity { OemId = ownerOemId, OemOwner = actor.UserName };
|
||||||
|
Assert.Throws<UnauthorizedAccessException>(() => Resolve(OEMMarkupTargetType.User, actor, owner,
|
||||||
|
new UserEntity { UserName = "main-user", OemId = "target-oem" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0)]
|
||||||
|
[TestCase(1)]
|
||||||
|
public void SubUserCannotBeTarget(int adminLevel)
|
||||||
|
{
|
||||||
|
Assert.Throws<InvalidOperationException>(() => Resolve(OEMMarkupTargetType.User,
|
||||||
|
new UserEntity { UserName = "operator", SaLevel = (short)adminLevel },
|
||||||
|
new OEMEntity { OemId = "target-oem", OemOwner = "operator" },
|
||||||
|
new UserEntity { UserName = "sub-user", ParentUserName = "main-user", OemId = "target-oem" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AdminOemRuleUsesParentOem()
|
||||||
|
{
|
||||||
|
Assert.That(Resolve(OEMMarkupTargetType.OEM,
|
||||||
|
new UserEntity { UserName = "admin", SaLevel = 1, OemId = "admin-oem" }, null,
|
||||||
|
oem: new OEMEntity { OemId = "child", ParentOemId = "parent" }), Is.EqualTo("parent"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OemOwnerCannotSetOemRule()
|
||||||
|
{
|
||||||
|
Assert.Throws<UnauthorizedAccessException>(() => Resolve(OEMMarkupTargetType.OEM,
|
||||||
|
new UserEntity { UserName = "owner", SaLevel = 0 }, new OEMEntity { OemId = "parent", OemOwner = "owner" },
|
||||||
|
oem: new OEMEntity { OemId = "child", ParentOemId = "parent" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(null, 0)]
|
||||||
|
[TestCase("parent", 1)]
|
||||||
|
public void RootOrDeletedOemCannotBeTarget(string? parent, int isDeleted)
|
||||||
|
{
|
||||||
|
Assert.Throws<InvalidOperationException>(() => Resolve(OEMMarkupTargetType.OEM,
|
||||||
|
new UserEntity { SaLevel = 1 }, null,
|
||||||
|
oem: new OEMEntity { OemId = "child", ParentOemId = parent, IsDel = (byte)isDeleted }));
|
||||||
|
}
|
||||||
|
|
||||||
|
//[TestCase(null)]
|
||||||
|
//[TestCase(-1)]
|
||||||
|
[TestCase(12)]
|
||||||
|
public void MissingOrNegativeMarkupIsRejectedBeforeDatabaseAccess(int? markup)
|
||||||
|
{
|
||||||
|
using var sql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Server=192.168.0.200;Port=3306;Database=mysql;Uid=root;Pwd=123456;").Build();
|
||||||
|
var service = new UserService(sql, null!);
|
||||||
|
Assert.Throws<ArgumentException>(() => service.SetMarkupRule(new SetMarkupRuleRequest
|
||||||
|
{
|
||||||
|
UserName = "13388889999", TargetType = OEMMarkupTargetType.User, TargetId = "13313717678",
|
||||||
|
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = markup
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
using Autofac;
|
||||||
|
using Autofac.Integration.WebApi;
|
||||||
|
using KJD_Web;
|
||||||
|
using KJD_Web.Services.Shops;
|
||||||
|
using KJD_Web.Services.Users;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using Store.Framework.DependencyInjection;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Web.Http;
|
||||||
|
|
||||||
|
namespace WebServiceTest;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class MarkupRuleTest
|
||||||
|
{
|
||||||
|
private IFreeSql _sql = null!;
|
||||||
|
private UserService _service = null!;
|
||||||
|
private IContainer _container;
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
var config = new HttpConfiguration();
|
||||||
|
_container = ContainerConfig.BuildContainer();
|
||||||
|
config.DependencyResolver = new AutofacWebApiDependencyResolver(_container);
|
||||||
|
WebApiConfig.Register(config);
|
||||||
|
|
||||||
|
//// 仅构造 ORM;这些测试不连接数据库。
|
||||||
|
//_sql = new FreeSql.FreeSqlBuilder()
|
||||||
|
// .UseConnectionString(FreeSql.DataType.MySql, "Server=127.0.0.1;Database=unused;User Id=unused;Password=unused;")
|
||||||
|
// .Build();
|
||||||
|
_service = _container.Resolve<UserService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
_container?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(UserPaymentTypes.中转仓扣费支出, 220)]
|
||||||
|
[TestCase(UserPaymentTypes.退货包裹扣费支出, 250)]
|
||||||
|
[TestCase(UserPaymentTypes.礼物单支出, 160)]
|
||||||
|
[TestCase(UserPaymentTypes.同步物流, 190)]
|
||||||
|
public void DefaultFloorPrice(UserPaymentTypes type, int expected) =>
|
||||||
|
Assert.That(_service.GetDefaultFloorPrice(type), Is.EqualTo(expected));
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MissingBaseFeeConfigurationFailsExplicitly()
|
||||||
|
{
|
||||||
|
var error = Assert.Throws<TargetInvocationException>(() => typeof(OEMMarkupBaseFeeSettings)
|
||||||
|
.GetMethod("ReadFee", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { "missing_base_fee_test" }));
|
||||||
|
Assert.That(error!.InnerException, Is.TypeOf<System.Configuration.ConfigurationErrorsException>());
|
||||||
|
Assert.That(error.InnerException!.Message, Does.Contain("missing_base_fee_test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("15266666662")]
|
||||||
|
[TestCase("18199116224")]
|
||||||
|
[TestCase("13313717678")]
|
||||||
|
[TestCase("18990991234")]
|
||||||
|
public void QueryUserActualPrice(string userName)
|
||||||
|
{
|
||||||
|
var ruleQueries = new List<string>();
|
||||||
|
_container.Resolve<IFreeSql>().Aop.CommandBefore += (_, e) =>
|
||||||
|
{
|
||||||
|
if (e.Command.CommandText.Contains("oem_markup_rule"))
|
||||||
|
ruleQueries.Add(e.Command.CommandText);
|
||||||
|
};
|
||||||
|
var price = _service.GetUserFinalPrice(userName, UserPaymentTypes.中转仓扣费支出);
|
||||||
|
TestContext.WriteLine($"用户 {userName} 的中转仓快递最终价格:{price} 分({price / 100m:F2} 元)");
|
||||||
|
Assert.That(price, Is.GreaterThanOrEqualTo(0));
|
||||||
|
Assert.That(ruleQueries.Count, Is.LessThanOrEqualTo(1));
|
||||||
|
foreach (var sql in ruleQueries)
|
||||||
|
{
|
||||||
|
TestContext.WriteLine(sql);
|
||||||
|
Assert.That(sql, Does.Contain("WHERE").And.Contain("target_id").And.Contain("payment_type"));
|
||||||
|
}
|
||||||
|
var queryCount = ruleQueries.Count;
|
||||||
|
_service.GetUserFinalPrice(userName, UserPaymentTypes.中转仓扣费支出);
|
||||||
|
Assert.That(ruleQueries.Count, Is.EqualTo(queryCount * 2), "再次查询应重新读取加价规则");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RuleLookupMatchesEntireKeyAndDefaultsToZero()
|
||||||
|
{
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>
|
||||||
|
{
|
||||||
|
new() { SetterOemId = "parent", TargetType = OEMMarkupTargetType.User, TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 30 },
|
||||||
|
new() { SetterOemId = "old-parent", TargetType = OEMMarkupTargetType.User, TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 90 },
|
||||||
|
new() { SetterOemId = "parent", TargetType = OEMMarkupTargetType.OEM, TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 40 },
|
||||||
|
new() { SetterOemId = "parent", TargetType = OEMMarkupTargetType.User, TargetId = "other-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 50 },
|
||||||
|
new() { SetterOemId = "parent", TargetType = OEMMarkupTargetType.User, TargetId = "main-user", PaymentType = UserPaymentTypes.退货包裹扣费支出, Markup = 60 }
|
||||||
|
};
|
||||||
|
Assert.That(Lookup(rules), Is.EqualTo(30));
|
||||||
|
Assert.That(Lookup(new List<OEMMarkupRuleEntity>()), Is.Zero);
|
||||||
|
rules[0].Markup = 0;
|
||||||
|
Assert.That(Lookup(rules), Is.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CorruptRulesFailInsteadOfSilentlyChangingPrice()
|
||||||
|
{
|
||||||
|
var rule = new OEMMarkupRuleEntity { SetterOemId = "parent", TargetType = OEMMarkupTargetType.User, TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = -1 };
|
||||||
|
var negative = Assert.Throws<TargetInvocationException>(() => Lookup(new List<OEMMarkupRuleEntity> { rule }));
|
||||||
|
Assert.That(negative!.InnerException, Is.TypeOf<InvalidOperationException>());
|
||||||
|
rule.Markup = 10;
|
||||||
|
var duplicate = Assert.Throws<TargetInvocationException>(() => Lookup(new List<OEMMarkupRuleEntity> { rule, rule }));
|
||||||
|
Assert.That(duplicate!.InnerException, Is.TypeOf<InvalidOperationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(false, false, 220)]
|
||||||
|
[TestCase(true, false, 250)]
|
||||||
|
[TestCase(false, true, 240)]
|
||||||
|
[TestCase(true, true, 270)]
|
||||||
|
public void TwoLevelPriceAllowsEitherRuleToBeMissing(bool hasUserRule, bool hasOemRule, int expected)
|
||||||
|
{
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>
|
||||||
|
{
|
||||||
|
new() { SetterOemId = "old", TargetType = OEMMarkupTargetType.User, TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 100 },
|
||||||
|
new() { SetterOemId = "A", TargetType = OEMMarkupTargetType.OEM, TargetId = "B", PaymentType = UserPaymentTypes.退货包裹扣费支出, Markup = 100 }
|
||||||
|
};
|
||||||
|
if (hasUserRule) rules.Add(new() { SetterOemId = "B", TargetType = OEMMarkupTargetType.User, TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 30 });
|
||||||
|
if (hasOemRule) rules.Add(new() { SetterOemId = "A", TargetType = OEMMarkupTargetType.OEM, TargetId = "B", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 20 });
|
||||||
|
var price = typeof(UserService).GetMethod("CalculateUserPrice", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { rules, new UserEntity { Id = 123, UserName = "main-user", OemId = "B" }, UserPaymentTypes.中转仓扣费支出, 220 });
|
||||||
|
Assert.That(price, Is.EqualTo(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Lookup(List<OEMMarkupRuleEntity> rules) => (int)typeof(UserService)
|
||||||
|
.GetMethod("GetMarkup", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { rules, "parent", OEMMarkupTargetType.User, "main-user", UserPaymentTypes.中转仓扣费支出 })!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
using KJD_Web.Services.Users;
|
||||||
|
using KJD_Web.Responses.Users;
|
||||||
|
using Store.Contracts.User.Entitys;
|
||||||
|
using Store.Contracts.User.Enums;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WebServiceTest;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class MarkupUserNameTest
|
||||||
|
{
|
||||||
|
[TestCase(false, false)]
|
||||||
|
[TestCase(false, true)]
|
||||||
|
[TestCase(true, false)]
|
||||||
|
[TestCase(true, true)]
|
||||||
|
public void MarkupArrayContainsBothLevelsAndDefaultsMissingRulesToZero(bool hasOemRule, bool hasUserRule)
|
||||||
|
{
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>
|
||||||
|
{
|
||||||
|
new() { SetterOemId = "old-oem", TargetType = OEMMarkupTargetType.User, TargetId = "main-user",
|
||||||
|
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 99 },
|
||||||
|
new() { SetterOemId = "A", TargetType = OEMMarkupTargetType.OEM, TargetId = "B",
|
||||||
|
PaymentType = UserPaymentTypes.退货包裹扣费支出, Markup = 88 }
|
||||||
|
};
|
||||||
|
if (hasOemRule) rules.Add(new() { SetterOemId = "A", TargetType = OEMMarkupTargetType.OEM,
|
||||||
|
TargetId = "B", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 10 });
|
||||||
|
if (hasUserRule) rules.Add(new() { SetterOemId = "B", TargetType = OEMMarkupTargetType.User,
|
||||||
|
TargetId = "main-user", PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 20 });
|
||||||
|
var result = (UserMarkupResponse[])typeof(UserService)
|
||||||
|
.GetMethod("BuildUserMarkups", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { rules, new UserEntity { UserName = "main-user", OemId = "B" },
|
||||||
|
UserPaymentTypes.中转仓扣费支出, "A" })!;
|
||||||
|
Assert.That(result.Select(a => a.Level), Is.EqualTo(new[] { 1, 2 }));
|
||||||
|
Assert.That(result.Select(a => a.OemId), Is.EqualTo(new[] { "A", "B" }));
|
||||||
|
Assert.That(result.Select(a => a.Markup), Is.EqualTo(new[] { hasOemRule ? 10 : 0, hasUserRule ? 20 : 0 }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(null, null)]
|
||||||
|
[TestCase("", " ")]
|
||||||
|
[TestCase("B", null)]
|
||||||
|
public void MissingParentIsNullAndUnassignedUserUsesDefaultOem(string? oemId, string? parentOemId)
|
||||||
|
{
|
||||||
|
var result = (UserMarkupResponse[])typeof(UserService)
|
||||||
|
.GetMethod("BuildUserMarkups", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object?[] { new List<OEMMarkupRuleEntity>(),
|
||||||
|
new UserEntity { UserName = "main-user", OemId = oemId },
|
||||||
|
UserPaymentTypes.中转仓扣费支出, parentOemId })!;
|
||||||
|
Assert.That(result[0].OemId, Is.Null);
|
||||||
|
Assert.That(result[1].OemId, Is.EqualTo(string.IsNullOrWhiteSpace(oemId) ? "00000000" : oemId));
|
||||||
|
Assert.That(result.Select(a => a.Markup), Is.EqualTo(new[] { 0, 0 }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(null)]
|
||||||
|
[TestCase("different-parent")]
|
||||||
|
public void FirstLevelUsesRuleSetterEvenWhenParentIsMissingOrDifferent(string? parentOemId)
|
||||||
|
{
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>
|
||||||
|
{
|
||||||
|
new() { SetterOemId = "wrong-type", TargetType = OEMMarkupTargetType.OEM, TargetId = "B",
|
||||||
|
PaymentType = UserPaymentTypes.退货包裹扣费支出, Markup = 99 },
|
||||||
|
new() { SetterOemId = "A", TargetType = OEMMarkupTargetType.OEM, TargetId = "B",
|
||||||
|
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 12 }
|
||||||
|
};
|
||||||
|
var result = (UserMarkupResponse[])typeof(UserService)
|
||||||
|
.GetMethod("BuildUserMarkups", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object?[] { rules, new UserEntity { UserName = "main-user", OemId = "B" },
|
||||||
|
UserPaymentTypes.中转仓扣费支出, parentOemId })!;
|
||||||
|
Assert.That(result[0].OemId, Is.EqualTo("A"));
|
||||||
|
Assert.That(result[0].Markup, Is.EqualTo(12));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(false, 220)]
|
||||||
|
[TestCase(true, 250)]
|
||||||
|
public void UserRuleMatchesUserNameInsteadOfNumericId(bool hasUserRule, int expected)
|
||||||
|
{
|
||||||
|
var rules = new List<OEMMarkupRuleEntity>
|
||||||
|
{
|
||||||
|
new() { SetterOemId = "B", TargetType = OEMMarkupTargetType.User, TargetId = "123",
|
||||||
|
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 90 }
|
||||||
|
};
|
||||||
|
if (hasUserRule)
|
||||||
|
rules.Add(new() { SetterOemId = "B", TargetType = OEMMarkupTargetType.User, TargetId = "main-user",
|
||||||
|
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 30 });
|
||||||
|
|
||||||
|
var price = typeof(UserService).GetMethod("CalculateUserPrice", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||||
|
.Invoke(null, new object[] { rules, new UserEntity { Id = 123, UserName = "main-user", OemId = "B" },
|
||||||
|
UserPaymentTypes.中转仓扣费支出, 220 });
|
||||||
|
Assert.That(price, Is.EqualTo(expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,8 +105,8 @@ internal class ShopTest
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
DateTime startDate = DateTime.Parse("2026/10/5");
|
DateTime startDate = DateTime.Parse("2026/07/1");
|
||||||
DateTime endDate = DateTime.Parse("2026/10/14");
|
DateTime endDate = DateTime.Parse("2026/11/10");
|
||||||
|
|
||||||
for (DateTime d = startDate; d <= endDate; d = d.AddDays(1))
|
for (DateTime d = startDate; d <= endDate; d = d.AddDays(1))
|
||||||
{
|
{
|
||||||
@@ -134,14 +134,19 @@ internal class ShopTest
|
|||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetShopSalesOrderTest()
|
[TestCaseSource(nameof(CaseArray))]
|
||||||
|
public void GetShopSalesOrderTest(DateTime date)
|
||||||
{
|
{
|
||||||
var shopService = _container.Resolve<ShopService>();
|
var shopService = _container.Resolve<ShopService>();
|
||||||
var shopIds =shopService.GetShopIds("15937791563");
|
var shopIds =shopService.GetShopIds("18990991234");
|
||||||
//shopIds = null;
|
//shopIds = null;
|
||||||
var shopStatsService = _container.Resolve<ShopRevenueStatisticsService>();
|
var shopStatsService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||||
DateTime date = DateTime.Parse("2026/10/17");
|
//DateTime date = DateTime.Parse("2026/10/1");
|
||||||
|
|
||||||
|
//if (!string.IsNullOrEmpty(dateString))
|
||||||
|
//{
|
||||||
|
// date = DateTime.Parse(dateString);
|
||||||
|
//}
|
||||||
Console.WriteLine($"开始:{date.ToLongDateString()}");
|
Console.WriteLine($"开始:{date.ToLongDateString()}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace WebServiceTest
|
|||||||
WXOemManage manage = new WXOemManage();
|
WXOemManage manage = new WXOemManage();
|
||||||
string ret = manage.OemWithdrawals(new KJD_Web.BLL.WXXD.Requests.OemWithdrawalQueryRequest
|
string ret = manage.OemWithdrawals(new KJD_Web.BLL.WXXD.Requests.OemWithdrawalQueryRequest
|
||||||
{
|
{
|
||||||
UserName = "18990991234",
|
UserName = "13459139999",
|
||||||
});
|
});
|
||||||
Console.WriteLine(ret);
|
Console.WriteLine(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ internal class UserTest
|
|||||||
//[TestCase("15907090308")]
|
//[TestCase("15907090308")]
|
||||||
//[TestCase("17837688880")]
|
//[TestCase("17837688880")]
|
||||||
//[TestCase("13048056467")]
|
//[TestCase("13048056467")]
|
||||||
[TestCase("17318585555")]
|
[TestCase("17337708962")]
|
||||||
//[TestCase("13459139999")]
|
//[TestCase("13459139999")]
|
||||||
//[TestCase("18737568536")]
|
//[TestCase("18737568536")]
|
||||||
//[TestCase("18949822610")]
|
//[TestCase("18949822610")]
|
||||||
@@ -93,7 +93,7 @@ internal class UserTest
|
|||||||
public void UserPaymentTest()
|
public void UserPaymentTest()
|
||||||
{
|
{
|
||||||
var userService = _container.Resolve<UserService>();
|
var userService = _container.Resolve<UserService>();
|
||||||
userService.UserPayment("13693693691", "", Store.Contracts.User.Enums.UserPaymentTypes.同步单号);
|
userService.UserPayment("13693693691", "", Store.Contracts.User.Enums.UserPaymentTypes.同步物流);
|
||||||
|
|
||||||
}
|
}
|
||||||
[Test]
|
[Test]
|
||||||
@@ -103,6 +103,19 @@ internal class UserTest
|
|||||||
var data = userService.GetUserAmountSummary("17734871710");
|
var data = userService.GetUserAmountSummary("17734871710");
|
||||||
Console.WriteLine(JsonConvert.SerializeObject(data));
|
Console.WriteLine(JsonConvert.SerializeObject(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BuyImageAnalysisQuota()
|
||||||
|
{
|
||||||
|
var userService = _container.Resolve<UserService>();
|
||||||
|
var data = userService.BuyImageAnalysisQuota(new KJD_Web.Requests.Users.ImageAnalysisRequest
|
||||||
|
{
|
||||||
|
UserName = "18990991234",
|
||||||
|
Amount = 1
|
||||||
|
});
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(data));
|
||||||
|
}
|
||||||
//[Test]
|
//[Test]
|
||||||
//public void Fill()
|
//public void Fill()
|
||||||
//{
|
//{
|
||||||
|
|||||||
Reference in new issue
Block a user