From 4258fbba5a32430a327b365d78c2fecd6d8795ba Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 23 Apr 2022 14:40:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWY.Client/APIServices/OrderService.cs | 34 ++++++++ BBWY.Client/APIServices/ShopService.cs | 31 +++++++ .../Response/Order/ExportOrderResponse.cs | 76 ++++++++++++++++++ .../Response/Shop/PurchaseAccountResponse.cs | 19 +++++ .../APIModel/Response/Shop/ShopResponse.cs | 17 ---- BBWY.Client/Models/Shop/PurchaseAccount.cs | 27 +++++++ BBWY.Client/Models/Shop/Shop.cs | 5 -- .../ViewModels/Order/OrderListViewModel.cs | 56 +++++++++++++ .../Setting/ShopSettingViewModel.cs | 64 +++++++++++++++ BBWY.Client/ViewModels/ViewModelLocator.cs | 9 +++ BBWY.Client/Views/Order/OrderList.xaml | 1 + BBWY.Client/Views/Setting/ShopSetting.xaml | 60 ++++++++++++-- .../Controllers/VenderController.cs | 11 +++ BBWY.Server.API/Startup.cs | 11 +++ BBWY.Server.API/appsettings.json | 3 +- BBWY.Server.Business/FreeSqlMultiDBManager.cs | 12 +++ BBWY.Server.Business/Vender/VenderBusiness.cs | 80 ++++++++++++++++++- BBWY.Server.Model/Db/Mds/Purchaseaccount.cs | 60 ++++++++++++++ .../Db/PurchaseScheme/PurchaseAccount.cs | 4 + BBWY.Server.Model/Db/_MDS重新生成.bat | 2 + .../Dto/Request/Vender/ShopSettingRequest.cs | 34 ++++++++ 21 files changed, 584 insertions(+), 32 deletions(-) create mode 100644 BBWY.Client/APIServices/ShopService.cs create mode 100644 BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs create mode 100644 BBWY.Client/Models/APIModel/Response/Shop/PurchaseAccountResponse.cs create mode 100644 BBWY.Client/Models/Shop/PurchaseAccount.cs create mode 100644 BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs create mode 100644 BBWY.Server.Business/FreeSqlMultiDBManager.cs create mode 100644 BBWY.Server.Model/Db/Mds/Purchaseaccount.cs create mode 100644 BBWY.Server.Model/Db/_MDS重新生成.bat create mode 100644 BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs diff --git a/BBWY.Client/APIServices/OrderService.cs b/BBWY.Client/APIServices/OrderService.cs index 259247fa..1b1fb135 100644 --- a/BBWY.Client/APIServices/OrderService.cs +++ b/BBWY.Client/APIServices/OrderService.cs @@ -199,5 +199,39 @@ namespace BBWY.Client.APIServices globalContext.User.Shop.AppToken }, null, HttpMethod.Post); } + + public ApiResponse> ExportOrderList(string orderId, + DateTime startDate, + DateTime endDate, + OrderState? orderState, + string sku, + string productNo, + string waybill, + string contactName, + int pageIndex, + int pageSize, + long shopId, + bool onlyDF, + bool excludeSD, + bool excludeCanceled) + { + return SendRequest>(globalContext.BBYWApiHost, "api/order/ExportOrderList", new + { + orderId, + startDate, + endDate, + orderState, + pageIndex, + pageSize, + shopId, + sku, + productNo, + waybill, + contactName, + onlyDF, + excludeSD, + excludeCanceled + }, null, HttpMethod.Post); + } } } diff --git a/BBWY.Client/APIServices/ShopService.cs b/BBWY.Client/APIServices/ShopService.cs new file mode 100644 index 00000000..234f969e --- /dev/null +++ b/BBWY.Client/APIServices/ShopService.cs @@ -0,0 +1,31 @@ +using BBWY.Client.Models; +using BBWY.Common.Http; +using BBWY.Common.Models; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; + +namespace BBWY.Client.APIServices +{ + public class ShopService : BaseApiService, IDenpendency + { + public ShopService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) { } + + public ApiResponse SaveShopSetting(long shopId, string managerPwd, decimal platformCommissionRatio, PurchaseAccount purchaseAccount) + { + return SendRequest(globalContext.BBYWApiHost, "api/vender/SaveShopSetting", new + { + shopId, + managerPwd, + platformCommissionRatio, + PurchaseAccountId = purchaseAccount.Id, + purchaseAccount.AccountName, + purchaseAccount.AppKey, + purchaseAccount.AppSecret, + purchaseAccount.AppToken, + purchaseAccount.PurchasePlatformId + }, null, HttpMethod.Post); + } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs b/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs new file mode 100644 index 00000000..0eee8bfd --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Client.Models +{ + public class ExportOrderResponse + { + public string OrderId { get; set; } + + public DateTime OrderStartTime { get; set; } + + public string SkuIds { get; set; } + + /// + /// 代发订单号 + /// + public string PurchaseOrderIds { get; set; } + + /// + /// 订单总额 + /// + public decimal OrderTotalPrice { get; set; } + + /// + /// 采购金额 + /// + public decimal PurchaseSkuAmount { get; set; } + + /// + /// 头程费用 + /// + public decimal FirstFreight { get; set; } + + /// + /// 仓储费 + /// + public decimal StorageAmount { get; set; } + + /// + /// 发货快递费 + /// + public decimal DeliveryExpressFreight { get; set; } + + /// + /// 平台扣点金额 + /// + public decimal PlatformCommissionAmount { get; set; } + + /// + /// 补差金额(用户支付) + /// + public decimal FreightPrice { get; set; } + + /// + /// 总成本 + /// + public decimal TotalCost { get; set; } + + public decimal Profit { get; set; } + + public decimal ProfitRatio { get; set; } + + public string ConsigneeStr { get; set; } + + public StorageType? StorageType { get; set; } + + public OrderState OrderState { get; set; } + + public override string ToString() + { + //日期,店铺订单号,SKU编码,代发下单单号,售价,采购金额,头程费用,仓储服务费,快递费,平台扣点,补差金额,利润,利润率,收件人联系方式 + return $"{OrderStartTime:yyyy-MM-dd HH:mm:ss},{OrderId},{SkuIds},{PurchaseOrderIds},{OrderTotalPrice},{PurchaseSkuAmount},{FirstFreight},{StorageAmount},{DeliveryExpressFreight},{PlatformCommissionAmount},{FreightPrice},{Profit},{ProfitRatio},{ConsigneeStr}"; + } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/Shop/PurchaseAccountResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/PurchaseAccountResponse.cs new file mode 100644 index 00000000..7eee156e --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/Shop/PurchaseAccountResponse.cs @@ -0,0 +1,19 @@ +namespace BBWY.Client.Models +{ + public class PurchaseAccountResponse + { + public long Id { get; set; } + + public string AccountName { get; set; } + + public long ShopId { get; set; } + + public Platform PurchasePlatformId { get; set; } + + public string AppKey { get; set; } + + public string AppSecret { get; set; } + + public string AppToken { get; set; } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index 97f5559e..e4e35e04 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -22,21 +22,4 @@ namespace BBWY.Client.Models public IList PurchaseList { get; set; } } - - public class PurchaseAccountResponse - { - public long Id { get; set; } - - public string AccountName { get; set; } - - public long ShopId { get; set; } - - public Platform PurchasePlatformId { get; set; } - - public string AppKey { get; set; } - - public string AppSecret { get; set; } - - public string AppToken { get; set; } - } } diff --git a/BBWY.Client/Models/Shop/PurchaseAccount.cs b/BBWY.Client/Models/Shop/PurchaseAccount.cs new file mode 100644 index 00000000..096845fa --- /dev/null +++ b/BBWY.Client/Models/Shop/PurchaseAccount.cs @@ -0,0 +1,27 @@ +using System; + +namespace BBWY.Client.Models +{ + public class PurchaseAccount : NotifyObject,ICloneable + { + private string accountName; + private Platform purchasePlatformId; + private string appKey; + private string appSecret; + private string appToken; + + public long Id { get; set; } + + public long ShopId { get; set; } + public string AccountName { get => accountName; set { Set(ref accountName, value); } } + public Platform PurchasePlatformId { get => purchasePlatformId; set { Set(ref purchasePlatformId, value); } } + public string AppKey { get => appKey; set { Set(ref appKey, value); } } + public string AppSecret { get => appSecret; set { Set(ref appSecret, value); } } + public string AppToken { get => appToken; set { Set(ref appToken, value); } } + + public object Clone() + { + return this.MemberwiseClone(); + } + } +} diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index 0facae53..7e44f3ff 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -31,9 +31,4 @@ namespace BBWY.Client.Models public IList PurchaseAccountList { get; set; } } - - public class PurchaseAccount : PurchaseAccountResponse - { - - } } diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index cabb2d6e..f5debc7b 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -6,10 +6,12 @@ using BBWY.Common.Models; using BBWY.Controls; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Messaging; +using Microsoft.Win32; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -78,6 +80,8 @@ namespace BBWY.Client.ViewModels public ICommand SyncOrderCommand { get; set; } + public ICommand ExportCommand { get; set; } + public ICommand CopyTextCommand { get; set; } public ICommand CopyOrderWaybillCommand { get; set; } @@ -148,6 +152,7 @@ namespace BBWY.Client.ViewModels EditCostCommand = new RelayCommand(EditCost); OutStockCommand = new RelayCommand((o) => OutStock(o)); EditVenderRemarkCommand = new RelayCommand(EditVenderRemark); + ExportCommand = new RelayCommand(Export); SearchOrderCommand.Execute(null); } @@ -565,5 +570,56 @@ namespace BBWY.Client.ViewModels order.Flag = flag; }); } + + private void Export() + { + var sfd = new SaveFileDialog() { Filter= "csv files(*.csv)|*.csv" }; + if (sfd.ShowDialog() != true) + return; + + var ssaveFileName = sfd.FileName; + IsLoading = true; + Thread.Sleep(random.Next(500, 2000)); + Task.Factory.StartNew(() => orderService.ExportOrderList(SearchOrderId, + StartDate, + EndDate, + OrderState, + SearchSku, + SearchProductNo, + SearchWaybill, + SearchContactName, + pageIndex, + pageSize, + globalContext.User.Shop.ShopId, + OnlyDF, + ExcludeSD, + ExcludeCanceled)).ContinueWith(t => + { + var r = t.Result; + if (!r.Success) + { + IsLoading = false; + App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "导出")); + return; + } + + try + { + var list = r.Data.Select(x => x.ToString()).ToList(); + list.Insert(0, "日期,店铺订单号,SKU编码,代发下单单号,售价,采购金额,头程费用,仓储服务费,快递费,平台扣点,补差金额,利润,利润率,收件人联系方式,售后类型,售后与特殊情况备注"); + System.IO.File.WriteAllLines(ssaveFileName, list, Encoding.UTF8); + App.Current.Dispatcher.Invoke(() => MessageBox.Show("导出完成", "导出")); + } + catch (Exception ex) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "导出")); + return; + } + finally + { + IsLoading = false; + } + }); + } } } diff --git a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs new file mode 100644 index 00000000..f320a62a --- /dev/null +++ b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs @@ -0,0 +1,64 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using BBWY.Common.Models; +using GalaSoft.MvvmLight.Command; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; + +namespace BBWY.Client.ViewModels +{ + public class ShopSettingViewModel : BaseVM, IDenpendency + { + private bool isLoading; + private GlobalContext globalContext; + private ShopService shopService; + private PurchaseAccount purchaseAccount; + public PurchaseAccount PurchaseAccount { get => purchaseAccount; set { Set(ref purchaseAccount, value); } } + + public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } + public ICommand SaveCommand { get; set; } + + public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService) + { + this.globalContext = globalContext; + this.shopService = shopService; + SaveCommand = new RelayCommand(Save); + } + + protected override void Load() + { + this.PurchaseAccount = globalContext.User.Shop.PurchaseAccountList == null || globalContext.User.Shop.PurchaseAccountList.Count() == 0 ? + new PurchaseAccount() : + globalContext.User.Shop.PurchaseAccountList[0].Clone() as PurchaseAccount; + } + + protected override void Unload() + { + this.PurchaseAccount = null; + } + + private void Save() + { + IsLoading = true; + Task.Factory.StartNew(() => shopService.SaveShopSetting(globalContext.User.Shop.ShopId, "", 0, PurchaseAccount)).ContinueWith(r => + { + IsLoading = false; + var response = r.Result; + if (!response.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "保存店铺设置")); + 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); + }); + } + } +} diff --git a/BBWY.Client/ViewModels/ViewModelLocator.cs b/BBWY.Client/ViewModels/ViewModelLocator.cs index 851d87c1..5daff652 100644 --- a/BBWY.Client/ViewModels/ViewModelLocator.cs +++ b/BBWY.Client/ViewModels/ViewModelLocator.cs @@ -88,5 +88,14 @@ namespace BBWY.Client.ViewModels } } } + + public ShopSettingViewModel ShopSetting + { + get + { + using var s = sp.CreateScope(); + return s.ServiceProvider.GetRequiredService(); + } + } } } diff --git a/BBWY.Client/Views/Order/OrderList.xaml b/BBWY.Client/Views/Order/OrderList.xaml index 4a47e75d..8936bb3a 100644 --- a/BBWY.Client/Views/Order/OrderList.xaml +++ b/BBWY.Client/Views/Order/OrderList.xaml @@ -149,6 +149,7 @@ + diff --git a/BBWY.Client/Views/Setting/ShopSetting.xaml b/BBWY.Client/Views/Setting/ShopSetting.xaml index ba7a72d5..dbe71da3 100644 --- a/BBWY.Client/Views/Setting/ShopSetting.xaml +++ b/BBWY.Client/Views/Setting/ShopSetting.xaml @@ -4,17 +4,26 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BBWY.Client.Views.Setting" - xmlns:b="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" + xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:cmodel="clr-namespace:BBWY.Client.Models" + xmlns:b="http://schemas.microsoft.com/xaml/behaviors" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" - Title="ShopSetting"> + Title="ShopSetting" + DataContext="{Binding ShopSetting,Source={StaticResource Locator}}"> + + + + + - + + + + + + + + - + + @@ -38,16 +56,44 @@ - - + - + + + + + + + + + + + + + + + + diff --git a/BBWY.Server.API/Controllers/VenderController.cs b/BBWY.Server.API/Controllers/VenderController.cs index fbd01b72..84c7ca02 100644 --- a/BBWY.Server.API/Controllers/VenderController.cs +++ b/BBWY.Server.API/Controllers/VenderController.cs @@ -46,6 +46,17 @@ namespace BBWY.Server.API.Controllers return venderBusiness.GetLogisticsList(platformRequest); } + /// + /// 保存店铺设置 + /// + /// + /// + [HttpPost] + public long SaveShopSetting([FromBody] ShopSettingRequest shopSettingRequest) + { + return venderBusiness.SaveShopSetting(shopSettingRequest); + } + /// /// 接收JD店铺Token更新 /// diff --git a/BBWY.Server.API/Startup.cs b/BBWY.Server.API/Startup.cs index 20570bbe..4e17b59e 100644 --- a/BBWY.Server.API/Startup.cs +++ b/BBWY.Server.API/Startup.cs @@ -39,8 +39,19 @@ namespace BBWY.Server.API var idOption = new IdGeneratorOptions(1); var idGenerator = new DefaultIdGenerator(idOption); services.AddSingleton(typeof(IIdGenerator), idGenerator); + + var fsql = new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, Configuration.GetConnectionString("DB")).Build(); services.AddSingleton(typeof(IFreeSql), fsql); + + var fsql2 = new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, Configuration.GetConnectionString("MDSDB")).Build(); + + + services.AddSingleton(new FreeSqlMultiDBManager() + { + BBWYfsql = fsql, + MDSfsql = fsql2, + }); services.AddSingleton(typeof(NLog.ILogger), NLog.LogManager.GetCurrentClassLogger()); services.AddSingleton(); services.AddSingleton(); diff --git a/BBWY.Server.API/appsettings.json b/BBWY.Server.API/appsettings.json index a9504486..cbe7b837 100644 --- a/BBWY.Server.API/appsettings.json +++ b/BBWY.Server.API/appsettings.json @@ -9,7 +9,8 @@ "AllowedHosts": "*", "ConnectionStrings": { //"DB": "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy;charset=utf8;sslmode=none;" - "DB": "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy_test;charset=utf8;sslmode=none;" + "DB": "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy_test;charset=utf8;sslmode=none;", + "MDSDB": "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=mds;charset=utf8;sslmode=none;" }, "GlobalSetting": { "MdsApi": "http://mdsapi.qiyue666.com", diff --git a/BBWY.Server.Business/FreeSqlMultiDBManager.cs b/BBWY.Server.Business/FreeSqlMultiDBManager.cs new file mode 100644 index 00000000..bc713cbd --- /dev/null +++ b/BBWY.Server.Business/FreeSqlMultiDBManager.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Server.Business +{ + public class FreeSqlMultiDBManager + { + public IFreeSql BBWYfsql { get; set; } + public IFreeSql MDSfsql { get; set; } + } +} diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index d93417c3..d0a4954e 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -2,19 +2,29 @@ using BBWY.Common.Http; using BBWY.Common.Models; using BBWY.Server.Model; +using BBWY.Server.Model.Db; +using BBWY.Server.Model.Db.Mds; using BBWY.Server.Model.Dto; using Microsoft.Extensions.Options; using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Net.Http; +using Yitter.IdGenerator; namespace BBWY.Server.Business { public class VenderBusiness : BasePlatformRelayBusiness, IDenpendency { - public VenderBusiness(RestApiService restApiService, IOptions options) : base(restApiService, options) + private FreeSqlMultiDBManager freeSqlMultiDBManager; + private IIdGenerator idGenerator; + public VenderBusiness(FreeSqlMultiDBManager freeSqlMultiDBManager, + RestApiService restApiService, + IOptions options, + IIdGenerator idGenerator) : base(restApiService, options) { - + this.freeSqlMultiDBManager = freeSqlMultiDBManager; + this.idGenerator = idGenerator; } public VenderResponse GetVenderInfo(PlatformRequest platformRequest) @@ -59,5 +69,71 @@ namespace BBWY.Server.Business AppToken = jDShopToken.Access_Token }, new Dictionary() { { "qy", "qy" } }, HttpMethod.Post); } + + public long SaveShopSetting(ShopSettingRequest shopSettingRequest) + { + if (shopSettingRequest.PurchaseAccountId == 0) + { + shopSettingRequest.PurchaseAccountId = idGenerator.NewLong(); + var pa = new PurchaseAccount() + { + Id = shopSettingRequest.PurchaseAccountId, + AccountName = shopSettingRequest.AccountName, + AppKey = shopSettingRequest.AppKey, + AppSecret = shopSettingRequest.AppSecret, + AppToken = shopSettingRequest.AppToken, + CreateTime = DateTime.Now, + CreatorId = "", + Deleted = 0, + PurchasePlatformId = shopSettingRequest.PurchasePlatformId, + ShopId = shopSettingRequest.ShopId + }; + + var mdspa = new Purchaseaccount() + { + Id = shopSettingRequest.PurchaseAccountId.ToString(), + AccountName = shopSettingRequest.AccountName, + AppKey = shopSettingRequest.AppKey, + AppSecret = shopSettingRequest.AppSecret, + AppToken = shopSettingRequest.AppToken, + CreateTime = DateTime.Now, + CreatorId = "", + Deleted = 0, + PurchasePlatformId = ((int)shopSettingRequest.PurchasePlatformId).ToString(), + ShopId = shopSettingRequest.ShopId.ToString() + }; + + + freeSqlMultiDBManager.BBWYfsql.Insert(pa).ExecuteAffrows(); + freeSqlMultiDBManager.MDSfsql.Transaction(() => + { + freeSqlMultiDBManager.MDSfsql.Insert(mdspa).ExecuteAffrows(); + //修改扣点和管理密码 + + }); + } + else + { + freeSqlMultiDBManager.BBWYfsql.Update(shopSettingRequest.PurchaseAccountId) + .Set(pa => pa.AppKey, shopSettingRequest.AppKey) + .Set(pa => pa.AppSecret, shopSettingRequest.AppSecret) + .Set(pa => pa.AppToken, shopSettingRequest.AppToken) + .Set(pa => pa.AccountName, shopSettingRequest.AccountName) + .ExecuteAffrows(); + + freeSqlMultiDBManager.MDSfsql.Transaction(() => + { + freeSqlMultiDBManager.MDSfsql.Update(shopSettingRequest.PurchaseAccountId.ToString()) + .Set(pa => pa.AppKey, shopSettingRequest.AppKey) + .Set(pa => pa.AppSecret, shopSettingRequest.AppSecret) + .Set(pa => pa.AppToken, shopSettingRequest.AppToken) + .Set(pa => pa.AccountName, shopSettingRequest.AccountName) + .ExecuteAffrows(); + //修改扣点和管理密码 + + }); + } + return shopSettingRequest.PurchaseAccountId; + } } } diff --git a/BBWY.Server.Model/Db/Mds/Purchaseaccount.cs b/BBWY.Server.Model/Db/Mds/Purchaseaccount.cs new file mode 100644 index 00000000..ce0c8230 --- /dev/null +++ b/BBWY.Server.Model/Db/Mds/Purchaseaccount.cs @@ -0,0 +1,60 @@ +using FreeSql.DataAnnotations; +using System; + +namespace BBWY.Server.Model.Db.Mds +{ + + /// + /// 采购账号表 + /// + [Table(Name = "purchaseaccount", DisableSyncStructure = true)] + public partial class Purchaseaccount { + + /// + /// 主键 + /// + [Column(StringLength = 50, IsPrimary = true, IsNullable = false)] + public string Id { get; set; } + + + public string AccountName { get; set; } + + + public string AppKey { get; set; } + + + public string AppSecret { get; set; } + + + public string AppToken { get; set; } + + /// + /// 创建时间 + /// + [Column(DbType = "datetime")] + public DateTime CreateTime { get; set; } + + /// + /// 创建人Id + /// + [Column(StringLength = 50)] + public string CreatorId { get; set; } + + /// + /// 否已删除 + /// + [Column(DbType = "tinyint(4)")] + public sbyte Deleted { get; set; } + + [Column(StringLength = 50)] + public string PurchasePlatformId { get; set; } + + /// + /// 采购账号归属店铺ID + /// + [Column(StringLength = 50)] + public string ShopId { get; set; } + + } + +} diff --git a/BBWY.Server.Model/Db/PurchaseScheme/PurchaseAccount.cs b/BBWY.Server.Model/Db/PurchaseScheme/PurchaseAccount.cs index 94b6b6b1..eebfbcc6 100644 --- a/BBWY.Server.Model/Db/PurchaseScheme/PurchaseAccount.cs +++ b/BBWY.Server.Model/Db/PurchaseScheme/PurchaseAccount.cs @@ -58,4 +58,8 @@ namespace BBWY.Server.Model.Db } + + + + } diff --git a/BBWY.Server.Model/Db/_MDS重新生成.bat b/BBWY.Server.Model/Db/_MDS重新生成.bat new file mode 100644 index 00000000..fb0e713e --- /dev/null +++ b/BBWY.Server.Model/Db/_MDS重新生成.bat @@ -0,0 +1,2 @@ + +FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace BBWY.Server.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=mds;charset=utf8;sslmode=none;" -FileName "{name}.cs" diff --git a/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs b/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs new file mode 100644 index 00000000..26442fcb --- /dev/null +++ b/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Server.Model.Dto +{ + public class ShopSettingRequest + { + public long ShopId { get; set; } + + public string ManagerPwd { get; set; } + + /// + /// 平台扣点 + /// + public decimal PlatformCommissionRatio { get; set; } + + public long PurchaseAccountId { get; set; } + + + public string AccountName { get; set; } + + + public string AppKey { get; set; } + + + public string AppSecret { get; set; } + + + public string AppToken { get; set; } + + public Enums.Platform PurchasePlatformId { get; set; } + } +}