diff --git a/Store.Framework/Enums/ShopStatus.cs b/Store.Framework/Enums/ShopStatus.cs new file mode 100644 index 0000000..9116967 --- /dev/null +++ b/Store.Framework/Enums/ShopStatus.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Store.Framework.Enums; + +/// +/// 商铺状态 +/// +public enum ShopStatus +{ + +} diff --git a/Store.Framework/Inerterfaces/IShop.cs b/Store.Framework/Inerterfaces/IShop.cs new file mode 100644 index 0000000..39832c9 --- /dev/null +++ b/Store.Framework/Inerterfaces/IShop.cs @@ -0,0 +1,44 @@ +using Store.Framework.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Store.Framework.Inerterfaces; + +public interface IShop +{ + /// + /// 商铺Id + /// + public string ShopId { get; set; } + /// + /// 商铺名 + /// + public string ShopName { get; set; } + /// + /// 登录密码 + /// + + public string Password { get; set; } + + /// + /// Cookie信息 + /// + public Cookies Cookie { get; set; } + + /// + /// 分组名称 + /// + public string GroupName { get; set; } + + /// + /// 商铺提示信息 + /// + public string Msg { get; set; } + /// + /// 是否登录成功 + /// + public bool IsLoggedIn { get; set; } +} diff --git a/Store.Framework/Models/ShopBase.cs b/Store.Framework/Models/ShopBase.cs index 9d59c1d..b42cc4b 100644 --- a/Store.Framework/Models/ShopBase.cs +++ b/Store.Framework/Models/ShopBase.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using Store.Framework.Inerterfaces; using System; using System.Collections.Generic; using System.Linq; @@ -7,48 +8,44 @@ using System.Threading.Tasks; namespace Store.Framework.Models { - /// - /// 商铺信息 - /// - public abstract class ShopBase - { - [JsonProperty("id")] - public string Id { get; set; } + /// + /// 商铺信息 + /// + public abstract class ShopBase : IShop + { + public int Id { get; set; } + /// + /// 商铺Id + /// + public string ShopId { get; set; } + /// + /// 商铺名 + /// + public string ShopName { get; set; } + /// + /// 登录密码 + /// - [JsonProperty("shop_account")] - public string Name { get; set; } + public string Password { get; set; } - [JsonProperty("login_pass")] - public string Password { get; set; } + /// + /// Cookie信息 + /// + public Cookies Cookie { get; set; } - /// - /// Cookie信息 - /// - [JsonProperty("cookie")] - public Cookies Cookie { get; set; } + /// + /// 分组名称 + /// + public string GroupName { get; set; } - /// - /// 分组名称 - /// - [JsonProperty("group_name")] - public string GroupName { get; set; } + /// + /// 商铺提示信息 + /// + public string Msg { get; set; } + /// + /// 是否登录成功 + /// + public bool IsLoggedIn { get; set; } - /// - /// 商铺提示信息 - /// - [JsonProperty("login_status")] - public string Msg { get; set; } - } - - /// - /// 商铺信息 - /// - /// 状态码 - public abstract class ShopBase : ShopBase - { - /// - /// 状态 - /// - public TStatus Status { get; set; } - } + } } \ No newline at end of file diff --git a/Store.Framework/Services/ShopManager.cs b/Store.Framework/Services/ShopManager.cs index c72142d..b2aa5b0 100644 --- a/Store.Framework/Services/ShopManager.cs +++ b/Store.Framework/Services/ShopManager.cs @@ -107,7 +107,7 @@ namespace Store.Client.Services foreach (Match match in matches) { string key = match.Groups["key"].Value; - Shop shop = shops.FirstOrDefault(s => s.Id == key || s.Name == key); + Shop shop = shops.FirstOrDefault(s => s.Id == key || s.ShopName == key); if (shop == null) continue; diff --git a/Store.Product/Publish/PublishContext .cs b/Store.Product/Publish/PublishContext .cs index aa28196..41b82a1 100644 --- a/Store.Product/Publish/PublishContext .cs +++ b/Store.Product/Publish/PublishContext .cs @@ -1,4 +1,5 @@ -using Store.Framework.Models; +using Store.Framework.Inerterfaces; +using Store.Framework.Models; using Store.Product.Models.Product; using Store.Product.Models.PublishParameters; using Store.Product.Models.PublishParameters.Wx; @@ -19,7 +20,7 @@ public class PublishContextBase /// /// 商铺 /// - public Shop Shop { get; set; } + public IShop Shop { get; set; } /// /// 商铺名称 /// @@ -31,7 +32,7 @@ public class PublishContextBase { return ""; } - return Shop.Name; + return Shop.ShopName; } } diff --git a/Store.Product/Publish/Steps/WXPublishParameters.cs b/Store.Product/Publish/Steps/WXPublishParameters.cs index 7e8276b..25811b9 100644 --- a/Store.Product/Publish/Steps/WXPublishParameters.cs +++ b/Store.Product/Publish/Steps/WXPublishParameters.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using Store.Product.Models.PublishParameters; using Store.Product.Models.PublishParameters.Wx; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; @@ -227,7 +228,7 @@ public class WXPublishParameters: PublishParameters /// /// 待裂变标题文本,使用换行分隔。 /// - public string FissionTitles { get; set; } = ""; + public Queue FissionTitles { get; set; } = new Queue(); /// /// 是否删除标题开头的特殊字符。 /// diff --git a/Store.Product/Publish/Steps/Wx/FissionTitleStep.cs b/Store.Product/Publish/Steps/Wx/FissionTitleStep.cs index a35d622..dd01f59 100644 --- a/Store.Product/Publish/Steps/Wx/FissionTitleStep.cs +++ b/Store.Product/Publish/Steps/Wx/FissionTitleStep.cs @@ -38,17 +38,13 @@ public sealed class FissionTitleStep : WxProductPublishStepBase } protected override Task ExecuteProvider(WXPublishContext context, CancellationToken cancellationToken) { - var titles = context.Parameters.FissionTitles.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); - if (titles.Count == 0) + if (context.Parameters.FissionTitles.Count == 0) { throw new Exception("裂变标题数量不足,将暂停上传"); } - context.Product.Title = titles[0]; + context.Product.Title = context.Parameters.FissionTitles.Dequeue(); context.Parameters.IsFissionTitle = true; - titles.RemoveAt(0); - context.Parameters.FissionTitles = string.Join("\r\n", titles); context.Progress.Report("标题裂变成功,更改为:" + context.Product.Title); - return Task.CompletedTask; } } diff --git a/Store.Product/Publish/Steps/Wx/InitializeUploadProductStep.cs b/Store.Product/Publish/Steps/Wx/InitializeUploadProductStep.cs index 265c202..dda3d8b 100644 --- a/Store.Product/Publish/Steps/Wx/InitializeUploadProductStep.cs +++ b/Store.Product/Publish/Steps/Wx/InitializeUploadProductStep.cs @@ -25,8 +25,7 @@ using Work; namespace Store.Product.Publish.Steps.Wx; /// -/// 由 WXDBProdUploadForm.UploadProduct 的“初始化上传参数与店铺登录校验”区段迁移。 -/// TODO(迁移): 原区段中的 TEMUKJD/WXUpload/窗体服务引用需按 Store.Product 运行时适配逐项核对。 +/// 初始化上传参数与店铺登录校验 /// public sealed class InitializeUploadProductStep : WxProductPublishStepBase { @@ -34,7 +33,7 @@ public sealed class InitializeUploadProductStep : WxProductPublishStepBase protected override Task ExecuteProvider(WXPublishContext context, CancellationToken cancellationToken) { - if (context.Parameters.Shop == null || string.IsNullOrEmpty(context.Parameters.Shop.ShopId) || context.Parameters.Shop.LoginStatus != "登录成功") + if (context.ShopName == null || string.IsNullOrEmpty(context.Shop.ShopId) || context.Shop.IsLoggedIn == false) { throw new Exception("店铺为空或未登录!"); } diff --git a/TEMUKJD/KJD.csproj b/TEMUKJD/KJD.csproj index 012a862..dcd466a 100644 --- a/TEMUKJD/KJD.csproj +++ b/TEMUKJD/KJD.csproj @@ -65,7 +65,6 @@ - diff --git a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs index 4ebf37d..57a986c 100644 --- a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs @@ -36,8 +36,8 @@ using TemuKJD.UserControls; using TemuKJD.WXForms.ShopForms; using Work; using Work.BLL.Tools; -using Store.Product.Models.PublishParameters; -using Store.Product.Publish.Steps; +//using Store.Product.Models.PublishParameters; +//using Store.Product.Publish.Steps; using Work.Services; using static System.Net.Mime.MediaTypeNames; @@ -52,7 +52,7 @@ namespace TemuKJD.WXForms.ProductForms public CancellationTokenSource cancellationTokenSource { get; set; } = null; public bool IsWxNotUseSoftwareDefaultAddressOnce { get; set; } = false; - public WXPublishParameters PublishParameters { get; set; } = new WXPublishParameters(); + //public WXPublishParameters PublishParameters { get; set; } = new WXPublishParameters(); ConcurrentList lstAddPriceRule = new ConcurrentList(); @@ -1064,97 +1064,97 @@ namespace TemuKJD.WXForms.ProductForms void AddProductArr(List shopIdLst) { - PublishParameters = new WXPublishParameters - { - // 复用基类已有参数。 - TitlePrefix = txtTitleHeadWord.Text.Trim(), - StorageType = chkUpDraft.Checked ? ProductStorage.InStock : ProductStorage.OnSale, - IsFilterPrice = new SwitchParams>( - !string.IsNullOrWhiteSpace(txtMinPrice.Text) || !string.IsNullOrWhiteSpace(txtMaxPrice.Text), - new Tuple( - string.IsNullOrWhiteSpace(txtMinPrice.Text) ? 0 : txtMinPrice.Text.Trim().ParseToInt(), - string.IsNullOrWhiteSpace(txtMaxPrice.Text) ? int.MaxValue : txtMaxPrice.Text.Trim().ParseToInt())), - IsFilterCustomTitleKeywors = chkSkipReplaceText.Checked, - IsRemoveCustomTitleKeywors = !chkSkipReplaceText.Checked && !string.IsNullOrWhiteSpace(txtReplaceText.Text), + //PublishParameters = new WXPublishParameters + //{ + // // 复用基类已有参数。 + // TitlePrefix = txtTitleHeadWord.Text.Trim(), + // StorageType = chkUpDraft.Checked ? ProductStorage.InStock : ProductStorage.OnSale, + // IsFilterPrice = new SwitchParams>( + // !string.IsNullOrWhiteSpace(txtMinPrice.Text) || !string.IsNullOrWhiteSpace(txtMaxPrice.Text), + // new Tuple( + // string.IsNullOrWhiteSpace(txtMinPrice.Text) ? 0 : txtMinPrice.Text.Trim().ParseToInt(), + // string.IsNullOrWhiteSpace(txtMaxPrice.Text) ? int.MaxValue : txtMaxPrice.Text.Trim().ParseToInt())), + // IsFilterCustomTitleKeywors = chkSkipReplaceText.Checked, + // IsRemoveCustomTitleKeywors = !chkSkipReplaceText.Checked && !string.IsNullOrWhiteSpace(txtReplaceText.Text), - // 原 WXUploadRule 对应参数。 - PreSaleDays = txtPreDays.Text.Trim().ParseToInt(), - FilterWords = txtReplaceText.Text.Trim(), - IsSkipHasFilterWordsProd = chkSkipReplaceText.Checked, - SkuMinPrice = string.IsNullOrWhiteSpace(txtMinPrice.Text) ? 0 : txtMinPrice.Text.Trim().ParseToInt(), - SkuMaxPrice = string.IsNullOrWhiteSpace(txtMaxPrice.Text) ? int.MaxValue : txtMaxPrice.Text.Trim().ParseToInt(), - WaitSeconds = txtWaitSeconds.Text.Trim().ParseToInt(), - OnlyHighestPriceSku = chkHighestPriceSku.Checked, - OnlyLowestPriceSku = chkLowestPriceSku.Checked, - SameSpecSamePriceUp = chkSameSpecPriceUp.Checked, - SameSpecSamePriceDown = chkSameSpecPriceDown.Checked, - SkipUploaded = chkSkipUploaded.Checked, - SkipExisting = chkSkipUploaded.Checked, - UpDraft = chkUpDraft.Checked, - IsPreSale = chkPreSale.Checked, - TitleHeadWords = txtTitleHeadWord.Text.Trim(), - IsSaveBound = chkSaveBound.Checked, - FilterBoundMinSave = txtFilterBoundMin.Text.Trim().ParseToInt(), - FilterBoundMaxSave = txtFilterBoundMax.Text.Trim().ParseToInt(), - IsAiShortTitle = chkAiShortTitle.Checked, - IsUseWXComplateProd = chkUseWXComplateProd.Checked, - IsUseShanghaiReturnOrderAddress = chkUseShanghaiReturnOrderAddress.Checked, + // // 原 WXUploadRule 对应参数。 + // PreSaleDays = txtPreDays.Text.Trim().ParseToInt(), + // FilterWords = txtReplaceText.Text.Trim(), + // IsSkipHasFilterWordsProd = chkSkipReplaceText.Checked, + // SkuMinPrice = string.IsNullOrWhiteSpace(txtMinPrice.Text) ? 0 : txtMinPrice.Text.Trim().ParseToInt(), + // SkuMaxPrice = string.IsNullOrWhiteSpace(txtMaxPrice.Text) ? int.MaxValue : txtMaxPrice.Text.Trim().ParseToInt(), + // WaitSeconds = txtWaitSeconds.Text.Trim().ParseToInt(), + // OnlyHighestPriceSku = chkHighestPriceSku.Checked, + // OnlyLowestPriceSku = chkLowestPriceSku.Checked, + // SameSpecSamePriceUp = chkSameSpecPriceUp.Checked, + // SameSpecSamePriceDown = chkSameSpecPriceDown.Checked, + // SkipUploaded = chkSkipUploaded.Checked, + // SkipExisting = chkSkipUploaded.Checked, + // UpDraft = chkUpDraft.Checked, + // IsPreSale = chkPreSale.Checked, + // TitleHeadWords = txtTitleHeadWord.Text.Trim(), + // IsSaveBound = chkSaveBound.Checked, + // FilterBoundMinSave = txtFilterBoundMin.Text.Trim().ParseToInt(), + // FilterBoundMaxSave = txtFilterBoundMax.Text.Trim().ParseToInt(), + // IsAiShortTitle = chkAiShortTitle.Checked, + // IsUseWXComplateProd = chkUseWXComplateProd.Checked, + // IsUseShanghaiReturnOrderAddress = chkUseShanghaiReturnOrderAddress.Checked, - // UploadProduct 内直接读取的窗体参数。 - IsFissionTitle = chkFissionGoodsName.Checked, - FissionTitles = txtFissionTitle.Text, - IsRemoveSpecialChar = chkRemoveSpecialChar.Checked, - IsCommissionUpload = chkCommission.Checked, - IsCommissionIncrease = cmbCommissionAddOrReduce.Text == "增加", - CommissionMinPercent = txtMinUpCommission.Text.Trim().ParseToInt(), - CommissionMaxPercent = txtMaxUpCommission.Text.Trim().ParseToInt(), - CommissionChangePercent = txtCommissionChangeValue.Text.Trim().ParseToInt(), - IsUseRecommendation = chkUseRecommand.Checked, - IsImageRandomBlock = chkImgRandomBlock.Checked, - IsRandomMainImageOrder = chkRandomMainImgOrder.Checked, - IsRandomDetailImageOrder = chkRandomDetailImgOrder.Checked, - IsFissionRandomPriceChange = chkFissionRandomPriceChange.Checked, - FissionRandomPriceChangeValue = txtFissionRandomPriceChange.Text.Trim().ParseToDecimal(), - SpecialBrandName = cmbSpBrandName.Text.Trim(), - IsAiImage = chkAiImage.Checked, - AiImageCount = txtAiImgCount.Text.Trim().ParseToInt(), - IsDefaultBestBefore = chkDefaultBestBefore.Checked, - DefaultBestBeforeDays = txtDefaultBestBefore.Text.Trim().ParseToInt(), - IsRandomImageBorder = chkRandomImgBorder.Checked, - MainBorderImageCount = txtMainBorderImgCount.Text.Trim().ParseToInt(), - DetailBorderImageCount = txtDetailBorderImgCount.Text.Trim().ParseToInt(), - IsFreightInsurance = chkFreightInsurance.Checked, - IsTestNoAuditUpload = chkTestNoAuditUpload.Checked, - IsCheckSubmitSuccess = chkIsSubmitSuccess.Checked, - UseSoftwareDefaultAddress = GlobalConfig.GlobalSettings.IsWxUseSoftwareDefaultAddress, - IgnoreSoftwareDefaultAddressOnce = IsWxNotUseSoftwareDefaultAddressOnce, + // // UploadProduct 内直接读取的窗体参数。 + // IsFissionTitle = chkFissionGoodsName.Checked, + // FissionTitles = txtFissionTitle.Text, + // IsRemoveSpecialChar = chkRemoveSpecialChar.Checked, + // IsCommissionUpload = chkCommission.Checked, + // IsCommissionIncrease = cmbCommissionAddOrReduce.Text == "增加", + // CommissionMinPercent = txtMinUpCommission.Text.Trim().ParseToInt(), + // CommissionMaxPercent = txtMaxUpCommission.Text.Trim().ParseToInt(), + // CommissionChangePercent = txtCommissionChangeValue.Text.Trim().ParseToInt(), + // IsUseRecommendation = chkUseRecommand.Checked, + // IsImageRandomBlock = chkImgRandomBlock.Checked, + // IsRandomMainImageOrder = chkRandomMainImgOrder.Checked, + // IsRandomDetailImageOrder = chkRandomDetailImgOrder.Checked, + // IsFissionRandomPriceChange = chkFissionRandomPriceChange.Checked, + // FissionRandomPriceChangeValue = txtFissionRandomPriceChange.Text.Trim().ParseToDecimal(), + // SpecialBrandName = cmbSpBrandName.Text.Trim(), + // IsAiImage = chkAiImage.Checked, + // AiImageCount = txtAiImgCount.Text.Trim().ParseToInt(), + // IsDefaultBestBefore = chkDefaultBestBefore.Checked, + // DefaultBestBeforeDays = txtDefaultBestBefore.Text.Trim().ParseToInt(), + // IsRandomImageBorder = chkRandomImgBorder.Checked, + // MainBorderImageCount = txtMainBorderImgCount.Text.Trim().ParseToInt(), + // DetailBorderImageCount = txtDetailBorderImgCount.Text.Trim().ParseToInt(), + // IsFreightInsurance = chkFreightInsurance.Checked, + // IsTestNoAuditUpload = chkTestNoAuditUpload.Checked, + // IsCheckSubmitSuccess = chkIsSubmitSuccess.Checked, + // UseSoftwareDefaultAddress = GlobalConfig.GlobalSettings.IsWxUseSoftwareDefaultAddress, + // IgnoreSoftwareDefaultAddressOnce = IsWxNotUseSoftwareDefaultAddressOnce, - // 加价规则与商品价格/SKU/图片参数一起迁移。 - DefaultAddPriceRule = new WXAddPriceRule - { - MoreThanPrice = defaultAddPriceRule.MoreThanPrice, - LessThanPrice = defaultAddPriceRule.LessThanPrice, - AddPriceTimes = defaultAddPriceRule.AddPriceTimes, - AddMorePrice = defaultAddPriceRule.AddMorePrice, - SinglePriceAdd = defaultAddPriceRule.SinglePriceAdd, - AddMorePriceFirst = defaultAddPriceRule.AddMorePriceFirst, - StockNum = defaultAddPriceRule.StockNum, - IsStepAddPrice = defaultAddPriceRule.IsStepAddPrice, - ShippingPriceTimes = defaultAddPriceRule.ShippingPriceTimes - }, - AddPriceRules = lstAddPriceRule.Select(rule => new WXAddPriceRule - { - MoreThanPrice = rule.MoreThanPrice, - LessThanPrice = rule.LessThanPrice, - AddPriceTimes = rule.AddPriceTimes, - AddMorePrice = rule.AddMorePrice, - SinglePriceAdd = rule.SinglePriceAdd, - AddMorePriceFirst = rule.AddMorePriceFirst, - StockNum = rule.StockNum, - IsStepAddPrice = rule.IsStepAddPrice, - ShippingPriceTimes = rule.ShippingPriceTimes - }).ToList() - }; + // // 加价规则与商品价格/SKU/图片参数一起迁移。 + // DefaultAddPriceRule = new WXAddPriceRule + // { + // MoreThanPrice = defaultAddPriceRule.MoreThanPrice, + // LessThanPrice = defaultAddPriceRule.LessThanPrice, + // AddPriceTimes = defaultAddPriceRule.AddPriceTimes, + // AddMorePrice = defaultAddPriceRule.AddMorePrice, + // SinglePriceAdd = defaultAddPriceRule.SinglePriceAdd, + // AddMorePriceFirst = defaultAddPriceRule.AddMorePriceFirst, + // StockNum = defaultAddPriceRule.StockNum, + // IsStepAddPrice = defaultAddPriceRule.IsStepAddPrice, + // ShippingPriceTimes = defaultAddPriceRule.ShippingPriceTimes + // }, + // AddPriceRules = lstAddPriceRule.Select(rule => new WXAddPriceRule + // { + // MoreThanPrice = rule.MoreThanPrice, + // LessThanPrice = rule.LessThanPrice, + // AddPriceTimes = rule.AddPriceTimes, + // AddMorePrice = rule.AddMorePrice, + // SinglePriceAdd = rule.SinglePriceAdd, + // AddMorePriceFirst = rule.AddMorePriceFirst, + // StockNum = rule.StockNum, + // IsStepAddPrice = rule.IsStepAddPrice, + // ShippingPriceTimes = rule.ShippingPriceTimes + // }).ToList() + //}; Invoke(new Action(() => { @@ -1327,7 +1327,6 @@ namespace TemuKJD.WXForms.ProductForms { this.pbLoading.Visible = false; })); - GlobalConfig.ShopLoginList Task.Run(() => { DateTime startTime = DateTime.Now; diff --git a/test/Store.Test/UnitTest1.cs b/test/Store.Test/UnitTest1.cs index bc66f6e..ab6c795 100644 --- a/test/Store.Test/UnitTest1.cs +++ b/test/Store.Test/UnitTest1.cs @@ -112,7 +112,7 @@ public class Tests { Shop = new Shop { - Name = "乐乐人小店", + ShopName = "乐乐人小店", Cookie = new Cookies("biz_token=b_000001a0_80071145_44612ea2_a87897a5_12c2c339; biz_ticket=; biz_magic=09bcc3e825c8826c562d62ca3442e35e8eb4ce13b73e4097661f11c9bd90f46e; biz_rand=CAESIO762C8Iu/hxVBpyNsXZiqDGlOsa5U3WBKBd3PvU0p6d; device_id=7b7080668b28f2aadba6d7f208ca35833c4ce75fe4c107eca6a5e5785fccc8ad") }, Product = new WxProductUploadProduct { Title = "原商品标题" },