Browse Source

1

AddValidOverTime
506583276@qq.com 2 years ago
parent
commit
c308431625
  1. 10
      BBWY.Client/APIServices/BatchPurchaseService.cs
  2. 11
      BBWY.Client/APIServices/LogisticsService.cs
  3. 1
      BBWY.Client/App.xaml.cs
  4. 18
      BBWY.Client/Models/APIModel/Response/Logistics/StoreResponse.cs
  5. 16
      BBWY.Client/Models/Enums.cs
  6. 49
      BBWY.Client/Models/QiKu/PackSkuConfig.cs
  7. 22
      BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs
  8. 20
      BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs
  9. 105
      BBWY.Client/ViewModels/QiKu/PackSkuSplitConfigViewModel.cs
  10. 9
      BBWY.Client/ViewModels/ViewModelLocator.cs
  11. 6
      BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml
  12. 2
      BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml
  13. 137
      BBWY.Client/Views/BatchPurchase/PackSkuConfigWindow.xaml
  14. 44
      BBWY.Client/Views/BatchPurchase/PackSkuConfigWindow.xaml.cs
  15. 50
      BBWY.Client/Views/BatchPurchase/PackSkuSplitCountAndStoreWindow.xaml
  16. 64
      BBWY.Client/Views/BatchPurchase/PackSkuSplitCountAndStoreWindow.xaml.cs
  17. 2
      BBWY.Client/Views/MainWindow.xaml
  18. 12
      BBWY.Common/Extensions/CopyExtensions.cs
  19. 13
      BBWY.Server.API/Controllers/PurchaseOrderController.cs
  20. 13
      BBWY.Server.API/Controllers/PurchaseSchemeController.cs
  21. 14
      BBWY.Server.API/Controllers/VenderController.cs
  22. 5
      BBWY.Server.API/Startup.cs
  23. 4
      BBWY.Server.Business/PlatformSDK/QuanTanBusiness.cs
  24. 37
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  25. 112
      BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs
  26. 301
      BBWY.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs
  27. 112
      BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
  28. 20
      BBWY.Server.Business/Sync/StoreHouseSyncBusiness.cs
  29. 33
      BBWY.Server.Business/Vender/VenderBusiness.cs
  30. 16
      BBWY.Server.Model/Dto/Request/PurchaseOrder/Callback/BBWYBDelivertCallBackRequest.cs
  31. 2
      BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
  32. 9
      BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase/BatchPurchaseCreateOrderRequest.cs
  33. 10
      BBWY.Server.Model/Dto/Request/PurchaseScheme/BatchUpdateQTPurchaseSchemeBelongPurchaserRequest.cs
  34. 42
      BBWY.Server.Model/Dto/Request/PurchaseScheme/PurcasheSkuBasicInfoRequest.cs
  35. 37
      BBWY.Server.Model/Dto/Request/QiKu/PackSkuConfigRequest.cs
  36. 9
      BBWY.Server.Model/Dto/Request/Stock/StoreRequest.cs
  37. 58
      BBWY.Server.Model/Dto/Response/PurchaseScheme/PurchaseProductBasicInfoResponse.cs
  38. 9
      BBWY.Server.Model/Enums.cs
  39. 91
      BBWY.Test/Program.cs

10
BBWY.Client/APIServices/BatchPurchaseService.cs

@ -1,4 +1,5 @@
using BBWY.Client.Models;
using BBWY.Client.Models.QiKu;
using BBWY.Common.Http;
using BBWY.Common.Models;
using System;
@ -71,7 +72,8 @@ namespace BBWY.Client.APIServices
PurchaseOrderMode purchaseOrderMode,
IList<PurchaseAccount> purchaseAccountList,
string extensions,
string remark)
string remark,
IList<PackSkuConfig> packSkuConfigList)
{
var productParamList = new List<object>();
foreach (var productSkuWithScheme in productSkuWithSchemeList)
@ -93,8 +95,7 @@ namespace BBWY.Client.APIServices
BelongSkuTitle = productSkuWithScheme.Title,
BelongLogo = productSkuWithScheme.Logo,
BelongQuantity = productSkuWithScheme.Quantity,
BelongPurchaseSchemeId = productSkuWithScheme.PurchaseSchemeId,
BelongPurchaseSchemeId = productSkuWithScheme.PurchaseSchemeId
});
}
}
@ -109,7 +110,8 @@ namespace BBWY.Client.APIServices
remark,
autoPay,
globalContext.User.Shop.ShopId,
globalContext.User.Shop.ShopName
globalContext.User.Shop.ShopName,
packSkuConfigList
}, null, HttpMethod.Post);
}

11
BBWY.Client/APIServices/LogisticsService.cs

@ -20,5 +20,16 @@ namespace BBWY.Client.APIServices
globalContext.User.Shop.AppToken
}, null, HttpMethod.Post);
}
public ApiResponse<IList<StoreResponse>> GetStoreList()
{
return SendRequest<IList<StoreResponse>>(globalContext.BBYWApiHost, "api/vender/GetStoreHouseList", new
{
globalContext.User.Shop.Platform,
globalContext.User.Shop.AppKey,
globalContext.User.Shop.AppSecret,
globalContext.User.Shop.AppToken
}, null, HttpMethod.Post);
}
}
}

1
BBWY.Client/App.xaml.cs

@ -122,6 +122,7 @@ namespace BBWY.Client
serviceCollection.AddTransient<EditServiceOrderViewModel>();
serviceCollection.AddTransient<BatchPurchaseCreateNewOrderViewModel>();
serviceCollection.AddTransient<BatchPurchaseAddProductSkuViewModel>();
serviceCollection.AddTransient<PackSkuSplitConfigViewModel>();
#region 注册拳探SDK相关类
serviceCollection.AddSingleton<QuanTanProductClient>();

18
BBWY.Client/Models/APIModel/Response/Logistics/StoreResponse.cs

@ -0,0 +1,18 @@
using System;
namespace BBWY.Client.Models
{
public class StoreResponse
{
public DateTime? CreateTime { get; set; }
public string Id { get; set; }
public string Name { get; set; }
public Platform Platform { get; set; }
public StockStatus Status { get; set; }
public StockType Type { get; set; }
}
}

16
BBWY.Client/Models/Enums.cs

@ -402,6 +402,22 @@
= 2,
= 3
}
/// <summary>
/// 京东仓库类型 1商家仓 2京东仓
/// </summary>
public enum StockType
{
= 1, = 2
}
/// <summary>
/// 仓库状态 0暂停,1使用
/// </summary>
public enum StockStatus
{
= 0, 使 = 1
}
public enum PackCerState
{
= 0, = 1

49
BBWY.Client/Models/QiKu/PackSkuConfig.cs

@ -0,0 +1,49 @@
using System.Collections.ObjectModel;
namespace BBWY.Client.Models.QiKu
{
public class PackSkuConfig : NotifyObject
{
public PackSkuConfig()
{
PackSkuSplitConfigList = new ObservableCollection<PackSkuSplitConfig>();
}
private int splitCount;
private string remarkMessage;
public string SkuId { get; set; }
public string Logo { get; set; }
public string Title { get; set; }
/// <summary>
/// 采购数量
/// </summary>
public int PurchaseCount { get; set; }
/// <summary>
/// 分箱数量
/// </summary>
public int SplitCount { get => splitCount; set { Set(ref splitCount, value); } }
public string RemarkMessage { get => remarkMessage; set { Set(ref remarkMessage, value); } }
public ObservableCollection<PackSkuSplitConfig> PackSkuSplitConfigList { get; set; }
}
public class PackSkuSplitConfig : NotifyObject
{
private int packCount;
private StoreResponse store;
public int Index { get; set; }
public int PackCount { get => packCount; set { Set(ref packCount, value); } }
public StoreResponse Store { get => store; set { Set(ref store, value); } }
}
}

22
BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs

@ -1,5 +1,6 @@
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Client.Models.QiKu;
using BBWY.Client.Views.BatchPurchase;
using BBWY.Common.Trigger;
using GalaSoft.MvvmLight.Command;
@ -194,6 +195,22 @@ namespace BBWY.Client.ViewModels
return;
}
IList<PackSkuConfig> packSkuConfigList = null;
var isContainsQT = ProductSkuWithSchemeList.Any(ps => ps.PurchasePlatform == Platform.);
if (isContainsQT)
{
var packWindow = new PackSkuConfigWindow(ProductSkuWithSchemeList.Where(ps => ps.PurchasePlatform == Platform.).Select(ps => new PackSkuConfig()
{
Logo = ps.Logo,
SkuId = ps.SkuId,
Title = ps.Title,
PurchaseCount = ps.Quantity
}).ToList());
if (packWindow.ShowDialog() != true)
return;
packSkuConfigList = packWindow.GetPackSkuConfigList();
}
IsLoading = true;
Task.Factory.StartNew(() => batchPurchaseService.CreateOrder(ProductSkuWithSchemeList,
@ -211,7 +228,8 @@ namespace BBWY.Client.ViewModels
this.PurchaseOrderMode,
globalContext.User.Shop.PurchaseAccountList,
this.extensions,
this.PurchaseRemark)).ContinueWith(t =>
this.PurchaseRemark,
packSkuConfigList)).ContinueWith(t =>
{
IsLoading = false;
var response = t.Result;
@ -375,5 +393,7 @@ namespace BBWY.Client.ViewModels
if (purchaseSchemeProductSku.ItemTotal > 1)
purchaseSchemeProductSku.ItemTotal--;
}
}
}

20
BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs

@ -185,7 +185,7 @@ namespace BBWY.Client.ViewModels.PackTask
{
Set(ref isSetBarCode, value);
// IsNeedBarCode = IsSetBarCode ? Need.不需要 : Need.需要;
// IsNeedBarCode = IsSetBarCode ? Need.不需要 : Need.需要;
}
}
@ -199,7 +199,7 @@ namespace BBWY.Client.ViewModels.PackTask
{
Set(ref isSetCertificate, value);
//IsNeedCertificateModel = IsSetCertificate ? Need.不需要 : Need.需要;
//IsNeedCertificateModel = IsSetCertificate ? Need.不需要 : Need.需要;
}
}
private string setSpuCerStatus;
@ -330,7 +330,7 @@ namespace BBWY.Client.ViewModels.PackTask
{
return;
}
if (TaskId>0&&string.IsNullOrEmpty(SpuId))//修改界面刷新配置数据
if (TaskId > 0 && string.IsNullOrEmpty(SpuId))//修改界面刷新配置数据
{
SearchSku(SkuId);
}
@ -452,7 +452,7 @@ namespace BBWY.Client.ViewModels.PackTask
}
var productSku = packTaskService.GetProductSku(skuid);
if (productSku == null || !productSku.Success||productSku.Data==null)
if (productSku == null || !productSku.Success || productSku.Data == null)
return;
BrandName = productSku.Data.BrandName;
CertificateModel = productSku.Data.Cers;
@ -504,7 +504,7 @@ namespace BBWY.Client.ViewModels.PackTask
IsNeedCertificateModel = config.NeedCer ? Need. : Need.;
IsSetBarCode = !config.NeedBar;
IsSetCertificate =!config.NeedCer;
IsSetCertificate = !config.NeedCer;
bool isSelected = false;
foreach (var item in increates)
@ -533,7 +533,7 @@ namespace BBWY.Client.ViewModels.PackTask
return;
}
//加载配置文件
//加载配置文件
}
public void SearSpuCer()
@ -651,7 +651,7 @@ namespace BBWY.Client.ViewModels.PackTask
});
});
}
// SearchSku(SkuId);
// SearchSku(SkuId);
}
private void OpenSkuDetail(object param)
@ -713,14 +713,14 @@ namespace BBWY.Client.ViewModels.PackTask
SkuCount = SkuCount,
UserId = globalContext.User.Id.ToString(),
ShopId = globalContext.User.Shop.ShopId.ToString(),
NeedBar =IsNeedBarCode==Need.,
NeedCer =IsNeedCertificateModel==Need.
NeedBar = IsNeedBarCode == Need.,
NeedCer = IsNeedCertificateModel == Need.
//IsWorry = IsWorry
};
if (IsNeedBarCode == Need.)
{
if (BarCodeModel == null ||IsSetBarCode|| BarCodeModel.Id <= 0)
if (BarCodeModel == null || IsSetBarCode || BarCodeModel.Id <= 0)
{
new TipsWindow("请设置条形码模板").Show();
return;

105
BBWY.Client/ViewModels/QiKu/PackSkuSplitConfigViewModel.cs

@ -0,0 +1,105 @@
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Client.Models.QiKu;
using BBWY.Client.Views.BatchPurchase;
using GalaSoft.MvvmLight.Command;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class PackSkuSplitConfigViewModel : BaseVM
{
public IList<PackSkuConfig> PackSkuConfigList { get; set; }
private IList<StoreResponse> storeList;
public ICommand SetSplitCountCommand { get; set; }
public ICommand SetPackCountAndStoreCommand { get; set; }
public ICommand SaveCommand { get; set; }
private LogisticsService logisticsService;
public PackSkuSplitConfigViewModel(LogisticsService logisticsService)
{
this.logisticsService = logisticsService;
SetSplitCountCommand = new RelayCommand<PackSkuConfig>(SetSplitCount);
SetPackCountAndStoreCommand = new RelayCommand<PackSkuSplitConfig>(SetPackCountAndStore);
SaveCommand = new RelayCommand(Save);
PackSkuConfigList = new ObservableCollection<PackSkuConfig>();
}
public void SetData(IList<PackSkuConfig> packSkuConfigList)
{
foreach (var item in packSkuConfigList)
PackSkuConfigList.Add(item);
}
public IList<PackSkuConfig> GetPackSkuConfigList()
{
return PackSkuConfigList;
}
private void SetSplitCount(PackSkuConfig packSkuConfig)
{
if (packSkuConfig.SplitCount <= 0)
{
MessageBox.Show("份数不正确");
return;
}
packSkuConfig.PackSkuSplitConfigList.Clear();
for (var i = 1; i <= packSkuConfig.SplitCount; i++)
{
packSkuConfig.PackSkuSplitConfigList.Add(new PackSkuSplitConfig()
{
Index = i,
PackCount = 0
});
}
}
private void SetPackCountAndStore(PackSkuSplitConfig packSkuSplitConfig)
{
if (storeList == null)
{
var response = logisticsService.GetStoreList();
if (!response.Success)
{
MessageBox.Show(response.Msg, "获取仓库");
return;
}
storeList = response.Data;
}
var w = new PackSkuSplitCountAndStoreWindow(packSkuSplitConfig.PackCount, packSkuSplitConfig.Store, storeList);
if (w.ShowDialog() == true)
{
packSkuSplitConfig.PackCount = w.Quantity;
packSkuSplitConfig.Store = w.Store;
}
}
private void Save()
{
if (PackSkuConfigList.Any(s => s.PackSkuSplitConfigList.Count() == 0 ||
s.PackSkuSplitConfigList.Any(sp => sp.PackCount <= 0)))
{
MessageBox.Show("装箱设置不正确", "提示");
return;
}
if (PackSkuConfigList.Any(s => s.PurchaseCount != s.PackSkuSplitConfigList.Sum(sp => sp.PackCount)))
{
MessageBox.Show("打包份数总数与采购数量不相等", "提示");
return;
}
GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(true, "PackSkuConfigWindowClose");
}
}
}

9
BBWY.Client/ViewModels/ViewModelLocator.cs

@ -295,6 +295,15 @@ namespace BBWY.Client.ViewModels
}
}
public PackSkuSplitConfigViewModel PackSkuConfig
{
get
{
using var s = sp.CreateScope();
return s.ServiceProvider.GetRequiredService<PackSkuSplitConfigViewModel>();
}
}
public QualityViewModel QualityTask
{

6
BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml

@ -137,7 +137,7 @@
</TextBlock>
<TextBlock Margin="10,0,0,0">
<Run Text="数量:"/>
<Run Text="{Binding Quantity}"/>
<Run Text="{Binding Quantity,Mode=TwoWay}"/>
</TextBlock>
</StackPanel>
@ -237,7 +237,7 @@
Height="18"
Command="{Binding DataContext.SubtractQuantityCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"
CommandParameter="{Binding }"/>
<c:BTextBox Text="{Binding ItemTotal,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,0" VerticalAlignment="Center"
<c:BTextBox Text="{Binding ItemTotal,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,0" VerticalAlignment="Center"
Width="40" HorizontalContentAlignment="Center" Padding="0,0,3,0"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"/>
<c:BButton Content="+" Background="White" Foreground="Black"
@ -347,6 +347,8 @@
Command="{Binding PreviewOrderCommand}" Background="#1CC2A2"/>
<c:BButton Content="提交订单" Width="80" HorizontalAlignment="Right"
Command="{Binding FastCreateOrderCommand}" Margin="0,0,5,0"/>
<!--<c:BButton Content="下一步" Width="80" HorizontalAlignment="Right"
Command="{Binding NextCommand}" Margin="0,0,5,0"/>-->
</StackPanel>
</Grid>
</c:BWindow>

2
BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml

@ -202,7 +202,7 @@
<c:BButton Content="{Binding Id}" Style="{StaticResource LinkButton}"
Command="{Binding DataContext.CopyTextCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding Id}" Margin="5,0,0,0"/>
<c:BButton x:Name="btn_orderState" Content="{Binding OrderState}" Margin="5,0,0,0" Height="25" Padding="5,0" Background="{StaticResource Text.Link.Color}"/>
<c:BButton x:Name="btn_orderState" Content="{Binding OrderState}" Margin="5,0,0,0" Height="25" Padding="5,0" Background="{Binding OrderState,ConverterParameter=已取消:#EC808D:#02A7F0,Converter={StaticResource objConverter}}"/>
<Border Width="1" Margin="5,5,0,5" Background="{StaticResource Border.Brush}"/>
<StackPanel x:Name="txt_consignee" Margin="5,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="下单账号:"/>

137
BBWY.Client/Views/BatchPurchase/PackSkuConfigWindow.xaml

@ -0,0 +1,137 @@
<c:BWindow x:Class="BBWY.Client.Views.BatchPurchase.PackSkuConfigWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BBWY.Client.Views.BatchPurchase"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
Title="PackSkuConfigWindow" Height="500" Width="1024"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed"
Style="{StaticResource bwstyle}"
DataContext="{Binding PackSkuConfig,Source={StaticResource Locator}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
Background="{StaticResource Border.Background}">
<TextBlock Text="分箱与落仓" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ListBox x:Name="listbox"
ItemsSource="{Binding PackSkuConfigList}"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="1,0,0,0"
Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding ActualWidth,ElementName=listbox,Converter={StaticResource widthConverter},ConverterParameter=3}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!--{Binding Logo}-->
<c:BAsyncImage UrlSource="{Binding Logo}"
Width="130" DecodePixelWidth="130"
VerticalAlignment="Top" Margin="0,5,0,5"
Cursor="Hand"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0">
<Run Text="SKU:"/>
<Run Text="{Binding SkuId}"/>
</TextBlock>
<TextBlock VerticalAlignment="Center" Grid.Column="1" Margin="5,0,0,0">
<Run Text="采购数量:"/>
<Run Text="{Binding PurchaseCount}"/>
</TextBlock>
<TextBlock VerticalAlignment="Center" Margin="5,0,5,0" Grid.Row="1">
<Run Text="SKU名称:"/>
<Run Text="{Binding Title}"/>
</TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" Margin="5,0,0,0">
<TextBlock Text="份数:" VerticalAlignment="Center"/>
<c:BTextBox Text="{Binding SplitCount}" Width="40" Margin="5,0" Height="25"/>
<c:BButton Command="{Binding DataContext.SetSplitCountCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding }"
Content="设置"
Style="{StaticResource LinkButton}"/>
</StackPanel>
<ListBox Grid.Row="2" Grid.ColumnSpan="2"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
BorderThickness="1,1,0,1"
BorderBrush="{StaticResource Border.Brush}"
ItemsSource="{Binding PackSkuSplitConfigList}"
Width="Auto"
Margin="5,0,0,6"
HorizontalAlignment="Left"
Visibility="{Binding SplitCount,ConverterParameter=0:Collapsed:Visible,Converter={StaticResource objConverter}}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="120" Height="80">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Index,StringFormat=第\{0\}份}" Style="{StaticResource middleTextBlock}"/>
<c:BButton Content="设置" Style="{StaticResource LinkButton}" Grid.Row="1"
Command="{Binding DataContext.SetPackCountAndStoreCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"
CommandParameter="{Binding }"/>
<TextBlock Grid.Row="2" Style="{StaticResource middleTextBlock}">
<Run Text="{Binding PackCount,StringFormat=\{0\}件}"/>
<Run Text="{Binding Store.Name}"/>
</TextBlock>
<Border Width="1" Grid.RowSpan="3" HorizontalAlignment="Right"
Background="{StaticResource Border.Brush}"/>
<Border Height="1" Background="{StaticResource Border.Brush}"
VerticalAlignment="Bottom"/>
<Border Height="1" Background="{StaticResource Border.Brush}"
VerticalAlignment="Bottom" Grid.Row="1"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<c:BTextBox Grid.Row="3" Text="{Binding RemarkMessage,Mode=TwoWay}" WaterRemark="打包备注" AcceptsReturn="True" TextWrapping="Wrap" Grid.ColumnSpan="2" Height="70" Margin="5"/>
</Grid>
<Border Grid.ColumnSpan="2" VerticalAlignment="Bottom" Height="1" Background="{StaticResource Border.Brush}"/>
<Border HorizontalAlignment="Right" Width="1" Background="{StaticResource Border.Brush}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<c:BButton Content="提交订单" Width="80" HorizontalAlignment="Right" Grid.Row="2"
Command="{Binding SaveCommand}" Margin="0,0,5,0"/>
</Grid>
</c:BWindow>

44
BBWY.Client/Views/BatchPurchase/PackSkuConfigWindow.xaml.cs

@ -0,0 +1,44 @@
using BBWY.Client.Models.QiKu;
using BBWY.Client.ViewModels;
using BBWY.Controls;
using System.Collections.Generic;
namespace BBWY.Client.Views.BatchPurchase
{
/// <summary>
/// PackSkuConfigWindow.xaml 的交互逻辑
/// </summary>
public partial class PackSkuConfigWindow : BWindow
{
private PackSkuSplitConfigViewModel vm;
public PackSkuConfigWindow(IList<PackSkuConfig> list)
{
InitializeComponent();
vm = this.DataContext as PackSkuSplitConfigViewModel;
vm.SetData(list);
this.Loaded += PackSkuConfigWindow_Loaded;
this.Unloaded += PackSkuConfigWindow_Unloaded;
}
private void PackSkuConfigWindow_Unloaded(object sender, System.Windows.RoutedEventArgs e)
{
GalaSoft.MvvmLight.Messaging.Messenger.Default.Unregister(this);
}
private void PackSkuConfigWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<bool>(this, "PackSkuConfigWindowClose", (r) =>
{
this.DialogResult = r;
this.Close();
});
}
public IList<PackSkuConfig> GetPackSkuConfigList()
{
return vm.GetPackSkuConfigList();
}
}
}

50
BBWY.Client/Views/BatchPurchase/PackSkuSplitCountAndStoreWindow.xaml

@ -0,0 +1,50 @@
<c:BWindow x:Class="BBWY.Client.Views.BatchPurchase.PackSkuSplitCountAndStoreWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BBWY.Client.Views.BatchPurchase"
mc:Ignorable="d"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
Title="PackSkuSplitCountAndStoreWindow" Height="160" Width="250"
Style="{StaticResource bwstyle}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="5"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
Background="{StaticResource Border.Background}"
Grid.ColumnSpan="2">
<TextBlock Text="装箱设置" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<TextBlock Text="件数:" HorizontalAlignment="Right" VerticalAlignment="Center"
Grid.Row="2"/>
<c:BTextBox x:Name="txtQuantity" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center"
Margin="5,0,10,0"/>
<TextBlock Text="落仓去向:" HorizontalAlignment="Right" VerticalAlignment="Center"
Grid.Row="3"/>
<ComboBox x:Name="cbx_stroeList" Grid.Row="3" Grid.Column="1" Height="30"
Margin="5,0,10,0"
DisplayMemberPath="Name"
VerticalContentAlignment="Center"/>
<c:BButton x:Name="btn_save" Content="保存" Width="80" HorizontalAlignment="Right" Grid.Row="4"
Margin="0,0,5,0" Click="btn_save_Click"
Grid.Column="1"/>
</Grid>
</c:BWindow>

64
BBWY.Client/Views/BatchPurchase/PackSkuSplitCountAndStoreWindow.xaml.cs

@ -0,0 +1,64 @@
using BBWY.Client.Models;
using BBWY.Controls;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace BBWY.Client.Views.BatchPurchase
{
/// <summary>
/// PackSkuSplitCountAndStoreWindow.xaml 的交互逻辑
/// </summary>
public partial class PackSkuSplitCountAndStoreWindow : BWindow
{
public int Quantity { get; set; }
public StoreResponse Store { get; set; }
private IList<StoreResponse> storeList;
public PackSkuSplitCountAndStoreWindow(int quantity, StoreResponse store, IList<StoreResponse> storeList)
{
InitializeComponent();
this.Quantity = quantity;
this.Store = store;
this.storeList = storeList;
this.Loaded += PackSkuSplitCountAndStoreWindow_Loaded;
}
private void PackSkuSplitCountAndStoreWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
this.txtQuantity.Text = Quantity.ToString();
this.cbx_stroeList.ItemsSource = storeList;
if (Store != null)
this.cbx_stroeList.SelectedItem = storeList.FirstOrDefault(s => s.Id == Store.Id);
else
this.cbx_stroeList.SelectedItem = storeList.FirstOrDefault();
}
private void btn_save_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (!int.TryParse(txtQuantity.Text, out int q))
{
MessageBox.Show("件数不正确", "提示");
return;
}
if (q <= 0)
{
MessageBox.Show("件数不正确", "提示");
return;
}
if (cbx_stroeList.SelectedItem == null)
{
MessageBox.Show("请选择一个仓库", "提示");
return;
}
this.Quantity = q;
this.Store = cbx_stroeList.SelectedItem as StoreResponse;
this.DialogResult = true;
this.Close();
}
}
}

2
BBWY.Client/Views/MainWindow.xaml

@ -26,7 +26,7 @@
<!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>-->
<TextBlock Text="{Binding GlobalContext.User.Shop.ShopName}" Margin="5,0,0,0"/>
<TextBlock Text="v10106" Margin="5,0,0,0"/>
<TextBlock Text="v10107" Margin="5,0,0,0"/>
</StackPanel>
</Border>
<Grid Grid.Row="1">

12
BBWY.Common/Extensions/CopyExtensions.cs

@ -0,0 +1,12 @@
using Newtonsoft.Json;
namespace BBWY.Common.Extensions
{
public static class CopyExtensions
{
public static T Copy<T>(this T p)
{
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(p));
}
}
}

13
BBWY.Server.API/Controllers/PurchaseOrderController.cs

@ -105,9 +105,20 @@ namespace BBWY.Server.API.Controllers
/// <param name="request"></param>
[HttpPost]
[AllowAnonymous]
public void QuanTanEditPriceCallback(QuanTanEditPriceNotifyRequest request)
public void QuanTanEditPriceCallback([FromBody] QuanTanEditPriceNotifyRequest request)
{
purchaseOrderBusiness.QuanTanEditPriceCallback(request);
}
/// <summary>
/// 签收采购单
/// </summary>
/// <param name="request"></param>
[HttpPost]
[AllowAnonymous]
public void SignPurchaseOrder([FromBody] BBWYBSignCallBackRequest request)
{
purchaseOrderBusiness.SignPurchaseOrder(request);
}
}
}

13
BBWY.Server.API/Controllers/PurchaseSchemeController.cs

@ -9,7 +9,7 @@ using System.Collections.Generic;
namespace BBWY.Server.API.Controllers
{
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
//[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class PurchaseSchemeController : BaseApiController
{
private PurchaseSchemeBusiness purchaseSchemeBusiness;
@ -70,5 +70,16 @@ namespace BBWY.Server.API.Controllers
{
return purchaseSchemeBusiness.GetSharePurchaser(querySchemeRequest);
}
/// <summary>
/// 批量修改拳探采购方案归属采购商
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<string> BatchUpdateQTPurchaseSchemeBelongPurchaser([FromBody]BatchUpdateQTPurchaseSchemeBelongPurchaserRequest request)
{
return purchaseSchemeBusiness.BatchUpdateQTPurchaseSchemeBelongPurchaser(request);
}
}
}

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

@ -1,5 +1,6 @@
using BBWY.Common.Models;
using BBWY.Server.Business;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
@ -109,9 +110,20 @@ namespace BBWY.Server.API.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<WaiterResponse> GetServiceGroupList([FromBody]PlatformRequest request)
public IList<WaiterResponse> GetServiceGroupList([FromBody] PlatformRequest request)
{
return venderBusiness.GetServiceGroupList(request);
}
/// <summary>
/// 获取店铺关联的仓库列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<Storehouse> GetStoreHouseList([FromBody] PlatformRequest request)
{
return venderBusiness.GetStoreHouseList(request);
}
}
}

5
BBWY.Server.API/Startup.cs

@ -13,6 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json.Serialization;
using QuanTan.SDK.Client;
using System;
using System.IO;
using System.Linq;
@ -83,6 +84,10 @@ namespace BBWY.Server.API
services.AddSingleton<PlatformSDKBusiness, JDBusiness>();
services.AddSingleton<PlatformSDKBusiness, _1688Business>();
services.AddSingleton<PlatformSDKBusiness, QuanTanBusiness>();
#region 注册拳探SDK相关类
services.AddSingleton<QuanTanProductClient>();
#endregion
//var stores = Configuration.GetSection("Stores").Get<IList<Store>>();
services.Configure<GlobalConfig>(Configuration.GetSection("GlobalSetting"));

4
BBWY.Server.Business/PlatformSDK/QuanTanBusiness.cs

@ -29,7 +29,7 @@ namespace BBWY.Server.Business
orderId = payPurchaseOrderRequest.OrderId,
userAccount = payPurchaseOrderRequest.AppToken
}, payPurchaseOrderRequest.AppKey, payPurchaseOrderRequest.AppSecret);
if (qtResponse.Status == 200) return new PayPurchaseOrderResponse { Success = true, PurchaseOrderState= PurchaseOrderState. };
if (qtResponse.Status == 200) return new PayPurchaseOrderResponse { Success = true, PurchaseOrderState = PurchaseOrderState. };
if (qtResponse.Message != null && qtResponse.Message.Contains("已支付"))
{
@ -163,7 +163,7 @@ namespace BBWY.Server.Business
extended = JsonConvert.SerializeObject(new
{
BuyerAccount = createOnlinePurchaseOrderRequest.AppToken,
createOnlinePurchaseOrderRequest.SourceSku,
BelongSkus = createOnlinePurchaseOrderRequest.SourceSku,
createOnlinePurchaseOrderRequest.SourceShopName
})
};

37
BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -369,7 +369,7 @@ namespace BBWY.Server.Business
#region CallBack
#region 1688CallBack
#region 1688 CallBack
public void CallbackFrom1688(string jsonStr)
{
nLogManager.Default().Info(jsonStr);
@ -415,7 +415,7 @@ namespace BBWY.Server.Business
}
#endregion
#region 拳探回调
#region QuanTan Callback
public void QuanTanSendGoodsCallback(QuanTanSendGoodsNotifyRequest request)
{
Task.Factory.StartNew(() => DeliveryCallback(request.OrderId, new WayBillNoResponse()
@ -425,12 +425,12 @@ namespace BBWY.Server.Business
WayBillNo = request.WayBillNo,
}, Enums.Platform.), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler);
//Task.Factory.StartNew(() => DeliveryCallbackForPurchaseOrder(request.OrderId, new WayBillNoResponse()
//{
// LogisticsCompanyId = request.ExpressId,
// LogisticsCompanyName = request.ExpressName,
// WayBillNo = request.WayBillNo,
//}, Enums.Platform.拳探), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler);
Task.Factory.StartNew(() => DeliveryCallbackForPurchaseOrder(request.OrderId, new WayBillNoResponse()
{
LogisticsCompanyId = request.ExpressId,
LogisticsCompanyName = request.ExpressName,
WayBillNo = request.WayBillNo,
}, Enums.Platform.), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler);
}
public void QuanTanEditPriceCallback(QuanTanEditPriceNotifyRequest request)
@ -442,6 +442,19 @@ namespace BBWY.Server.Business
}
#endregion
#region bbwyb Callback
public void SignPurchaseOrder(BBWYBSignCallBackRequest request)
{
var pv2 = fsql.Select<PurchaseOrderV2>(request.OrderId).ToOne();
if (pv2.OrderState == Enums.PurchaseOrderState.)
{
fsql.Update<PurchaseOrderV2>(request.OrderId).Set(p => p.OrderState, Enums.PurchaseOrderState.)
.Set(p => p.SignTime, DateTime.Now)
.ExecuteAffrows();
}
}
#endregion
/// <summary>
/// 采购平台发货回调(一件代发)
/// </summary>
@ -572,6 +585,14 @@ namespace BBWY.Server.Business
if (purchaseOrderV2 == null)
throw new Exception("未查询到采购单信息");
fsql.Update<PurchaseOrderV2>(purchaseOrderId).SetIf(purchaseOrderV2.OrderState == Enums.PurchaseOrderState. ||
purchaseOrderV2.OrderState == Enums.PurchaseOrderState.,
p => p.OrderState, Enums.PurchaseOrderState.)
.Set(p => p.ExpressName, wayBillNoResponse.LogisticsCompanyName)
.Set(p => p.WaybillNo, wayBillNoResponse.WayBillNo)
.ExecuteAffrows();
}
catch (Exception ex)
{

112
BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs

@ -1,4 +1,5 @@
using BBWY.Common.Models;
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Db.QK;
@ -9,6 +10,8 @@ using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -19,18 +22,19 @@ namespace BBWY.Server.Business
{
private ProductBusiness productBusiness;
private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
//private TaskSchedulerManager taskSchedulerManager;
private RestApiService restApiService;
public BatchPurchaseBusiness(IFreeSql fsql,
NLogManager nLogManager,
IIdGenerator idGenerator,
ProductBusiness productBusiness,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator)
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
RestApiService restApiService) : base(fsql, nLogManager, idGenerator)
{
this.productBusiness = productBusiness;
this.platformSDKBusinessList = platformSDKBusinessList;
this.restApiService = restApiService;
}
/// <summary>
@ -218,6 +222,7 @@ namespace BBWY.Server.Business
var successSkuIdList = new List<string>();
var failSkuList = new List<BatchCreareOrderFailDetail>();
var qikuPackSkuConfigRequestList = new List<object>();
var extJArray = JsonConvert.DeserializeObject<JArray>(request.Extensions);
var purchaseGroups = request.ProductParamList.GroupBy(p => p.PurchaserId);
@ -242,6 +247,19 @@ namespace BBWY.Server.Business
else if (purchasePlatform == Enums.Platform.)
tradeMode = extJson.Value<string>("OrderTradeTypeCode");
#region 处理JD SKU和拳探SKU的对应关系
var belongSkus_mappingList = new List<JObject>();
foreach (var belongSkuGroup in belongSkuGroups)
{
var firstProductParam = belongSkuGroup.FirstOrDefault();
if (!belongSkus_mappingList.Any(j => j.Value<string>("BelongSkuId") == firstProductParam.BelongSkuId))
{
belongSkus_mappingList.Add(JObject.FromObject(new { firstProductParam.BelongSkuId, SkuId = firstProductParam.PurchaseSkuId }));
}
}
#endregion
var createOrderResponse = platformSDKBusinessList.FirstOrDefault(p => p.Platform == purchasePlatform)
.FastCreateOrder(new CreateOnlinePurchaseOrderRequest()
{
@ -253,7 +271,7 @@ namespace BBWY.Server.Business
PurchaseOrderMode = request.PurchaseOrderMode,
Remark = request.Remark,
SourceShopName = request.ShopName,
SourceSku = string.Join(",", belongSkuGroups.Select(g => g.Key)),
SourceSku = belongSkus_mappingList,
CargoParamList = productParamList.Select(p => new CargoParamRequest()
{
ProductId = p.PurchaseProductId,
@ -279,6 +297,10 @@ namespace BBWY.Server.Business
List<long> updatePurchaseTimeSchemeIdList = productParamList.Select(p => p.BelongPurchaseSchemeId).Distinct().ToList();
List<PurchaseOrderSku> insertPurchaseOrderSkuList = new List<PurchaseOrderSku>();
List<object> skuPackConfigList = null;
if (purchasePlatform == Enums.Platform.)
skuPackConfigList = new List<object>();
foreach (var belongSkuGroup in belongSkuGroups)
{
var firstProductParam = belongSkuGroup.FirstOrDefault();
@ -308,6 +330,29 @@ namespace BBWY.Server.Business
CreateTime = DateTime.Now
};
insertPurchaseOrderSkuList.Add(purchaseOrderSku);
if (purchasePlatform == Enums.Platform.)
{
var skuPackConfig = request.PackSkuConfigList?.FirstOrDefault(s => s.SkuId == firstProductParam.BelongSkuId);
if (skuPackConfig != null)
{
skuPackConfigList.Add(new
{
skuId = firstProductParam.BelongSkuId,
skuCount = skuPackConfig.PurchaseCount,
markMessage = skuPackConfig.RemarkMessage,
wareHourses = skuPackConfig.PackSkuSplitConfigList.Select(x => new
{
wareId = x.Store.Id,
wareName = x.Store.Name,
count = x.PackCount
})
});
}
}
}
var purchaseOrderV2 = new PurchaseOrderV2()
@ -345,6 +390,20 @@ namespace BBWY.Server.Business
fsql.Update<PurchaseScheme>(updatePurchaseTimeSchemeIdList).Set(p => p.LastPurchaseTime, DateTime.Now).ExecuteAffrows();
});
successSkuIdList.AddRange(belongSkuGroups.Select(g => g.Key));
if (purchasePlatform == Enums.Platform.)
{
qikuPackSkuConfigRequestList.Add(new
{
orderId = purchaseOrderV2.Id,
//shopId = request.ShopId.ToString(),
shopId = purchaseGroup.Key, //拳探店铺Id(商家Id)
originShopName = request.ShopName,
userName = purchaseAccount.AccountName,
platform = Enums.Platform.,
purchaseTaskModels = skuPackConfigList
});
}
}
catch (Exception ex)
{
@ -357,6 +416,30 @@ namespace BBWY.Server.Business
}
}
if (qikuPackSkuConfigRequestList.Count() > 0)
{
Task.Factory.StartNew(() =>
{
foreach (var qikuPackSkuConfigRequest in qikuPackSkuConfigRequestList)
{
try
{
var qikuResponse = restApiService.SendRequest("http://qiku.qiyue666.com/",
"api/PackPurchaseTask/BatchPublicPurchaseTask",
qikuPackSkuConfigRequest,
null,
HttpMethod.Post);
if (qikuResponse.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception(qikuResponse.Content);
}
catch (Exception ex)
{
nLogManager.GetLogger($"发布打包任务-{request.ShopName}").Error(ex, JsonConvert.SerializeObject(qikuPackSkuConfigRequest));
}
}
});
}
return new BatchCreareOrderResponse()
{
FailSkuList = failSkuList,
@ -466,12 +549,27 @@ namespace BBWY.Server.Business
var platformSDKBusiness = platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform);
var payOrderResponse = platformSDKBusiness.CancelPurchaseOrder(request);
if (payOrderResponse.Success)
if (payOrderResponse.Success)//取消成功
{
//var order = fsql.Select<PurchaseOrderV2>().Where(p => p.Id == request.OrderId).ToOne();
fsql.Update<PurchaseOrderV2>(request.OrderId)
.Set(po => po.OrderState, Enums.PurchaseOrderState.)
.ExecuteAffrows();
try
{
var qikuResponse = restApiService.SendRequest("http://qiku.qiyue666.com/",
$"/api/PackPurchaseTask/CancelOrderPackTask?orderId={request.OrderId}",
null,
null,
HttpMethod.Post);
if (qikuResponse.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception(qikuResponse.Content);
}
catch (Exception ex)
{
nLogManager.GetLogger($"取消打包任务-{request.OrderId}").Error(ex, JsonConvert.SerializeObject(request));
}
}

301
BBWY.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs

@ -0,0 +1,301 @@
using BBWY.Common.Extensions;
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json.Linq;
using QuanTan.SDK.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
namespace BBWY.Server.Business
{
public class PurchaseProductAPIService : IDenpendency
{
private RestApiService restApiService;
private IMemoryCache memoryCache;
private string oneBoundKey = "t5060712539";
private string oneBoundSecret = "20211103";
private string qtAppId = "BBWY2023022001";
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe";
private TimeSpan purchaseProductCacheTimeSpan;
//private TimeSpan _1688SessionIdTimeSpan;
//private ConcurrentDictionary<string, (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)> productChaches;
private IDictionary<string, string> _1688ProductDetailRequestHeader;
private char[] skuPropertiesSplitChar = new char[] { ';' };
private QuanTanProductClient quanTanProductClient;
public PurchaseProductAPIService(RestApiService restApiService, IMemoryCache memoryCache, QuanTanProductClient quanTanProductClient)
{
this.memoryCache = memoryCache;
this.restApiService = restApiService;
_1688ProductDetailRequestHeader = new Dictionary<string, string>()
{
{ "Host","detail.1688.com"},
{ "User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70"},
{ "Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"},
{ "Accept-Encoding","gzip, deflate, br"},
{ "Accept-Language","zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"}
};
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1);
this.quanTanProductClient = quanTanProductClient;
}
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request)
{
var cacheKey = $"{request.PurchaseProductId}_{request.PriceMode}";
if (memoryCache.TryGetValue<PurchaseSkuBasicInfoResponse>(cacheKey, out var tuple))
return tuple.Copy();
PurchaseSkuBasicInfoResponse response = null;
if (request.FirstApiMode == Enums.PurchaseProductAPIMode.Spider)
{
response = LoadFromSpider(request);
if (response == null)
response = LoadFromOneBound(request);
}
else if (request.FirstApiMode == Enums.PurchaseProductAPIMode.OneBound)
{
response = LoadFromOneBound(request);
if (response == null)
response = LoadFromSpider(request);
}
if (response != null)
{
try
{
memoryCache.Set(cacheKey, response, purchaseProductCacheTimeSpan);
}
catch { }
}
return response?.Copy();
}
private PurchaseSkuBasicInfoResponse LoadFromOneBound(PurchaseSkuBasicInfoRequest request)
{
try
{
string platformStr = string.Empty;
if (request.Platform == Enums.Platform.)
platformStr = "1688";
if (string.IsNullOrEmpty(platformStr))
return null;
var result = restApiService.SendRequest("https://api-gw.onebound.cn/", $"{platformStr}/item_get", $"key={oneBoundKey}&secret={oneBoundSecret}&num_iid={request.PurchaseProductId}&lang=zh-CN&cache=no&agent={(request.PriceMode == Enums.PurchaseOrderMode.批发 ? 0 : 1)}", null, HttpMethod.Get, paramPosition: ParamPosition.Query, enableRandomTimeStamp: true);
if (result.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"{result.StatusCode} {result.Content}");
var jobject = JObject.Parse(result.Content);
var isOK = jobject.Value<string>("error_code") == "0000";
if (isOK)
{
var skuJArray = (JArray)jobject["item"]["skus"]["sku"];
if (skuJArray.Count == 0)
{
//errorMsg = $"商品{purchaseSchemeProduct.PurchaseProductId}缺少sku信息";
return null;
}
var list = skuJArray.Select(j => new PurchaseSkuItemBasicInfoResponse()
{
PurchaseProductId = request.PurchaseProductId,
Price = j.Value<decimal>("price"),
PurchaseSkuId = j.Value<string>("sku_id"),
PurchaseSkuSpecId = j.Value<string>("spec_id"),
Title = j.Value<string>("properties_name"),
Logo = GetOneBoundSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"])
}).ToList();
var purchaserId = jobject["item"]["seller_info"].Value<string>("user_num_id");
var purchaserName = jobject["item"]["seller_info"].Value<string>("title");
if (string.IsNullOrEmpty(purchaserName))
purchaserName = jobject["item"]["seller_info"].Value<string>("shop_name");
var purchaserLocation = jobject["item"].Value<string>("location");
return new PurchaseSkuBasicInfoResponse()
{
Purchaser = new Model.Db.Purchaser()
{
Id = purchaserId,
Location = purchaserLocation,
Name = purchaserName,
Platform = request.Platform
},
ItemList = list,
PurchasePlatform = request.Platform,
PurchaseProductId = request.PurchaseProductId
};
}
}
catch { }
{
return null;
}
}
private string GetOneBoundSkuLogo(JToken skuJToken, JArray prop_img)
{
if (!prop_img.HasValues)
return "pack://application:,,,/Resources/Images/defaultItem.png";
var properties = skuJToken.Value<string>("properties").Split(skuPropertiesSplitChar, StringSplitOptions.RemoveEmptyEntries);
foreach (var p in properties)
{
var imgJToken = prop_img.FirstOrDefault(g => g.Value<string>("properties") == p);
if (imgJToken != null)
return imgJToken.Value<string>("url");
}
return "pack://application:,,,/Resources/Images/defaultItem.png";
}
private PurchaseSkuBasicInfoResponse LoadFromSpider(PurchaseSkuBasicInfoRequest request)
{
switch (request.Platform)
{
case Enums.Platform.:
return LoadFrom1688Spider(request);
case Enums.Platform.:
return LoadFromQTSpider(request);
}
return null;
}
private PurchaseSkuBasicInfoResponse LoadFrom1688Spider(PurchaseSkuBasicInfoRequest request)
{
//https://detail.1688.com/offer/672221374773.html?clickid=65f3772cd5d16f190ce4991414607&sessionid=3de47a0c26dcbfde4692064bd55861&sk=order
//globalData/tempModel/sellerUserId
//globalData/tempModel/companyName
//data/1081181309101/data/location
//data/1081181309582/data/pirceModel/[currentPrices]/[0]price
try
{
var _1688pageResult = restApiService.SendRequest("https://detail.1688.com",
$"offer/{request.PurchaseProductId}.html",
$"clickid={Guid.NewGuid().ToString().Md5Encrypt()}&sessionid={Guid.NewGuid().ToString().Md5Encrypt()}&sk={(request.PriceMode == Enums.PurchaseOrderMode.批发 ? "order" : "consign")}",
_1688ProductDetailRequestHeader,
HttpMethod.Get,
httpClientName: "gzip");
if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK)
return null;
var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA=)(.*)(\r*\n*\s*</script>)");
if (!match.Success)
return null;
var jsonStr = match.Groups[2].Value;
var jobject = JObject.Parse(jsonStr);
//16347413030323
var purchaser = new Purchaser()
{
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(),
Name = jobject["globalData"]["tempModel"]["companyName"].ToString(),
Location = jobject["data"]["1081181309101"] != null ?
jobject["data"]["1081181309101"]["data"]["location"].ToString() :
jobject["data"]["16347413030323"]["data"]["location"].ToString(),
Platform = Enums.Platform.
};
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 ||
j.Value<int>("fid") == 1627207 ||
j.Value<int>("fid") == 1234 ||
j.Value<int>("fid") == 3151)["value"]
.Children()
.Select(j => new
{
name = j.Value<string>("name"),
imageUrl = j.Value<string>("imageUrl")
}).ToList();
var firstPrice = jobject["data"]["1081181309582"] != null ?
jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") :
jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
var list = new List<PurchaseSkuItemBasicInfoResponse>();
foreach (var jsku in jobject["globalData"]["skuModel"]["skuInfoMap"].Children())
{
var jskuProperty = jsku as JProperty;
var name = jskuProperty.Name;
var matchName = name.Contains("&gt;") ? name.Substring(0, name.IndexOf("&gt;")) : name;
var value = jskuProperty.Value;
var skuPrice = value.Value<decimal>("price");
list.Add(new PurchaseSkuItemBasicInfoResponse()
{
PurchaseProductId = request.PurchaseProductId,
Price = skuPrice == 0M ? firstPrice : skuPrice,
Title = name,
PurchaseSkuId = value.Value<string>("skuId"),
PurchaseSkuSpecId = value.Value<string>("specId"),
Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png"
});
}
return new PurchaseSkuBasicInfoResponse()
{
ItemList = list,
Purchaser = purchaser,
PurchaseProductId = request.PurchaseProductId,
PurchasePlatform = Enums.Platform.
};
}
catch
{
return null;
}
}
private PurchaseSkuBasicInfoResponse LoadFromQTSpider(PurchaseSkuBasicInfoRequest request)
{
try
{
var response = quanTanProductClient.GetProductInfo(request.PurchaseProductId, qtAppId, qtAppSecret);
if (response.Status != 200)
return null;
return new PurchaseSkuBasicInfoResponse()
{
Purchaser = new Purchaser()
{
Id = response.Data.Supplier.VenderId,
Name = response.Data.Supplier.VerdenName,
Location = response.Data.Supplier.Location
},
PurchaseProductId = request.PurchaseProductId,
PurchasePlatform = Enums.Platform.,
ItemList = response.Data.ProductSku.Select(s => new PurchaseSkuItemBasicInfoResponse()
{
Logo = s.Logo,
Price = s.Price,
PurchaseProductId = s.ProductId,
PurchaseSkuId = s.SkuId,
Title = s.Title
}).ToList()
};
}
catch
{
return null;
}
}
}
}

112
BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs

@ -1,7 +1,9 @@
using BBWY.Common.Extensions;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using FreeSql;
using System;
using System.Collections.Generic;
using System.Linq;
@ -11,7 +13,11 @@ namespace BBWY.Server.Business
{
public class PurchaseSchemeBusiness : BaseBusiness, IDenpendency
{
public PurchaseSchemeBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator) { }
private PurchaseProductAPIService purchaseProductAPIService;
public PurchaseSchemeBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, PurchaseProductAPIService purchaseProductAPIService) : base(fsql, nLogManager, idGenerator)
{
this.purchaseProductAPIService = purchaseProductAPIService;
}
private void ExtractNewPurchaser<T>(IList<T> purchaserSchemeList, IList<Purchaser> addPurchaserList) where T : InputPurchaseSchemeRequest
{
@ -223,7 +229,7 @@ namespace BBWY.Server.Business
var purchaserList = fsql.Select<Purchaser>().Where(p => sharePurchaserIdList.Contains(p.Id)).ToList();
foreach (var p in purchaserList)
{
var scheme = purchaseSchemeList.FirstOrDefault(ps=>ps.PurchaserId == p.Id);
var scheme = purchaseSchemeList.FirstOrDefault(ps => ps.PurchaserId == p.Id);
if (scheme != null)
{
p.DefaultCost = scheme.DefaultCost;
@ -255,5 +261,107 @@ namespace BBWY.Server.Business
fsql.Delete<PurchaseSchemeProductSku>().Where(p => p.SkuPurchaseSchemeId == schemeId).ExecuteAffrows();
});
}
/// <summary>
/// 获取采购Sku的基本信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public PurchaseSkuBasicInfoResponse GetPurchaseSkuBasicInfo(PurchaseSkuBasicInfoRequest request)
{
return purchaseProductAPIService.GetProductInfo(request);
}
public IList<PurchaseSkuBasicInfoResponse> BatchGetPurchaseSkuBasicInfo(BatchPurchaseSkuBasicInfoRequest request)
{
var list = new List<PurchaseSkuBasicInfoResponse>();
foreach (var param in request.Params)
{
foreach (var purchaseId in param.PurchaseProductIds)
{
var response = GetPurchaseSkuBasicInfo(new PurchaseSkuBasicInfoRequest()
{
FirstApiMode = request.FirstApiMode,
PriceMode = request.PriceMode,
Platform = param.Platform,
PurchaseProductId = purchaseId
});
if (response != null)
{
if (param.PurchaseSkuIds != null && param.PurchaseSkuIds.Count() > 0)
{
for (var i = 0; i < response.ItemList.Count(); i++)
{
var skuInfo = response.ItemList[i];
if (!param.PurchaseSkuIds.Any(s => s == skuInfo.PurchaseSkuId))
{
response.ItemList.RemoveAt(i);
i--;
}
}
}
list.Add(response);
}
}
}
return list;
}
/// <summary>
/// 批量修改拳探采购方案归属采购商
/// </summary>
/// <param name="request">修改成功的拳探skuId</param>
/// <returns></returns>
public IList<string> BatchUpdateQTPurchaseSchemeBelongPurchaser(BatchUpdateQTPurchaseSchemeBelongPurchaserRequest request)
{
var purchaseSchemeList = GetPurchaseSchemeList(new QuerySchemeRequest()
{
PurchasePlatform = Enums.Platform.,
PurchaserId = request.PurchaserId
});
var qtPurchaserList = fsql.Select<Purchaser>().Where(p => p.Platform == Enums.Platform.).ToList();
IList<string> updateSkuChangeInfoList = new List<string>();
IList<IUpdate<PurchaseScheme>> updatePurchaseSchemeList = new List<IUpdate<PurchaseScheme>>();
foreach (var purchaseScheme in purchaseSchemeList)
{
var firstProduct = purchaseScheme.PurchaseSchemeProductList.FirstOrDefault();
var purchaseBasicInfoList = BatchGetPurchaseSkuBasicInfo(new BatchPurchaseSkuBasicInfoRequest()
{
FirstApiMode = Enums.PurchaseProductAPIMode.Spider,
PriceMode = Enums.PurchaseOrderMode.,
Params = new List<BatchPurchaseSkuBasicInfoParamRequest>()
{
new BatchPurchaseSkuBasicInfoParamRequest()
{
Platform = Enums.Platform.,
PurchaseProductIds = new string[]{firstProduct.PurchaseProductId}
}
}
});
if (purchaseBasicInfoList.Count() == 0)
continue;
var p = purchaseBasicInfoList.FirstOrDefault().Purchaser;
if (p != null && p.Id != purchaseScheme.PurchaserId)
{
var update = fsql.Update<PurchaseScheme>(purchaseScheme.Id).Set(ps => ps.PurchaserId, p.Id);
updatePurchaseSchemeList.Add(update);
var oldPurchasr = qtPurchaserList.FirstOrDefault(op => op.Id == purchaseScheme.PurchaserId);
updateSkuChangeInfoList.Add($"{purchaseScheme.SkuId} -> {oldPurchasr?.Name} -> {p.Name}");
}
}
if (updatePurchaseSchemeList.Count() > 0)
{
fsql.Transaction(() =>
{
foreach (var update in updatePurchaseSchemeList)
update.ExecuteAffrows();
});
}
return updateSkuChangeInfoList;
}
}
}

20
BBWY.Server.Business/Sync/StoreHouseSyncBusiness.cs

@ -78,14 +78,20 @@ namespace BBWY.Server.Business.Sync
}
}
var storeHouseIds = storeHouseList.Select(s => s.Id).ToArray();
var dbStoreIds = fsql.Select<Storehouse>(storeHouseIds).ToList(s => s.Id);
var exceptIds = storeHouseIds.Except(dbStoreIds);
if (exceptIds.Count() > 0)
//var storeHouseIds = storeHouseList.Select(s => s.Id).ToArray();
//var dbStoreIds = fsql.Select<Storehouse>(storeHouseIds).ToList(s => s.Id);
//var exceptIds = storeHouseIds.Except(dbStoreIds);
//if (exceptIds.Count() > 0)
//{
// var insertList = storeHouseList.Where(s => exceptIds.Contains(s.Id)).ToList();
// fsql.Insert(insertList).ExecuteAffrows();
//}
fsql.Transaction(() =>
{
var insertList = storeHouseList.Where(s => exceptIds.Contains(s.Id)).ToList();
fsql.Insert(insertList).ExecuteAffrows();
}
fsql.Delete<Storehouse>().Where(s => 1 == 1).ExecuteAffrows();
fsql.Insert(storeHouseList).ExecuteAffrows();
});
}
private void ResolveJDStoreHouse(JArray jarray, ShopResponse shop, IList<Storehouse> storeHouseList)

33
BBWY.Server.Business/Vender/VenderBusiness.cs

@ -7,6 +7,7 @@ using BBWY.Server.Model.Db.Mds;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@ -323,5 +324,37 @@ namespace BBWY.Server.Business
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
}
public IList<Storehouse> GetStoreHouseList(PlatformRequest request)
{
var restApiResult = restApiService.SendRequest(GetPlatformRelayAPIHost(request.Platform), "api/PlatformSDK/GetStoreHouseList", new PlatformRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
SaveResponseLog = false
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (restApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception(restApiResult.Content);
var response = JsonConvert.DeserializeObject<ApiResponse<JArray>>(restApiResult.Content);
if (response.Data == null || response.Data.Count() == 0)
return null;
var storeHouseList = new List<Storehouse>();
foreach (var storeHouseJToken in response.Data)
{
var seq_num = storeHouseJToken.Value<string>("seq_num");
storeHouseList.Add(new Storehouse()
{
Id = seq_num,
Name = storeHouseJToken.Value<string>("name"),
Platform = request.Platform,
CreateTime = DateTime.Now,
Status = (Enums.StockStatus)storeHouseJToken.Value<int>("use_flag"),
Type = (Enums.StockType)storeHouseJToken.Value<int>("type")
});
}
return storeHouseList;
}
}
}

16
BBWY.Server.Model/Dto/Request/PurchaseOrder/Callback/BBWYBDelivertCallBackRequest.cs

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BBWY.Server.Model.Dto
{
public class BBWYBDeliveryCallBackRequest
{
public string OrderId { get; set; }
}
public class BBWYBSignCallBackRequest : BBWYBDeliveryCallBackRequest
{
}
}

2
BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs

@ -48,7 +48,7 @@
public string Extensions { get; set; }
public string SourceSku { get; set; }
public object SourceSku { get; set; }
public string SourceShopName { get; set; }

9
BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase/BatchPurchaseCreateOrderRequest.cs

@ -1,4 +1,6 @@
namespace BBWY.Server.Model.Dto
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
public class BatchPurchaseCreateOrderRequest : BatchPurchasePreviewOrderRequest
{
@ -18,6 +20,9 @@
public string AutoPay { get; set; }
/// <summary>
/// 打包设置
/// </summary>
public IList<PackSkuConfigRequest> PackSkuConfigList { get; set; }
}
}

10
BBWY.Server.Model/Dto/Request/PurchaseScheme/BatchUpdateQTPurchaseSchemeBelongPurchaserRequest.cs

@ -0,0 +1,10 @@
namespace BBWY.Server.Model.Dto
{
public class BatchUpdateQTPurchaseSchemeBelongPurchaserRequest
{
/// <summary>
/// 采购商Id 可空
/// </summary>
public string PurchaserId { get; set; }
}
}

42
BBWY.Server.Model/Dto/Request/PurchaseScheme/PurcasheSkuBasicInfoRequest.cs

@ -0,0 +1,42 @@
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
public class PurchaseSkuBasicInfoRequest
{
public Enums.Platform Platform { get; set; }
/// <summary>
/// 采购商品Id
/// </summary>
public string PurchaseProductId { get; set; }
public Enums.PurchaseOrderMode PriceMode { get; set; }
public Enums.PurchaseProductAPIMode FirstApiMode { get; set; }
}
public class BatchPurchaseSkuBasicInfoRequest
{
public IList<BatchPurchaseSkuBasicInfoParamRequest> Params { get; set; }
public Enums.PurchaseOrderMode PriceMode { get; set; }
public Enums.PurchaseProductAPIMode FirstApiMode { get; set; }
}
public class BatchPurchaseSkuBasicInfoParamRequest
{
public Enums.Platform Platform { get; set; }
/// <summary>
/// 采购商品Id(采购spu)
/// </summary>
public string[] PurchaseProductIds { get; set; }
/// <summary>
/// 需要保留的采购SkuId,如果传递了该数组,将过滤不在该数组的采购sku
/// </summary>
public string[] PurchaseSkuIds { get; set; }
}
}

37
BBWY.Server.Model/Dto/Request/QiKu/PackSkuConfigRequest.cs

@ -0,0 +1,37 @@
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
public class PackSkuConfigRequest
{
public PackSkuConfigRequest()
{
}
/// <summary>
/// 采购备注信息
/// </summary>
public string RemarkMessage { get; set; }
/// <summary>
/// 店铺Sku
/// </summary>
public string SkuId { get; set; }
/// <summary>
/// 采购数量
/// </summary>
public int PurchaseCount { get; set; }
public IList<PackSkuSplitConfigRequest> PackSkuSplitConfigList { get; set; }
}
public class PackSkuSplitConfigRequest
{
public int Index { get; set; }
public int PackCount { get; set; }
public StoreRequest Store { get; set; }
}
}

9
BBWY.Server.Model/Dto/Request/Stock/StoreRequest.cs

@ -0,0 +1,9 @@
namespace BBWY.Server.Model.Dto
{
public class StoreRequest
{
public string Id { get; set; }
public string Name { get; set; }
}
}

58
BBWY.Server.Model/Dto/Response/PurchaseScheme/PurchaseProductBasicInfoResponse.cs

@ -0,0 +1,58 @@
using BBWY.Server.Model.Db;
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
/// <summary>
/// 采购Sku基础信息对象
/// </summary>
public class PurchaseSkuBasicInfoResponse
{
public Enums.Platform PurchasePlatform { get; set; }
public string PurchaseProductId { get; set; }
/// <summary>
/// 采购SKU基础信息列表
/// </summary>
public IList<PurchaseSkuItemBasicInfoResponse> ItemList { get; set; }
/// <summary>
/// 采购商
/// </summary>
public Purchaser Purchaser { get; set; }
}
/// <summary>
/// 采购Sku基础信息对象
/// </summary>
public class PurchaseSkuItemBasicInfoResponse
{
/// <summary>
/// 采购SPU
/// </summary>
public string PurchaseProductId { get; set; }
/// <summary>
/// 采购SKU
/// </summary>
public string PurchaseSkuId { get; set; }
/// <summary>
/// 采购SPEC 1688独有属性 下单需要
/// </summary>
public string PurchaseSkuSpecId { get; set; }
/// <summary>
/// SKU标题
/// </summary>
public string Title { get; set; }
public string Logo { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal Price { get; set; }
}
}

9
BBWY.Server.Model/Enums.cs

@ -33,6 +33,15 @@
= 1
}
/// <summary>
/// 采购商品API模式 Spider = 0,OneBound = 1
/// </summary>
public enum PurchaseProductAPIMode
{
Spider = 0,
OneBound = 1
}
/// <summary>
/// 仓储类型
/// </summary>

91
BBWY.Test/Program.cs

@ -1,7 +1,11 @@
using Jd.Api;
using com.alibaba.openapi.client;
using com.alibaba.openapi.client.policy;
using Jd.Api;
using Jd.Api.Request;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
@ -22,6 +26,14 @@ namespace BBWY.Test
}
}
private static SyncAPIClient GetSyncAPIClient(string appKey, string appSecret)
{
var sercvice = new ServiceCollection();
sercvice.AddHttpClient();
var servicePriovder = sercvice.BuildServiceProvider();
return new SyncAPIClient(appKey, appSecret, new Common.Http.RestApiService(servicePriovder.GetRequiredService<IHttpClientFactory>()));
}
static void Main(string[] args)
{
@ -41,29 +53,70 @@ namespace BBWY.Test
//var token = "4a0ddc095e054c7aa90adcaccb14f83cwzgr"; //可比车品
var token = "50a4c0f5c55848b5a8a715709e8d6fe0jntb"; //卿卿玩具专营店
//var dt1 = DateTime.Now;
//List<string> list = new List<string>();
//for (var i = 1; i <= 5000000; i++)
//{
// var str = tomMd5($"Mozilla/5.0 (Linux; Android 12; 21121210C Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 Mobile Safari/537.36 T7/13.8 SP-engine/2.46.0 baiduboxapp/13.8.1.10 (Baidu; P1 12) NABar/1.0 Edg/102.0.5005.63_{i}_192.158.241.{i}_28726526517321");
// Console.WriteLine($"生成第{i}位指纹,长度{str.Length},{str}");
// list.Add(str);
//}
//var dt2 = DateTime.Now;
//Console.WriteLine($"总数量{list.Count},总耗时{(dt2 - dt1).TotalSeconds}秒");
var request = new
{
AppKey = "3944754",
AppSecret = "NahdPJS5uzM",
AppToken = "a9a67b4a-1117-4ae6-8422-8188eedd3480",
OrderId = "1885695962273561469"
};
{
var client = GetSyncAPIClient(request.AppKey, request.AppSecret);
RequestPolicy reqPolicy = new RequestPolicy();
reqPolicy.HttpMethod = "POST";
reqPolicy.NeedAuthorization = false;
reqPolicy.RequestSendTimestamp = false;
reqPolicy.UseHttps = false;
reqPolicy.UseSignture = true;
reqPolicy.AccessPrivateApi = false;
Request _request = new Request();
APIId apiId = new APIId();
apiId.Name = "alibaba.trade.getLogisticsInfos.buyerView";
apiId.NamespaceValue = "com.alibaba.logistics";
apiId.Version = 1;
_request.ApiId = apiId;
var jdClient = GetJdClient(appkey, appSecret);
var req = new AscFreightViewRequest();
var param = new { orderId = request.OrderId, webSite = "1688", fields = "logisticsCompanyId,logisticsCompanyName,logisticsBillNo" };
_request.RequestEntity = param;
if (!string.IsNullOrEmpty(request.AppToken))
_request.AccessToken = request.AppToken;
var result = client.NewRequest(_request, reqPolicy);
}
{
var client = GetSyncAPIClient(request.AppKey, request.AppSecret);
RequestPolicy reqPolicy = new RequestPolicy();
reqPolicy.HttpMethod = "POST";
reqPolicy.NeedAuthorization = false;
reqPolicy.RequestSendTimestamp = false;
reqPolicy.UseHttps = false;
reqPolicy.UseSignture = true;
reqPolicy.AccessPrivateApi = false;
Request _request = new Request();
APIId apiId = new APIId
{
Name = "alibaba.trade.get.buyerView",
NamespaceValue = "com.alibaba.trade",
Version = 1
};
_request.ApiId = apiId;
var param = new
{
webSite = "1688",
orderId = request.OrderId,
includeFields = "baseInfo,productItems"
};
_request.RequestEntity = param;
if (!string.IsNullOrEmpty(request.AppToken))
_request.AccessToken = request.AppToken;
var result = client.NewRequest(_request, reqPolicy);
}
req.buId = "11926867";
req.operatePin = "开发测试";
req.operateNick = "开发测试";
req.serviceId = 1701316861;
req.orderId = 264691201058;
var res = jdClient.Execute(req,token, DateTime.Now.ToLocalTime());
Console.ReadKey();
}

Loading…
Cancel
Save