1库存上传可以修改类目, 2修复选品上传标题内有中文导致无法上传问题 3商品核价过滤优化

This commit is contained in:
wule committed 2025-11-21 18:46:14 +08:00
1 parent 55d4a27d90
commit a23020725a
10 files changed
+945 -606

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -25,6 +25,7 @@ namespace TemuKJD.KJDForms.AdminForms
public partial class AdminProductPriceCheckForm : Form
{
PriceCheckConfig priceCheckConfig = null;
List<PriceCheckFilterConfig> lstPriceCheckFilterConfig = new List<PriceCheckFilterConfig>();
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
public List<ShopLoginInfo> lstAdminShopInfo { get; set; } = new List<ShopLoginInfo>();
public List<TemuForChainProductInfo> lstCheckPriceInfo = new List<TemuForChainProductInfo>();
@@ -36,9 +37,14 @@ namespace TemuKJD.KJDForms.AdminForms
private void AdminProductPriceCheckForm_Load(object sender, EventArgs e)
{
lstPriceCheckFilterConfig = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<PriceCheckFilterConfig>>("price_check_filter_config");
if (lstPriceCheckFilterConfig == null)
lstPriceCheckFilterConfig = new List<PriceCheckFilterConfig>();
this.dgvShop.AddSelectorColumn("colSelect");
this.dgvPriceCheck.AddSelectorColumn("colCheck");
this.dgvPriceCheck.AddMergeColumnHeader(new List<string>() { "colOk", "colCancel" }, "同意/拒绝报价");
this.dgvPriceCheck.AddImgColumn("colProductSkcPic", "colImgUrl");
this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddMilliseconds(-1);
this.dtpStartTime.Value = DateTime.Now.Date.AddDays(-7);
@@ -259,13 +265,13 @@ namespace TemuKJD.KJDForms.AdminForms
{
case "规格名称":
{
var PriceInfo = lstCheckPriceInfo.FirstOrDefault(p => p.productId.ParseToString() == prodId);
if (PriceInfo != null)
var priceInfo = lstCheckPriceInfo.FirstOrDefault(p => p.productId.ParseToString() == prodId);
if (priceInfo != null)
{
this.pnlSpecDetail.Visible = true;
string skuName = "";
var prodSkuList = PriceInfo.skcList.FirstOrDefault().skuList;
var prodSkuList = priceInfo.skcList.FirstOrDefault().skuList;
if (prodSkuList != null)
{
foreach (var sku in prodSkuList)
@@ -509,7 +515,9 @@ namespace TemuKJD.KJDForms.AdminForms
private void btnSearchPrice_Click(object sender, EventArgs e)
{
this.pnlDetailOperate1.Visible = true;
this.pnlDetailOperate2.Visible = false;
this.btnMutliOk.Visible = true;
this.btnMutliCancel.Visible = true;
this.pnlMutliCancelWithTitleWrong.Visible = false;
this.dgvPriceCheck.Columns["colOk"].Visible = true;
this.dgvPriceCheck.Columns["colCancel"].Visible = true;
this.dgvPriceCheck.Columns["colCancelWithTitleWrong"].Visible = false;
@@ -518,9 +526,11 @@ namespace TemuKJD.KJDForms.AdminForms
private void btnSearchPrice2_Click(object sender, EventArgs e)
{
this.pnlDetailOperate2.Location = this.pnlDetailOperate1.Location;
this.pnlDetailOperate1.Visible = false;
this.pnlDetailOperate2.Visible = true;
this.btnMutliOk.Visible = false;
this.btnMutliCancel.Visible = false;
this.pnlMutliCancelWithTitleWrong.Visible = true;
this.pnlMutliCancelWithTitleWrong.Location = btnMutliOk.Location;
this.dgvPriceCheck.Columns["colOk"].Visible = false;
this.dgvPriceCheck.Columns["colCancel"].Visible = false;
this.dgvPriceCheck.Columns["colCancelWithTitleWrong"].Visible = true;
@@ -546,7 +556,7 @@ namespace TemuKJD.KJDForms.AdminForms
}
}
this.chkFilter.Checked = false;
this.chkFilterTitle.Checked = false;
this.dgvPriceCheck.Rows.Clear();
this.lstCheckPriceInfo.Clear();
this.pbLoading.Visible = true;
@@ -605,7 +615,7 @@ namespace TemuKJD.KJDForms.AdminForms
if (jArr == null)
jArr = new JArray();
List<string> extCodeLst = new List<string>();
List<string> extCodeTmpLst = new List<string>();
List<TemuForChainProductInfo> checkPriceInfoTmpLst = new List<TemuForChainProductInfo>();
foreach (var item in jArr)
{
@@ -613,12 +623,12 @@ namespace TemuKJD.KJDForms.AdminForms
TemuForChainProductInfo priceInfo = JsonHelper.DeserializeJsonToObject<TemuForChainProductInfo>(jStr);
lstCheckPriceInfo.Add(priceInfo);
checkPriceInfoTmpLst.Add(priceInfo);
extCodeLst.Add(priceInfo.skcList.FirstOrDefault()?.extCode);
extCodeTmpLst.Add(priceInfo.skcList.FirstOrDefault()?.extCode);
}
List<TemuDBExtCodePriceInfo> extCodePriceList = new List<TemuDBExtCodePriceInfo>();
try
{
extCodePriceList = GetServerExtCodePriceLst(extCodeLst.Distinct().ToList());
extCodePriceList = GetServerExtCodePriceLst(extCodeTmpLst.Distinct().ToList());
}
catch (Exception ex)
{
@@ -686,7 +696,7 @@ namespace TemuKJD.KJDForms.AdminForms
//else
// suggestSupplyPrice += "¥";
suggestSupplyPrice = (reviewInfo.suggestSupplyPrice / 100.0).ToString() + "¥";
suggestSupplyPrice = "¥" + (reviewInfo.suggestSupplyPrice.ParseToDecimal() / 100).ToString("0.00");
}
var reviewExtCode = priceInfo.skcList.FirstOrDefault()?.extCode;
var extCodePrice = extCodePriceList.FirstOrDefault(p => reviewExtCode == p.ext_code);
@@ -700,17 +710,15 @@ namespace TemuKJD.KJDForms.AdminForms
priceInfo.supplierId,
priceInfo.supplierName,
imgUrl,
defaultBitmap,
DataGridViewExtension.defaultBitmap,
priceInfo.productId,
priceInfo.skcList.FirstOrDefault()?.skcId,
priceInfo.productName,
skuName,
reviewExtCode,
extCodePrice == null ? "-" : (extCodePrice.original_price / 100.0).ParseToString(),
// sku不同价的会被分成多个review,priceInfo此时为价格范围
reviewInfo.productSkuList.FirstOrDefault()?.supplierPrice, //priceInfo.supplierPrice
suggestSupplyPrice,//核价
//reviewInfo.suggestSupplyPrice == null ? "-" : reviewInfo.suggestSupplyPrice.ParseToString(),
extCodePrice?.original_price / 100m, //extCodePrice == null ? "-" : (extCodePrice.original_price / 100m).ParseToString(),
reviewInfo.supplyPrice / 100m, //reviewInfo.productSkuList.FirstOrDefault()?.supplierPrice, //priceInfo.supplierPrice // sku不同价的会被分成多个review,priceInfo此时为价格范围
reviewInfo.suggestSupplyPrice / 100m, //suggestSupplyPrice.ParseToDecimal(),//核价 //reviewInfo.suggestSupplyPrice == null ? "-" : reviewInfo.suggestSupplyPrice.ParseToString(),
"", //新报价
reviewInfo.times, // 修改报价次数
BaseClass.StampToDateTime((priceInfo.skcList.FirstOrDefault()?.statusTime.createdTime.ParseToLong() / 1000).ParseToInt()).ToString("yy/MM/dd HH:mm:ss"),
@@ -720,21 +728,47 @@ namespace TemuKJD.KJDForms.AdminForms
""
); ;
dgvPriceCheck.Rows[rowId].Height = 60;
if (chkFilter.Checked && !CheckContainsWords(priceInfo.productName))
{
dgvPriceCheck.Rows[rowId].Visible = false;
}
if (checkRestoreSizeAndNumber(priceInfo))
//if (dgvPriceCheck.Rows[rowId].Cells["colExtCodePrice"].Value.ParseToString().IsNullOrEmpty())
// dgvPriceCheck.Rows[rowId].Cells["colExtCodePrice"].Value = "-";
if (CheckRestoreTitleWords(priceInfo.productName))
{
dgvPriceCheck.Rows[rowId].Cells["colProdName"].Style.ForeColor = Color.Red;
}
else
{
dgvPriceCheck.Rows[rowId].Cells["colProdName"].Style.ForeColor = dgvPriceCheck.DefaultCellStyle.ForeColor;
if (chkFilterTitle.Checked)
dgvPriceCheck.Rows[rowId].Visible = false;
}
if (checkRestoreSizeAndNumber(priceInfo))
{
dgvPriceCheck.Rows[rowId].Cells["colSkuName"].Style.ForeColor = Color.Red;
}
else
{
dgvPriceCheck.Rows[rowId].Cells["colSkuName"].Style.ForeColor = dgvPriceCheck.DefaultCellStyle.ForeColor;
}
if (totalProdIndex % 2 == 1)
dgvPriceCheck.Rows[rowId].DefaultCellStyle.BackColor = Color.White;
else
dgvPriceCheck.Rows[rowId].DefaultCellStyle.BackColor = Color.WhiteSmoke;
var extCodeLst = this.dgvPriceCheck.Rows.Cast<DataGridViewRow>()
.Select(r => r.Cells["colExtCode"].Value.ParseToString())
.Where(s => !string.IsNullOrEmpty(s.Trim('-'))).Distinct().ToList();
this.dgvExtCode.Rows.Clear();
foreach (var ext in extCodeLst)
{
var filterConfig = lstPriceCheckFilterConfig.FirstOrDefault(c => c.ExtCode == ext);
var pos = this.dgvExtCode.Rows.Add(
false,
ext,
filterConfig == null ? "" : GetConfigDesStr(filterConfig.Symbol, filterConfig.Price1, filterConfig.Price2)
);
}
}));
}
this.ShowDgvImg();
}
}
catch (Exception ex)
@@ -895,60 +929,6 @@ namespace TemuKJD.KJDForms.AdminForms
return HttpResponseBLL.PostResponse2(shop, url, body, referer);
}
Bitmap defaultBitmap = new Bitmap(80, 80);
void ShowDgvImg()
{
Task.Run(() =>
{
foreach (DataGridViewRow row in this.dgvPriceCheck.Rows)
{
if (row.Index > 0 && row.Cells["colProductSkcPic"].Displayed == false)
{
try
{
Invoke(new Action(() =>
{
row.Cells["colProductSkcPic"].Value = defaultBitmap;
}));
}
catch
{
}
continue;
}
if (row.Cells["colProductSkcPic"].Value != null && row.Cells["colProductSkcPic"].Value != defaultBitmap)
continue;
Image image = null;
string imgUrl = row.Cells["colImgUrl"]?.Value.ParseToString();
string getImgError = "";
if (!string.IsNullOrWhiteSpace(imgUrl))
image = GetHtml.GetUrlImg(imgUrl, out getImgError);
if (!string.IsNullOrEmpty(getImgError))
//BaseMsgForm.ShowError("图片加载失败 " + getImgError);
image = TemuKJD.Properties.Resources.errpic;
try
{
Invoke(new Action(() =>
{
if (dgvPriceCheck.Rows.Contains(row))
row.Cells["colProductSkcPic"].Value = image;
}));
}
catch
{
}
}
});
}
private void dgvPriceCheck_Scroll(object sender, ScrollEventArgs e)
{
this.ShowDgvImg();
}
private void btnRestoreProdName_Click(object sender, EventArgs e)
{
var products = this.dgvPriceCheck.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true)
@@ -982,7 +962,7 @@ namespace TemuKJD.KJDForms.AdminForms
}
var pName = price.productName;
if (CheckContainsWords(pName))
if (CheckRestoreTitleWords(pName))
{
}
else
@@ -1261,31 +1241,9 @@ namespace TemuKJD.KJDForms.AdminForms
});
}
private void chkFilter_CheckedChanged(object sender, EventArgs e)
private void chkFilterTitle_CheckedChanged(object sender, EventArgs e)
{
if (chkFilter.Checked == false)
{
foreach (DataGridViewRow row in dgvPriceCheck.Rows)
{
row.Visible = true;
}
}
else
{
foreach (DataGridViewRow row in dgvPriceCheck.Rows)
{
var pName = row.Cells["colProdName"].Value.ParseToString();
if (CheckContainsWords(pName))
{
}
else
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
}
}
FilterRows();
}
bool MouseLeftButtonDown = false;
@@ -1377,7 +1335,7 @@ namespace TemuKJD.KJDForms.AdminForms
}
}
bool CheckContainsWords(string filterProdName)
bool CheckRestoreTitleWords(string filterProdName)
{
return filterProdName != RestoreProductName(filterProdName);
}
@@ -1744,6 +1702,208 @@ namespace TemuKJD.KJDForms.AdminForms
{
this.txtExtCode.Text = this.txtSkcId.Text = "";
}
private void dgvExtCode_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return;
string headerText = dgvExtCode.Columns[e.ColumnIndex].HeaderText;
var row = dgvExtCode.Rows[e.RowIndex];
switch (headerText)
{
case "":
case "选":
case "货号":
row.Cells["colSelectExtCode"].Value = !row.Cells["colSelectExtCode"].Value.ParseToBool();
FilterRows();
break;
}
}
void FilterRows()
{
var filterExtCodeLst = dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true)
.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
foreach (DataGridViewRow row in dgvPriceCheck.Rows)
{
row.Visible = true;
row.Cells["colCheck"].Value = false;
//continue;
var prodId = row.Cells["colProductId"].Value.ParseToString();
var rowExtCode = row.Cells["colExtCode"].Value.ParseToString();
var rowAdjustPrice = row.Cells["colAdjustPrice"].Value.ParseToDecimal();
// 过滤价格
// 只有有选中数据时才过滤,全不选时不过滤
if (filterExtCodeLst != null && filterExtCodeLst.Count > 0)
{
var filterExtCode = filterExtCodeLst.FirstOrDefault(e => e == rowExtCode);
var filterExtCodeConfig = lstPriceCheckFilterConfig.FirstOrDefault(c => c.ExtCode == rowExtCode);
if (string.IsNullOrWhiteSpace(filterExtCode))
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
else if (filterExtCodeConfig != null)
{
if (filterExtCodeConfig.Symbol == "≥" && rowAdjustPrice < filterExtCodeConfig.Price1)
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
if (filterExtCodeConfig.Symbol == "≤" && rowAdjustPrice > filterExtCodeConfig.Price1)
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
if (filterExtCodeConfig.Symbol.StartsWith("≤") && filterExtCodeConfig.Symbol.EndsWith("≥") &&
rowAdjustPrice > filterExtCodeConfig.Price1 && rowAdjustPrice < filterExtCodeConfig.Price2)
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
if (filterExtCodeConfig.Symbol.StartsWith("≥") && filterExtCodeConfig.Symbol.EndsWith("≤") &&
(rowAdjustPrice < filterExtCodeConfig.Price1 || rowAdjustPrice > filterExtCodeConfig.Price2))
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
}
}
// 过滤保留未还原的标题
if (chkFilterTitle.Checked)
{
var pName = row.Cells["colProdName"].Value.ParseToString();
if (!CheckRestoreTitleWords(pName))
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
else
{
}
}
if (ucCheckBox1.Checked)
{
var priceInfo = lstCheckPriceInfo.FirstOrDefault(p => p.productId.ParseToString() == prodId);
if (priceInfo != null)
{
if (!checkRestoreSizeAndNumber(priceInfo))
{
row.Cells["colCheck"].Value = false;
row.Visible = false;
}
else
{
}
}
}
}
}
private void btnSaveFilterParams_Click(object sender, EventArgs e)
{
var rows = this.dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true).ToList();
var extCodeLst = rows.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
if (extCodeLst.Count == 0)
{
BaseMsgForm.ShowError("请查询商品后在左边列表选择货号!");
return;
}
decimal price1 = txtPrice1.Text.ParseToDecimal();
decimal price2 = txtPrice2.Text.ParseToDecimal();
if ((cmbSymbol.Text == "≤ ≥" || cmbSymbol.Text == "≥ ≤") && price2 < price1)
{
BaseMsgForm.ShowError("高价格不能小于低价格");
return;
}
foreach (var extCode in extCodeLst)
{
lstPriceCheckFilterConfig.RemoveAll(p => p.ExtCode == extCode);
var priceParam = new PriceCheckFilterConfig()
{
ExtCode = extCode,
Symbol = cmbSymbol.Text,
Price1 = txtPrice1.Text.Trim().ParseToDecimal(),
Price2 = txtPrice2.Text.Trim().ParseToDecimal(),
};
lstPriceCheckFilterConfig.Add(priceParam);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("price_check_filter_config", lstPriceCheckFilterConfig);
BaseMsgForm.ShowInfo("选中货号的价格过滤配置已保存!");
foreach (var row in rows)
{
row.Cells["colFilterRule"].Value = GetConfigDesStr(cmbSymbol.Text.Trim(), txtPrice1.Text.Trim().ParseToDecimal(), txtPrice2.Text.Trim().ParseToDecimal());
}
FilterRows();
}
string GetConfigDesStr(string symbol, decimal price1, decimal price2)
{
if (symbol == "≤")
return "≤" + price1;
else if (symbol == "≥ ≤")
return "≥" + price1 + " 且 ≤" + price2;
else if (symbol == "≤ ≥")
return "≤" + price1 + " 或 ≥" + price2;
return "≥" + price1.ToString();
}
private void btnRestoreFilterParams_Click(object sender, EventArgs e)
{
var rows = this.dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true).ToList();
var extCodeLst = rows.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
if (extCodeLst.Count == 0)
{
BaseMsgForm.ShowError("请查询商品后在左边列表选择货号!");
return;
}
if (BaseMsgForm.ShowConfirm("确定要清除选中货号的价格过滤配置吗?", "提示").DialogResult == DialogResult.OK)
{
foreach (var extCode in extCodeLst)
{
lstPriceCheckFilterConfig.RemoveAll(p => p.ExtCode == extCode);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("price_check_filter_config", lstPriceCheckFilterConfig);
BaseMsgForm.ShowInfo("选中货号的价格过滤配置已清除!");
foreach (var row in rows)
{
row.Cells["colFilterRule"].Value = "";
}
}
FilterRows();
}
private void cmbSymbol_TextChanged(object sender, EventArgs e)
{
if (cmbSymbol.Text == "≤ ≥" || cmbSymbol.Text == "≥ ≤")
{
txtPrice2.Visible = true;
label16.Visible = true;
}
else
{
txtPrice2.Visible = false;
label16.Visible = false;
}
}
private void chkFilterSize_CheckedChanged(object sender, EventArgs e)
{
FilterRows();
}
}
public class PriceCheckConfig
@@ -1757,4 +1917,12 @@ namespace TemuKJD.KJDForms.AdminForms
public string PriceDown { get; set; } = "0.1";
public bool SearchAllShop { get; set; } = true;
}
public class PriceCheckFilterConfig
{
public string ExtCode { get; set; }
public string Symbol { get; set; }
public decimal Price1 { get; set; }
public decimal Price2 { get; set; }
}
}
@@ -117,6 +117,15 @@
<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="colFilterRule.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>