微信商品上传货号extcode优化 产品数据库查询逻辑优化
This commit is contained in:
1 parent
4fdcc94a91
commit
5ade769d7d
5 files changed
+131
-11
No files matched your search
@@ -104,8 +104,8 @@
|
|||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<LangVersion>12.0</LangVersion>
|
<LangVersion>12.0</LangVersion>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -191,6 +191,7 @@
|
|||||||
<Compile Include="Model\Config\WxShopKfStatistics.cs" />
|
<Compile Include="Model\Config\WxShopKfStatistics.cs" />
|
||||||
<Compile Include="Model\Config\WxShopMainStatistics.cs" />
|
<Compile Include="Model\Config\WxShopMainStatistics.cs" />
|
||||||
<Compile Include="Model\Config\WxShopUploadInfo.cs" />
|
<Compile Include="Model\Config\WxShopUploadInfo.cs" />
|
||||||
|
<Compile Include="Model\Data\ProductLatestOutAmountInfo.cs" />
|
||||||
<Compile Include="Model\Data\WXBuyUrlNotesInfo.cs" />
|
<Compile Include="Model\Data\WXBuyUrlNotesInfo.cs" />
|
||||||
<Compile Include="Model\Data\WXOrderDecryptAddressInfo.cs" />
|
<Compile Include="Model\Data\WXOrderDecryptAddressInfo.cs" />
|
||||||
<Compile Include="Model\DBModel\oem.cs" />
|
<Compile Include="Model\DBModel\oem.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AllBase.Model.Data
|
||||||
|
{
|
||||||
|
public class ProductLatestOutAmountInfo
|
||||||
|
{
|
||||||
|
public string order_id { get; set; } // 3739003536152355584
|
||||||
|
|
||||||
|
public string out_product_id { get; set; } // EC1960398929745-15938489009A
|
||||||
|
public string out_sku_id { get; set; } // BSEC18052272175281198712A
|
||||||
|
public int sku_cnt { get; set; } // 1
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外采金额,单位分
|
||||||
|
/// </summary>
|
||||||
|
public int out_amount { get; set; } // 1129
|
||||||
|
|
||||||
|
public string shop_id { get; set; } // 1960967267443629494
|
||||||
|
public string product_id { get; set; } // 10001456670425
|
||||||
|
public string sku_id { get; set; } // 26988803933
|
||||||
|
public string sku_code { get; set; } // BSEC18052272175281198712A
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using AllBase;
|
using AllBase;
|
||||||
using AllBase.Helper;
|
using AllBase.Helper;
|
||||||
|
using AllBase.Model.Data;
|
||||||
using AllBase.Model.Param;
|
using AllBase.Model.Param;
|
||||||
using AllBase.Model.Result;
|
using AllBase.Model.Result;
|
||||||
using AllBase.Model.Result._1688;
|
using AllBase.Model.Result._1688;
|
||||||
@@ -173,14 +174,25 @@ namespace TemuKJD.PDDForms.ProductSelectForms
|
|||||||
lstTemuDbProduct.Clear();
|
lstTemuDbProduct.Clear();
|
||||||
dgvDbProduct.Columns["colViewUv"].Visible = false;
|
dgvDbProduct.Columns["colViewUv"].Visible = false;
|
||||||
}
|
}
|
||||||
|
if (cancellationTokenSource!= null)
|
||||||
|
cancellationTokenSource.Cancel();
|
||||||
|
cancellationTokenSource = new CancellationTokenSource();
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
var cancelToken = cancellationTokenSource.Token;
|
||||||
int pageCount;
|
int pageCount;
|
||||||
int pageSize = 100;
|
int pageSize = 100;
|
||||||
decimal seconds;
|
decimal seconds;
|
||||||
Invoke(new Action(() => { pageSize = this.ucSplitPage1.PageSize; }));
|
Invoke(new Action(() => { pageSize = this.ucSplitPage1.PageSize; }));
|
||||||
var list = GetProductList(out pageCount, out seconds, page, pageSize);
|
var list = GetProductList(out pageCount, out seconds, page, pageSize);
|
||||||
|
if (cancelToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 测试获取爆款数据
|
||||||
//var list = GetHotProductList(out pageCount, out seconds, page, pageSize);
|
//var list = GetHotProductList(out pageCount, out seconds, page, pageSize);
|
||||||
|
// 测试获取商品最后几笔订单的外采价格
|
||||||
|
//var outAmountList = GetProductLatestOutAmountList(string.Join(",", list.Select(l => l.ext_code.IsNullOrEmpty() ? WXDBProdUploadForm.GetNewExtCode(l.spu_id) : l.ext_code)));
|
||||||
|
|
||||||
lstTemuDbProduct.AddRange(list);
|
lstTemuDbProduct.AddRange(list);
|
||||||
this.ucSplitPage1.TotalPage = pageCount;
|
this.ucSplitPage1.TotalPage = pageCount;
|
||||||
|
|
||||||
@@ -199,6 +211,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
|
|||||||
}));
|
}));
|
||||||
foreach (var prod in lstTemuDbProduct.Reverse().ToList())
|
foreach (var prod in lstTemuDbProduct.Reverse().ToList())
|
||||||
{
|
{
|
||||||
|
if (cancelToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
|
||||||
string catName = (prod.cat_name ?? prod.cat_id);
|
string catName = (prod.cat_name ?? prod.cat_id);
|
||||||
if (prod.wx_cat_leaf != null)
|
if (prod.wx_cat_leaf != null)
|
||||||
{
|
{
|
||||||
@@ -286,6 +301,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (cancelToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
ShowDgvImg();
|
ShowDgvImg();
|
||||||
@@ -295,7 +313,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
|
|||||||
this.statusBar.lblTaskStatus.Text += ",耗时:" + seconds;
|
this.statusBar.lblTaskStatus.Text += ",耗时:" + seconds;
|
||||||
#endif
|
#endif
|
||||||
}));
|
}));
|
||||||
});
|
}, cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap defaultBitmap = null;
|
Bitmap defaultBitmap = null;
|
||||||
@@ -443,6 +461,49 @@ namespace TemuKJD.PDDForms.ProductSelectForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ProductLatestOutAmountInfo> GetProductLatestOutAmountList(string outProductIds)
|
||||||
|
{
|
||||||
|
List<ProductLatestOutAmountInfo> list = new List<ProductLatestOutAmountInfo>();
|
||||||
|
|
||||||
|
var url = BaseClass.BuildWXObjString("product/wx_get_product_latest_buy_amount_list");
|
||||||
|
var data = "";
|
||||||
|
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
data = "&out_product_ids=" + outProductIds;
|
||||||
|
data += "&latest_cnt=10";
|
||||||
|
}));
|
||||||
|
data += "&sign=" + BaseClass.GetMd5(DateTime.Now.ToString("yyyyMMddHHmm") + "wxxd").ToLower();
|
||||||
|
var html = GetHtml.PostUtf8(url, data);
|
||||||
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||||
|
html = GetHtml.PostUtf8(url, data);
|
||||||
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||||
|
{
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
BaseMsgForm.ShowError("获取商品列表失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
|
||||||
|
}));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
var seconds = BaseRegex.GetDecimalJson(ref html, "seconds");
|
||||||
|
|
||||||
|
var jArr = JObject.Parse(html)["data"];
|
||||||
|
if (jArr.Count() == 0)
|
||||||
|
return list;
|
||||||
|
var sProd = JsonHelper.SerializeObject(jArr);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list = JsonHelper.DeserializeJsonToList<ProductLatestOutAmountInfo>(sProd);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new List<ProductLatestOutAmountInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<KJDDBProduct> GetProductList(out int pageCount, out decimal seconds, int page = 1, int pageSize = 200)
|
public List<KJDDBProduct> GetProductList(out int pageCount, out decimal seconds, int page = 1, int pageSize = 200)
|
||||||
{
|
{
|
||||||
List<KJDDBProduct> list = new List<KJDDBProduct>();
|
List<KJDDBProduct> list = new List<KJDDBProduct>();
|
||||||
|
|||||||
@@ -1545,7 +1545,24 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string UploadProduct(ShopLoginInfo shop, KJDDBProduct dbProd, TemuDBProductSelect selectProd, DataGridViewCell cell, DateTime startTime)
|
public static string GetEC1ExtCode(string spu_id)
|
||||||
|
{
|
||||||
|
if (spu_id.IsNullOrEmpty())
|
||||||
|
throw new Exception("货号指定失败,值不能为空!");
|
||||||
|
if (!spu_id.StartsWith("EC1") && !spu_id.EndsWith("A"))
|
||||||
|
return "EC1" + spu_id + "A";
|
||||||
|
return spu_id;
|
||||||
|
}
|
||||||
|
public static string GetNewExtCode(string spu_id)
|
||||||
|
{
|
||||||
|
if (spu_id.IsNullOrEmpty())
|
||||||
|
throw new Exception("货号指定失败,值不能为空!");
|
||||||
|
if (!spu_id.StartsWith("P1-"))
|
||||||
|
return "P1-" + spu_id;
|
||||||
|
return spu_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
string UploadProduct(ShopLoginInfo shop, KJDDBProduct dbProd, TemuDBProductSelect selectProd, DataGridViewCell cell, DateTime startTime)
|
||||||
{
|
{
|
||||||
#region 初始化上传商品对象
|
#region 初始化上传商品对象
|
||||||
// 生成初始化上传商品对象
|
// 生成初始化上传商品对象
|
||||||
@@ -1627,7 +1644,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
{
|
{
|
||||||
var searchExtCode = dbProd.ext_code;
|
var searchExtCode = dbProd.ext_code;
|
||||||
if (searchExtCode.ParseToString().Length < 10)
|
if (searchExtCode.ParseToString().Length < 10)
|
||||||
searchExtCode = "EC1" + dbProd.spu_id + "A";
|
searchExtCode = GetEC1ExtCode(dbProd.spu_id);
|
||||||
if (dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId"))
|
if (dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId"))
|
||||||
{
|
{
|
||||||
var sku_secret_json = dbProd.sku_secret_json;
|
var sku_secret_json = dbProd.sku_secret_json;
|
||||||
@@ -2371,7 +2388,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
if (extCode.IsNullOrEmpty() || extCode.Length <= 10)
|
if (extCode.IsNullOrEmpty() || extCode.Length <= 10)
|
||||||
{
|
{
|
||||||
//extCode = "EC" + Randomx.GetId(1000).ToString().PadLeft(3, '0') + dbProd.spu_id + "C";
|
//extCode = "EC" + Randomx.GetId(1000).ToString().PadLeft(3, '0') + dbProd.spu_id + "C";
|
||||||
extCode = "EC1" + dbProd.spu_id + "A";
|
extCode = GetEC1ExtCode(dbProd.spu_id);
|
||||||
}
|
}
|
||||||
upProdParam.product.info.spuCode = extCode;
|
upProdParam.product.info.spuCode = extCode;
|
||||||
upProdParam.product.info.outProductId = extCode;
|
upProdParam.product.info.outProductId = extCode;
|
||||||
|
|||||||
@@ -189,15 +189,24 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
isNotCount = false;
|
isNotCount = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cancellationTokenSource != null)
|
||||||
|
cancellationTokenSource.Cancel();
|
||||||
|
cancellationTokenSource = new CancellationTokenSource();
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
int pageCount;
|
var cancelToken = cancellationTokenSource.Token;
|
||||||
|
|
||||||
|
int pageCount;
|
||||||
int totalCount;
|
int totalCount;
|
||||||
int pageSize = 100;
|
int pageSize = 100;
|
||||||
decimal seconds;
|
decimal seconds;
|
||||||
Invoke(new Action(() => { pageSize = this.ucSplitPage1.PageSize; }));
|
Invoke(new Action(() => { pageSize = this.ucSplitPage1.PageSize; }));
|
||||||
var list = GetProductList(out pageCount, out totalCount, out seconds, page, pageSize, isNotCount);
|
var list = GetProductList(out pageCount, out totalCount, out seconds, page, pageSize, isNotCount);
|
||||||
lstTemuDbProduct.AddRange(list);
|
|
||||||
|
if (cancelToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lstTemuDbProduct.AddRange(list);
|
||||||
this.ucSplitPage1.TotalPage = pageCount;
|
this.ucSplitPage1.TotalPage = pageCount;
|
||||||
this.ucSplitPage1.TotalCount = totalCount;
|
this.ucSplitPage1.TotalCount = totalCount;
|
||||||
|
|
||||||
@@ -211,6 +220,9 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
}
|
}
|
||||||
foreach (var prod in lstTemuDbProduct.Reverse().ToList())
|
foreach (var prod in lstTemuDbProduct.Reverse().ToList())
|
||||||
{
|
{
|
||||||
|
if (cancelToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
|
||||||
var catName = GetProdCateName(prod);
|
var catName = GetProdCateName(prod);
|
||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -270,7 +282,9 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Invoke(new Action(() =>
|
if (cancelToken.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
ShowDgvImg();
|
ShowDgvImg();
|
||||||
this.pbLoading.Visible = false;
|
this.pbLoading.Visible = false;
|
||||||
@@ -280,7 +294,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
#endif
|
#endif
|
||||||
this.statusBar.lblTaskStatus.Text += needKeepStatusText;
|
this.statusBar.lblTaskStatus.Text += needKeepStatusText;
|
||||||
}));
|
}));
|
||||||
});
|
}, cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetProdCateName(KJDDBProduct prod)
|
public static string GetProdCateName(KJDDBProduct prod)
|
||||||
|
|||||||
Reference in new issue
Block a user