增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,141 @@
|
||||
using AllBase;
|
||||
using AllBase.Extension;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Config;
|
||||
using AllBase.Model.DBModel;
|
||||
using AllBase.Model.Param.WXParam;
|
||||
using AllBase.Model.Result;
|
||||
using AllBase.Model.Result.PDDResult;
|
||||
using AllBase.Model.Result.WXResult;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Store.Framework.Extensions;
|
||||
using Store.Product.Models.PublishParameters.Wx;
|
||||
using Store.Product.Publish;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Work;
|
||||
|
||||
namespace Store.Product.Publish.Steps.Wx;
|
||||
/// <summary>
|
||||
/// 由 WXDBProdUploadForm.UploadProduct 的“获取推单运费模板并计算运费”区段迁移。
|
||||
/// TODO(迁移): 原区段中的 TEMUKJD/WXUpload/窗体服务引用需按 Store.Product 运行时适配逐项核对。
|
||||
/// </summary>
|
||||
public sealed class CalculateShippingTemplateStep : WxProductPublishStepBase
|
||||
{
|
||||
public override string Description => "获取推单运费模板并计算运费";
|
||||
|
||||
protected override Task ExecuteProvider(WXPublishContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
if (cell != null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cell.Value = "正在选取运费模板";
|
||||
}));
|
||||
}
|
||||
|
||||
shippingTemplateJson = "";
|
||||
shipPrice = 0;
|
||||
|
||||
if (dbProd.product_get_type_text == "厂商直采")
|
||||
{
|
||||
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))
|
||||
{
|
||||
// 获取运费模板
|
||||
var urlShip = BaseClass.BuildObjString("product/e57_get_freight_template");
|
||||
var dataShip = Work.UserLogin.GetSignaturex() + "&coid=" + dbProd.skc_id;
|
||||
var shipRst = GetHtml.PostUtf8(urlShip, dataShip);
|
||||
if (string.IsNullOrEmpty(shipRst) || !shipRst.Contains("\"code\":0"))
|
||||
shipRst = GetHtml.PostUtf8(urlShipping, dataShipping);
|
||||
if (!shipRst.Contains("\"code\":0"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJson(ref shipRst, "msg");
|
||||
if (string.IsNullOrEmpty(errMsg))
|
||||
errMsg = shipRst;
|
||||
throw new Exception("运费模板获取失败 " + errMsg);
|
||||
}
|
||||
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)
|
||||
{
|
||||
throw new Exception("运费模板解析失败 " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
throw new Exception("运费模板获取失败 " + ex.Message);
|
||||
}
|
||||
}
|
||||
if (shipPrice <= 0)
|
||||
{
|
||||
throw new Exception("运费模板获取失败 未获取到");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user