订单金额统计利润计算功能

This commit is contained in:
wule committed 2025-09-02 19:03:37 +08:00
1 parent eca6a8a9e7
commit cc539ce604
27 files changed
+2090 -214

No files matched your search

@@ -16,6 +16,7 @@ using System.Windows.Forms;
using TemuKJD.Extension;
using TemuKJD.KJDForms.BaseForms;
using TemuKJD.KJDForms.ShopForms;
using Work;
namespace TemuKJD.KJDForms.ProductForms
{
@@ -24,6 +25,7 @@ namespace TemuKJD.KJDForms.ProductForms
private CheckBox chkSelectAll = null;
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
List<TemuListProductInfo> lstProductInfo = new List<TemuListProductInfo>();
List<TemuDBProductPurchasePriceInfo> lstProductPurchasePrice = new List<TemuDBProductPurchasePriceInfo>();
public PurchasePriceForm()
{
@@ -38,6 +40,7 @@ namespace TemuKJD.KJDForms.ProductForms
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
this.dgvProduct.AddSelectorColumn("colCheck");
//this.dgvProduct.MergeColumnHeader(new List<string>() { "colSupplierId", "colSupplierName" }, "店铺信息", true);
}
private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
{
@@ -315,42 +318,50 @@ namespace TemuKJD.KJDForms.ProductForms
if (jArr == null)
jArr = new JArray();
List<TemuListProductInfo> productInfoLst = new List<TemuListProductInfo>();
List<string> productInfoSpuIdLst = new List<string>();
foreach (var item in jArr)
{
string sItem = JsonHelper.SerializeObject(item);
TemuListProductInfo pInfo = JsonHelper.DeserializeJsonToObject<TemuListProductInfo>(sItem); // 反序列化得到类
List<string> productInfoSpuIdLst= new List<string>();
if (pInfo != null && !lstProductInfo.Any(a => a.productId == pInfo.productId))
{
lstProductInfo.Add(pInfo);
productInfoLst.Add(pInfo);
productInfoSpuIdLst.Add(pInfo.productId.ParseToString());
Invoke(new Action(() =>
{
int rowId = this.dgvProduct.Rows.Add(
true,
shop.ShopId,
shop.ShopAccount, // pInfo.supplierName, // 列表里取不到,这里取shop里的
pInfo.mainImageUrl.Replace("https", "http").Replace("img.kwcdn.com", "img.cdnfe.com") + "?imageMogr2/thumbnail/60x",
defaultBitmap,//image, // skc图片
pInfo.productId,
pInfo.productSkcId,
pInfo.productName, // 商品标题
pInfo.extCode,
"",
"",
"设置",
"" // 操作结果,状态
);
dgvProduct.Rows[rowId].Height = 60;
}));
}
}
List<TemuDBProductPurchasePriceInfo> productPurchasePriceList = GetPurchasePrice(productInfoSpuIdLst);
this.lstProductPurchasePrice.AddRange(productPurchasePriceList);
foreach (var pInfo in productInfoLst)
{
Invoke(new Action(() =>
{
int rowId = this.dgvProduct.Rows.Add(
true,
shop.ShopId,
shop.ShopAccount, // pInfo.supplierName, // 列表里取不到,这里取shop里的
pInfo.mainImageUrl.Replace("https", "http").Replace("img.kwcdn.com", "img.cdnfe.com") + "?imageMogr2/thumbnail/60x",
defaultBitmap,//image, // skc图片
pInfo.productId,
pInfo.productSkcId,
pInfo.productName, // 商品标题
pInfo.extCode,
"",
"",
"设置",
"" // 操作结果,状态
);
dgvProduct.Rows[rowId].Height = 60;
}));
}
}
catch (Exception ex)
{
BaseMsgForm.ShowError(ex.Message);
catch (Exception ex)
{
BaseMsgForm.ShowError(ex.Message);
}
Invoke(new Action(() =>
{
@@ -449,9 +460,37 @@ namespace TemuKJD.KJDForms.ProductForms
ShowDgvImg(this.dgvProduct);
}
void GetPurchasePrice()
List<TemuDBProductPurchasePriceInfo> GetPurchasePrice(List<string> productIdList)
{
List<TemuDBProductPurchasePriceInfo> list = new List<TemuDBProductPurchasePriceInfo>();
for (int i = 0; i < productIdList.Count; i++)
{
productIdList[i] = productIdList[i].Replace(",", "").Replace("'", "").Replace("\"", "");
}
var url = BaseClass.BuildObjString("price/get_purchase_price_list");
var data = UserLogin.GetSignaturex();
data += "&page=1";
data += "&page_size=" + productIdList.Count;
data += "&in_spu_id=" + string.Join(",", productIdList);
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"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
return list;
}
if (!html.Contains("data"))
return list;
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() == 0)
return list;
return JsonHelper.DeserializeJsonToList<TemuDBProductPurchasePriceInfo>(jArr.ToString());
}
}
}