微信筛选店铺 店铺分组 运费加价
This commit is contained in:
1 parent
b4fa5cacb1
commit
afaabea1fa
33 files changed
+1338
-536
No files matched your search
+517
-276
File diff suppressed because it is too large.
Load diff
@@ -48,6 +48,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
//public Dictionary<string, List<string>> dicCheckedShopIdList = new Dictionary<string, List<string>>();
|
||||
public Dictionary<string, bool> dicCheckedShopId = new Dictionary<string, bool>();
|
||||
public Dictionary<string, WxShopUploadInfo> dicShopUpload = new Dictionary<string, WxShopUploadInfo>();
|
||||
public string pdd_product_cates = "";
|
||||
public WXDBProdUploadForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -55,15 +56,12 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
|
||||
private void UserSelectDbProductForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
cmbSpProdType.SelectedIndex = 0;
|
||||
this.splitContainer1.Dock = DockStyle.Fill;
|
||||
this.panel1.Location = new Point(40, 30);
|
||||
this.panel1.Width = this.Width - 80;
|
||||
this.panel1.Height = this.Height - 60;
|
||||
this.panel1.SendToBack();
|
||||
|
||||
cmbWxSafe.SelectedIndex = 0;
|
||||
|
||||
lstTemuDBProductSelect = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<TemuDBProductSelect>>("wx_db_prod_upload_list");
|
||||
if (lstTemuDBProductSelect == null)
|
||||
lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList<TemuDBProductSelect>();
|
||||
@@ -116,6 +114,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
txtAddMorePrice.TextChanged -= txtAddPrice_TextChanged;
|
||||
txtSinglePriceAdd.TextChanged -= txtAddPrice_TextChanged;
|
||||
txtStockNum.TextChanged -= txtAddPrice_TextChanged;
|
||||
txtShippingPriceTimes.TextChanged -= txtAddPrice_TextChanged;
|
||||
chkAddMorePriceFirst.CheckedChanged -= chkAddMorePriceFirst_CheckedChanged;
|
||||
chkStepAddPrice.CheckedChanged -= chkStepAddPrice_CheckedChanged;
|
||||
|
||||
@@ -123,6 +122,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
this.txtAddMorePrice.Text = defaultAddPriceRule.AddMorePrice.ToString();
|
||||
this.txtSinglePriceAdd.Text = defaultAddPriceRule.SinglePriceAdd.ToString();
|
||||
this.txtStockNum.Text = defaultAddPriceRule.StockNum.ToString();
|
||||
this.txtShippingPriceTimes.Text = defaultAddPriceRule.ShippingPriceTimes.ToString();
|
||||
this.chkAddMorePriceFirst.Checked = defaultAddPriceRule.AddMorePriceFirst;
|
||||
this.chkStepAddPrice.Checked = defaultAddPriceRule.IsStepAddPrice;
|
||||
|
||||
@@ -130,6 +130,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
txtAddMorePrice.TextChanged += txtAddPrice_TextChanged;
|
||||
txtSinglePriceAdd.TextChanged += txtAddPrice_TextChanged;
|
||||
txtStockNum.TextChanged += txtAddPrice_TextChanged;
|
||||
txtShippingPriceTimes.TextChanged += txtAddPrice_TextChanged;
|
||||
chkAddMorePriceFirst.CheckedChanged += chkAddMorePriceFirst_CheckedChanged;
|
||||
chkStepAddPrice.CheckedChanged += chkStepAddPrice_CheckedChanged;
|
||||
|
||||
@@ -251,7 +252,8 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||||
{
|
||||
//if (list.Any(l => l == row.Cells["colShopId"]?.Value?.ToString()))
|
||||
row.Cells["colSelect"].Value = true;
|
||||
if(row.Visible == true)
|
||||
row.Cells["colSelect"].Value = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,20 +326,52 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
//BaseMsgForm.ShowError("商品分组获取失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
|
||||
BaseMsgForm.ShowError("商品类目获取失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
pdd_product_cates = BaseRegex.GetStringJson(ref html, "data");
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (cmbSourceType.Text != "厂商直采")
|
||||
{
|
||||
cmbCateFilter.Items.Clear();
|
||||
var groups = BaseRegex.GetStringJson(ref html, "data");
|
||||
foreach (var item in groups.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
cmbCateFilter.Items.Add(item);
|
||||
}
|
||||
cmbCateFilter.Items.Add("");
|
||||
}));
|
||||
fillPddCate();
|
||||
}
|
||||
else
|
||||
{
|
||||
fillWxCate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void fillPddCate()
|
||||
{
|
||||
cmbCateFilter1.Items.Clear();
|
||||
cmbCateFilter2.Items.Clear();
|
||||
cmbCateFilter3.Items.Clear();
|
||||
cmbCateFilter1.Text = "";
|
||||
cmbCateFilter2.Text = "";
|
||||
cmbCateFilter3.Text = "";
|
||||
foreach (var item in pdd_product_cates.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
cmbCateFilter1.Items.Add(item);
|
||||
}
|
||||
cmbCateFilter1.Items.Add("");
|
||||
}
|
||||
|
||||
void fillWxCate()
|
||||
{
|
||||
cmbCateFilter1.Items.Clear();
|
||||
cmbCateFilter2.Items.Clear();
|
||||
cmbCateFilter3.Items.Clear();
|
||||
cmbCateFilter1.Text = "";
|
||||
cmbCateFilter2.Text = "";
|
||||
cmbCateFilter3.Text = "";
|
||||
foreach (var cate in GlobalConfig.WxCatList.Where(c => c.level == 1).ToList())
|
||||
{
|
||||
cmbCateFilter1.Items.Add(cate.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1449,6 +1483,95 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
upProdParam.product.info.aiGenShortTitle = upProdParam.product.info.shortTitle;
|
||||
#endregion
|
||||
|
||||
#region 获取推单运费模板,计算运费加价。
|
||||
|
||||
var shippingTemplateJson = "";
|
||||
var shipPrice = 0;
|
||||
|
||||
if (dbProd.wx_cat_leaf != null)
|
||||
{
|
||||
var urlShipping = BaseClass.BuildObjString("product/wx_get_shipping_template");
|
||||
var dataShipping = Work.UserLogin.GetSignaturex() +
|
||||
"&coid=" + dbProd.skc_id;
|
||||
var htmlShipping = GetHtml.PostUtf8(urlShipping, dataShipping);
|
||||
if (string.IsNullOrEmpty(htmlShipping) || !htmlShipping.Contains("\"code\":200"))
|
||||
htmlShipping = GetHtml.PostUtf8(urlShipping, dataShipping);
|
||||
if (string.IsNullOrEmpty(htmlShipping) || !htmlShipping.Contains("\"code\":200"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (htmlShipping.Contains("\"data\":\"\""))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
shippingTemplateJson = JsonHelper.SerializeObject(JsonHelper.JObjectParse(htmlShipping)["data"]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(shippingTemplateJson))
|
||||
{
|
||||
|
||||
// 获取运费模板
|
||||
//"https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=10361546";
|
||||
var urlShip = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/freightTemplate/list?warehouseNum=" + dbProd.skc_id;
|
||||
var shipRst = WXHttpResponseBLL.e57GetResponse(urlShip, "");
|
||||
try
|
||||
{
|
||||
//[{"id":"204","warehouseNum":"15016108","freightType":0,"provinces":"香港特别行政区,台湾省,澳门特别行政区","freightPrice":9999900,"createBy":"vmslin","createTime":"2026-01-30T16:45:03+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:45:03+08:00"},{"id":"205","warehouseNum":"15016108","freightType":3,"provinces":"海南省,新疆维吾尔自治区,西藏自治区,内蒙古自治区","freightPrice":1530,"createBy":"vmslin","createTime":"2026-01-30T16:45:51+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:45:51+08:00"},{"id":"206","warehouseNum":"15016108","freightType":1,"provinces":"北京市,上海市","freightPrice":410,"createBy":"vmslin","createTime":"2026-01-30T16:46:04+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:46:04+08:00"},{"id":"207","warehouseNum":"15016108","freightType":1,"provinces":"安徽省,重庆市,福建省,广东省,甘肃省,广西壮族自治区,贵州省,河北省,湖北省,黑龙江省,河南省,湖南省,吉林省,江苏省,江西省,辽宁省,宁夏回族自治区,青海省,四川省,山东省,山西省,陕西省,天津市,云南省,浙江省","freightPrice":310,"createBy":"vmslin","createTime":"2026-01-30T16:46:17+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:46:17+08:00"}]
|
||||
shippingTemplateJson = JsonHelper.SerializeObject(JsonHelper.JObjectParse(shipRst)["data"]);
|
||||
if (shipRst.Contains("\"code\":0") && !string.IsNullOrEmpty(shippingTemplateJson))
|
||||
{
|
||||
urlShipping = BaseClass.BuildObjString("product/wx_add_mdy_shipping_template");
|
||||
dataShipping = Work.UserLogin.GetSignaturex() +
|
||||
"&coid=" + dbProd.skc_id +
|
||||
"&shipping_template_json=" + shippingTemplateJson;
|
||||
htmlShipping = GetHtml.PostUtf8(urlShipping, dataShipping);
|
||||
if (string.IsNullOrEmpty(htmlShipping) || !htmlShipping.Contains("\"code\":200"))
|
||||
htmlShipping = GetHtml.PostUtf8(urlShipping, dataShipping);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(shippingTemplateJson))
|
||||
{
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
var shipObjs = JArray.Parse(shippingTemplateJson);
|
||||
foreach (var shipObj in shipObjs)
|
||||
{
|
||||
var provincesStr = shipObj["provinces"].ParseToString();
|
||||
if (provincesStr.Split(',').Length > count)
|
||||
{
|
||||
count = provincesStr.Split(',').Length;
|
||||
shipPrice = shipObj["freightPrice"].ParseToInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"运费模板获取失败 " + ex.Message + "\"}";
|
||||
}
|
||||
}
|
||||
if (shipPrice <=0)
|
||||
{
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"运费模板获取失败 未获取到\"}";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 售后信息
|
||||
|
||||
var afterSaleAddress = "";
|
||||
@@ -1497,7 +1620,8 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
urlAfterSale = BaseClass.BuildObjString("product/wx_add_mdy_after_sale");
|
||||
dataAfterSale = Work.UserLogin.GetSignaturex() +
|
||||
"&coid=" + dbProd.skc_id + "&after_sale_json=" + afterSaleAddress;
|
||||
"&coid=" + dbProd.skc_id +
|
||||
"&after_sale_json=" + afterSaleAddress;
|
||||
htmlAfterSale = GetHtml.PostUtf8(urlAfterSale, dataAfterSale);
|
||||
if (string.IsNullOrEmpty(htmlAfterSale) || !htmlAfterSale.Contains("\"code\":200"))
|
||||
htmlAfterSale = GetHtml.PostUtf8(urlAfterSale, dataAfterSale);
|
||||
@@ -1936,6 +2060,8 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
}
|
||||
}
|
||||
// 聚水潭上微信小店,加运费(其他平台shipPrice默认为0)
|
||||
skuParam.productSkuInfo.salePrice += (shipPrice * defaultAddPriceRule.ShippingPriceTimes).ParseToInt();
|
||||
// sku图
|
||||
skuParam.productSkuInfo.thumbImg = upProdParam.product.info.productSaleAttrs[0].items.FirstOrDefault(a => a.value == skuInfo.spec[0].spec_name)?.imgUrl;
|
||||
skuParam.productSkuInfo.skuCode = skuInfo.out_sku_sn;
|
||||
@@ -2448,11 +2574,26 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
data += "&in_ext_codes=" + txtExtCodeFilter.Text;
|
||||
data += "&in_spu_ids=" + txtIdFilter.Text;
|
||||
data += "&in_groups=" + cmbGroupFilter.Text;
|
||||
data += "&in_cates=" + cmbCateFilter.Text;
|
||||
if (cmbSourceType.Text != "厂商直采")
|
||||
data += "&in_cates=" + cmbCateFilter1.Text;
|
||||
else
|
||||
{
|
||||
var cate1 = GlobalConfig.WxCatList.FirstOrDefault(c => c.level == 1 && c.name == cmbCateFilter1.Text.Trim());
|
||||
var cates2 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate1?.cat_id).ToList();
|
||||
var cate2 = cates2.FirstOrDefault(c => c.level == 2 && c.name == cmbCateFilter2.Text.Trim());
|
||||
var cates3 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate2?.cat_id).ToList();
|
||||
var cate3 = cates3.FirstOrDefault(c => c.level == 3 && c.name == cmbCateFilter3.Text.Trim());
|
||||
|
||||
if (!string.IsNullOrEmpty(cmbCateFilter1.Text) && cate1 != null)
|
||||
data += "&wx_cat_1=" + cate1.cat_id;
|
||||
if (!string.IsNullOrEmpty(cmbCateFilter2.Text) && cate2 != null)
|
||||
data += "&wx_cat_2=" + cate2.cat_id;
|
||||
if (!string.IsNullOrEmpty(cmbCateFilter3.Text) && cate3 != null)
|
||||
data += "&wx_cat_3=" + cate3.cat_id;
|
||||
}
|
||||
data += "&product_get_type=" + cmbSourceType.Text.Trim();
|
||||
data += "&wx_safe_status=" + cmbWxSafe.Text.Trim();
|
||||
data += "&special_prod_type=" + cmbSpProdType.Text.Trim();
|
||||
data += "&is_supplier_prod_ok=" + cmbSet.Text.Trim();
|
||||
data += "&wx_safe_status=" + cmbWxSafe.Text.Trim().Replace("安全+未校验", "安全商品,未校验");
|
||||
data += "&is_supplier_prod_ok=" + cmbJstInitSet.Text.Trim();
|
||||
}));
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
@@ -2546,6 +2687,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
defaultAddPriceRule.AddMorePrice = txtAddMorePrice.Text.Trim().ParseToDecimal();
|
||||
defaultAddPriceRule.SinglePriceAdd = txtSinglePriceAdd.Text.Trim().ParseToDecimal();
|
||||
defaultAddPriceRule.StockNum = txtStockNum.Text.Trim().ParseToInt();
|
||||
defaultAddPriceRule.ShippingPriceTimes = txtShippingPriceTimes.Text.Trim().ParseToDecimal();
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig<AddPriceRule>("wx_default_add_price_rule", defaultAddPriceRule);
|
||||
}
|
||||
}
|
||||
@@ -2604,9 +2746,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
txtIdFilter.Text = "";
|
||||
txtExtCodeFilter.Text = "";
|
||||
cmbGroupFilter.Text = "";
|
||||
cmbCateFilter.Text = "";
|
||||
cmbWxSafe.SelectedIndex = 0;
|
||||
cmbSpProdType.SelectedIndex = 0;
|
||||
cmbCateFilter1.Text = "";
|
||||
cmbWxSafe.Text = "安全+未校验";
|
||||
cmbSourceType.Text = "厂商直采";
|
||||
int prodCount;
|
||||
GetRandomProductList(out prodCount, 1, 1);
|
||||
lblGoodsCount.Text = "产品库 " + prodCount + " 件";
|
||||
@@ -2764,6 +2906,98 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void cmbSourceType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cmbSourceType.Text != "厂商直采")
|
||||
fillPddCate();
|
||||
else
|
||||
fillWxCate();
|
||||
}
|
||||
|
||||
private void cmbSourceType_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void cmbCateFilter1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cmbSourceType.Text != "厂商直采")
|
||||
return;
|
||||
|
||||
cmbCateFilter2.Text = "";
|
||||
cmbCateFilter2.Items.Clear();
|
||||
var cate1 = GlobalConfig.WxCatList.FirstOrDefault(c => c.level == 1 && c.name == cmbCateFilter1.Text.Trim());
|
||||
var cates2 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate1?.cat_id).ToList();
|
||||
foreach (var cate2 in cates2)
|
||||
{
|
||||
cmbCateFilter2.Items.Add(cate2.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void cmbCateFilter2_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cmbSourceType.Text != "厂商直采")
|
||||
return;
|
||||
|
||||
cmbCateFilter3.Text = "";
|
||||
cmbCateFilter3.Items.Clear();
|
||||
var cate1 = GlobalConfig.WxCatList.FirstOrDefault(c => c.level == 1 && c.name == cmbCateFilter1.Text.Trim());
|
||||
var cates2 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate1?.cat_id).ToList();
|
||||
var cate2 = cates2.FirstOrDefault(c => c.level == 2 && c.name == cmbCateFilter2.Text.Trim());
|
||||
var cates3 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate2?.cat_id).ToList();
|
||||
foreach (var cate3 in cates3)
|
||||
{
|
||||
cmbCateFilter3.Items.Add(cate3.name);
|
||||
}
|
||||
}
|
||||
|
||||
private void cmbCateFilter3_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var cate1 = GlobalConfig.WxCatList.FirstOrDefault(c => c.level == 1 && c.name == cmbCateFilter1.Text.Trim());
|
||||
var cates2 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate1?.cat_id).ToList();
|
||||
var cate2 = cates2.FirstOrDefault(c => c.level == 2 && c.name == cmbCateFilter2.Text.Trim());
|
||||
var cates3 = GlobalConfig.WxCatList.Where(c => c.f_cat_id == cate2?.cat_id).ToList();
|
||||
var cate3 = cates3.FirstOrDefault(c => c.level == 3 && c.name == cmbCateFilter3.Text.Trim());
|
||||
}
|
||||
|
||||
private void btnFilterBound_Click(object sender, EventArgs e)
|
||||
{
|
||||
var bound = txtFilterBound.Text.Trim().ParseToInt();
|
||||
var cates = GlobalConfig.WxCatBoundList.Where(b => b.cat_bound <= bound);
|
||||
lstTemuDBProductSelect.RemoveAll(p => !cates.Any(c => c.leaf_id.ParseToString() == p.wx_cat_leaf));
|
||||
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", this.lstTemuDBProductSelect);
|
||||
lblWaitToUp.Text = "待上传 " + lstTemuDBProductSelect.Count + " 件";
|
||||
}
|
||||
|
||||
private void btnFilterShop_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach(DataGridViewRow row in dgvShop.Rows)
|
||||
{
|
||||
if (!row.Cells["colShopName"].Value.ParseToString().Contains(txtFilterShopName.Text.Trim()))
|
||||
{
|
||||
row.Visible = false;
|
||||
row.Cells["colSelect"].Value = false;
|
||||
continue;
|
||||
}
|
||||
if (!row.Cells["colShopNotes"].Value.ParseToString().Contains(txtFilterShopNotes.Text.Trim()))
|
||||
{
|
||||
row.Visible = false;
|
||||
row.Cells["colSelect"].Value = false;
|
||||
continue;
|
||||
}
|
||||
row.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEmptyShop_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtFilterShopName.Text = "";
|
||||
txtFilterShopNotes.Text = "";
|
||||
btnFilterShop_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public class WXUpload
|
||||
@@ -3113,6 +3347,10 @@ Content-Type: application/octet-stream
|
||||
/// </summary>
|
||||
public int StockNum { get; set; } = 0;
|
||||
public bool IsStepAddPrice { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 运费倍率
|
||||
/// </summary>
|
||||
public decimal ShippingPriceTimes { get; set; } = 1.0m;
|
||||
}
|
||||
|
||||
public class WXUploadRule
|
||||
|
||||
Reference in new issue
Block a user