From 3b76d3082d4dfb27dd256919e0720541b1769222 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Mon, 27 Feb 2023 22:34:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E8=AE=BE=E7=BD=AE=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=B9=B3=E5=8F=B0=EF=BC=8C=E5=85=B3=E8=81=94=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=88=87=E6=8D=A2=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Client/Models/Order/OrderDropShipping.cs | 14 ++++- .../Purchase/1688PreviewPurchaseViewModel.cs | 54 +------------------ .../Setting/ShopSettingViewModel.cs | 46 +++++++++++++--- .../Views/Order/RelationPurchaseOrder.xaml.cs | 22 ++++++-- BBWY.Client/Views/Setting/ShopSetting.xaml | 2 +- BBWY.Server.Business/Vender/VenderBusiness.cs | 8 --- .../CreateOnlinePurchaseOrderRequest.cs | 5 ++ 7 files changed, 76 insertions(+), 75 deletions(-) diff --git a/BBWY.Client/Models/Order/OrderDropShipping.cs b/BBWY.Client/Models/Order/OrderDropShipping.cs index 3a5def49..b9af1438 100644 --- a/BBWY.Client/Models/Order/OrderDropShipping.cs +++ b/BBWY.Client/Models/Order/OrderDropShipping.cs @@ -19,7 +19,17 @@ namespace BBWY.Client.Models public decimal DeliveryFreight { get => deliveryFreight; set { Set(ref deliveryFreight, value); } } public string PurchaseOrderId { get => purchaseOrderId; set { Set(ref purchaseOrderId, value); } } public string MerchantOrderId { get => merchantOrderId; set { Set(ref merchantOrderId, value); } } - public Platform PurchasePlatform { get => purchasePlatform; set { Set(ref purchasePlatform, value); } } + public Platform PurchasePlatform + { + get => purchasePlatform; + set + { + if (Set(ref purchasePlatform, value)) + { + OnPurchasePlatformChanged?.Invoke(this); + } + } + } public decimal PurchaseAmount { get => purchaseAmount; set { Set(ref purchaseAmount, value); } } public decimal SkuAmount @@ -71,6 +81,8 @@ namespace BBWY.Client.Models [JsonIgnore] public Action OnPurchaseAmountChanged { get; set; } + [JsonIgnore] + public Action OnPurchasePlatformChanged { get; set; } public object Clone() { diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs index 596fdfba..f2c1d4ff 100644 --- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs +++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs @@ -161,7 +161,6 @@ namespace BBWY.Client.ViewModels tradeMode = string.Empty; ProductAmount = FreightAmount = TotalAmount = 0; ContactName = Address = Mobile = Province = City = County = Town = PrucahseRemark = string.Empty; - } private void LoadPurchaseProduct(Platform platform, PurchaseSchemeProduct purchaseSchemeProduct, OrderSku orderSku, ManualResetEvent ewh) @@ -192,55 +191,6 @@ namespace BBWY.Client.ViewModels ewh.Dispose(); } - //private IList LoadPurchaseProductCore(PurchaseSchemeProduct purchaseSchemeProduct, out string errorMsg) - //{ - // errorMsg = string.Empty; - // //1688商品详情接口 - // var response = oneBoundAPIService.GetProductInfo("1688", purchaseSchemeProduct.PurchaseProductId); - // if (!response.Success) - // { - // //记录日志 - - // errorMsg = response.Msg; - // Console.WriteLine(errorMsg); - // return null; - // } - // var jobject = response.Data; - - - // var skuJArray = (JArray)jobject["item"]["skus"]["sku"]; - // if (skuJArray.Count == 0) - // { - // errorMsg = $"商品{purchaseSchemeProduct.PurchaseProductId}缺少sku信息"; - // return null; - // } - - // return skuJArray.Select(j => new PurchaseSchemeProductSku() - // { - // ProductId = purchaseSchemeProduct.ProductId, - // SkuId = purchaseSchemeProduct.SkuId, - // PurchaseProductId = purchaseSchemeProduct.PurchaseProductId, - // Price = j.Value("price"), - // PurchaseSkuId = j.Value("sku_id"), - // PurchaseSkuSpecId = j.Value("spec_id"), - // Title = j.Value("properties_name"), - // Logo = GetSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"]) - // }).ToList(); - //} - - private string GetSkuLogo(JToken skuJToken, JArray prop_img) - { - if (!prop_img.HasValues) - return "pack://application:,,,/Resources/Images/defaultItem.png"; - var properties = skuJToken.Value("properties").Split(';', StringSplitOptions.RemoveEmptyEntries); - foreach (var p in properties) - { - var imgJToken = prop_img.FirstOrDefault(g => g.Value("properties") == p); - if (imgJToken != null) - return imgJToken.Value("url"); - } - return "pack://application:,,,/Resources/Images/defaultItem.png"; - } private void OnItemTotalChanged(int itemTotal) { @@ -255,7 +205,7 @@ namespace BBWY.Client.ViewModels IsLoading = false; return; } - + if (string.IsNullOrEmpty(ContactName) || string.IsNullOrEmpty(Address) || string.IsNullOrEmpty(Mobile) || @@ -279,7 +229,7 @@ namespace BBWY.Client.ViewModels Province = Province, TelePhone = Mobile, Town = Town - }, PurchaseSchemeProductSkuList, Platform.阿里巴巴, purchaseAccount, PurchaseOrderMode)) + }, PurchaseSchemeProductSkuList, purchaseAccount.PurchasePlatformId, purchaseAccount, PurchaseOrderMode)) .ContinueWith(t => { IsLoading = false; diff --git a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs index 057e029c..ddf919fe 100644 --- a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs +++ b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs @@ -29,8 +29,11 @@ namespace BBWY.Client.ViewModels private string siNanDingDingKey; private SiNanPolicyLevel selectedSiNanPolicyLevel; + private Platform purchasePlatform; + public ICommand SaveCommand { get; set; } + public ICommand SetPanelIndexCommand { get; set; } public PurchaseAccount PurchaseAccount { get => purchaseAccount; set { Set(ref purchaseAccount, value); } } @@ -52,6 +55,19 @@ namespace BBWY.Client.ViewModels public string SiNanDingDingKey { get => siNanDingDingKey; set { Set(ref siNanDingDingKey, value); } } public SiNanPolicyLevel SelectedSiNanPolicyLevel { get => selectedSiNanPolicyLevel; set { Set(ref selectedSiNanPolicyLevel, value); } } + /// + /// 采购平台 + /// + public Platform PurchasePlatform + { + get => purchasePlatform; + set + { + if (Set(ref purchasePlatform, value)) + OnPurchasePlatformChanged(); + } + } + public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService) { PanelIndex = 0; @@ -89,6 +105,9 @@ namespace BBWY.Client.ViewModels protected override void Load() { + if (globalContext.User.Shop.PurchaseAccountList == null) + globalContext.User.Shop.PurchaseAccountList = new List(); + IsLoading = false; if (!string.IsNullOrEmpty(globalContext.User.Shop.ManagePwd)) { @@ -99,9 +118,7 @@ namespace BBWY.Client.ViewModels isValidated = true; this.ManagePwd = globalContext.User.Shop.ManagePwd; this.PlatformCommissionRatio = (globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M) * 100; - this.PurchaseAccount = globalContext.User.Shop.PurchaseAccountList == null || globalContext.User.Shop.PurchaseAccountList.Count() == 0 ? - new PurchaseAccount() : - globalContext.User.Shop.PurchaseAccountList[0].Clone() as PurchaseAccount; + DingDingKey = globalContext.User.Shop.DingDingKey; DingDingWebHook = globalContext.User.Shop.DingDingWebHook; SelectedSkuSafeTurnoverDay = SafeDayList.FirstOrDefault(s => s.Value == globalContext.User.Shop.SkuSafeTurnoverDays.ToString()); @@ -109,11 +126,13 @@ namespace BBWY.Client.ViewModels SelectedSiNanPolicyLevel = (SiNanPolicyLevel)globalContext.User.Shop.SiNanPolicyLevel; SiNanDingDingKey = globalContext.User.Shop.SiNanDingDingKey; SiNanDingDingWebHook = globalContext.User.Shop.SiNanDingDingWebHook; + + PurchasePlatform = Platform.阿里巴巴; } protected override void Unload() { - this.PurchaseAccount = null; + //this.PurchaseAccount = null; this.PlatformCommissionRatio = 0M; this.ManagePwd = string.Empty; this.isValidated = false; @@ -163,11 +182,7 @@ namespace BBWY.Client.ViewModels return; } - if (globalContext.User.Shop.PurchaseAccountList == null) - globalContext.User.Shop.PurchaseAccountList = new List(); - globalContext.User.Shop.PurchaseAccountList.Clear(); PurchaseAccount.Id = response.Data; - globalContext.User.Shop.PurchaseAccountList.Add(PurchaseAccount); globalContext.User.Shop.PlatformCommissionRatio = p; globalContext.User.Shop.ManagePwd = this.ManagePwd; globalContext.User.Shop.DingDingKey = this.DingDingKey; @@ -179,5 +194,20 @@ namespace BBWY.Client.ViewModels globalContext.User.Shop.SiNanPolicyLevel = (int)this.SelectedSiNanPolicyLevel; }); } + + private void OnPurchasePlatformChanged() + { + var pa = globalContext.User.Shop.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == PurchasePlatform); + if (pa == null) + { + pa = new PurchaseAccount() + { + PurchasePlatformId = PurchasePlatform, + }; + globalContext.User.Shop.PurchaseAccountList.Add(pa); + } + + this.PurchaseAccount = pa; + } } } diff --git a/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs b/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs index f9c314c3..1bddfeeb 100644 --- a/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs +++ b/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs @@ -87,6 +87,7 @@ namespace BBWY.Client.Views.Order OrderDropShippingList.Add(ods1); ods1.OnPurchaseAmountChanged = OnPurchaseAmountChanged; + ods1.OnPurchasePlatformChanged = OnPurchasePlatformChanged; } } @@ -99,12 +100,18 @@ namespace BBWY.Client.Views.Order OnPurchaseAmountChanged(); - AddOrderDropShippingCommand = new RelayCommand(() => OrderDropShippingList.Add(new OrderDropShipping() + AddOrderDropShippingCommand = new RelayCommand(() => { - OrderId = this.OrderId, - BuyerAccount = PurchaseAccountList.FirstOrDefault()?.AccountName, - OnPurchaseAmountChanged = OnPurchaseAmountChanged - })); + var ods = new OrderDropShipping() + { + OrderId = this.OrderId, + //BuyerAccount = PurchaseAccountList.FirstOrDefault()?.AccountName, + OnPurchaseAmountChanged = OnPurchaseAmountChanged, + OnPurchasePlatformChanged = OnPurchasePlatformChanged + }; + ods.PurchasePlatform = Platform.阿里巴巴; + OrderDropShippingList.Add(ods); + }); AddRelationPurchaseOrderSkuCommand = new RelayCommand(AddRelationPurchaseOrderSku); CloseShowChooseSkuPanelCommand = new RelayCommand(() => IsShowChooseSkuPanel = false); RePurchaseCommand = new RelayCommand(() => @@ -197,5 +204,10 @@ namespace BBWY.Client.Views.Order foreach (var noChooseSku in noChooseList) ChooseRelationPurchaseOrderSkuList.Add(noChooseSku); } + + private void OnPurchasePlatformChanged(OrderDropShipping orderDropShipping) + { + orderDropShipping.BuyerAccount = PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == orderDropShipping.PurchasePlatform)?.AccountName; + } } } diff --git a/BBWY.Client/Views/Setting/ShopSetting.xaml b/BBWY.Client/Views/Setting/ShopSetting.xaml index c004f840..852e73e6 100644 --- a/BBWY.Client/Views/Setting/ShopSetting.xaml +++ b/BBWY.Client/Views/Setting/ShopSetting.xaml @@ -104,7 +104,7 @@ () { { "qy", "qy" } }, HttpMethod.Post); var shop = freeSqlMultiDBManager.MDSfsql.Select().Where(s => s.ShopName == venderResponse.ShopName).ToOne(); if (shop == null) diff --git a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs index 6fee8dd6..801e6c7c 100644 --- a/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs +++ b/BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs @@ -41,5 +41,10 @@ /// 采购商Id /// public string PurchaserId { get; set; } + + /// + /// 扩展数据 + /// + public string Extensions { get; set; } } }