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

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

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary>
/// 版本ID
/// </summary>
public static int VersionCount = 678;
public static int VersionCount = 683;
//public static int VersionCount = 613;
/// <summary>
@@ -24,6 +24,8 @@ namespace TemuKJD.KJDForms.ProductForms
/// </summary>
public partial class ProductChangePriceForm : LRBaseForm
{
public bool IsAuto = false;
decimal wantPrice;
string skcId = "";
string productId = "";
string productName = "";
@@ -31,7 +33,8 @@ namespace TemuKJD.KJDForms.ProductForms
TemuListProductInfo productInfo = null;
WarehouseProductSubOrderInfo wareHouseOrderInfo = null;
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)
{
@@ -44,7 +47,7 @@ namespace TemuKJD.KJDForms.ProductForms
}
//TemuListProductInfo
public ProductChangePriceForm(ShopLoginInfo _shop, TemuListProductInfo _prod)
public ProductChangePriceForm(ShopLoginInfo _shop, TemuListProductInfo _prod, decimal _wantPrice = 0)
{
InitializeComponent();
shop = _shop;
@@ -52,6 +55,7 @@ namespace TemuKJD.KJDForms.ProductForms
skcId = productInfo?.productSkcId.ParseToString();
productId = productInfo?.productId.ParseToString();
productName = productInfo?.productName.ParseToString();
wantPrice = _wantPrice;
}
private void ProductChangePriceForm_Load(object sender, EventArgs e)
@@ -88,6 +92,10 @@ namespace TemuKJD.KJDForms.ProductForms
{
pbLoading.Visible = false;
}));
if (IsAuto)
{
SaveNewPrice();
}
});
}
@@ -95,20 +103,29 @@ namespace TemuKJD.KJDForms.ProductForms
{
if (shop == null || productId.IsNullOrEmpty() || skcId.IsNullOrEmpty() || productName.IsNullOrEmpty())
{
BaseMsgForm.ShowError("店铺商品信息为空!");
if (IsAuto)
ErrMsg = "店铺商品信息为空!";
else
BaseMsgForm.ShowError("店铺商品信息为空!");
return;
}
#region 检测登录
if (shop.LoginStatus2 != "国际版在线")
{
BaseMsgForm.ShowError("店铺未登录!");
if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
return;
}
ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
if (shop.LoginStatus2 != "国际版在线")
{
BaseMsgForm.ShowError("店铺未登录!");
if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
return;
}
#endregion
@@ -129,7 +146,10 @@ namespace TemuKJD.KJDForms.ProductForms
if (string.IsNullOrEmpty(sErr))
sErr = adjustRst;
BaseMsgForm.ShowError("查询失败:" + sErr);
if (IsAuto)
ErrMsg = "查询失败:" + sErr;
else
BaseMsgForm.ShowError("查询失败:" + sErr);
return;
}
@@ -142,6 +162,7 @@ namespace TemuKJD.KJDForms.ProductForms
foreach (var item in adjustPriceInfo.spuAdjustResult[productId].skcItems[0].items)
{
int mainRowId = -1;
// 修改日常价格
Invoke(new Action(() =>
{
mainRowId = this.dgvOrder.Rows.Add(
@@ -153,7 +174,7 @@ namespace TemuKJD.KJDForms.ProductForms
"",
"日常价格", //申报价格类型
item.originSupplyPrice.ParseToDecimal() / 100m, //原申报价格
"", //调整后的申报价格
wantPrice == 0 ? "" : wantPrice.ToString("0.00"), //调整后的申报价格
"调价成功之后生成的交易订单",
""
);
@@ -161,13 +182,14 @@ namespace TemuKJD.KJDForms.ProductForms
}));
if (item?.marketingActivityPriceDTOList == null)
continue;
// 修改活动价格
foreach (var activityPriceDTO in item.marketingActivityPriceDTOList)
{
int rowId = -1;
Invoke(new Action(() =>
{
rowId = this.dgvOrder.Rows.Add(
true,
IsAuto ? false : true,
productId,
skcId,
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();
await Task.Run(() =>
{
Thread.Sleep(10);
});
Task.Run(() =>
{
SaveNewPrice();
});
}
public void SaveNewPrice()
{
if (shop == null || productId.IsNullOrEmpty() || skcId.IsNullOrEmpty() || productName.IsNullOrEmpty())
{
BaseMsgForm.ShowError("店铺商品信息为空!");
@@ -310,62 +345,70 @@ namespace TemuKJD.KJDForms.ProductForms
}
}
pbLoading.Visible = true;
Invoke(new Action(() =>
{
pbLoading.Visible = true;
}));
#region 检测登录
if (shop.LoginStatus2 != "国际版在线")
{
BaseMsgForm.ShowError("店铺未登录!");
if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
pbLoading.Visible = false;
return;
}
ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
if (shop.LoginStatus2 != "国际版在线")
{
BaseMsgForm.ShowError("店铺未登录!");
if (IsAuto)
ErrMsg = "店铺未登录!";
else
BaseMsgForm.ShowError("店铺未登录!");
pbLoading.Visible = false;
return;
}
#endregion
await Task.Run(() =>
{
Thread.Sleep(200);
});
AdjustParam param = new AdjustParam();
if (dicAdjustReason.Keys.Contains(cmbChangePriceReason.Text))
param.adjustReason = dicAdjustReason[cmbChangePriceReason.Text];
if (!string.IsNullOrWhiteSpace(txtReason.Text))
param.reason = txtReason.Text.Trim();
param.adjustItems = new List<adjustItem>();
adjustItem adjustItem = new adjustItem()
Invoke(new Action(() =>
{
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)
if (dicAdjustReason.Keys.Contains(cmbChangePriceReason.Text))
param.adjustReason = dicAdjustReason[cmbChangePriceReason.Text];
if (!string.IsNullOrWhiteSpace(txtReason.Text))
param.reason = txtReason.Text.Trim();
param.adjustItems = new List<adjustItem>();
adjustItem adjustItem = new adjustItem()
{
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(),
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(),
};
adjustItem.skuAdjustList.Add(adjItem);
if (adjItem.activityInvitationId == 0)
adjItem.activityInvitationId = null;
var adjItem = new skuAdjust
{
activityInvitationId = row.Cells["colAdjustPriceTypeId"].Value.ParseToLong(),
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(),
};
adjustItem.skuAdjustList.Add(adjItem);
if (adjItem.activityInvitationId == 0)
adjItem.activityInvitationId = null;
}
}
}
}));
int tryCount = 0;
tryAgain:
@@ -385,49 +428,67 @@ namespace TemuKJD.KJDForms.ProductForms
sErr = adjustBatchRst;
sErr = sErr.Replace("\\n", "\n").Replace("\n", "\r\n").Replace("\r\r", "\r");
BaseMsgForm.ShowError("调价失败:" + sErr);
pbLoading.Visible = false;
if (IsAuto)
ErrMsg = "调价失败:" + sErr;
else
BaseMsgForm.ShowError("调价失败:" + sErr);
Invoke(new Action(() =>
{
pbLoading.Visible = false;
}));
return;
}
IsAdjustPrice = true;
// 更新统计列表的数据价格
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(),
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 adjItem = new skuAdjust
{
var sku = wareHouseOrderInfo.skuQuantityDetailList.FirstOrDefault(s => s.productSkuId.ParseToLong() == adjItem.skuId);
if (sku != null)
sku.supplierPrice = adjItem.targetSupplyPrice;
}
if (productInfo != null)
activityInvitationId = row.Cells["colAdjustPriceTypeId"].Value.ParseToLong(),
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的是商品基础价格,否则是活动价格
{
var sku = productInfo.productSkuSummaries.FirstOrDefault(s => s.productSkuId.ParseToLong() == adjItem.skuId);
if (sku!= null)
if (wareHouseOrderInfo != 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">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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">
<value>True</value>
</metadata>
@@ -17,15 +17,19 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
{
public partial class ChangeStockForm : LRBaseForm
{
public bool IsSuccess = false;
public bool IsEditSuccess = false;
public bool IsAuto = false;
public string ErrMsg = "";
public changeStockParam stockParam;
ShopLoginInfo shop;
TemuListProductInfo product;
public ChangeStockForm(ShopLoginInfo _shop, TemuListProductInfo _product)
int wantStock;
public ChangeStockForm(ShopLoginInfo _shop, TemuListProductInfo _product, int _wantStock = 0)
{
InitializeComponent();
shop = _shop;
product = _product;
product = _product;
wantStock = _wantStock;
}
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.lblStockAfterChange.Text = "";
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);
}
}
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.productId = this.product.productId;
@@ -73,35 +107,48 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
stockChangeDtoParam.productSkcId = this.product.productSkcId;
stockChangeDtoParam.stockUpdateSource = 1;
stockChangeDtoParam.skuVirtualStockChangeList = new List<skuVirtualStockChange>();
foreach (var control in flowLayoutPanel1.Controls)
Invoke(new Action(() =>
{
var edit = control as UcStockEdit;
if (edit == null)
foreach (var control in flowLayoutPanel1.Controls)
{
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)
{
BaseMsgForm.ShowError("请至少改动一项价格!");
if (IsAuto)
IsEditSuccess = true;
else
BaseMsgForm.ShowError("请至少改动一项价格!");
return;
}
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"))
{
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();
if (string.IsNullOrEmpty(msg))
msg = rst;
BaseMsgForm.ShowError("修改库存失败:" + msg);
return;
if (IsAuto)
this.ErrMsg = "修改库存失败:" + msg;
else
BaseMsgForm.ShowError("修改库存失败:" + msg);
}
else
{
IsSuccess = true;
BaseMsgForm.ShowInfo("修改库存成功!");
this.Close();
IsEditSuccess = true;
if (!IsAuto)
{
BaseMsgForm.ShowInfo("修改库存成功!");
this.Close();
}
}
}
private string EditStock(ShopLoginInfo shop, changeStockParam stockParam)
{
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.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "ComplianceForm";
this.Text = "ComplianceForm";
this.TitleText = "ComplianceForm";
this.Text = "合规信息";
this.TitleText = "合规信息";
this.Load += new System.EventHandler(this.ComplianceForm_Load);
this.Controls.SetChildIndex(this.panel2, 0);
this.panel2.ResumeLayout(false);
@@ -16,11 +16,17 @@ using TemuKJD.BLL;
namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
{
/// <summary>
/// 修改合规信息
/// </summary>
public partial class ComplianceForm : LRBaseForm
{
/// <summary>
/// 批量自动操作,不弹框
/// </summary>
public bool IsAuto = false;
public string ErrMsg = "";
public bool EditSuccess = false;
public bool IsEditComplianceSuccess = false;
public ShopLoginInfo shop;
public complianceInfo complianceInfo;
public complianceDetailInfo complianceDetailInfo;
@@ -37,7 +43,22 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
private void ComplianceForm_Load(object sender, EventArgs e)
{
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()
@@ -70,24 +91,26 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
JObject jObj = JObject.Parse(compDetailTemplateRst);
lstComplianceDetailTemplateInfo = JsonHelper.DeserializeJsonToList<complianceDetailTemplateInfo>(jObj["result"]["template_list"].ToString());
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)
Invoke(new Action(() =>
{
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)
{
if (IsAuto)
{
ErrMsg = ex.Message;
Close();
}
BaseMsgForm.ShowError(ex.Message);
else
BaseMsgForm.ShowError(ex.Message);
return;
}
}
@@ -100,177 +123,184 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
JObject jObj = JObject.Parse(compDetailRst);
complianceDetailInfo = JsonHelper.DeserializeJsonToObject<complianceDetailInfo>(jObj["result"].ToString());
// 欧盟负责人
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)
Invoke(new Action(() =>
{
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;
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.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)
{
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);
if (complianceDetail != null && complianceDetail.task_status == 3)
{
this.txtCode.Text = complianceDetail?.input_text?.Values?.FirstOrDefault()?.multi_line_inputs?.FirstOrDefault()?.name;
}
// 商品识别码
var complianceDetail = complianceDetailInfo?.template_list?.FirstOrDefault(t => t.task_type == 61);
if (complianceDetail != null && complianceDetail.task_status == 3)
{
this.txtCode.Text = complianceDetail?.input_text?.Values?.FirstOrDefault()?.multi_line_inputs?.FirstOrDefault()?.name;
}
}));
}
catch (Exception ex)
{
if (IsAuto)
{
ErrMsg = ex.Message;
Close();
}
BaseMsgForm.ShowError(ex.Message);
else
BaseMsgForm.ShowError(ex.Message);
}
}
}
public void btnSave_Click(object sender, EventArgs e)
{
try
Task.Run(() =>
{
EditCompliance();
}
catch (Exception ex)
{
if (IsAuto)
try
{
ErrMsg = ex.Message;
Close();
EditCompliance();
}
BaseMsgForm.ShowError(ex.Message);
}
catch (Exception ex)
{
if (IsAuto)
ErrMsg = ex.Message;
else
BaseMsgForm.ShowError(ex.Message);
}
});
}
private void EditCompliance()
{
JObject compObj = new JObject();
compObj.Add("cat_id", complianceInfo.cat_id);
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)
Invoke(new Action(() =>
{
var wait_task = complianceInfo.wait_task_dtolist.FirstOrDefault(t => t.task_type == temp.task_type);
JObject j_template_edit = new JObject();
j_template_edit_list.Add(j_template_edit);
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)
compObj.Add("cat_id", complianceInfo.cat_id);
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 detailTemplateInfo = lstComplianceDetailTemplateInfo.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 wait_task = complianceInfo.wait_task_dtolist.FirstOrDefault(t => t.task_type == temp.task_type);
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)
JObject j_template_edit = new JObject();
j_template_edit_list.Add(j_template_edit);
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();
jArr.Add(value_id);
(j_template_edit["properties"] as JObject).Add(property_id.ParseToString(), jArr);
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;
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
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)
//材质分类 // task_id = 101044552836267 // task_type = 166 // template_id == 1004
else if (temp.task_type == 166)
{
(j_template_edit["input_text"] as JObject).Add(property_id.ParseToString(), 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);
j_template_edit.Add("sku_multi_detail", new JObject());
}
}
// 欧盟负责人
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)
//商品识别码 // 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
var value_id = detailTemplateInfo?.template_property_dtolist?.FirstOrDefault()?.property_value_list?.FirstOrDefault(p => p.value_name == "该信息不适用该产品")?.vid;
if (property_id != null && value_id != null)
if (property_id != null)
{
var jArr = new JArray();
jArr.Add(value_id);
(j_template_edit["properties"] as JObject).Add(property_id.ParseToString(), jArr);
(j_template_edit["input_text"] as JObject).Add(property_id.ParseToString(), 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);
}
}
// 欧盟负责人
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 editComplianceRst = EditCompliance(shop, compObj); // {"success":true,"error_code":1000000,"result":{"result":true}}
editComplianceRst = GetHtml.Unicode2String(editComplianceRst);
if (editComplianceRst.Contains("\"success\":true"))
{
EditSuccess = true;
IsEditComplianceSuccess = true;
if (!IsAuto)
{
BaseMsgForm.ShowInfo("修改成功!");
this.Close();
this.Close();
}
}
else
{
@@ -281,11 +311,9 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
sErrMsg = editComplianceRst;
if (IsAuto)
{
ErrMsg = sErrMsg;
Close();
}
BaseMsgForm.ShowError(sErrMsg);
else
BaseMsgForm.ShowError(sErrMsg);
}
}
@@ -30,6 +30,12 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
private void ReceiveAreaForm_Load(object sender, EventArgs e)
{
if (receiveArea == null)
{
BaseMsgForm.ShowError("修改期望到货区域失败:期望到货区域参数为空!");
return;
}
if (receiveArea.expectReceiveAreaConfigType == 1)
{
this.radioButton1.Checked = true;
@@ -49,6 +55,12 @@ namespace TemuKJD.KJDForms.ProductForms.TemuJitSubForms
private void btnSave_Click(object sender, EventArgs e)
{
if (receiveArea == null)
{
BaseMsgForm.ShowError("修改期望到货区域失败:期望到货区域参数为空!");
return;
}
int areaId = 1;
if (this.radioButton2.Checked)
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 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>
@@ -54,8 +76,11 @@ namespace TemuKJD.UserComponent
/// <param name="e"></param>
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);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), RowHeadersDefaultCellStyle.Font, rectangle, Color.DarkGray, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
if (AutoRowNumber)
{
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>