优化加入jit操作中的卡顿问题
This commit is contained in:
1 parent
d0ee274e2f
commit
b23eb0e497
10 files changed
+1789
-784
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user