From 3bb766babc5ceb449b619bad75315dbeb3bb5fe0 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 02:29:50 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E8=B4=A2=E5=8A=A1=E9=83=A8=E6=8A=80?= =?UTF-8?q?=E6=9C=AF=E9=83=A8=E8=91=A3=E4=BA=8B=E5=8A=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=BA=97=E9=93=BA=EF=BC=8C=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=B8=85=E7=A9=BAwebview2=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Client/APIServices/ShopService.cs | 4 +- BBWY.Client/App.xaml.cs | 4 +- .../APIModel/Response/Shop/ShopResponse.cs | 11 ++- BBWY.Client/Models/MappingProfile.cs | 7 +- BBWY.Client/Models/Shop/Department.cs | 23 +---- BBWY.Client/Models/Shop/Department2.cs | 18 ---- BBWY.Client/Models/Shop/Shop.cs | 6 +- BBWY.Client/Models/User/User.cs | 2 +- .../ProcurementAuditViewModel.cs | 29 ++---- BBWY.Client/ViewModels/MainViewModel.cs | 99 +++++++++---------- .../FinancialTerminal/ProcurementAudit.xaml | 2 +- BBWY.Client/Views/MainWindow.xaml | 2 +- BBWY.Client/Views/Order/GrabJDMibole.xaml.cs | 1 + BBWY.Client/Views/SelectShop.xaml | 2 +- BBWY.Client/Views/SelectShop.xaml.cs | 9 +- BBWY.Client/WebView2Manager.cs | 29 +++--- BBWY.Server.Business/MDSBusiness.cs | 4 +- BBWY.Server.Business/Vender/VenderBusiness.cs | 52 +++++++++- .../Dto/Response/Vender/DepartmentResponse.cs | 16 +-- .../Dto/Response/Vender/ShopResponse.cs | 28 +++++- 20 files changed, 186 insertions(+), 162 deletions(-) delete mode 100644 BBWY.Client/Models/Shop/Department2.cs diff --git a/BBWY.Client/APIServices/ShopService.cs b/BBWY.Client/APIServices/ShopService.cs index 1d1da395..563472e6 100644 --- a/BBWY.Client/APIServices/ShopService.cs +++ b/BBWY.Client/APIServices/ShopService.cs @@ -42,9 +42,9 @@ namespace BBWY.Client.APIServices /// 获取部门及下属店铺 /// /// - public ApiResponse> GetDepartmentList() + public ApiResponse> GetDepartmentList() { - return SendRequest>(globalContext.BBYWApiHost, "api/vender/GetDeparmentList", null, null, HttpMethod.Get); + return SendRequest>(globalContext.BBYWApiHost, "api/vender/GetDeparmentList", null, null, HttpMethod.Get); } diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 0949e230..40d6a32b 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -31,7 +31,9 @@ namespace BBWY.Client string userToken = string.Empty; #if DEBUG userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA3NDY1MDMzNDIwODAwIiwidGVhbUlkIjoiMTQzNjI4ODUwMDIzNTI0MzUyMCIsImV4cCI6MTY4MjU3NzUzNn0.76Ll9syp3R21VD01NxpHmcs7TyBKzqeob3i5avpLv-E"; //齐越小一 - //"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDUzOTA0NTczMjM5Mzk4NDAwIiwidGVhbUlkIjoiMTQzOTg5ODI2MDg3MjM2ODEyOCIsImV4cCI6MTY4MjQwODY1OH0.Po9-Dw_CgbAB7kjh7broLGIjOdsL2JifPtodNKClRIw"; + + //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA1OTcyOTk3ODUzMTg0IiwidGVhbUlkIjoiMTQzOTkwNDA1MDc3NzY5MDExMiIsImV4cCI6MTY4NjQxODcyOH0.K7-MXjt_zfNK5v_08VjmCDnhAGF6SI7sEQr5sgDn7Jk"; //齐越珍珍 + #else var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty; if (string.IsNullOrEmpty(uid)) diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index 29c6e1a0..3786154c 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -8,7 +8,7 @@ namespace BBWY.Client.Models public Platform PlatformId { get; set; } - public long? ShopId { get; set; } + public long ShopId { get; set; } public string ShopName { get; set; } @@ -30,4 +30,13 @@ namespace BBWY.Client.Models public string TeamName { get; set; } } + + public class DepartmentResponse + { + public string Id { get; set; } + + public string Name { get; set; } + + public IList ShopList { get; set; } + } } diff --git a/BBWY.Client/Models/MappingProfile.cs b/BBWY.Client/Models/MappingProfile.cs index d9d6c71b..a93b0001 100644 --- a/BBWY.Client/Models/MappingProfile.cs +++ b/BBWY.Client/Models/MappingProfile.cs @@ -18,15 +18,16 @@ namespace BBWY.Client.Models .ForMember(t => t.TeamName, opt => opt.MapFrom(f => f.DepartmentName)) .ForMember(t => t.Name, opt => opt.MapFrom(f => f.UserName)); - CreateMap().ForMember(t => t.ShopId, opt => opt.MapFrom(f => f.ShopId)) - .ForMember(t => t.Name, opt => opt.MapFrom(f => f.ShopName)) - .ForMember(t => t.VenderType, opt => opt.MapFrom(f => f.ShopType)) + CreateMap().ForMember(t => t.VenderType, opt => opt.MapFrom(f => f.ShopType)) .ForMember(t => t.Platform, opt => opt.MapFrom(f => f.PlatformId)) .ForMember(t => t.PurchaseAccountList, opt => opt.MapFrom(f => f.PurchaseList)); + CreateMap(); + CreateMap(); CreateMap(); CreateMap(); + } } } diff --git a/BBWY.Client/Models/Shop/Department.cs b/BBWY.Client/Models/Shop/Department.cs index 6b5ae9f9..8da5ed12 100644 --- a/BBWY.Client/Models/Shop/Department.cs +++ b/BBWY.Client/Models/Shop/Department.cs @@ -8,30 +8,11 @@ namespace BBWY.Client.Models public string Name { get; set; } - public IList ShopList { get; set; } + public IList ShopList { get; set; } public Department() { - ShopList = new List(); - } - } - - public class SimpleShop : NotifyObject - { - private bool isSelected; - - /// - /// ShopId - /// - public long Id { get; set; } - - public string Name { get; set; } - - public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } } - - public override string ToString() - { - return Name; + ShopList = new List(); } } } diff --git a/BBWY.Client/Models/Shop/Department2.cs b/BBWY.Client/Models/Shop/Department2.cs deleted file mode 100644 index 6163dfac..00000000 --- a/BBWY.Client/Models/Shop/Department2.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; - -namespace BBWY.Client.Models -{ - public class Department2 - { - public string Id { get; set; } - - public string Name { get; set; } - - public IList ShopList { get; set; } - - public Department2() - { - ShopList = new List(); - } - } -} diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index 58823ec3..b930e46e 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -4,8 +4,10 @@ namespace BBWY.Client.Models { public class Shop : NotifyObject { - private string name; + private bool isSelected; + private string shopName; + public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } } /// /// 店铺Id /// @@ -27,7 +29,7 @@ namespace BBWY.Client.Models public string AppToken { get; set; } - public string Name { get => name; set { Set(ref name, value); } } + public string ShopName { get => shopName; set { Set(ref shopName, value); } } public IList PurchaseAccountList { get; set; } diff --git a/BBWY.Client/Models/User/User.cs b/BBWY.Client/Models/User/User.cs index e782f434..6c6b3f22 100644 --- a/BBWY.Client/Models/User/User.cs +++ b/BBWY.Client/Models/User/User.cs @@ -24,6 +24,6 @@ namespace BBWY.Client.Models public Shop Shop { get => shop; set { Set(ref shop, value); } } - public IList DepartmentList { get; set; } + public IList DepartmentList { get; set; } } } diff --git a/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs b/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs index 73002e72..a1fc3734 100644 --- a/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs +++ b/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs @@ -20,6 +20,7 @@ namespace BBWY.Client.ViewModels { public class ProcurementAuditViewModel : BaseVM, IDenpendency { + private GlobalContext globalContext; private AuditFile selectAuditFile; private bool isLoading; private bool isAudited; @@ -138,8 +139,9 @@ namespace BBWY.Client.ViewModels public ICommand ImportJDShopOrderCommand { get; set; } - public ProcurementAuditViewModel(ShopService shopService, PurchaseOrderService purchaseOrderService) + public ProcurementAuditViewModel(ShopService shopService, PurchaseOrderService purchaseOrderService, GlobalContext globalContext) { + this.globalContext = globalContext; AuditFileList = new ObservableCollection(); AuditCommand = new RelayCommand(Audit); ClearAuditCommand = new RelayCommand(ClearAudit); @@ -166,22 +168,9 @@ namespace BBWY.Client.ViewModels private void LoadDepartment() { - Task.Factory.StartNew(() => shopService.GetDepartmentList()).ContinueWith(t => - { - var response = t.Result; - if (!response.Success) - { - App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示")); - return; - } - - App.Current.Dispatcher.Invoke(() => - { - foreach (var d in response.Data) - DepartmentList.Add(d); - SelectedDepartment = DepartmentList[0]; - }); - }); + foreach (var d in globalContext.User.DepartmentList) + DepartmentList.Add(d); + SelectedDepartment = DepartmentList[0]; } private void Audit() @@ -220,11 +209,11 @@ namespace BBWY.Client.ViewModels } - private void AuditByPayBill(EventWaitHandle ewh, IList shopList, DateTime startDate, DateTime endDate) + private void AuditByPayBill(EventWaitHandle ewh, IList shopList, DateTime startDate, DateTime endDate) { try { - var auditPurchaseOrderResponse = purchaseOrderService.GetAuditPurchaseOrderList(shopList.Select(s => s.Id).ToList(), startDate, endDate); + var auditPurchaseOrderResponse = purchaseOrderService.GetAuditPurchaseOrderList(shopList.Select(s => s.ShopId).ToList(), startDate, endDate); if (!auditPurchaseOrderResponse.Success) throw new Exception($"获取采购单失败,{auditPurchaseOrderResponse.Msg}"); @@ -243,7 +232,7 @@ namespace BBWY.Client.ViewModels payBill.RelationPurchaseOrderId = relationPurchaseOrder.PurchaseOrderId; payBill.RelationShopOrderId = relationPurchaseOrder.OrderId; payBill.BelongShopId = relationPurchaseOrder.ShopId; - payBill.BelongShop = shopList.FirstOrDefault(s => s.Id == relationPurchaseOrder.ShopId)?.Name; + payBill.BelongShop = shopList.FirstOrDefault(s => s.ShopId == relationPurchaseOrder.ShopId)?.ShopName; #endregion } } diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index f4bf3ace..8d6758d6 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -24,11 +24,13 @@ namespace BBWY.Client.ViewModels private IHttpClientFactory httpClientFactory; private MdsApiService mdsApiService; private LogisticsService logisticsService; + private ShopService shopService; private MenuModel selectedMenuModel; private bool showShopChoosePanel; private bool showWB2RuntimeDownloadPanel; private double wb2DownloadProgress; - + private IList managerDepartment; + private WebView2Manager w2m; public GlobalContext GlobalContext { get; set; } public IList MenuList { get; set; } @@ -78,11 +80,19 @@ namespace BBWY.Client.ViewModels #endregion #region Methods - public MainViewModel(GlobalContext globalContext, MdsApiService mdsApiService, LogisticsService logisticsService, IHttpClientFactory httpClientFactory) + public MainViewModel(GlobalContext globalContext, + MdsApiService mdsApiService, + LogisticsService logisticsService, + ShopService shopService, + IHttpClientFactory httpClientFactory, + WebView2Manager w2m) { + this.w2m = w2m; + this.managerDepartment = new List() { "董事办", "财务部", "技术部" }; this.httpClientFactory = httpClientFactory; this.mdsApiService = mdsApiService; this.logisticsService = logisticsService; + this.shopService = shopService; ClosingCommand = new RelayCommand(Exit); //ChooseShopCommand = new RelayCommand((s) => ChooseShop(s)); OpenSelectShopCommand = new RelayCommand(OpenSelectShop); @@ -151,14 +161,7 @@ namespace BBWY.Client.ViewModels GlobalContext.User = mdsUserResponse.Data.Map(); #if RELEASE - if (GlobalContext.User.TeamName == "财务部") - { - App.Current.Dispatcher.Invoke(() => - { - for (var i = 0; i < 3; i++) { MenuList.RemoveAt(0); } - }); - } - else + if (!managerDepartment.Contains(GlobalContext.User.TeamName)) //非管理账号,屏蔽财务端 { App.Current.Dispatcher.Invoke(() => { @@ -167,22 +170,9 @@ namespace BBWY.Client.ViewModels } #endif + IList departmentList = null; - //请求用户信息接口 - //GlobalContext.User = new User() - //{ - // Id = userId, - // Name = "ShanJ", - // Store = new Store() - // { - // Platform = Platform.京东, - // AppKey = "120EA9EC65AB017567D78CC1139EEEA5", - // AppSecret = "866a9877f5f24b03b537483b4defe75d", - // AppToken = "d8433fb2a4994484b5d9e5a5896a6dfdmyjj" //10388155 - // } - //}; - - if (GlobalContext.User.TeamName != "财务部") + if (!managerDepartment.Contains(GlobalContext.User.TeamName)) { var shopListResponse = mdsApiService.GetShopsByUserTeam(GlobalContext.User.Id); if (!shopListResponse.Success) @@ -194,44 +184,45 @@ namespace BBWY.Client.ViewModels { ShowShopChoosePanel = false; ChooseShop(shopList[0], true); + return; } else { ShowShopChoosePanel = true; - IList department2s = new List(); + departmentList = new List(); foreach (var shop in shopList) { - var department = department2s.FirstOrDefault(d => d.Id == shop.TeamId); + var department = departmentList.FirstOrDefault(d => d.Id == shop.TeamId); if (department == null) { - department = new Department2() { Id = shop.TeamId, Name = shop.TeamName }; - department2s.Add(department); + department = new Department() { Id = shop.TeamId, Name = shop.TeamName }; + departmentList.Add(department); } department.ShopList.Add(shop); } - GlobalContext.User.DepartmentList = department2s; - - App.Current.Dispatcher.Invoke(() => - { - var selectShop = new SelectShop(department2s); - if (selectShop.ShowDialog() == true) - { - ChooseShop(selectShop.Shop, true); - } - else - { - Environment.Exit(Environment.ExitCode); - } - }); - - //App.Current.Dispatcher.Invoke(() => - //{ - // foreach (var s in shopList) - // ShopList.Add(s); - //}); - //ShowShopChoosePanel = true; } } + else + { + var response = shopService.GetDepartmentList(); + if (!response.Success) + throw new Exception(response.Msg); + departmentList = response.Data.Map>(); + } + + GlobalContext.User.DepartmentList = departmentList; + App.Current.Dispatcher.Invoke(() => + { + var selectShop = new SelectShop(departmentList); + if (selectShop.ShowDialog() == true) + { + ChooseShop(selectShop.Shop, true); + } + else + { + Environment.Exit(Environment.ExitCode); + } + }); } catch (Exception ex) { @@ -256,6 +247,12 @@ namespace BBWY.Client.ViewModels vm.WareManager.Refresh(); if (vm.IsCreateWareStock) vm.WareStock.Refresh(); + + try + { + w2m.Close(); + } + catch { } } } @@ -268,7 +265,7 @@ namespace BBWY.Client.ViewModels string.IsNullOrEmpty(shop.AppToken) || (shop.Platform == Platform.京东 && string.IsNullOrEmpty(shop.VenderType))) { - var error = $"{shop.Name} 店铺数据不完整"; + var error = $"{shop.ShopName} 店铺数据不完整"; if (_throw) throw new Exception(error); else diff --git a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml index 9c2d9661..354083b0 100644 --- a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml +++ b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml @@ -43,7 +43,7 @@ - + diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 2d1bb93f..a59705fa 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -25,7 +25,7 @@ - + diff --git a/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs b/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs index e8d80ad9..a010160d 100644 --- a/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs +++ b/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs @@ -42,6 +42,7 @@ namespace BBWY.Client.Views.Order { w2m = s.ServiceProvider.GetRequiredService(); } + w2m.Init(); grid.Children.Add(w2m.wb2); if (w2m.IsInitializationCompleted) diff --git a/BBWY.Client/Views/SelectShop.xaml b/BBWY.Client/Views/SelectShop.xaml index 123e12a5..9f2da93b 100644 --- a/BBWY.Client/Views/SelectShop.xaml +++ b/BBWY.Client/Views/SelectShop.xaml @@ -46,7 +46,7 @@ diff --git a/BBWY.Client/Views/SelectShop.xaml.cs b/BBWY.Client/Views/SelectShop.xaml.cs index 974c4329..7a8bb7f8 100644 --- a/BBWY.Client/Views/SelectShop.xaml.cs +++ b/BBWY.Client/Views/SelectShop.xaml.cs @@ -19,10 +19,10 @@ namespace BBWY.Client.Views /// public partial class SelectShop : BWindow { - public IList DepartmentList { get; set; } + public IList DepartmentList { get; set; } public Shop Shop { get; set; } - public SelectShop(IList departmentList) + public SelectShop(IList departmentList) { InitializeComponent(); this.DepartmentList = departmentList; @@ -31,7 +31,7 @@ namespace BBWY.Client.Views private void SelectShop_Loaded(object sender, RoutedEventArgs e) { - var d = cbx_department.SelectedItem as Department2; + var d = cbx_department.SelectedItem as Department; cbx_shop.ItemsSource = d.ShopList; } @@ -45,8 +45,9 @@ namespace BBWY.Client.Views private void cbx_department_SelectionChanged(object sender, SelectionChangedEventArgs e) { - var d = cbx_department.SelectedItem as Department2; + var d = cbx_department.SelectedItem as Department; cbx_shop.ItemsSource = d.ShopList; + cbx_shop.SelectedIndex = 0; } } } diff --git a/BBWY.Client/WebView2Manager.cs b/BBWY.Client/WebView2Manager.cs index 104711c3..8bd89399 100644 --- a/BBWY.Client/WebView2Manager.cs +++ b/BBWY.Client/WebView2Manager.cs @@ -11,22 +11,27 @@ namespace BBWY.Client public class WebView2Manager : IDenpendency { public WebView2 wb2 { get; private set; } - private bool isInitializationCompleted; - - public WebView2Manager() + //public WebView2Manager() + //{ + // Init(); + //} + public void Init() { - wb2 = new WebView2(); - var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: io.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WebView2UserData")).Result; - wb2.EnsureCoreWebView2Async(wb2Setting); - wb2.CoreWebView2InitializationCompleted += Wb2_CoreWebView2InitializationCompleted; - wb2.NavigationCompleted += Wb2_NavigationCompleted; - wb2.WebMessageReceived += Wb2_WebMessageReceived; + if (wb2 == null) + { + wb2 = new WebView2(); + var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: io.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WebView2UserData")).Result; + wb2.EnsureCoreWebView2Async(wb2Setting); + wb2.CoreWebView2InitializationCompleted += Wb2_CoreWebView2InitializationCompleted; + wb2.NavigationCompleted += Wb2_NavigationCompleted; + wb2.WebMessageReceived += Wb2_WebMessageReceived; + } } public Action OnWebMessageReceived; public Action OnNavigationCompleted; public Action CoreWebView2InitializationCompleted; - public bool IsInitializationCompleted { get => isInitializationCompleted; } + public bool IsInitializationCompleted { get ; private set; } private void Wb2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) { @@ -41,18 +46,20 @@ namespace BBWY.Client private void Wb2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e) { CoreWebView2InitializationCompleted?.Invoke(e); - isInitializationCompleted = true; + IsInitializationCompleted = true; } public void Close() { if (wb2 != null && wb2.CoreWebView2 != null) { + IsInitializationCompleted = false; wb2.CoreWebView2InitializationCompleted -= Wb2_CoreWebView2InitializationCompleted; wb2.NavigationCompleted -= Wb2_NavigationCompleted; wb2.WebMessageReceived -= Wb2_WebMessageReceived; var udf = wb2.CoreWebView2.Environment.UserDataFolder; wb2.Dispose(); + wb2 = null; try { io.Directory.Delete(udf, true); diff --git a/BBWY.Server.Business/MDSBusiness.cs b/BBWY.Server.Business/MDSBusiness.cs index 58cecf5f..b65ba032 100644 --- a/BBWY.Server.Business/MDSBusiness.cs +++ b/BBWY.Server.Business/MDSBusiness.cs @@ -44,8 +44,8 @@ namespace BBWY.Server.Business AppToken = shopJToken.Value("AppToken"), Platform = (Enums.Platform)shopJToken.Value("PlatformId"), VenderType = shopJToken.Value("ShopType"), - ShopId = shopId, - Name = shopJToken.Value("ShopName"), + ShopId = shopId.ToString(), + ShopName = shopJToken.Value("ShopName"), ManagePwd = shopJToken.Value("ManagePwd") }; try { shopResponse.PlatformCommissionRatio = shopJToken.Value("PlatformCommissionRatio"); } diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index 715a19ce..341f506a 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -157,23 +157,65 @@ namespace BBWY.Server.Business { DepartmentId = ud.Id, ud.DepartmentName, + ShopPKId = s.Id, s.ShopId, - s.ShopName + s.ShopName, + s.ShopType, + s.AppKey, + s.AppSecret, + s.AppToken, + s.ManagePwd, + s.PlatformCommissionRatio, + s.PlatformId }).GroupBy(x => x.DepartmentId); if (relationGroups.Count() == 0) return null; - var list = new List(); + var departmentList = new List(); + var shopIdList = new List(); //主键Id集合 + foreach (var relationGroup in relationGroups) { var department = new DepartmentResponse() { Id = relationGroup.Key, Name = relationGroup.FirstOrDefault().DepartmentName, - ShopList = relationGroup.Select(x => new SimpleShopResponse() { Id = x.ShopId, Name = x.ShopName }).ToList() + ShopList = relationGroup.Select(x => new ShopResponse() + { + Id = x.ShopPKId, + AppKey = string.IsNullOrEmpty(x.AppKey) ? "120EA9EC65AB017567D78CC1139EEEA5" : x.AppKey, + AppSecret = string.IsNullOrEmpty(x.AppSecret) ? "866a9877f5f24b03b537483b4defe75d" : x.AppSecret, + AppToken = x.AppToken, + ManagePwd = x.ManagePwd, + Platform = (Enums.Platform)x.PlatformId, + PlatformCommissionRatio = x.PlatformCommissionRatio, + ShopId = x.ShopId, + ShopName = x.ShopName, + VenderType = x.ShopType + }).ToList() }; - list.Add(department); + departmentList.Add(department); + shopIdList.AddRange(department.ShopList.Select(s => s.Id)); + } + shopIdList = shopIdList.Distinct().ToList(); + var purchaseAccountList = freeSqlMultiDBManager.MDSfsql.Select().Where(pa => shopIdList.Contains(pa.ShopId)) + .ToList(pa => new PurchaseAccountResponse() + { + AccountName = pa.AccountName, + AppKey = pa.AppKey, + AppSecret = pa.AppSecret, + AppToken = pa.AppToken, + Id = pa.Id, + ShopId = pa.ShopId, + PurchasePlatformId = (Enums.Platform)int.Parse(pa.PurchasePlatformId) + }); + foreach (var d in departmentList) + { + foreach (var s in d.ShopList) + { + s.PurchaseList = purchaseAccountList.Where(pa => pa.ShopId == s.Id).ToList(); + } } - return list; + return departmentList; } } } diff --git a/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs b/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs index 56e8d6a8..ddec4899 100644 --- a/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs @@ -8,21 +8,11 @@ namespace BBWY.Server.Model.Dto public string Name { get; set; } - public IList ShopList { get; set; } + public IList ShopList { get; set; } public DepartmentResponse() { - ShopList = new List(); + ShopList = new List(); } - } - - public class SimpleShopResponse - { - /// - /// ShopId - /// - public string Id { get; set; } - - public string Name { get; set; } - } + } } diff --git a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs index 45bd4eaa..f31e934a 100644 --- a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs @@ -1,15 +1,16 @@ using System; using System.Collections.Generic; using System.Text; -using static BBWY.Server.Model.Enums; namespace BBWY.Server.Model.Dto { public class ShopResponse { - public long ShopId { get; set; } + public string Id { get; set; } - public string Name { get; set; } + public string ShopId { get; set; } + + public string ShopName { get; set; } /// /// 商家类型 @@ -19,7 +20,7 @@ namespace BBWY.Server.Model.Dto /// /// 店铺平台 /// - public Platform Platform { get; set; } + public Enums.Platform Platform { get; set; } public string AppKey { get; set; } @@ -30,5 +31,24 @@ namespace BBWY.Server.Model.Dto public string ManagePwd { get; set; } public decimal? PlatformCommissionRatio { get; set; } + + public IList PurchaseList { get; set; } + } + + public class PurchaseAccountResponse + { + public string Id { get; set; } + + public string AccountName { get; set; } + + public string ShopId { get; set; } + + public Enums.Platform PurchasePlatformId { get; set; } + + public string AppKey { get; set; } + + public string AppSecret { get; set; } + + public string AppToken { get; set; } } } From 2ec356fd701652f25c44e6923333e7cfa909cd18 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 02:32:01 +0800 Subject: [PATCH 2/8] 1 --- BBWY.Client/Models/Shop/Shop.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index b930e46e..796df30d 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -42,5 +42,10 @@ namespace BBWY.Client.Models public string TeamId { get; set; } public string TeamName { get; set; } + + public override string ToString() + { + return ShopName; + } } } From 1a6d905ed3cc0ac5052ba0c4832b20cbdf7e09d2 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 13:09:59 +0800 Subject: [PATCH 3/8] 1 --- BBWY.Client/App.xaml.cs | 4 +++- BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs | 2 +- BBWY.Client/Views/MainWindow.xaml | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 40d6a32b..3e443232 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -30,9 +30,11 @@ namespace BBWY.Client var gl = new GlobalContext(); string userToken = string.Empty; #if DEBUG - userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA3NDY1MDMzNDIwODAwIiwidGVhbUlkIjoiMTQzNjI4ODUwMDIzNTI0MzUyMCIsImV4cCI6MTY4MjU3NzUzNn0.76Ll9syp3R21VD01NxpHmcs7TyBKzqeob3i5avpLv-E"; //齐越小一 + //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA3NDY1MDMzNDIwODAwIiwidGVhbUlkIjoiMTQzNjI4ODUwMDIzNTI0MzUyMCIsImV4cCI6MTY4MjU3NzUzNn0.76Ll9syp3R21VD01NxpHmcs7TyBKzqeob3i5avpLv-E"; //齐越小一 //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA1OTcyOTk3ODUzMTg0IiwidGVhbUlkIjoiMTQzOTkwNDA1MDc3NzY5MDExMiIsImV4cCI6MTY4NjQxODcyOH0.K7-MXjt_zfNK5v_08VjmCDnhAGF6SI7sEQr5sgDn7Jk"; //齐越珍珍 + + userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTE0NjczMzA5NzQ5MjQ4IiwidGVhbUlkIjoiMTQ0ODY4MTU0NDE4ODE3MDI0MCIsImV4cCI6MTY4NjQ1OTY0Mn0.4yCbZxOtogD0N868-YgySR5A-16VNnrp8fC13VCRs20"; //齐越耐克 #else var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty; diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index 3786154c..2e230f95 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -8,7 +8,7 @@ namespace BBWY.Client.Models public Platform PlatformId { get; set; } - public long ShopId { get; set; } + public long? ShopId { get; set; } public string ShopName { get; set; } diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 4fffc59f..b7bddebe 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -9,7 +9,7 @@ DataContext="{Binding Main,Source={StaticResource Locator}}" mc:Ignorable="d" Style="{StaticResource bwstyle}" - Title="{Binding GlobalContext.User.Shop.Name,StringFormat=步步为盈 \{0\}}" Height="450" Width="800"> + Title="{Binding GlobalContext.User.Shop.ShopName,StringFormat=步步为盈 \{0\}}" Height="450" Width="800"> @@ -25,7 +25,7 @@ - + From 2477e476fb32fdf2ebcb1a406adb1dfb6bc6575b Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 13:11:43 +0800 Subject: [PATCH 4/8] 1 --- BBWY.Client/ViewModels/MainViewModel.cs | 36 ++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 8d6758d6..ec1fb5d9 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -236,25 +236,31 @@ namespace BBWY.Client.ViewModels private void OpenSelectShop() { - var selectShop = new SelectShop(GlobalContext.User.DepartmentList); - if (selectShop.ShowDialog() == true) + try { - ChooseShop(selectShop.Shop, true); - var vm = App.Current.Resources["Locator"] as ViewModelLocator; - if (vm.IsCreateOrderList) - vm.OrderList.Refresh(); - if (vm.IsCreateWareManager) - vm.WareManager.Refresh(); - if (vm.IsCreateWareStock) - vm.WareStock.Refresh(); - - try + var selectShop = new SelectShop(GlobalContext.User.DepartmentList); + if (selectShop.ShowDialog() == true) { - w2m.Close(); + ChooseShop(selectShop.Shop, true); + var vm = App.Current.Resources["Locator"] as ViewModelLocator; + if (vm.IsCreateOrderList) + vm.OrderList.Refresh(); + if (vm.IsCreateWareManager) + vm.WareManager.Refresh(); + if (vm.IsCreateWareStock) + vm.WareStock.Refresh(); + + try + { + w2m.Close(); + } + catch { } } - catch { } } - + catch (Exception ex) + { + MessageBox.Show(ex.Message, "切换失败"); + } } private void ChooseShop(Shop shop, bool _throw = false) From 9151263b289f170670156d3a9aef5409173cd66a Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 13:13:14 +0800 Subject: [PATCH 5/8] 10021 --- BBWY.Client/Views/MainWindow.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index b7bddebe..16b6f432 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + From a3ed2870b8ac85a4f6bd43343e2db24f6b89ca75 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 19:36:20 +0800 Subject: [PATCH 6/8] 1 --- BBWY.Client/App.xaml.cs | 4 ++-- BBWY.Client/ViewModels/MainViewModel.cs | 1 + BBWY.Server.Business/MDSBusiness.cs | 2 +- BBWY.Server.Business/Order/OrderBusiness.cs | 8 ++++---- .../PurchaseOrder/PurchaseOrderBusiness.cs | 6 +++--- BBWY.Server.Business/Vender/VenderBusiness.cs | 2 +- BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 3e443232..13716fff 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -30,11 +30,11 @@ namespace BBWY.Client var gl = new GlobalContext(); string userToken = string.Empty; #if DEBUG - //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA3NDY1MDMzNDIwODAwIiwidGVhbUlkIjoiMTQzNjI4ODUwMDIzNTI0MzUyMCIsImV4cCI6MTY4MjU3NzUzNn0.76Ll9syp3R21VD01NxpHmcs7TyBKzqeob3i5avpLv-E"; //齐越小一 + userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDA1MTUxNjE5NTk0NTg4MTYwIiwidGVhbUlkIjoiMTQxMDk1NTYwNDYxMjA5MTkwNCIsImV4cCI6MTY4NjQ4MjU0M30.emnQNDcbqnuO2jH0Kgfk2Ui7crrwzRb986Sa511iS-U"; //齐越小一 //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA1OTcyOTk3ODUzMTg0IiwidGVhbUlkIjoiMTQzOTkwNDA1MDc3NzY5MDExMiIsImV4cCI6MTY4NjQxODcyOH0.K7-MXjt_zfNK5v_08VjmCDnhAGF6SI7sEQr5sgDn7Jk"; //齐越珍珍 - userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTE0NjczMzA5NzQ5MjQ4IiwidGVhbUlkIjoiMTQ0ODY4MTU0NDE4ODE3MDI0MCIsImV4cCI6MTY4NjQ1OTY0Mn0.4yCbZxOtogD0N868-YgySR5A-16VNnrp8fC13VCRs20"; //齐越耐克 + //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTE0NjczMzA5NzQ5MjQ4IiwidGVhbUlkIjoiMTQ0ODY4MTU0NDE4ODE3MDI0MCIsImV4cCI6MTY4NjQ1OTY0Mn0.4yCbZxOtogD0N868-YgySR5A-16VNnrp8fC13VCRs20"; //齐越耐克 #else var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty; diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index ec1fb5d9..0aa0f357 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -204,6 +204,7 @@ namespace BBWY.Client.ViewModels } else { + ShowShopChoosePanel = true; var response = shopService.GetDepartmentList(); if (!response.Success) throw new Exception(response.Msg); diff --git a/BBWY.Server.Business/MDSBusiness.cs b/BBWY.Server.Business/MDSBusiness.cs index b65ba032..6eac3699 100644 --- a/BBWY.Server.Business/MDSBusiness.cs +++ b/BBWY.Server.Business/MDSBusiness.cs @@ -42,7 +42,7 @@ namespace BBWY.Server.Business AppKey = shopJToken.Value("AppKey"), AppSecret = shopJToken.Value("AppSecret"), AppToken = shopJToken.Value("AppToken"), - Platform = (Enums.Platform)shopJToken.Value("PlatformId"), + PlatformId = (Enums.Platform)shopJToken.Value("PlatformId"), VenderType = shopJToken.Value("ShopType"), ShopId = shopId.ToString(), ShopName = shopJToken.Value("ShopName"), diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index 93c49700..e0ca6f11 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -913,10 +913,10 @@ namespace BBWY.Server.Business var shop = mdsBusiness.GetShopInfoByShopId(shopId); try { - if (!syncOrderMethodDic.ContainsKey(shop.Platform)) + if (!syncOrderMethodDic.ContainsKey(shop.PlatformId)) throw new Exception("不支持的平台"); - var relayAPIHost = GetPlatformRelayAPIHost(shop.Platform); + var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId); var orderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetOrderList", new SearchPlatformOrderRequest() { StartDate = startTime ?? DateTime.Now.AddHours(-3), @@ -926,7 +926,7 @@ namespace BBWY.Server.Business AppToken = shop.AppToken, PageIndex = 1, PageSize = 100, - Platform = shop.Platform, + Platform = shop.PlatformId, JDColType = string.IsNullOrEmpty(shop.VenderType) ? "0" : shop.VenderType, SaveResponseLog = true, OrderId = orderId @@ -941,7 +941,7 @@ namespace BBWY.Server.Business if (orderListResponse.Data == null || orderListResponse.Data.Count == 0) return; - syncOrderMethodDic[shop.Platform](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken, shop.PlatformCommissionRatio ?? 0.05M); + syncOrderMethodDic[shop.PlatformId](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken, shop.PlatformCommissionRatio ?? 0.05M); } catch (Exception ex) { diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index dcaacd6c..5cd868ab 100644 --- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -543,7 +543,7 @@ namespace BBWY.Server.Business AppKey = shop.AppKey, AppSecret = shop.AppSecret, AppToken = shop.AppToken, - Platform = shop.Platform + Platform = shop.PlatformId }); if (logisticsCompanyList != null) logisticsCompanyListInfo = JsonConvert.SerializeObject(logisticsCompanyList); @@ -552,7 +552,7 @@ namespace BBWY.Server.Business #region 物流公司翻译 currentProgress = "物流公司翻译"; //logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); - logisticsCompanyId = logisticsCompanyConverter.Converter(wayBillNoResponse.LogisticsCompanyName, callbackPlatform, shop.Platform, logisticsCompanyList); + logisticsCompanyId = logisticsCompanyConverter.Converter(wayBillNoResponse.LogisticsCompanyName, callbackPlatform, shop.PlatformId, logisticsCompanyList); #endregion #region 店铺平台订单出库 @@ -563,7 +563,7 @@ namespace BBWY.Server.Business AppSecret = shop.AppSecret, AppToken = shop.AppToken, OrderId = orderDropshipping.OrderId, - Platform = shop.Platform, + Platform = shop.PlatformId, WayBillNo = wayBillNoResponse.WayBillNo, LogisticsId = logisticsCompanyId, //物流公司Id SaveResponseLog = true diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index 341f506a..7fa4fbdf 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -186,7 +186,7 @@ namespace BBWY.Server.Business AppSecret = string.IsNullOrEmpty(x.AppSecret) ? "866a9877f5f24b03b537483b4defe75d" : x.AppSecret, AppToken = x.AppToken, ManagePwd = x.ManagePwd, - Platform = (Enums.Platform)x.PlatformId, + PlatformId = (Enums.Platform)x.PlatformId, PlatformCommissionRatio = x.PlatformCommissionRatio, ShopId = x.ShopId, ShopName = x.ShopName, diff --git a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs index f31e934a..3324e336 100644 --- a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs @@ -20,7 +20,7 @@ namespace BBWY.Server.Model.Dto /// /// 店铺平台 /// - public Enums.Platform Platform { get; set; } + public Enums.Platform PlatformId { get; set; } public string AppKey { get; set; } From b50eef04e8e43c6f594fbffcaabe47a3d996f19d Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 11 Jun 2022 19:43:49 +0800 Subject: [PATCH 7/8] 1 --- BBWY.Client/Views/MainWindow.xaml | 2 +- BBWY.Server.Business/MDSBusiness.cs | 2 +- BBWY.Server.Business/Order/OrderBusiness.cs | 2 +- BBWY.Server.Business/Vender/VenderBusiness.cs | 2 +- BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 16b6f432..dd8432cf 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + diff --git a/BBWY.Server.Business/MDSBusiness.cs b/BBWY.Server.Business/MDSBusiness.cs index 6eac3699..1b4e5dc0 100644 --- a/BBWY.Server.Business/MDSBusiness.cs +++ b/BBWY.Server.Business/MDSBusiness.cs @@ -43,7 +43,7 @@ namespace BBWY.Server.Business AppSecret = shopJToken.Value("AppSecret"), AppToken = shopJToken.Value("AppToken"), PlatformId = (Enums.Platform)shopJToken.Value("PlatformId"), - VenderType = shopJToken.Value("ShopType"), + ShopType = shopJToken.Value("ShopType"), ShopId = shopId.ToString(), ShopName = shopJToken.Value("ShopName"), ManagePwd = shopJToken.Value("ManagePwd") diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index e0ca6f11..b0cdd75b 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -927,7 +927,7 @@ namespace BBWY.Server.Business PageIndex = 1, PageSize = 100, Platform = shop.PlatformId, - JDColType = string.IsNullOrEmpty(shop.VenderType) ? "0" : shop.VenderType, + JDColType = string.IsNullOrEmpty(shop.ShopType) ? "0" : shop.ShopType, SaveResponseLog = true, OrderId = orderId }, null, HttpMethod.Post); diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index 7fa4fbdf..3fffa115 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -190,7 +190,7 @@ namespace BBWY.Server.Business PlatformCommissionRatio = x.PlatformCommissionRatio, ShopId = x.ShopId, ShopName = x.ShopName, - VenderType = x.ShopType + ShopType = x.ShopType }).ToList() }; departmentList.Add(department); diff --git a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs index 3324e336..4a48bcd0 100644 --- a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs @@ -15,7 +15,7 @@ namespace BBWY.Server.Model.Dto /// /// 商家类型 /// - public string VenderType { get; set; } + public string ShopType { get; set; } /// /// 店铺平台 From 0c1f19090b02dbefb30ed2bd4595ebafa10b03f7 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Mon, 13 Jun 2022 07:32:19 +0800 Subject: [PATCH 8/8] 1 --- BBWY.Client/APIServices/OrderService.cs | 24 ++- .../Response/Order/ExportOrderResponse.cs | 2 +- .../Models/Order/ManualEditCostOrderSku.cs | 203 ++++++++++++++++++ BBWY.Client/Models/Order/Order.cs | 5 + .../ViewModels/Order/OrderListViewModel.cs | 52 ++++- BBWY.Client/Views/MainWindow.xaml | 2 +- .../Views/Order/ManualCalculationCost.xaml | 151 ++++++++++++- .../Views/Order/ManualCalculationCost.xaml.cs | 56 +++-- BBWY.Client/Views/Order/OrderList.xaml | 41 +++- .../Views/Order/RelationPurchaseOrder.xaml | 2 +- BBWY.Client/Views/Order/SD.xaml.cs | 6 +- BBWY.Server.Business/Order/OrderBusiness.cs | 55 +++-- .../Statistics/StatisticsBusiness.cs | 2 +- BBWY.Server.Model/Db/Order/OrderCostDetail.cs | 170 ++++++++------- .../Order/ManualCalculationCostRequest.cs | 69 ++++-- BBWY.Server.Model/MappingProfiles.cs | 1 + 16 files changed, 678 insertions(+), 163 deletions(-) create mode 100644 BBWY.Client/Models/Order/ManualEditCostOrderSku.cs diff --git a/BBWY.Client/APIServices/OrderService.cs b/BBWY.Client/APIServices/OrderService.cs index 5745a981..829f88be 100644 --- a/BBWY.Client/APIServices/OrderService.cs +++ b/BBWY.Client/APIServices/OrderService.cs @@ -3,6 +3,7 @@ using BBWY.Common.Http; using BBWY.Common.Models; using System; using System.Collections.Generic; +using System.Linq; using System.Net.Http; namespace BBWY.Client.APIServices @@ -94,10 +95,12 @@ namespace BBWY.Client.APIServices /// 手动计算成本 /// /// - /// 是否设置仓储类型 + /// /// + /// + /// /// - public ApiResponse ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal purchaseCost, decimal deliveryExpressFreight, decimal platformCommissionRatio) + public ApiResponse ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, IList manualEditCostOrderSkuList, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/ManualCalculationCost", new @@ -105,8 +108,21 @@ namespace BBWY.Client.APIServices orderId, isSetStorageType, storageType, - purchaseCost, - deliveryExpressFreight, + OrderCostDetailList = manualEditCostOrderSkuList.Select(osku => new + { + SkuId = osku.Id, + osku.ConsumableAmount, + osku.DeliveryExpressFreight, + osku.FirstFreight, + DeductionQuantity = osku.ItemTotal, + osku.OperationAmount, + osku.PurchaseFreight, + osku.ProductId, + osku.SkuAmount, + osku.StorageAmount, + osku.TotalCost, + osku.UnitCost + }), platformCommissionRatio }, null, HttpMethod.Post); } diff --git a/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs b/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs index 4c3ad4ff..deb232e0 100644 --- a/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs @@ -69,7 +69,7 @@ namespace BBWY.Client.Models public override string ToString() { - //日期,店铺订单号,SKU编码,代发下单单号,售价,采购金额,头程费用,仓储服务费,快递费,平台扣点,补差金额,利润,利润率,收件人联系方式 + //日期,店铺订单号,SKU编码,代发下单单号,售价,商品成本,头程费用,仓储服务费,快递费,平台扣点,补差金额,利润,利润率,收件人联系方式 return $"{OrderStartTime:yyyy-MM-dd HH:mm:ss},{OrderId},{SkuIds},{StorageType},{PurchaseOrderIds},{OrderTotalPrice},{PurchaseSkuAmount},{FirstFreight},{StorageAmount},{DeliveryExpressFreight},{PlatformCommissionAmount},{FreightPrice},{Profit},{ProfitRatio},{ConsigneeStr}"; } } diff --git a/BBWY.Client/Models/Order/ManualEditCostOrderSku.cs b/BBWY.Client/Models/Order/ManualEditCostOrderSku.cs new file mode 100644 index 00000000..d9276363 --- /dev/null +++ b/BBWY.Client/Models/Order/ManualEditCostOrderSku.cs @@ -0,0 +1,203 @@ +using System; + +namespace BBWY.Client.Models +{ + public class ManualEditCostOrderSku : NotifyObject + { + + /// + /// 发货运费 + /// + private decimal deliveryExpressFreight; + private string deliveryExpressFreightStr; + + /// + /// 单件成本 + /// + private decimal unitCost; + + /// + /// Sku成本(商品成本) + /// + private decimal skuAmount; + private string skuAmountStr; + + /// + /// 采购运费 + /// + private decimal purchaseFreight; + private string purchaseFreightStr; + + /// + /// 头程运费 + /// + private decimal firstFreight; + private string firstFreightStr; + + /// + /// 操作费 + /// + private decimal operationAmount; + private string operationAmountStr; + + /// + /// 耗材费 + /// + private decimal consumableAmount; + private string consumableAmountStr; + + /// + /// 仓储费 + /// + private decimal storageAmount; + private string storageAmountStr; + + /// + /// 总计(不含发货运费) + /// + private decimal totalCost; + + /// + /// SkuId + /// + public string Id { get; set; } + + public int ItemTotal { get; set; } + + public string ProductId { get; set; } + + public string ProductItemNum { get; set; } + + public double Price { get; set; } + + /// + /// Sku标题 + /// + public string Title { get; set; } + + public string Logo { get; set; } + public decimal DeliveryExpressFreight + { + get => deliveryExpressFreight; set + { + if (Set(ref deliveryExpressFreight, value)) + { + OnAmountChanged?.Invoke(); + } + } + } + public decimal UnitCost { get => unitCost; set { Set(ref unitCost, value); } } + public decimal SkuAmount + { + get => skuAmount; set + { + if (Set(ref skuAmount, value)) + { + CalculationCost(); + } + } + } + public decimal PurchaseFreight { get => purchaseFreight; set { if (Set(ref purchaseFreight, value)) { CalculationCost(); } } } + public decimal FirstFreight { get => firstFreight; set { if (Set(ref firstFreight, value)) { CalculationCost(); } } } + public decimal OperationAmount { get => operationAmount; set { if (Set(ref operationAmount, value)) { CalculationCost(); } } } + public decimal ConsumableAmount { get => consumableAmount; set { if (Set(ref consumableAmount, value)) { CalculationCost(); } } } + public decimal StorageAmount { get => storageAmount; set { if (Set(ref storageAmount, value)) { CalculationCost(); } } } + public decimal TotalCost + { + get => totalCost; set + { + if (Set(ref totalCost, value)) + { + OnAmountChanged?.Invoke(); + } + } + } + + private void CalculationCost() + { + TotalCost = SkuAmount + PurchaseFreight + FirstFreight + OperationAmount + ConsumableAmount + StorageAmount; + UnitCost = ItemTotal == 0 ? 0 : TotalCost / ItemTotal; + } + + public Action OnAmountChanged { get; set; } + + public string SkuAmountStr + { + get => skuAmountStr; set + { + if (Set(ref skuAmountStr, value)) + { + if (decimal.TryParse(skuAmountStr, out decimal d)) + SkuAmount = d; + } + } + } + public string PurchaseFreightStr + { + get => purchaseFreightStr; set + { + if (Set(ref purchaseFreightStr, value)) + { + if (decimal.TryParse(purchaseFreightStr, out decimal d)) + PurchaseFreight = d; + } + } + } + public string FirstFreightStr + { + get => firstFreightStr; set + { + if (Set(ref firstFreightStr, value)) + { + if (decimal.TryParse(firstFreightStr, out decimal d)) + FirstFreight = d; + } + } + } + public string ConsumableAmountStr + { + get => consumableAmountStr; set + { + if (Set(ref consumableAmountStr, value)) + { + if (decimal.TryParse(consumableAmountStr, out decimal d)) + ConsumableAmount = d; + } + } + } + public string StorageAmountStr + { + get => storageAmountStr; set + { + if (Set(ref storageAmountStr, value)) + { + if (decimal.TryParse(storageAmountStr, out decimal d)) + StorageAmount = d; + } + } + } + public string OperationAmountStr + { + get => operationAmountStr; set + { + if (Set(ref operationAmountStr, value)) + { + if (decimal.TryParse(operationAmountStr, out decimal d)) + OperationAmount = d; + } + } + } + + public string DeliveryExpressFreightStr + { + get => deliveryExpressFreightStr; set + { + if (Set(ref deliveryExpressFreightStr, value)) + { + if (decimal.TryParse(deliveryExpressFreightStr, out decimal d)) + DeliveryExpressFreight = d; + } + } + } + } +} diff --git a/BBWY.Client/Models/Order/Order.cs b/BBWY.Client/Models/Order/Order.cs index e1ecbd67..20ebe5a1 100644 --- a/BBWY.Client/Models/Order/Order.cs +++ b/BBWY.Client/Models/Order/Order.cs @@ -80,6 +80,11 @@ namespace BBWY.Client.Models /// public decimal FreightPrice { get; set; } + /// + /// 实收金额 + /// + public decimal ActualAmount { get { return OrderSellerPrice + FreightPrice; } } + /// /// 商家优惠金额 /// diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index 2619f803..05908e2e 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -313,7 +313,7 @@ namespace BBWY.Client.ViewModels } else if (storageType == StorageType.SD) { - var sd = new SD(orderId, true, order.VenderRemark, order.Flag, string.Empty, null, string.Empty, string.Empty); + var sd = new SD(orderId, true, order.VenderRemark, order.Flag, string.Empty, null, string.Empty, string.Empty, 0M, 0M); sd.Closed += Sd_Closed; sd.ShowDialog(); } @@ -432,7 +432,7 @@ namespace BBWY.Client.ViewModels } else if (order.StorageType == StorageType.SD) { - var sd = new SD(order.Id, false, order.VenderRemark, order.Flag, order.SDKey, order.SDPayChannel, order.SDPayBillNo, order.SDOperator); + var sd = new SD(order.Id, false, order.VenderRemark, order.Flag, order.SDKey, order.SDPayChannel, order.SDPayBillNo, order.SDOperator, order.OrderCost.SDCommissionAmount, order.OrderCost.DeliveryExpressFreight); sd.Closed += Sd_Closed; sd.ShowDialog(); } @@ -475,7 +475,42 @@ namespace BBWY.Client.ViewModels } else { - var manualCalculationCost = new ManualCalculationCost(orderId, isSetStorageType, storageType); + var order = OrderList.FirstOrDefault(o => o.Id == orderId); + var orderSkuList = order.ItemList.Select(osku => new ManualEditCostOrderSku() + { + Id = osku.Id, + ItemTotal = osku.ItemTotal, + Logo = osku.Logo, + Price = osku.Price, + Title = osku.Title, + ProductId = osku.ProductId, + ProductItemNum = osku.ProductItemNum + }).ToList(); + foreach (var manualEditCostOrderSku in orderSkuList) + { + var orderCostDetailList = order.OrderCostDetailGroupList?.FirstOrDefault(g => g.SkuId == manualEditCostOrderSku.Id)?.Items; + if (orderCostDetailList != null && orderCostDetailList.Count > 0) + { + manualEditCostOrderSku.ConsumableAmount = orderCostDetailList.Sum(ocd => ocd.ConsumableAmount); + manualEditCostOrderSku.DeliveryExpressFreight = orderCostDetailList.Sum(ocd => ocd.DeliveryExpressFreight); + manualEditCostOrderSku.FirstFreight = orderCostDetailList.Sum(ocd => ocd.FirstFreight); + manualEditCostOrderSku.OperationAmount = orderCostDetailList.Sum(ocd => ocd.OperationAmount); + manualEditCostOrderSku.PurchaseFreight = orderCostDetailList.Sum(ocd => ocd.PurchaseFreight); + manualEditCostOrderSku.SkuAmount = orderCostDetailList.Sum(ocd => ocd.SkuAmount); + manualEditCostOrderSku.StorageAmount = orderCostDetailList.Sum(ocd => ocd.StorageAmount); + manualEditCostOrderSku.TotalCost = orderCostDetailList.Sum(ocd => ocd.TotalCost); + manualEditCostOrderSku.UnitCost = orderCostDetailList.FirstOrDefault().UnitCost; + } + manualEditCostOrderSku.ConsumableAmountStr = manualEditCostOrderSku.ConsumableAmount.ToString(); + manualEditCostOrderSku.DeliveryExpressFreightStr = manualEditCostOrderSku.DeliveryExpressFreight.ToString(); + manualEditCostOrderSku.FirstFreightStr = manualEditCostOrderSku.FirstFreight.ToString(); + manualEditCostOrderSku.OperationAmountStr = manualEditCostOrderSku.OperationAmount.ToString(); + manualEditCostOrderSku.PurchaseFreightStr = manualEditCostOrderSku.PurchaseFreight.ToString(); + manualEditCostOrderSku.SkuAmountStr = manualEditCostOrderSku.SkuAmount.ToString(); + manualEditCostOrderSku.StorageAmountStr = manualEditCostOrderSku.StorageAmount.ToString(); + } + + var manualCalculationCost = new ManualCalculationCost(orderId, isSetStorageType, storageType, orderSkuList); manualCalculationCost.Closed += ManualCalculationCost_Closed; manualCalculationCost.ShowDialog(); } @@ -491,11 +526,14 @@ namespace BBWY.Client.ViewModels var orderId = manualCalculationCost.OrderId; var storageType = manualCalculationCost.StorageType; var isSetStorageType = manualCalculationCost.IsSetStorageType; - var purchaseCost = manualCalculationCost.PurchaseCost; - var deliveryExpressFreight = manualCalculationCost.DeliveryExpressFreight; + var manualEditCostOrderSkuList = manualCalculationCost.ManualEditCostOrderSkuList; IsLoading = true; - Task.Factory.StartNew(() => orderService.ManualCalculationCost(orderId, isSetStorageType, storageType, purchaseCost, deliveryExpressFreight, globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)).ContinueWith(r => + Task.Factory.StartNew(() => orderService.ManualCalculationCost(orderId, + isSetStorageType, + storageType, + manualEditCostOrderSkuList, + globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)).ContinueWith(r => { var response = r.Result; if (!response.Success) @@ -631,7 +669,7 @@ namespace BBWY.Client.ViewModels try { var list = r.Data.Select(x => x.ToString()).ToList(); - list.Insert(0, "日期,店铺订单号,SKU编码,仓储类型,代发下单单号,售价,采购金额,头程费用,仓储服务费,快递费,平台扣点,补差金额,利润,利润率,收件人联系方式,售后类型,售后与特殊情况备注"); + list.Insert(0, "日期,店铺订单号,SKU编码,仓储类型,代发下单单号,售价,商品成本,头程费用,仓储服务费,快递费,平台扣点,补差金额,利润,利润率,收件人联系方式,售后类型,售后与特殊情况备注"); System.IO.File.WriteAllLines(ssaveFileName, list, Encoding.UTF8); App.Current.Dispatcher.Invoke(() => MessageBox.Show("导出完成", "导出")); } diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index dd8432cf..9700d262 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + diff --git a/BBWY.Client/Views/Order/ManualCalculationCost.xaml b/BBWY.Client/Views/Order/ManualCalculationCost.xaml index 9cf1e0c4..2311dd60 100644 --- a/BBWY.Client/Views/Order/ManualCalculationCost.xaml +++ b/BBWY.Client/Views/Order/ManualCalculationCost.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:BBWY.Client.Views.Order" xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" mc:Ignorable="d" - Title="手动计算成本" Height="450" Width="300" + Title="手动计算成本" Height="450" Width="1100" Style="{StaticResource bwstyle}" MinButtonVisibility="Collapsed" MaxButtonVisibility="Collapsed"> @@ -21,7 +21,140 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/BBWY.Client/Views/Order/ManualCalculationCost.xaml.cs b/BBWY.Client/Views/Order/ManualCalculationCost.xaml.cs index a5dab168..d798e5dc 100644 --- a/BBWY.Client/Views/Order/ManualCalculationCost.xaml.cs +++ b/BBWY.Client/Views/Order/ManualCalculationCost.xaml.cs @@ -1,5 +1,7 @@ using BBWY.Client.Models; using BBWY.Controls; +using System.Collections.Generic; +using System.Linq; using System.Windows; namespace BBWY.Client.Views.Order @@ -15,13 +17,20 @@ namespace BBWY.Client.Views.Order public StorageType StorageType { get; private set; } - public decimal PurchaseCost { get; private set; } + public List ManualEditCostOrderSkuList { get; set; } - public decimal DeliveryExpressFreight { get; private set; } - - public ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType) + public ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, IList manualEditCostOrderSkuList) { InitializeComponent(); + this.DataContext = this; + ManualEditCostOrderSkuList = new List(); + ManualEditCostOrderSkuList.AddRange(manualEditCostOrderSkuList); + foreach (var manualEditCostOrderSku in ManualEditCostOrderSkuList) + manualEditCostOrderSku.OnAmountChanged = () => + { + txtTotalCost.Text = ManualEditCostOrderSkuList.Sum(osku => osku.TotalCost).ToString(); + txtTotalDeliveryExpressFreight.Text = ManualEditCostOrderSkuList.Sum(osku => osku.DeliveryExpressFreight).ToString(); + }; this.OrderId = orderId; this.IsSetStorageType = isSetStorageType; this.StorageType = storageType; @@ -32,11 +41,14 @@ namespace BBWY.Client.Views.Order { txt_StorageType.Text = $"{this.StorageType}-手动计算成本"; - if (StorageType != StorageType.云仓 && StorageType != StorageType.京仓) - { - txtFirstFreight.Visibility = Visibility.Collapsed; - this.Height = 290; - } + //if (StorageType != StorageType.云仓 && StorageType != StorageType.京仓) + //{ + // txtFirstFreight.Visibility = Visibility.Collapsed; + // this.Height = 290; + //} + + txtTotalCost.Text = ManualEditCostOrderSkuList.Sum(osku => osku.TotalCost).ToString(); + txtTotalDeliveryExpressFreight.Text = ManualEditCostOrderSkuList.Sum(osku => osku.DeliveryExpressFreight).ToString(); } private void btn_fillFromLately_Click(object sender, System.Windows.RoutedEventArgs e) @@ -46,22 +58,22 @@ namespace BBWY.Client.Views.Order private void btn_Save_Click(object sender, System.Windows.RoutedEventArgs e) { - if (!decimal.TryParse(txtSkuAmount.Text, out decimal skuAmount) || - !decimal.TryParse(txtFeright.Text, out decimal feright) || - !decimal.TryParse(txtDeliveryExpressFreight.Text, out decimal deliveryExpressFreight)) - { - MessageBox.Show("请填写完整信息", "手动编辑成本"); - return; - } + //if (!decimal.TryParse(txtSkuAmount.Text, out decimal skuAmount) || + // !decimal.TryParse(txtFeright.Text, out decimal feright) || + // !decimal.TryParse(txtDeliveryExpressFreight.Text, out decimal deliveryExpressFreight)) + //{ + // MessageBox.Show("请填写完整信息", "手动编辑成本"); + // return; + //} - decimal.TryParse(txtFirstFreight.Text, out decimal firstFreight); - decimal.TryParse(txtOperationAmount.Text, out decimal operationAmount); - decimal.TryParse(txtConsumableAmount.Text, out decimal consumableAmount); - decimal.TryParse(txtStorageAmount.Text, out decimal storageAmount); + //decimal.TryParse(txtFirstFreight.Text, out decimal firstFreight); + //decimal.TryParse(txtOperationAmount.Text, out decimal operationAmount); + //decimal.TryParse(txtConsumableAmount.Text, out decimal consumableAmount); + //decimal.TryParse(txtStorageAmount.Text, out decimal storageAmount); - this.PurchaseCost = skuAmount + feright + firstFreight + operationAmount + consumableAmount + storageAmount; - this.DeliveryExpressFreight = deliveryExpressFreight; + //this.PurchaseCost = skuAmount + feright + firstFreight + operationAmount + consumableAmount + storageAmount; + //this.DeliveryExpressFreight = deliveryExpressFreight; this.DialogResult = true; this.Close(); } diff --git a/BBWY.Client/Views/Order/OrderList.xaml b/BBWY.Client/Views/Order/OrderList.xaml index 47191fc1..1dd8c044 100644 --- a/BBWY.Client/Views/Order/OrderList.xaml +++ b/BBWY.Client/Views/Order/OrderList.xaml @@ -482,7 +482,7 @@ CommandParameter="{Binding OrderDropShipping.PurchaseOrderId}"/> - + @@ -495,10 +495,30 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -510,12 +530,12 @@ + Style="{StaticResource NoScrollViewListBoxStyle}" Foreground="{StaticResource Text.Color}"> - - + + @@ -527,7 +547,7 @@ - + @@ -550,7 +570,8 @@ + ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" + Foreground="{StaticResource Text.Color}"> diff --git a/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml b/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml index f477bcf1..dfaeecbe 100644 --- a/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml +++ b/BBWY.Client/Views/Order/RelationPurchaseOrder.xaml @@ -138,7 +138,7 @@ - + ().Where(ocd => orderIdList.Contains(ocd.OrderId)).ToList().Map>(); + var orderCostDetailList = fsql.Select().Where(ocd => orderIdList.Contains(ocd.OrderId) && ocd.IsEnabled == true).ToList().Map>(); foreach (var order in orderList) order.OrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id).ToList(); #endregion @@ -242,13 +242,14 @@ namespace BBWY.Server.Business var orderIdList = orderSourceList.Select(o => o.OrderId).ToList(); var orderSkuList = fsql.Select().Where(osku => orderIdList.Contains(osku.OrderId)).ToList(); - var orderCostDetailGroup = fsql.Select().Where(ocd => orderIdList.Contains(ocd.OrderId)).GroupBy(ocd => ocd.OrderId).ToList(g => new - { - OrderId = g.Key, - SkuAmount = g.Sum(g.Value.SkuAmount), - FirstFreight = g.Sum(g.Value.FirstFreight), - StorageAmount = g.Sum(g.Value.StorageAmount) - }); + var orderCostDetailGroup = fsql.Select().Where(ocd => orderIdList.Contains(ocd.OrderId) && ocd.IsEnabled == true) + .GroupBy(ocd => ocd.OrderId).ToList(g => new + { + OrderId = g.Key, + SkuAmount = g.Sum(g.Value.SkuAmount), + FirstFreight = g.Sum(g.Value.FirstFreight), + StorageAmount = g.Sum(g.Value.StorageAmount) + }); foreach (var order in orderSourceList) { @@ -333,7 +334,7 @@ namespace BBWY.Server.Business var orderSkuList = fsql.Select().Where(osku => osku.OrderId == orderId).ToList().Map>(); var orderCouponList = fsql.Select().Where(oc => oc.OrderId == orderId).ToList().Map>(); - var orderCostDetailList = fsql.Select().Where(ocd => ocd.OrderId == orderId).ToList().Map>(); + var orderCostDetailList = fsql.Select().Where(ocd => ocd.OrderId == orderId && ocd.IsEnabled == true).ToList().Map>(); orderResponse.ItemList = orderSkuList; orderResponse.OrderCouponList = orderCouponList; @@ -415,7 +416,7 @@ namespace BBWY.Server.Business throw new BusinessException("库存为零不能自动计算成本"); var orderCost = fsql.Select(autoCalculationCostRequest.OrderId).ToOne(); - var orderCostDetails = fsql.Select().Where(ocd => ocd.OrderId == autoCalculationCostRequest.OrderId).ToList(); + var orderCostDetails = fsql.Select().Where(ocd => ocd.OrderId == autoCalculationCostRequest.OrderId && ocd.IsEnabled == true).ToList(); IUpdate orderUpdate = null; IUpdate updateOrderCost = null; @@ -558,13 +559,35 @@ namespace BBWY.Server.Business var dbOrder = fsql.Select(manualCalculationCostRequest.OrderId).ToOne(); if (dbOrder == null) throw new BusinessException($"订单号{manualCalculationCostRequest.OrderId}不存在"); + if (manualCalculationCostRequest.OrderCostDetailList == null || manualCalculationCostRequest.OrderCostDetailList.Count() == 0) + throw new BusinessException($"缺少明细信息"); IUpdate orderUpdate = null; IUpdate updateOrderCost = null; IInsert insertOrderCost = null; + List insertOrderCostDetailList = new List(); + if (manualCalculationCostRequest.IsSetStorageType) orderUpdate = fsql.Update(manualCalculationCostRequest.OrderId).Set(o => o.StorageType, manualCalculationCostRequest.StorageType); + insertOrderCostDetailList.AddRange(manualCalculationCostRequest.OrderCostDetailList.Map>()); + foreach (var orderCostDetail in insertOrderCostDetailList) + { + orderCostDetail.Id = idGenerator.NewLong(); + orderCostDetail.CreateTime = DateTime.Now; + orderCostDetail.OrderId = manualCalculationCostRequest.OrderId; + orderCostDetail.PurchaseOrderPKId = 0; + //orderCostDetail.TotalCost = orderCostDetail.SkuAmount + + // orderCostDetail.PurchaseFreight + + // orderCostDetail.FirstFreight + + // orderCostDetail.StorageAmount + + // orderCostDetail.ConsumableAmount + + // orderCostDetail.OperationAmount; + //orderCostDetail.UnitCost = orderCostDetail.TotalCost / orderCostDetail.DeductionQuantity; + } + + var totalPurchaseCost = insertOrderCostDetailList.Sum(ocd => ocd.TotalCost); + var totalDeliveryExpressFreight = insertOrderCostDetailList.Sum(ocd => ocd.DeliveryExpressFreight); var orderCost = fsql.Select(manualCalculationCostRequest.OrderId).ToOne(); if (orderCost == null) @@ -577,8 +600,8 @@ namespace BBWY.Server.Business PlatformCommissionRatio = manualCalculationCostRequest.PlatformCommissionRatio, PreferentialAmount = dbOrder.PreferentialAmount, Profit = 0, - PurchaseAmount = manualCalculationCostRequest.PurchaseCost, - DeliveryExpressFreight = manualCalculationCostRequest.DeliveryExpressFreight, + PurchaseAmount = totalPurchaseCost, + DeliveryExpressFreight = totalDeliveryExpressFreight, CreateTime = DateTime.Now, IsManualEdited = true }; @@ -592,8 +615,8 @@ namespace BBWY.Server.Business } else { - orderCost.PurchaseAmount = manualCalculationCostRequest.PurchaseCost; - orderCost.DeliveryExpressFreight = manualCalculationCostRequest.DeliveryExpressFreight; + orderCost.PurchaseAmount = totalPurchaseCost; + orderCost.DeliveryExpressFreight = totalDeliveryExpressFreight; orderCost.Profit = dbOrder.OrderSellerPrice + dbOrder.FreightPrice - orderCost.PurchaseAmount - @@ -605,9 +628,11 @@ namespace BBWY.Server.Business fsql.Transaction(() => { + fsql.Update().Set(ocd => ocd.IsEnabled, false).Where(ocd => ocd.OrderId == manualCalculationCostRequest.OrderId).ExecuteAffrows(); orderUpdate?.ExecuteAffrows(); insertOrderCost?.ExecuteAffrows(); updateOrderCost?.ExecuteAffrows(); + fsql.Insert(insertOrderCostDetailList).ExecuteAffrows(); }); } @@ -1029,7 +1054,7 @@ namespace BBWY.Server.Business if (interfaceCanceledOrderIdList.Count() > 0 && dbOrderList.Any(dbOrder => interfaceCanceledOrderIdList.Contains(dbOrder.Id) && dbOrder.OrderState != Enums.OrderState.已取消)) { - dbOrderCostDetailList = fsql.Select().Where(ocd => interfaceCanceledOrderIdList.Contains(ocd.OrderId)).ToList(); + dbOrderCostDetailList = fsql.Select().Where(ocd => interfaceCanceledOrderIdList.Contains(ocd.OrderId) && ocd.IsEnabled == true).ToList(); } var orderSkuIds = new List(); diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs index 22538288..de1c31ff 100644 --- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs +++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs @@ -88,7 +88,7 @@ namespace BBWY.Server.Business //查询orderSku var orderSkuList = fsql.Select().Where(osku => orderIdList.Contains(osku.OrderId)).ToList(); //查询成本明细 - var orderCostDetailList = fsql.Select().Where(ocd => orderIdList.Contains(ocd.OrderId)).ToList(); + var orderCostDetailList = fsql.Select().Where(ocd => orderIdList.Contains(ocd.OrderId) && ocd.IsEnabled == true).ToList(); detailList = new List(); var totalSDOrderCost = 0M; diff --git a/BBWY.Server.Model/Db/Order/OrderCostDetail.cs b/BBWY.Server.Model/Db/Order/OrderCostDetail.cs index 42a6790a..d259b2e1 100644 --- a/BBWY.Server.Model/Db/Order/OrderCostDetail.cs +++ b/BBWY.Server.Model/Db/Order/OrderCostDetail.cs @@ -5,88 +5,92 @@ namespace BBWY.Server.Model.Db { [Table(Name = "ordercostdetail", DisableSyncStructure = true)] - public partial class OrderCostDetail { - - [Column(DbType = "bigint(1)", IsPrimary = true)] - public long Id { get; set; } - - [Column(DbType = "datetime")] - public DateTime? CreateTime { get; set; } - - /// - /// 扣减数量 - /// - [Column(DbType = "int(1)")] - public int DeductionQuantity { get; set; } = 0; - - /// - /// 发货运费 - /// - [Column(DbType = "decimal(20,2)")] - public decimal DeliveryExpressFreight { get; set; } = 0.00M; - - [Column(StringLength = 50)] - public string OrderId { get; set; } - - [Column(StringLength = 50)] - public string ProductId { get; set; } - - /// - /// 单件成本 - /// - [Column(DbType = "decimal(20,2)")] - public decimal UnitCost { get; set; } = 0.00M; - - /// - /// 采购单流水Id - /// - [Column(DbType = "bigint(1)")] - public long PurchaseOrderPKId { get; set; } - - [Column(StringLength = 50)] - public string SkuId { get; set; } - - /// - /// Sku成本(商品成本) - /// - [Column(DbType = "decimal(20,2)")] - public decimal SkuAmount { get; set; } = 0.00M; - - /// - /// 采购运费 - /// - [Column(DbType = "decimal(20,2)")] - public decimal PurchaseFreight { get; set; } = 0.00M; - - /// - /// 头程运费 - /// - [Column(DbType = "decimal(20,2)")] - public decimal FirstFreight { get; set; } = 0.00M; - - /// - /// 操作费 - /// - [Column(DbType = "decimal(20,2)")] - public decimal OperationAmount { get; set; } = 0.00M; - - /// - /// 耗材费 - /// - [Column(DbType = "decimal(20,2)")] - public decimal ConsumableAmount { get; set; } = 0.00M; - - /// - /// 仓储费 - /// - [Column(DbType = "decimal(20,2)")] - public decimal StorageAmount { get; set; } = 0.00M; - - /// - /// 总计(不含发货运费) - /// - [Column(DbType = "decimal(20,2)")] - public decimal TotalCost { get; set; } = 0.00M; - } + public partial class OrderCostDetail + { + + [Column(DbType = "bigint(1)", IsPrimary = true)] + public long Id { get; set; } + + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } + + /// + /// 扣减数量 + /// + [Column(DbType = "int(1)")] + public int DeductionQuantity { get; set; } = 0; + + /// + /// 发货运费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal DeliveryExpressFreight { get; set; } = 0.00M; + + [Column(StringLength = 50)] + public string OrderId { get; set; } + + [Column(StringLength = 50)] + public string ProductId { get; set; } + + /// + /// 单件成本 + /// + [Column(DbType = "decimal(20,2)")] + public decimal UnitCost { get; set; } = 0.00M; + + /// + /// 采购单流水Id + /// + [Column(DbType = "bigint(1)")] + public long PurchaseOrderPKId { get; set; } + + [Column(StringLength = 50)] + public string SkuId { get; set; } + + /// + /// Sku成本(商品成本) + /// + [Column(DbType = "decimal(20,2)")] + public decimal SkuAmount { get; set; } = 0.00M; + + /// + /// 采购运费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal PurchaseFreight { get; set; } = 0.00M; + + /// + /// 头程运费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal FirstFreight { get; set; } = 0.00M; + + /// + /// 操作费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal OperationAmount { get; set; } = 0.00M; + + /// + /// 耗材费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal ConsumableAmount { get; set; } = 0.00M; + + /// + /// 仓储费 + /// + [Column(DbType = "decimal(20,2)")] + public decimal StorageAmount { get; set; } = 0.00M; + + /// + /// 总计(不含发货运费) + /// + [Column(DbType = "decimal(20,2)")] + public decimal TotalCost { get; set; } = 0.00M; + + [Column(DbType = "bit")] + public bool IsEnabled { get; set; } = true; + } } diff --git a/BBWY.Server.Model/Dto/Request/Order/ManualCalculationCostRequest.cs b/BBWY.Server.Model/Dto/Request/Order/ManualCalculationCostRequest.cs index ac39dc6a..401cb347 100644 --- a/BBWY.Server.Model/Dto/Request/Order/ManualCalculationCostRequest.cs +++ b/BBWY.Server.Model/Dto/Request/Order/ManualCalculationCostRequest.cs @@ -1,4 +1,6 @@ -namespace BBWY.Server.Model.Dto +using System.Collections.Generic; + +namespace BBWY.Server.Model.Dto { public class ManualCalculationCostRequest { @@ -8,19 +10,60 @@ public Enums.StorageType? StorageType { get; set; } - /// - /// 采购成本 - /// - public decimal PurchaseCost { get; set; } + ///// + ///// 采购成本 + ///// + //public decimal PurchaseCost { get; set; } + + ///// + ///// 发货运费 + ///// + //public decimal DeliveryExpressFreight { get; set; } - /// - /// 发货运费 - /// - public decimal DeliveryExpressFreight { get; set; } + public IList OrderCostDetailList { get; set; } - /// - /// 平台扣点 - /// - public decimal PlatformCommissionRatio { get; set; } + /// + /// 平台扣点 + /// + public decimal PlatformCommissionRatio { get; set; } } + + public class OrderCostDetailRequest + { + public int DeductionQuantity { get; set; } = 0; + + public decimal DeliveryExpressFreight { get; set; } = 0.00M; + + public string ProductId { get; set; } + + public string SkuId { get; set; } + + public decimal SkuAmount { get; set; } = 0.00M; + + public decimal PurchaseFreight { get; set; } = 0.00M; + + /// + /// 头程运费 + /// + public decimal FirstFreight { get; set; } = 0.00M; + + /// + /// 操作费 + /// + public decimal OperationAmount { get; set; } = 0.00M; + + /// + /// 耗材费 + /// + public decimal ConsumableAmount { get; set; } = 0.00M; + + /// + /// 仓储费 + /// + public decimal StorageAmount { get; set; } = 0.00M; + + public decimal TotalCost { get; set; } = 0M; + + public decimal UnitCost { get; set; } = 0M; + } } diff --git a/BBWY.Server.Model/MappingProfiles.cs b/BBWY.Server.Model/MappingProfiles.cs index 58d291c2..d93206b7 100644 --- a/BBWY.Server.Model/MappingProfiles.cs +++ b/BBWY.Server.Model/MappingProfiles.cs @@ -25,6 +25,7 @@ namespace BBWY.Server.Model CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap();