Browse Source

导出

qianyi
shanji 3 years ago
parent
commit
4258fbba5a
  1. 34
      BBWY.Client/APIServices/OrderService.cs
  2. 31
      BBWY.Client/APIServices/ShopService.cs
  3. 76
      BBWY.Client/Models/APIModel/Response/Order/ExportOrderResponse.cs
  4. 19
      BBWY.Client/Models/APIModel/Response/Shop/PurchaseAccountResponse.cs
  5. 17
      BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
  6. 27
      BBWY.Client/Models/Shop/PurchaseAccount.cs
  7. 5
      BBWY.Client/Models/Shop/Shop.cs
  8. 56
      BBWY.Client/ViewModels/Order/OrderListViewModel.cs
  9. 64
      BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs
  10. 9
      BBWY.Client/ViewModels/ViewModelLocator.cs
  11. 1
      BBWY.Client/Views/Order/OrderList.xaml
  12. 60
      BBWY.Client/Views/Setting/ShopSetting.xaml
  13. 11
      BBWY.Server.API/Controllers/VenderController.cs
  14. 11
      BBWY.Server.API/Startup.cs
  15. 3
      BBWY.Server.API/appsettings.json
  16. 12
      BBWY.Server.Business/FreeSqlMultiDBManager.cs
  17. 80
      BBWY.Server.Business/Vender/VenderBusiness.cs
  18. 60
      BBWY.Server.Model/Db/Mds/Purchaseaccount.cs
  19. 4
      BBWY.Server.Model/Db/PurchaseScheme/PurchaseAccount.cs
  20. 2
      BBWY.Server.Model/Db/_MDS重新生成.bat
  21. 34
      BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs

34
BBWY.Client/APIServices/OrderService.cs

@ -199,5 +199,39 @@ namespace BBWY.Client.APIServices
globalContext.User.Shop.AppToken
}, null, HttpMethod.Post);
}
public ApiResponse<IList<ExportOrderResponse>> 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<IList<ExportOrderResponse>>(globalContext.BBYWApiHost, "api/order/ExportOrderList", new
{
orderId,
startDate,
endDate,
orderState,
pageIndex,
pageSize,
shopId,
sku,
productNo,
waybill,
contactName,
onlyDF,
excludeSD,
excludeCanceled
}, null, HttpMethod.Post);
}
}
}

31
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<long> SaveShopSetting(long shopId, string managerPwd, decimal platformCommissionRatio, PurchaseAccount purchaseAccount)
{
return SendRequest<long>(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);
}
}
}

76
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; }
/// <summary>
/// 代发订单号
/// </summary>
public string PurchaseOrderIds { get; set; }
/// <summary>
/// 订单总额
/// </summary>
public decimal OrderTotalPrice { get; set; }
/// <summary>
/// 采购金额
/// </summary>
public decimal PurchaseSkuAmount { get; set; }
/// <summary>
/// 头程费用
/// </summary>
public decimal FirstFreight { get; set; }
/// <summary>
/// 仓储费
/// </summary>
public decimal StorageAmount { get; set; }
/// <summary>
/// 发货快递费
/// </summary>
public decimal DeliveryExpressFreight { get; set; }
/// <summary>
/// 平台扣点金额
/// </summary>
public decimal PlatformCommissionAmount { get; set; }
/// <summary>
/// 补差金额(用户支付)
/// </summary>
public decimal FreightPrice { get; set; }
/// <summary>
/// 总成本
/// </summary>
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}";
}
}
}

19
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; }
}
}

17
BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs

@ -22,21 +22,4 @@ namespace BBWY.Client.Models
public IList<PurchaseAccountResponse> 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; }
}
}

27
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();
}
}
}

5
BBWY.Client/Models/Shop/Shop.cs

@ -31,9 +31,4 @@ namespace BBWY.Client.Models
public IList<PurchaseAccount> PurchaseAccountList { get; set; }
}
public class PurchaseAccount : PurchaseAccountResponse
{
}
}

56
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<Order>(EditCost);
OutStockCommand = new RelayCommand<Order>((o) => OutStock(o));
EditVenderRemarkCommand = new RelayCommand<Order>(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;
}
});
}
}
}

64
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<PurchaseAccount>();
globalContext.User.Shop.PurchaseAccountList.Clear();
PurchaseAccount.Id = response.Data;
globalContext.User.Shop.PurchaseAccountList.Add(PurchaseAccount);
});
}
}
}

9
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<ShopSettingViewModel>();
}
}
}
}

1
BBWY.Client/Views/Order/OrderList.xaml

@ -149,6 +149,7 @@
</StackPanel>
</c:BButton.ToolTip>
</c:BButton>
<c:BButton Content="导出" Command="{Binding ExportCommand}" Width="50" Margin="5,0,0,0"/>
</StackPanel>
</Grid>

60
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}}">
<Page.Resources>
<ObjectDataProvider x:Key="PlatformProvider" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="cmodel:Platform"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<Style x:Key="textblockPropertyStyle" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,5,0"/>
</Style>
<Style x:Key="textboxValueStyle" TargetType="{x:Type b:BTextBox}">
<Style x:Key="textboxValueStyle" TargetType="{x:Type c:BTextBox}">
<Setter Property="Width" Value="150"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Height" Value="30"/>
@ -22,8 +31,17 @@
<Setter Property="BorderBrush" Value="{StaticResource TextBox.BorderBrush}"/>
</Style>
</Page.Resources>
<b:Interaction.Triggers>
<b:EventTrigger EventName="Loaded">
<b:InvokeCommandAction Command="{Binding LoadCommand}"/>
</b:EventTrigger>
<b:EventTrigger EventName="Unloaded">
<b:InvokeCommandAction Command="{Binding UnloadCommand}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
<Grid>
<Grid Margin="5,0" ShowGridLines="True">
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/>
<Grid Margin="5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
@ -38,16 +56,44 @@
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<TextBlock Text="管理密码" Style="{StaticResource textblockPropertyStyle}"/>
<b:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" IsEnabled="False"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"/>
<TextBlock Text="平台扣点" Style="{StaticResource textblockPropertyStyle}" Grid.Row="1"/>
<b:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="1"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="1" IsEnabled="False"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"/>
<TextBlock Text="采购平台" Style="{StaticResource textblockPropertyStyle}" Grid.Row="2"/>
<ComboBox ItemsSource="{Binding Source={StaticResource PlatformProvider}}"
Grid.Row="2" Grid.Column="1"
SelectedItem="{Binding PurchaseAccount.PurchasePlatformId}"
DisplayMemberPath="."
Height="25"
Width="150"
HorizontalAlignment="Left"
VerticalContentAlignment="Center"/>
<TextBlock Text="账号名称" Style="{StaticResource textblockPropertyStyle}" Grid.Row="3"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="3"
Text="{Binding PurchaseAccount.AccountName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="AppKey" Style="{StaticResource textblockPropertyStyle}" Grid.Row="4"/>
<c:BTextBox Grid.Column="1" Grid.Row="4"
Text="{Binding PurchaseAccount.AppKey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="AppSecret" Style="{StaticResource textblockPropertyStyle}" Grid.Row="5"/>
<c:BTextBox Grid.Column="1" Grid.Row="5"
Text="{Binding PurchaseAccount.AppSecret,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="AppToken" Style="{StaticResource textblockPropertyStyle}" Grid.Row="6"/>
<c:BTextBox Grid.Column="1" Grid.Row="6"
Text="{Binding PurchaseAccount.AppToken,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<c:BButton Content="保存" Grid.Column="1" Grid.Row="7" Width="80" HorizontalAlignment="Left"
Command="{Binding SaveCommand}"/>
</Grid>
</Grid>
</Page>

11
BBWY.Server.API/Controllers/VenderController.cs

@ -46,6 +46,17 @@ namespace BBWY.Server.API.Controllers
return venderBusiness.GetLogisticsList(platformRequest);
}
/// <summary>
/// 保存店铺设置
/// </summary>
/// <param name="shopSettingRequest"></param>
/// <returns></returns>
[HttpPost]
public long SaveShopSetting([FromBody] ShopSettingRequest shopSettingRequest)
{
return venderBusiness.SaveShopSetting(shopSettingRequest);
}
/// <summary>
/// 接收JD店铺Token更新
/// </summary>

11
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<RestApiService>();
services.AddSingleton<TaskSchedulerManager>();

3
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",

12
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; }
}
}

80
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<GlobalConfig> options) : base(restApiService, options)
private FreeSqlMultiDBManager freeSqlMultiDBManager;
private IIdGenerator idGenerator;
public VenderBusiness(FreeSqlMultiDBManager freeSqlMultiDBManager,
RestApiService restApiService,
IOptions<GlobalConfig> 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<string, string>() { { "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<PurchaseAccount>(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<Purchaseaccount>(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;
}
}
}

60
BBWY.Server.Model/Db/Mds/Purchaseaccount.cs

@ -0,0 +1,60 @@
using FreeSql.DataAnnotations;
using System;
namespace BBWY.Server.Model.Db.Mds
{
/// <summary>
/// 采购账号表
/// </summary>
[Table(Name = "purchaseaccount", DisableSyncStructure = true)]
public partial class Purchaseaccount {
/// <summary>
/// 主键
/// </summary>
[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; }
/// <summary>
/// 创建时间
/// </summary>
[Column(DbType = "datetime")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人Id
/// </summary>
[Column(StringLength = 50)]
public string CreatorId { get; set; }
/// <summary>
/// 否已删除
/// </summary>
[Column(DbType = "tinyint(4)")]
public sbyte Deleted { get; set; }
[Column(StringLength = 50)]
public string PurchasePlatformId { get; set; }
/// <summary>
/// 采购账号归属店铺ID
/// </summary>
[Column(StringLength = 50)]
public string ShopId { get; set; }
}
}

4
BBWY.Server.Model/Db/PurchaseScheme/PurchaseAccount.cs

@ -58,4 +58,8 @@ namespace BBWY.Server.Model.Db
}
}

2
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"

34
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; }
/// <summary>
/// 平台扣点
/// </summary>
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; }
}
}
Loading…
Cancel
Save