1 bxx相关逻辑 2 店铺活动相关逻辑

This commit is contained in:
wule committed 2025-09-09 19:07:29 +08:00
1 parent fc017993df
commit b44fa2a6c3
35 files changed
+460 -3861

No files matched your search

@@ -393,9 +393,11 @@ namespace TemuKJD.KJDForms.SalesCenterForms
pActThematic.activityTypeName = pActivity.activityName;
lstActivityThematic.Add(pActThematic);
string name = pActThematic.activityThematicName;
pActThematic.discount = BaseRegex.GetMatchRegexString(ref name, "(\\d{1,3}折)").ParseToString();
pActThematic.discount = pActThematic.discount.Replace("折", "");
pActThematic.discount = BaseRegex.GetMatchRegexString(ref name, "(\\d{1,3}(\\.?\\d?)折)").ParseToString();
pActThematic.discount = pActThematic.discount.Replace("折", "").Replace(".","");
pActThematic.discount = string.IsNullOrWhiteSpace(pActThematic.discount) ? "" : pActThematic.discount;
if (pActThematic.discount.Length == 1)
pActThematic.discount += "0"; // 补0
}
}
}
@@ -636,6 +638,8 @@ namespace TemuKJD.KJDForms.SalesCenterForms
var dailyPrice = skuObj["dailyPrice"].ParseToInt();
var discount = suggestActivityPrice * 100.0 / dailyPrice;
actInfo.discount = Math.Round(discount) + "";
if (actInfo.discount.Length == 1)
actInfo.discount += "0"; // 补0
Invoke(new Action(() =>
{
actRow.Cells["colDiscount"].Value = string.IsNullOrEmpty(actInfo.discount) ? "-" : actInfo.discount.TrimEnd('0') + "折";
@@ -665,7 +669,7 @@ namespace TemuKJD.KJDForms.SalesCenterForms
return lstDiscount.First();
if (discount >= lstDiscount.Last())
return lstDiscount.Last();
for (int i = 0; i < lstDiscount.Count - 2; i++)
for (int i = 0; i < lstDiscount.Count - 1; i++)
{
if (discount >= lstDiscount[i] && discount < lstDiscount[i + 1])
return lstDiscount[i];
@@ -732,6 +736,7 @@ namespace TemuKJD.KJDForms.SalesCenterForms
public List<string> GetNoSaleProd(string shopId)
{
int onSaleDays = 0;
int onSaleDays2 = 9999;
int saleCount = 0;
string days = "7";
//int i = 0;
@@ -741,6 +746,7 @@ namespace TemuKJD.KJDForms.SalesCenterForms
{
days = cmbDays.Text;
onSaleDays = numOnSaleDays.Value.ParseToInt();
onSaleDays2 = numOnSaleDays2.Value.ParseToInt();
saleCount = numSaleCount.Value.ParseToInt();
this.statusBar.lblTaskStatus.Text = "正在查询无销量商品...";
@@ -775,7 +781,7 @@ namespace TemuKJD.KJDForms.SalesCenterForms
{
page++;
string jsonRst = GetNoSaleProd(shop, days, onSaleDays, saleCount, page);
string jsonRst = GetNoSaleProd(shop, days, onSaleDays, onSaleDays2, saleCount, page);
if (!jsonRst.Contains("\"success\":true"))
{
@@ -871,7 +877,12 @@ namespace TemuKJD.KJDForms.SalesCenterForms
int tryCount = 0;
tryAgain:
Thread.Sleep(100 + Randomx.GetId(200));
if (chkNoSaleProd.Checked && noSaleProdIdLst.Count == 0)
{
noSaleProdIdLst.Add("123");
}
var jsonRst = GetActivityMatch(shop, activity.activityType, activity.activityThematicId, string.Join(",", noSaleProdIdLst));
if (jsonRst.Contains("指定的值含有无效的控制字符") || jsonRst.Contains("login") || jsonRst.Contains("Login"))
{
Invoke(new Action(() =>
@@ -948,8 +959,10 @@ namespace TemuKJD.KJDForms.SalesCenterForms
discountCtrl = this.actDiscount85;
// 如果是默认库存或者库存小于推荐值,使用推荐库存
int inventory = discountCtrl.Inventory;
if (inventory < prod.suggestActivityStock || discountCtrl.IsDefaultInventory)
inventory = prod.suggestActivityStock.ParseToInt();
//if (inventory < prod.suggestActivityStock || discountCtrl.IsDefaultInventory)
// inventory = prod.suggestActivityStock.ParseToInt();
if (inventory < prod.targetActivityStock || discountCtrl.IsDefaultInventory)
inventory = prod.targetActivityStock.ParseToInt();
Invoke(new Action(() =>
{
int rowId = dgvProduct.Rows.Add(
@@ -965,13 +978,23 @@ namespace TemuKJD.KJDForms.SalesCenterForms
prod.skcList.FirstOrDefault()?.extCode,
activity.discount.Trim('0') + "折",
prod.suggestActivityStock,
prod.targetActivityStock,
activity.discount.Trim('0') + "折",
inventory
);
dgvProduct.Rows[rowId].Height = 30;
prodSubmitRows.Add(dgvProduct.Rows[rowId]);
// 过低的报名数量则不参与活动
if (!discountCtrl.IsDefaultInventory && chkIfLowCancel.Checked && discountCtrl.Inventory < prod.targetActivityStock)
{
}
else
prodSubmitRows.Add(dgvProduct.Rows[rowId]);
}));
if (!discountCtrl.IsDefaultInventory && chkIfLowCancel.Checked && discountCtrl.Inventory < prod.targetActivityStock)
{
continue;
}
ActProductListItem activityProditem = new ActProductListItem();
activityProditem.productId = prod.productId;
activityProditem.activityStock = inventory;
@@ -1137,16 +1160,16 @@ namespace TemuKJD.KJDForms.SalesCenterForms
/// <param name="onSalesDays">加入站点天数</param>
/// <param name="page"></param>
/// <returns></returns>
private string GetNoSaleProd(ShopLoginInfo shop, string days, int onSalesDays, int saleCount = 0, int page=1)
private string GetNoSaleProd(ShopLoginInfo shop, string days, int onSalesDays, int onSalesDays2, int saleCount = 0, int page=1)
{
string url = "https://agentseller.temu.com/mms/venom/api/supplier/sales/management/listWarehouse";
string body;
if (days == "7")
body = @"{""pageNo"":" + page + @",""pageSize"":40,""isLack"":0,""selectStatusList"":[12],""priceAdjustRecentDays"":7,
""sevenDaysSaleVolumMin"":0, ""sevenDaysSaleVolumMax"":" + saleCount + @",""onSalesDurationOfflineGte"":" + onSalesDays + "}";
""sevenDaysSaleVolumMin"":0, ""sevenDaysSaleVolumMax"":" + saleCount + @",""onSalesDurationOfflineGte"":" + onSalesDays + @",""onSalesDurationOfflineLte"":" + onSalesDays2 + "}";
else
body = @"{""pageNo"":" + page + @",""pageSize"":40,""isLack"":0,""selectStatusList"":[12],""priceAdjustRecentDays"":7,
""thirtyDaysSaleVolumMin"":0, ""thirtyDaysSaleVolumMax"":" + saleCount + @",""onSalesDurationOfflineGte"":" + onSalesDays + "}";
""thirtyDaysSaleVolumMin"":0, ""thirtyDaysSaleVolumMax"":" + saleCount + @",""onSalesDurationOfflineGte"":" + onSalesDays + @",""onSalesDurationOfflineLte"":"+ onSalesDays2 + "}";
string refere = "https://agentseller.temu.com/stock/fully-mgt/sale-manage/main";
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
}