调整备货逻辑不允许品质分过低的商品自动备货(完成但尚未测试) 注释无用的相关接口(原小奶狗,小奶兔)
This commit is contained in:
1 parent
fceead357f
commit
8445ec1828
19 files changed
+865
-540
No files matched your search
@@ -165,7 +165,7 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
col.Visible = true;
|
||||
}
|
||||
if (col.Name == "colTodaySaleVolume" || col.Name == "colInCartNumber7d" || col.Name == "colSalesInventoryNum"
|
||||
|| col.Name == "colWaitReceiveNum" || col.Name == "colNeedStockUp")
|
||||
|| col.Name == "colWaitReceiveNum" || col.Name == "colNeedStockUp" || col.Name == "colQualityScore")
|
||||
{
|
||||
col.Visible = false;
|
||||
}
|
||||
@@ -296,6 +296,7 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
sInfo.supplierName,
|
||||
sInfo.subPurchaseOrderSn,
|
||||
sInfo.originalPurchaseOrderSn,
|
||||
sInfo.productSkcPicture.Replace("https", "http"),
|
||||
null,//image,
|
||||
sInfo.productId,
|
||||
sInfo.productSkcId,
|
||||
@@ -306,6 +307,7 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0.0,
|
||||
"",
|
||||
""
|
||||
);
|
||||
@@ -314,6 +316,10 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
}));
|
||||
}
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowDgvImg();
|
||||
}));
|
||||
|
||||
int total = BaseRegex.GetStringJson(ref jsonStr, "total").ParseToInt();
|
||||
totalPage = Math.Ceiling(total / 20.0).ParseToInt();
|
||||
@@ -435,7 +441,7 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
|
||||
page = Math.Max(page, 1);
|
||||
string url = "https://seller.kuajingmaihuo.com/marvel-mms/cn/api/kiana/venom/sales/management/listWarehouse";
|
||||
string body = @"{""pageNo"":" + page + @",""pageSize"":10,""isLack"":0,""selectStatusList"":[12],""priceAdjustRecentDays"":7}";
|
||||
string body = @"{""pageNo"":" + page + @",""pageSize"":40,""isLack"":0,""selectStatusList"":[12],""priceAdjustRecentDays"":7}";
|
||||
string refere = "https://seller.kuajingmaihuo.com/main/sale-manage/main";
|
||||
|
||||
return KJDHttpResponse.PostResponse(shop, url, body, refere);
|
||||
@@ -520,6 +526,47 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小于60分商品
|
||||
/// </summary>
|
||||
private string GetQualityInfo1_2(ShopLoginInfo shop, string productIds)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/bg-luna-agent-seller/goods/quality/supplyChain/qualityMetrics/pageQuery";
|
||||
string body = @"{""page"":1,""pageSize"":40,""qualityScoreEnum"":1,""productIds"":[" + productIds + "]}";
|
||||
string refere = "https://agentseller.temu.com/main/quality/dashboard";
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
/// <summary>
|
||||
/// 60分到70分商品
|
||||
/// </summary>
|
||||
private string GetQualityInfo2_2(ShopLoginInfo shop, string productIds)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/bg-luna-agent-seller/goods/quality/supplyChain/qualityMetrics/pageQuery";
|
||||
string body = @"{""page"":1,""pageSize"":40,""qualityScoreEnum"":2,""productIds"":[" + productIds + "]}";
|
||||
string refere = "https://agentseller.temu.com/main/quality/dashboard";
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
/// <summary>
|
||||
/// 70分到90分商品
|
||||
/// </summary>
|
||||
private string GetQualityInfo3_2(ShopLoginInfo shop, string productIds)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/bg-luna-agent-seller/goods/quality/supplyChain/qualityMetrics/pageQuery";
|
||||
string body = @"{""page"":1,""pageSize"":40,""qualityScoreEnum"":3,""productIds"":[" + productIds + "]}";
|
||||
string refere = "https://agentseller.temu.com/main/quality/dashboard";
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
/// <summary>
|
||||
/// 90分以上
|
||||
/// </summary>
|
||||
private string GetQualityInfo4_2(ShopLoginInfo shop, string productIds, int qualityScoreEnum = 4)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/bg-luna-agent-seller/goods/quality/supplyChain/qualityMetrics/pageQuery";
|
||||
string body = @"{""page"":1,""pageSize"":40,""qualityScoreEnum"":" + qualityScoreEnum + @",""productIds"":[" + productIds + "]}";
|
||||
string refere = "https://agentseller.temu.com/main/quality/dashboard";
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
@@ -730,7 +777,7 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
col.Visible = false;
|
||||
}
|
||||
if (col.Name == "colTodaySaleVolume" || col.Name == "colInCartNumber7d" || col.Name == "colSalesInventoryNum"
|
||||
|| col.Name == "colWaitReceiveNum" || col.Name == "colNeedStockUp")
|
||||
|| col.Name == "colWaitReceiveNum" || col.Name == "colNeedStockUp" || col.Name == "colQualityScore")
|
||||
{
|
||||
col.Visible = true;
|
||||
}
|
||||
@@ -832,6 +879,8 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
{
|
||||
BaseMsgForm.ShowError(ex.Message);
|
||||
}
|
||||
|
||||
List<SubOrderInfo> subOrderInfoLstTmp = new List<SubOrderInfo>();
|
||||
foreach (var item in jArr)
|
||||
{
|
||||
string sItem = item.ToString();
|
||||
@@ -862,50 +911,83 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
sInfo.needStockUp = true;
|
||||
else
|
||||
sInfo.needStockUp = false;
|
||||
lstSubOrderInfo.Add(sInfo);
|
||||
|
||||
//string url = sInfo.productSkcPicture.Replace("https", "http");
|
||||
//// var stream = WebRequest.Create(url).GetResponse().GetResponseStream();
|
||||
//Image image = null;
|
||||
//using (Stream stream = WebRequest.Create(url).GetResponse().GetResponseStream())
|
||||
//{
|
||||
// try {
|
||||
// image = Image.FromStream(stream);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rowId = this.dgvStock.Rows.Add(
|
||||
"",
|
||||
true,
|
||||
sInfo.supplierId,
|
||||
sInfo.supplierName,
|
||||
"",//sInfo.subPurchaseOrderSn,
|
||||
"",//sInfo.originalPurchaseOrderSn,
|
||||
null,//image,
|
||||
sInfo.productId,
|
||||
sInfo.productSkcId,
|
||||
sInfo.productName,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
sInfo.skuQuantityTotalInfo.inCartNumber7d,
|
||||
sInfo.skuQuantityTotalInfo.todaySaleVolume,
|
||||
sInfo.skuQuantityTotalInfo.inventoryNumInfo.warehouseInventoryNum,
|
||||
sInfo.skuQuantityTotalInfo.inventoryNumInfo.waitReceiveNum,
|
||||
sInfo.needStockUp == false ? "无需备货" : "可备货",
|
||||
""
|
||||
);
|
||||
if (rowId >= 0)
|
||||
dgvStock.Rows[rowId].Height = 60;
|
||||
//dgvStock.Rows.Cast[dgvStock.Rows].Height=60;
|
||||
}));
|
||||
subOrderInfoLstTmp.Add(sInfo);
|
||||
}
|
||||
}
|
||||
//获取品质信息------------------------------------------------------------------------
|
||||
List<TemuGoodsQualityInfo> qualityInfoLst = new List<TemuGoodsQualityInfo>();
|
||||
string productIds = string.Join(",", subOrderInfoLstTmp.Select(o=>o.productId));
|
||||
string qualityErr = "";
|
||||
try
|
||||
{
|
||||
for (int j = 1; j <= 4; j++)
|
||||
{
|
||||
var qualityRst1 = this.GetQualityInfo4_2(shop, productIds, j);
|
||||
if (qualityRst1.Contains("\"success\":true"))
|
||||
{
|
||||
var jObj = JObject.Parse(qualityRst1);
|
||||
string jStr = JsonHelper.SerializeObject(jObj["result"]["pageItems"]);
|
||||
qualityInfoLst.AddRange(JsonHelper.DeserializeJsonToList<TemuGoodsQualityInfo>(jStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
qualityErr = BaseRegex.GetStringJson(ref qualityRst1, "errorMsg");
|
||||
if (string.IsNullOrWhiteSpace(qualityErr))
|
||||
qualityErr += BaseRegex.GetStringJson(ref qualityRst1, "error_msg");
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(100, 200));
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { qualityErr += "\r\n" + ex.Message; };
|
||||
if (qualityErr != "")
|
||||
{
|
||||
BaseMsgForm.ShowError("获取商品品质信息失败!" + qualityErr);
|
||||
}
|
||||
foreach (var qualityInfo in qualityInfoLst)
|
||||
{
|
||||
var order = subOrderInfoLstTmp.FirstOrDefault(o => o.productId == qualityInfo.productId);
|
||||
if (order != null)
|
||||
order.goodsAfsScore = qualityInfo.goodsAfsScore;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
lstSubOrderInfo.AddRange(subOrderInfoLstTmp);
|
||||
foreach (var sInfo in subOrderInfoLstTmp)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rowId = this.dgvStock.Rows.Add(
|
||||
"",
|
||||
true,
|
||||
sInfo.supplierId,
|
||||
sInfo.supplierName,
|
||||
"",//sInfo.subPurchaseOrderSn,
|
||||
"",//sInfo.originalPurchaseOrderSn,
|
||||
sInfo.productSkcPicture.Replace("https", "http"),
|
||||
defaultBitmap,//image,
|
||||
sInfo.productId,
|
||||
sInfo.productSkcId,
|
||||
sInfo.productName,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
sInfo.skuQuantityTotalInfo.inCartNumber7d,
|
||||
sInfo.skuQuantityTotalInfo.todaySaleVolume,
|
||||
sInfo.skuQuantityTotalInfo.inventoryNumInfo.warehouseInventoryNum,
|
||||
sInfo.skuQuantityTotalInfo.inventoryNumInfo.waitReceiveNum,
|
||||
sInfo.goodsAfsScore == null ? "-" : (Math.Round(sInfo.goodsAfsScore.Value * 10) / 10).ToString(),
|
||||
sInfo.needStockUp == false ? "无需备货" : "可备货",
|
||||
""
|
||||
);
|
||||
if (rowId >= 0)
|
||||
dgvStock.Rows[rowId].Height = 60;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowDgvImg();
|
||||
}));
|
||||
|
||||
int total = BaseRegex.GetStringJson(ref jsonStr, "total").ParseToInt();
|
||||
totalPage = Math.Ceiling(total / 10.0).ParseToInt();
|
||||
@@ -995,6 +1077,17 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (stockUp.goodsAfsScore != null && stockUp.goodsAfsScore < 75)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "商品品质得分过低,请去网页手动备货";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == stockUp.supplierId.ToString());
|
||||
if (shop == null || shop.LoginStatus != "登录成功")
|
||||
@@ -1134,5 +1227,57 @@ namespace TemuKJD.KJDForms.ProductForms
|
||||
{
|
||||
this.isNewService = ucCheckBox1.Checked;
|
||||
}
|
||||
|
||||
Bitmap defaultBitmap = new Bitmap(80, 80);
|
||||
void ShowDgvImg()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach (DataGridViewRow row in this.dgvStock.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);
|
||||
|
||||
try
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colProductSkcPic"].Value = image;
|
||||
}));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void dgvStock_Scroll(object sender, ScrollEventArgs e)
|
||||
{
|
||||
ShowDgvImg();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user