优化加入jit操作中的卡顿问题

This commit is contained in:
wule committed 2025-11-20 09:42:23 +08:00
1 parent d0ee274e2f
commit b23eb0e497
10 files changed
+1788 -783

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary> /// <summary>
/// 版本ID /// 版本ID
/// </summary> /// </summary>
public static int VersionCount = 678; public static int VersionCount = 683;
//public static int VersionCount = 613; //public static int VersionCount = 613;
/// <summary> /// <summary>
@@ -24,6 +24,8 @@ namespace TemuKJD.KJDForms.ProductForms
/// </summary> /// </summary>
public partial class ProductChangePriceForm : LRBaseForm public partial class ProductChangePriceForm : LRBaseForm
{ {
public bool IsAuto = false;
decimal wantPrice;
string skcId = ""; string skcId = "";
string productId = ""; string productId = "";
string productName = ""; string productName = "";
@@ -31,7 +33,8 @@ namespace TemuKJD.KJDForms.ProductForms
TemuListProductInfo productInfo = null; TemuListProductInfo productInfo = null;
WarehouseProductSubOrderInfo wareHouseOrderInfo = null; WarehouseProductSubOrderInfo wareHouseOrderInfo = null;
Dictionary<string, int> dicAdjustReason = new Dictionary<string, int>(); Dictionary<string, int> dicAdjustReason = new Dictionary<string, int>();
public bool IsAdjustPrice = false; public string ErrMsg = "";
public bool IsAdjustPrice = false; // 是否调价成功
public ProductChangePriceForm(ShopLoginInfo _shop, WarehouseProductSubOrderInfo _wareHouseOrderInfo) public ProductChangePriceForm(ShopLoginInfo _shop, WarehouseProductSubOrderInfo _wareHouseOrderInfo)
{ {
@@ -44,7 +47,7 @@ namespace TemuKJD.KJDForms.ProductForms
} }
//TemuListProductInfo //TemuListProductInfo
public ProductChangePriceForm(ShopLoginInfo _shop, TemuListProductInfo _prod) public ProductChangePriceForm(ShopLoginInfo _shop, TemuListProductInfo _prod, decimal _wantPrice = 0)
{ {
InitializeComponent(); InitializeComponent();
shop = _shop; shop = _shop;
@@ -52,6 +55,7 @@ namespace TemuKJD.KJDForms.ProductForms
skcId = productInfo?.productSkcId.ParseToString(); skcId = productInfo?.productSkcId.ParseToString();
productId = productInfo?.productId.ParseToString(); productId = productInfo?.productId.ParseToString();
productName = productInfo?.productName.ParseToString(); productName = productInfo?.productName.ParseToString();
wantPrice = _wantPrice;
} }
private void ProductChangePriceForm_Load(object sender, EventArgs e) private void ProductChangePriceForm_Load(object sender, EventArgs e)
@@ -88,6 +92,10 @@ namespace TemuKJD.KJDForms.ProductForms
{ {
pbLoading.Visible = false; pbLoading.Visible = false;
})); }));
if (IsAuto)
{
SaveNewPrice();
}
}); });
} }
@@ -95,20 +103,29 @@ namespace TemuKJD.KJDForms.ProductForms
{ {
if (shop == null || productId.IsNullOrEmpty() || skcId.IsNullOrEmpty() || productName.IsNullOrEmpty()) if (shop == null || productId.IsNullOrEmpty() || skcId.IsNullOrEmpty() || productName.IsNullOrEmpty())
{ {
BaseMsgForm.ShowError("店铺商品信息为空!"); if (IsAuto)
ErrMsg = "店铺商品信息为空!";
else
BaseMsgForm.ShowError("店铺商品信息为空!");
return; return;
} }
#region 检测登录 #region 检测登录
if (shop.LoginStatus2 != "国际版在线") if (shop.LoginStatus2 != "国际版在线")
{ {
BaseMsgForm.ShowError("店铺未登录!"); if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
return; return;
} }
ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
if (shop.LoginStatus2 != "国际版在线") if (shop.LoginStatus2 != "国际版在线")
{ {
BaseMsgForm.ShowError("店铺未登录!"); if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
return; return;
} }
#endregion #endregion
@@ -129,7 +146,10 @@ namespace TemuKJD.KJDForms.ProductForms
if (string.IsNullOrEmpty(sErr)) if (string.IsNullOrEmpty(sErr))
sErr = adjustRst; sErr = adjustRst;
BaseMsgForm.ShowError("查询失败:" + sErr); if (IsAuto)
ErrMsg = "查询失败:" + sErr;
else
BaseMsgForm.ShowError("查询失败:" + sErr);
return; return;
} }
@@ -142,6 +162,7 @@ namespace TemuKJD.KJDForms.ProductForms
foreach (var item in adjustPriceInfo.spuAdjustResult[productId].skcItems[0].items) foreach (var item in adjustPriceInfo.spuAdjustResult[productId].skcItems[0].items)
{ {
int mainRowId = -1; int mainRowId = -1;
// 修改日常价格
Invoke(new Action(() => Invoke(new Action(() =>
{ {
mainRowId = this.dgvOrder.Rows.Add( mainRowId = this.dgvOrder.Rows.Add(
@@ -153,7 +174,7 @@ namespace TemuKJD.KJDForms.ProductForms
"", "",
"日常价格", //申报价格类型 "日常价格", //申报价格类型
item.originSupplyPrice.ParseToDecimal() / 100m, //原申报价格 item.originSupplyPrice.ParseToDecimal() / 100m, //原申报价格
"", //调整后的申报价格 wantPrice == 0 ? "" : wantPrice.ToString("0.00"), //调整后的申报价格
"调价成功之后生成的交易订单", "调价成功之后生成的交易订单",
"" ""
); );
@@ -161,13 +182,14 @@ namespace TemuKJD.KJDForms.ProductForms
})); }));
if (item?.marketingActivityPriceDTOList == null) if (item?.marketingActivityPriceDTOList == null)
continue; continue;
// 修改活动价格
foreach (var activityPriceDTO in item.marketingActivityPriceDTOList) foreach (var activityPriceDTO in item.marketingActivityPriceDTOList)
{ {
int rowId = -1; int rowId = -1;
Invoke(new Action(() => Invoke(new Action(() =>
{ {
rowId = this.dgvOrder.Rows.Add( rowId = this.dgvOrder.Rows.Add(
true, IsAuto ? false : true,
productId, productId,
skcId, skcId,
item.productSkuId, item.productSkuId,
@@ -285,9 +307,22 @@ namespace TemuKJD.KJDForms.ProductForms
} }
} }
private async void btnSave_Click(object sender, EventArgs e) public async void btnSave_Click(object sender, EventArgs e)
{ {
txtReason.Focus(); txtReason.Focus();
await Task.Run(() =>
{
Thread.Sleep(10);
});
Task.Run(() =>
{
SaveNewPrice();
});
}
public void SaveNewPrice()
{
if (shop == null || productId.IsNullOrEmpty() || skcId.IsNullOrEmpty() || productName.IsNullOrEmpty()) if (shop == null || productId.IsNullOrEmpty() || skcId.IsNullOrEmpty() || productName.IsNullOrEmpty())
{ {
BaseMsgForm.ShowError("店铺商品信息为空!"); BaseMsgForm.ShowError("店铺商品信息为空!");
@@ -310,62 +345,70 @@ namespace TemuKJD.KJDForms.ProductForms
} }
} }
pbLoading.Visible = true; Invoke(new Action(() =>
{
pbLoading.Visible = true;
}));
#region 检测登录 #region 检测登录
if (shop.LoginStatus2 != "国际版在线") if (shop.LoginStatus2 != "国际版在线")
{ {
BaseMsgForm.ShowError("店铺未登录!"); if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
pbLoading.Visible = false; pbLoading.Visible = false;
return; return;
} }
ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
if (shop.LoginStatus2 != "国际版在线") if (shop.LoginStatus2 != "国际版在线")
{ {
BaseMsgForm.ShowError("店铺未登录!"); if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
pbLoading.Visible = false; pbLoading.Visible = false;
return; return;
} }
#endregion #endregion
await Task.Run(() =>
{
Thread.Sleep(200);
});
AdjustParam param = new AdjustParam(); AdjustParam param = new AdjustParam();
if (dicAdjustReason.Keys.Contains(cmbChangePriceReason.Text)) Invoke(new Action(() =>
param.adjustReason = dicAdjustReason[cmbChangePriceReason.Text];
if (!string.IsNullOrWhiteSpace(txtReason.Text))
param.reason = txtReason.Text.Trim();
param.adjustItems = new List<adjustItem>();
adjustItem adjustItem = new adjustItem()
{ {
productId = this.productId.ParseToLong(), if (dicAdjustReason.Keys.Contains(cmbChangePriceReason.Text))
productName = this.productName, param.adjustReason = dicAdjustReason[cmbChangePriceReason.Text];
productSkcId = this.skcId.ParseToLong(), if (!string.IsNullOrWhiteSpace(txtReason.Text))
supplierId = this.shop.ShopId.ParseToLong(), param.reason = txtReason.Text.Trim();
}; param.adjustItems = new List<adjustItem>();
param.adjustItems.Add(adjustItem); adjustItem adjustItem = new adjustItem()
adjustItem.skuAdjustList = new List<skuAdjust>();
foreach (DataGridViewRow row in dgvOrder.Rows)
{
if (row.Cells["colSelect"].Value.ParseToBool() == true)
{ {
var adjItem = new skuAdjust productId = this.productId.ParseToLong(),
productName = this.productName,
productSkcId = this.skcId.ParseToLong(),
supplierId = this.shop.ShopId.ParseToLong(),
};
param.adjustItems.Add(adjustItem);
adjustItem.skuAdjustList = new List<skuAdjust>();
foreach (DataGridViewRow row in dgvOrder.Rows)
{
if (row.Cells["colSelect"].Value.ParseToBool() == true)
{ {
activityInvitationId = row.Cells["colAdjustPriceTypeId"].Value.ParseToLong(), var adjItem = new skuAdjust
oldPriceCurrency = "CNY", {
targetPriceCurrency = "CNY", activityInvitationId = row.Cells["colAdjustPriceTypeId"].Value.ParseToLong(),
oldSupplyPrice = (row.Cells["colSkuPrice"].Value.ParseToDecimal() * 100).ParseToInt(), oldPriceCurrency = "CNY",
syncPurchasePrice = 1, targetPriceCurrency = "CNY",
targetSupplyPrice = (row.Cells["colSkuNewPrice"].Value.ParseToDecimal() * 100).ParseToInt(), oldSupplyPrice = (row.Cells["colSkuPrice"].Value.ParseToDecimal() * 100).ParseToInt(),
skuId = row.Cells["colSkuId"].Value.ParseToLong(), syncPurchasePrice = 1,
}; targetSupplyPrice = (row.Cells["colSkuNewPrice"].Value.ParseToDecimal() * 100).ParseToInt(),
adjustItem.skuAdjustList.Add(adjItem); skuId = row.Cells["colSkuId"].Value.ParseToLong(),
if (adjItem.activityInvitationId == 0) };
adjItem.activityInvitationId = null; adjustItem.skuAdjustList.Add(adjItem);
if (adjItem.activityInvitationId == 0)
adjItem.activityInvitationId = null;
}
} }
} }));
int tryCount = 0; int tryCount = 0;
tryAgain: tryAgain:
@@ -385,49 +428,67 @@ namespace TemuKJD.KJDForms.ProductForms
sErr = adjustBatchRst; sErr = adjustBatchRst;
sErr = sErr.Replace("\\n", "\n").Replace("\n", "\r\n").Replace("\r\r", "\r"); sErr = sErr.Replace("\\n", "\n").Replace("\n", "\r\n").Replace("\r\r", "\r");
BaseMsgForm.ShowError("调价失败:" + sErr); if (IsAuto)
pbLoading.Visible = false; ErrMsg = "调价失败:" + sErr;
else
BaseMsgForm.ShowError("调价失败:" + sErr);
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
return; return;
} }
IsAdjustPrice = true;
// 更新统计列表的数据价格 // 更新统计列表的数据价格
foreach (DataGridViewRow row in dgvOrder.Rows) foreach (DataGridViewRow row in dgvOrder.Rows)
{ {
if (row.Cells["colSelect"].Value.ParseToBool() == true) Invoke(new Action(() =>
{ {
var adjItem = new skuAdjust if (row.Cells["colSelect"].Value.ParseToBool() == true)
{ {
activityInvitationId = row.Cells["colAdjustPriceTypeId"].Value.ParseToLong(), var adjItem = new skuAdjust
oldPriceCurrency = "CNY",
targetPriceCurrency = "CNY",
oldSupplyPrice = (row.Cells["colSkuPrice"].Value.ParseToDecimal() * 100).ParseToInt(),
syncPurchasePrice = 1,
targetSupplyPrice = (row.Cells["colSkuNewPrice"].Value.ParseToDecimal() * 100).ParseToInt(),
skuId = row.Cells["colSkuId"].Value.ParseToLong(),
};
if (adjItem.activityInvitationId == 0) // 为0的是商品基础价格,否则是活动价格
{
if (wareHouseOrderInfo != null)
{ {
var sku = wareHouseOrderInfo.skuQuantityDetailList.FirstOrDefault(s => s.productSkuId.ParseToLong() == adjItem.skuId); activityInvitationId = row.Cells["colAdjustPriceTypeId"].Value.ParseToLong(),
if (sku != null) oldPriceCurrency = "CNY",
sku.supplierPrice = adjItem.targetSupplyPrice; targetPriceCurrency = "CNY",
} oldSupplyPrice = (row.Cells["colSkuPrice"].Value.ParseToDecimal() * 100).ParseToInt(),
if (productInfo != null) syncPurchasePrice = 1,
targetSupplyPrice = (row.Cells["colSkuNewPrice"].Value.ParseToDecimal() * 100).ParseToInt(),
skuId = row.Cells["colSkuId"].Value.ParseToLong(),
};
if (adjItem.activityInvitationId == 0) // 为0的是商品基础价格,否则是活动价格
{ {
var sku = productInfo.productSkuSummaries.FirstOrDefault(s => s.productSkuId.ParseToLong() == adjItem.skuId); if (wareHouseOrderInfo != null)
if (sku!= null)
{ {
sku.supplierPrice = adjItem.targetSupplyPrice; var sku = wareHouseOrderInfo.skuQuantityDetailList.FirstOrDefault(s => s.productSkuId.ParseToLong() == adjItem.skuId);
if (sku != null)
sku.supplierPrice = adjItem.targetSupplyPrice;
}
if (productInfo != null)
{
var sku = productInfo.productSkuSummaries.FirstOrDefault(s => s.productSkuId.ParseToLong() == adjItem.skuId);
if (sku != null)
{
sku.supplierPrice = adjItem.targetSupplyPrice;
}
} }
} }
} }
} }));
}
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
IsAdjustPrice = true;
if (!IsAuto)
{
BaseMsgForm.ShowInfo("调价成功!");
Invoke(new Action(() =>
{
this.Close();
}));
} }
BaseMsgForm.ShowInfo("调价成功!");
pbLoading.Visible = false;
this.Close();
} }
} }
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -117,6 +117,12 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="colSelectExtCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colFilterExtCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colSelect.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="colSelect.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@@ -17,15 +17,19 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
{ {
public partial class ChangeStockForm : LRBaseForm public partial class ChangeStockForm : LRBaseForm
{ {
public bool IsSuccess = false; public bool IsEditSuccess = false;
public bool IsAuto = false;
public string ErrMsg = "";
public changeStockParam stockParam; public changeStockParam stockParam;
ShopLoginInfo shop; ShopLoginInfo shop;
TemuListProductInfo product; TemuListProductInfo product;
public ChangeStockForm(ShopLoginInfo _shop, TemuListProductInfo _product) int wantStock;
public ChangeStockForm(ShopLoginInfo _shop, TemuListProductInfo _product, int _wantStock = 0)
{ {
InitializeComponent(); InitializeComponent();
shop = _shop; shop = _shop;
product = _product; product = _product;
wantStock = _wantStock;
} }
private void btnBatchFill_Click(object sender, EventArgs e) private void btnBatchFill_Click(object sender, EventArgs e)
@@ -57,12 +61,42 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
edit.txtStockNow.Text = sku.virtualStock == null ? "-" : sku.virtualStock.ParseToString(); edit.txtStockNow.Text = sku.virtualStock == null ? "-" : sku.virtualStock.ParseToString();
edit.lblStockAfterChange.Text = ""; edit.lblStockAfterChange.Text = "";
edit.Tag = sku; edit.Tag = sku;
if (wantStock > 0)
{
if (sku.virtualStock.ParseToInt() > wantStock)
{
edit.cmbIsAddOrReduce.Text = "减少";
edit.txtAddOrReduceNum.Text = "" + (sku.virtualStock.ParseToInt() - wantStock);
}
else if (sku.virtualStock.ParseToInt() < wantStock)
{
edit.cmbIsAddOrReduce.Text = "增加";
edit.txtAddOrReduceNum.Text = "" + (wantStock - sku.virtualStock.ParseToInt());
}
}
this.flowLayoutPanel1.Controls.Add(edit); this.flowLayoutPanel1.Controls.Add(edit);
} }
} }
if (IsAuto)
{
Task.Run(() =>
{
SaveStock();
});
}
} }
private void btnSave_Click(object sender, EventArgs e) public void btnSave_Click(object sender, EventArgs e)
{
Task.Run(() =>
{
SaveStock();
});
}
void SaveStock()
{ {
stockParam = new changeStockParam(); stockParam = new changeStockParam();
stockParam.productId = this.product.productId; stockParam.productId = this.product.productId;
@@ -73,35 +107,48 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
stockChangeDtoParam.productSkcId = this.product.productSkcId; stockChangeDtoParam.productSkcId = this.product.productSkcId;
stockChangeDtoParam.stockUpdateSource = 1; stockChangeDtoParam.stockUpdateSource = 1;
stockChangeDtoParam.skuVirtualStockChangeList = new List<skuVirtualStockChange>(); stockChangeDtoParam.skuVirtualStockChangeList = new List<skuVirtualStockChange>();
foreach (var control in flowLayoutPanel1.Controls) Invoke(new Action(() =>
{ {
var edit = control as UcStockEdit; foreach (var control in flowLayoutPanel1.Controls)
if (edit == null)
{ {
continue; var edit = control as UcStockEdit;
if (edit == null)
{
continue;
}
var sku = edit.Tag as TemuProductSkusummaryItem;
if (sku == null)
{
continue;
}
skuVirtualStockChange change = new skuVirtualStockChange()
{
productSkuId = sku.productSkuId,
currentStockAvailable = sku.virtualStock.ParseToInt(),
virtualStockDiff = edit.txtAddOrReduceNum.Text.ParseToInt(),
};
if (edit.cmbIsAddOrReduce.Text == "减少")
change.virtualStockDiff = 0 - change.virtualStockDiff;
if (change.virtualStockDiff != 0)
stockChangeDtoParam.skuVirtualStockChangeList.Add(change);
} }
var sku = edit.Tag as TemuProductSkusummaryItem; }));
if (sku == null)
{
continue;
}
skuVirtualStockChange change = new skuVirtualStockChange()
{
productSkuId = sku.productSkuId,
currentStockAvailable = sku.virtualStock.ParseToInt(),
virtualStockDiff = edit.txtAddOrReduceNum.Text.ParseToInt(),
};
if (edit.cmbIsAddOrReduce.Text == "减少")
change.virtualStockDiff = 0 - change.virtualStockDiff;
if (change.virtualStockDiff != 0)
stockChangeDtoParam.skuVirtualStockChangeList.Add(change);
}
if (stockChangeDtoParam.skuVirtualStockChangeList.Count == 0) if (stockChangeDtoParam.skuVirtualStockChangeList.Count == 0)
{ {
BaseMsgForm.ShowError("请至少改动一项价格!"); if (IsAuto)
IsEditSuccess = true;
else
BaseMsgForm.ShowError("请至少改动一项价格!");
return; return;
} }
var rst = EditStock(shop, stockParam); var rst = EditStock(shop, stockParam);
for (int i = 0; i < 5 && rst.Contains("修改库存失败:请勿频繁提交"); i++)
{
rst = EditStock(shop, stockParam);
System.Threading.Thread.Sleep(Randomx.GetId(3000, 5000));
}
//{"result":null,"success":true,"errorCode":1000000,"errorMsg":null} // 修改失败
//{"result":null,"success":true,"errorCode":1000000,"errorMsg":null} // 修改成功
if (!rst.Contains("\"success\":true")) if (!rst.Contains("\"success\":true"))
{ {
var msg = BaseRegex.GetStringJson(ref rst, "errorMsg").ParseToString(); var msg = BaseRegex.GetStringJson(ref rst, "errorMsg").ParseToString();
@@ -109,19 +156,22 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
msg = BaseRegex.GetStringJson(ref rst, "error_msg").ParseToString(); msg = BaseRegex.GetStringJson(ref rst, "error_msg").ParseToString();
if (string.IsNullOrEmpty(msg)) if (string.IsNullOrEmpty(msg))
msg = rst; msg = rst;
BaseMsgForm.ShowError("修改库存失败:" + msg); if (IsAuto)
return; this.ErrMsg = "修改库存失败:" + msg;
else
BaseMsgForm.ShowError("修改库存失败:" + msg);
} }
else else
{ {
IsSuccess = true; IsEditSuccess = true;
BaseMsgForm.ShowInfo("修改库存成功!"); if (!IsAuto)
this.Close(); {
BaseMsgForm.ShowInfo("修改库存成功!");
this.Close();
}
} }
} }
private string EditStock(ShopLoginInfo shop, changeStockParam stockParam) private string EditStock(ShopLoginInfo shop, changeStockParam stockParam)
{ {
string url = "https://agentseller.temu.com/darwin-mms/api/kiana/foredawn/sales/stock/updateMmsProductSalesStock"; string url = "https://agentseller.temu.com/darwin-mms/api/kiana/foredawn/sales/stock/updateMmsProductSalesStock";
@@ -161,8 +161,8 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "ComplianceForm"; this.Name = "ComplianceForm";
this.Text = "ComplianceForm"; this.Text = "合规信息";
this.TitleText = "ComplianceForm"; this.TitleText = "合规信息";
this.Load += new System.EventHandler(this.ComplianceForm_Load); this.Load += new System.EventHandler(this.ComplianceForm_Load);
this.Controls.SetChildIndex(this.panel2, 0); this.Controls.SetChildIndex(this.panel2, 0);
this.panel2.ResumeLayout(false); this.panel2.ResumeLayout(false);
@@ -16,11 +16,17 @@ using TemuKJD.BLL;
namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
{ {
/// <summary>
/// 修改合规信息
/// </summary>
public partial class ComplianceForm : LRBaseForm public partial class ComplianceForm : LRBaseForm
{ {
/// <summary>
/// 批量自动操作,不弹框
/// </summary>
public bool IsAuto = false; public bool IsAuto = false;
public string ErrMsg = ""; public string ErrMsg = "";
public bool EditSuccess = false; public bool IsEditComplianceSuccess = false;
public ShopLoginInfo shop; public ShopLoginInfo shop;
public complianceInfo complianceInfo; public complianceInfo complianceInfo;
public complianceDetailInfo complianceDetailInfo; public complianceDetailInfo complianceDetailInfo;
@@ -37,7 +43,22 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
private void ComplianceForm_Load(object sender, EventArgs e) private void ComplianceForm_Load(object sender, EventArgs e)
{ {
if (shop != null && complianceInfo != null) if (shop != null && complianceInfo != null)
this.GetComplianceInfo(); {
this.Enabled = false;
Task.Run(() =>
{
this.GetComplianceInfo();
Invoke(new Action(() =>
{
this.Enabled = true;
if (IsAuto)
{
this.btnSave_Click(null, null);
}
}));
});
}
} }
void GetComplianceInfo() void GetComplianceInfo()
@@ -70,24 +91,26 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
JObject jObj = JObject.Parse(compDetailTemplateRst); JObject jObj = JObject.Parse(compDetailTemplateRst);
lstComplianceDetailTemplateInfo = JsonHelper.DeserializeJsonToList<complianceDetailTemplateInfo>(jObj["result"]["template_list"].ToString()); lstComplianceDetailTemplateInfo = JsonHelper.DeserializeJsonToList<complianceDetailTemplateInfo>(jObj["result"]["template_list"].ToString());
this.cmbLaw65.Text = "无需警示"; Invoke(new Action(() =>
var complianceDetailTemp = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == 4);
if (complianceDetailTemp != null && complianceDetailTemp.template_property_dtolist != null && complianceDetailTemp.template_property_dtolist.Count > 0)
{ {
foreach (var item in complianceDetailTemp.template_property_dtolist.FirstOrDefault().property_value_list) this.cmbLaw65.Text = "无需警示";
var complianceDetailTemp = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == 4);
if (complianceDetailTemp != null && complianceDetailTemp.template_property_dtolist != null && complianceDetailTemp.template_property_dtolist.Count > 0)
{ {
this.cmbLaw65.Items.Add(item.lang_prompt_map["zh-Hans"]); foreach (var item in complianceDetailTemp.template_property_dtolist.FirstOrDefault().property_value_list)
{
this.cmbLaw65.Items.Add(item.lang_prompt_map["zh-Hans"]);
}
} }
} }));
} }
catch (Exception ex) catch (Exception ex)
{ {
if (IsAuto) if (IsAuto)
{
ErrMsg = ex.Message; ErrMsg = ex.Message;
Close(); else
} BaseMsgForm.ShowError(ex.Message);
BaseMsgForm.ShowError(ex.Message); return;
} }
} }
@@ -100,177 +123,184 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
JObject jObj = JObject.Parse(compDetailRst); JObject jObj = JObject.Parse(compDetailRst);
complianceDetailInfo = JsonHelper.DeserializeJsonToObject<complianceDetailInfo>(jObj["result"].ToString()); complianceDetailInfo = JsonHelper.DeserializeJsonToObject<complianceDetailInfo>(jObj["result"].ToString());
// 欧盟负责人 Invoke(new Action(() =>
cmbEUPerson.Text = complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 25)?.rep_detail_list.FirstOrDefault()?.rep_name;
if (complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 25)?.rep_detail_list != null)
{ {
foreach (var item in complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 25)?.rep_detail_list) // 欧盟负责人
cmbEUPerson.Text = complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 25)?.rep_detail_list.FirstOrDefault()?.rep_name;
if (complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 25)?.rep_detail_list != null)
{ {
cmbEUPerson.Items.Add(item.rep_name); foreach (var item in complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 25)?.rep_detail_list)
{
cmbEUPerson.Items.Add(item.rep_name);
}
} }
} // 制造商信息
// 制造商信息 cmbMakerInfo.Text = complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 60)?.rep_detail_list.FirstOrDefault()?.rep_name;
cmbMakerInfo.Text = complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 60)?.rep_detail_list.FirstOrDefault()?.rep_name; if (complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 60)?.rep_detail_list != null)
if (complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 60)?.rep_detail_list != null)
{
foreach (var item in complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 60)?.rep_detail_list)
{ {
cmbMakerInfo.Items.Add(item.rep_name); foreach (var item in complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 60)?.rep_detail_list)
{
cmbMakerInfo.Items.Add(item.rep_name);
}
} }
} // 商品识别码
// 商品识别码 var complianceDetail = complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 61);
var complianceDetail = complianceDetailInfo.template_list.FirstOrDefault(t => t.task_type == 61); if (complianceDetail != null && complianceDetail.task_status == 3)
if (complianceDetail != null && complianceDetail.task_status == 3) {
{ this.txtCode.Text = complianceDetail?.input_text?.Values?.FirstOrDefault()?.multi_line_inputs?.FirstOrDefault()?.name;
this.txtCode.Text = complianceDetail?.input_text?.Values?.FirstOrDefault()?.multi_line_inputs?.FirstOrDefault()?.name; }
} }));
} }
catch (Exception ex) catch (Exception ex)
{ {
if (IsAuto) if (IsAuto)
{
ErrMsg = ex.Message; ErrMsg = ex.Message;
Close(); else
} BaseMsgForm.ShowError(ex.Message);
BaseMsgForm.ShowError(ex.Message);
} }
} }
} }
public void btnSave_Click(object sender, EventArgs e) public void btnSave_Click(object sender, EventArgs e)
{ {
try Task.Run(() =>
{ {
EditCompliance(); try
}
catch (Exception ex)
{
if (IsAuto)
{ {
ErrMsg = ex.Message; EditCompliance();
Close();
} }
BaseMsgForm.ShowError(ex.Message); catch (Exception ex)
} {
if (IsAuto)
ErrMsg = ex.Message;
else
BaseMsgForm.ShowError(ex.Message);
}
});
} }
private void EditCompliance() private void EditCompliance()
{ {
JObject compObj = new JObject(); JObject compObj = new JObject();
compObj.Add("cat_id", complianceInfo.cat_id); Invoke(new Action(() =>
compObj.Add("spu_id", complianceInfo.spu_id);
compObj.Add("goods_id", complianceInfo.goods_id);
compObj.Add("template_edit_request_list", new JArray());
var j_template_edit_list = compObj["template_edit_request_list"] as JArray;
foreach (var temp in complianceDetailInfo.template_list)
{ {
var wait_task = complianceInfo.wait_task_dtolist.FirstOrDefault(t => t.task_type == temp.task_type); compObj.Add("cat_id", complianceInfo.cat_id);
compObj.Add("spu_id", complianceInfo.spu_id);
JObject j_template_edit = new JObject(); compObj.Add("goods_id", complianceInfo.goods_id);
j_template_edit_list.Add(j_template_edit); compObj.Add("template_edit_request_list", new JArray());
j_template_edit.Add("task_id", wait_task.task_id); var j_template_edit_list = compObj["template_edit_request_list"] as JArray;
j_template_edit.Add("task_status", temp.task_status); foreach (var temp in complianceDetailInfo.template_list)
j_template_edit.Add("task_type", temp.task_type);
if (temp.template_id != null)
j_template_edit.Add("template_id", temp.template_id);
//加利福尼亚州65号法案
if (temp.task_type == 4)
{ {
var detailTemplateInfo = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == temp.task_type); var wait_task = complianceInfo.wait_task_dtolist.FirstOrDefault(t => t.task_type == temp.task_type);
if (detailTemplateInfo != null)
{
j_template_edit.Add("properties", new JObject());
j_template_edit.Add("images", new JObject());
j_template_edit.Add("input_text", new JObject());
var property_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_id; JObject j_template_edit = new JObject();
var value_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_value_list?.FirstOrDefault(p => p.value_name == this.cmbLaw65.Text.Trim())?.vid; j_template_edit_list.Add(j_template_edit);
if (property_id != null && value_id != null) j_template_edit.Add("task_id", wait_task.task_id);
j_template_edit.Add("task_status", temp.task_status);
j_template_edit.Add("task_type", temp.task_type);
if (temp.template_id != null)
j_template_edit.Add("template_id", temp.template_id);
//加利福尼亚州65号法案
if (temp.task_type == 4)
{
var detailTemplateInfo = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == temp.task_type);
if (detailTemplateInfo != null)
{ {
var jArr = new JArray(); j_template_edit.Add("properties", new JObject());
jArr.Add(value_id); j_template_edit.Add("images", new JObject());
(j_template_edit["properties"] as JObject).Add(property_id.ParseToString(), jArr); j_template_edit.Add("input_text", new JObject());
var property_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_id;
var value_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_value_list?.FirstOrDefault(p => p.value_name == this.cmbLaw65.Text.Trim())?.vid;
if (property_id != null && value_id != null)
{
var jArr = new JArray();
jArr.Add(value_id);
(j_template_edit["properties"] as JObject).Add(property_id.ParseToString(), jArr);
}
} }
} }
} //材质分类 // task_id = 101044552836267 // task_type = 166 // template_id == 1004
//材质分类 // task_id = 101044552836267 // task_type = 166 // template_id == 1004 else if (temp.task_type == 166)
else if (temp.task_type == 166)
{
j_template_edit.Add("sku_multi_detail", new JObject());
}
//商品识别码 // task_id = 101044552818783 // task_type = 61 // template_id == 51
else if (temp.task_type == 61)
{
j_template_edit.Add("properties", new JObject());
j_template_edit.Add("images", new JObject());
j_template_edit.Add("input_text", new JObject());
var detailTemplateInfo = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == temp.task_type);
var property_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_id; // 1100100115
if (property_id != null)
{ {
(j_template_edit["input_text"] as JObject).Add(property_id.ParseToString(), new JObject()); j_template_edit.Add("sku_multi_detail", new JObject());
(j_template_edit["input_text"][property_id.ParseToString()] as JObject).Add("multi_line_inputs", new JArray());
var multi_line_input = new JObject();
multi_line_input.Add("name", txtCode.Text.Trim());
(j_template_edit["input_text"][property_id.ParseToString()]["multi_line_inputs"] as JArray).Add(multi_line_input);
} }
} //商品识别码 // task_id = 101044552818783 // task_type = 61 // template_id == 51
// 欧盟负责人 else if (temp.task_type == 61)
else if (temp.task_type == 25)
{
j_template_edit.Add("is_not_required", wait_task.is_not_required);
j_template_edit.Add("task_name", "欧盟负责人");
j_template_edit.Add("status", wait_task.status);
j_template_edit.Add("punish_time", wait_task.punish_time);
j_template_edit.Add("sale_effect_info", JObject.Parse(JsonHelper.SerializeObject(wait_task.sale_effect_info)));
j_template_edit.Add("rep_detail_list", new JArray());
var rep_detail = temp.rep_detail_list.FirstOrDefault(r => r.rep_name == cmbEUPerson.Text.Trim());
rep_detail_param rep_param = new rep_detail_param { rep_id = rep_detail?.rep_id, rep_name = rep_detail?.rep_name };
(j_template_edit["rep_detail_list"] as JArray).Add(JObject.Parse(JsonHelper.SerializeObject(rep_param)));
}
// 制造商信息
else if (temp.task_type == 60)
{
j_template_edit.Add("is_not_required", wait_task.is_not_required);
j_template_edit.Add("task_name", "制造商信息");
j_template_edit.Add("status", wait_task.status);
j_template_edit.Add("punish_time", wait_task.punish_time);
j_template_edit.Add("sale_effect_info", JObject.Parse(JsonHelper.SerializeObject(wait_task.sale_effect_info)));
j_template_edit.Add("rep_detail_list", new JArray());
var rep_detail = temp.rep_detail_list.FirstOrDefault(r => r.rep_name == cmbMakerInfo.Text.Trim());
rep_detail_param rep_param = new rep_detail_param { rep_id = rep_detail?.rep_id, rep_name = rep_detail?.rep_name };
(j_template_edit["rep_detail_list"] as JArray).Add(JObject.Parse(JsonHelper.SerializeObject(rep_param)));
}
else
{
var detailTemplateInfo = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == temp.task_type);
if (detailTemplateInfo != null && detailTemplateInfo.template_property_dtolist?.FirstOrDefault()?.control_type == 3)
{ {
j_template_edit.Add("properties", new JObject()); j_template_edit.Add("properties", new JObject());
j_template_edit.Add("images", new JObject()); j_template_edit.Add("images", new JObject());
j_template_edit.Add("input_text", new JObject()); j_template_edit.Add("input_text", new JObject());
var detailTemplateInfo = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == temp.task_type);
var property_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_id; // 1100100115 var property_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_id; // 1100100115
var value_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_value_list?.FirstOrDefault(p => p.value_name == "该信息不适用该产品")?.vid; if (property_id != null)
if (property_id != null && value_id != null)
{ {
var jArr = new JArray(); (j_template_edit["input_text"] as JObject).Add(property_id.ParseToString(), new JObject());
jArr.Add(value_id); (j_template_edit["input_text"][property_id.ParseToString()] as JObject).Add("multi_line_inputs", new JArray());
(j_template_edit["properties"] as JObject).Add(property_id.ParseToString(), jArr); var multi_line_input = new JObject();
multi_line_input.Add("name", txtCode.Text.Trim());
(j_template_edit["input_text"][property_id.ParseToString()]["multi_line_inputs"] as JArray).Add(multi_line_input);
}
}
// 欧盟负责人
else if (temp.task_type == 25)
{
j_template_edit.Add("is_not_required", wait_task.is_not_required);
j_template_edit.Add("task_name", "欧盟负责人");
j_template_edit.Add("status", wait_task.status);
j_template_edit.Add("punish_time", wait_task.punish_time);
j_template_edit.Add("sale_effect_info", JObject.Parse(JsonHelper.SerializeObject(wait_task.sale_effect_info)));
j_template_edit.Add("rep_detail_list", new JArray());
var rep_detail = temp.rep_detail_list.FirstOrDefault(r => r.rep_name == cmbEUPerson.Text.Trim());
rep_detail_param rep_param = new rep_detail_param { rep_id = rep_detail?.rep_id, rep_name = rep_detail?.rep_name };
(j_template_edit["rep_detail_list"] as JArray).Add(JObject.Parse(JsonHelper.SerializeObject(rep_param)));
}
// 制造商信息
else if (temp.task_type == 60)
{
j_template_edit.Add("is_not_required", wait_task.is_not_required);
j_template_edit.Add("task_name", "制造商信息");
j_template_edit.Add("status", wait_task.status);
j_template_edit.Add("punish_time", wait_task.punish_time);
j_template_edit.Add("sale_effect_info", JObject.Parse(JsonHelper.SerializeObject(wait_task.sale_effect_info)));
j_template_edit.Add("rep_detail_list", new JArray());
var rep_detail = temp.rep_detail_list.FirstOrDefault(r => r.rep_name == cmbMakerInfo.Text.Trim());
rep_detail_param rep_param = new rep_detail_param { rep_id = rep_detail?.rep_id, rep_name = rep_detail?.rep_name };
(j_template_edit["rep_detail_list"] as JArray).Add(JObject.Parse(JsonHelper.SerializeObject(rep_param)));
}
else
{
var detailTemplateInfo = lstComplianceDetailTemplateInfo.FirstOrDefault(t => t.task_type == temp.task_type);
if (detailTemplateInfo != null && detailTemplateInfo.template_property_dtolist?.FirstOrDefault()?.control_type == 3)
{
j_template_edit.Add("properties", new JObject());
j_template_edit.Add("images", new JObject());
j_template_edit.Add("input_text", new JObject());
var property_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_id; // 1100100115
var value_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_value_list?.FirstOrDefault(p => p.value_name == "该信息不适用该产品")?.vid;
if (property_id != null && value_id != null)
{
var jArr = new JArray();
jArr.Add(value_id);
(j_template_edit["properties"] as JObject).Add(property_id.ParseToString(), jArr);
}
} }
} }
} }
} }));
var data = JsonHelper.SerializeObject(compObj); var data = JsonHelper.SerializeObject(compObj);
var editComplianceRst = EditCompliance(shop, compObj); // {"success":true,"error_code":1000000,"result":{"result":true}} var editComplianceRst = EditCompliance(shop, compObj); // {"success":true,"error_code":1000000,"result":{"result":true}}
editComplianceRst = GetHtml.Unicode2String(editComplianceRst); editComplianceRst = GetHtml.Unicode2String(editComplianceRst);
if (editComplianceRst.Contains("\"success\":true")) if (editComplianceRst.Contains("\"success\":true"))
{ {
EditSuccess = true; IsEditComplianceSuccess = true;
if (!IsAuto) if (!IsAuto)
{
BaseMsgForm.ShowInfo("修改成功!"); BaseMsgForm.ShowInfo("修改成功!");
this.Close(); this.Close();
}
} }
else else
{ {
@@ -281,11 +311,9 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
sErrMsg = editComplianceRst; sErrMsg = editComplianceRst;
if (IsAuto) if (IsAuto)
{
ErrMsg = sErrMsg; ErrMsg = sErrMsg;
Close(); else
} BaseMsgForm.ShowError(sErrMsg);
BaseMsgForm.ShowError(sErrMsg);
} }
} }
@@ -30,6 +30,12 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
private void ReceiveAreaForm_Load(object sender, EventArgs e) private void ReceiveAreaForm_Load(object sender, EventArgs e)
{ {
if (receiveArea == null)
{
BaseMsgForm.ShowError("修改期望到货区域失败:期望到货区域参数为空!");
return;
}
if (receiveArea.expectReceiveAreaConfigType == 1) if (receiveArea.expectReceiveAreaConfigType == 1)
{ {
this.radioButton1.Checked = true; this.radioButton1.Checked = true;
@@ -49,6 +55,12 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
if (receiveArea == null)
{
BaseMsgForm.ShowError("修改期望到货区域失败:期望到货区域参数为空!");
return;
}
int areaId = 1; int areaId = 1;
if (this.radioButton2.Checked) if (this.radioButton2.Checked)
areaId = 2; areaId = 2;
@@ -81,7 +93,7 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
} }
} }
private string EditReceiveArea(ShopLoginInfo shop, int AreaId, string skcIds) public static string EditReceiveArea(ShopLoginInfo shop, int AreaId, string skcIds)
{ {
string url = "https://agentseller.temu.com/mms/turbo/supplier/pick/out/config/editExpectReceiveArea"; string url = "https://agentseller.temu.com/mms/turbo/supplier/pick/out/config/editExpectReceiveArea";
string body; string body;
+27 -2
View File
@@ -47,6 +47,28 @@ namespace TemuKJD.UserComponent
} }
} }
private bool autoRowNumber = true;
/// <summary>
/// 边框颜色
/// </summary>
[Description("自动行号"), Category("UserProperty")]
public bool AutoRowNumber
{
get
{
return autoRowNumber;
}
set
{
if (autoRowNumber != value)
{
autoRowNumber = value;
this.Invalidate();
}
}
}
/// <summary> /// <summary>
/// 自动生成行号 /// 自动生成行号
/// </summary> /// </summary>
@@ -54,8 +76,11 @@ namespace TemuKJD.UserComponent
/// <param name="e"></param> /// <param name="e"></param>
private void DataGridViewEx_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) private void DataGridViewEx_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{ {
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, RowHeadersWidth - 4, e.RowBounds.Height); if (AutoRowNumber)
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), RowHeadersDefaultCellStyle.Font, rectangle, Color.DarkGray, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); {
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), RowHeadersDefaultCellStyle.Font, rectangle, Color.DarkGray, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
} }
/// <summary> /// <summary>