Browse Source

批量采购对接齐库打包任务

AddValidOverTime
shanji 2 years ago
parent
commit
72d495d56b
  1. 10
      BBWY.Client/APIServices/BatchPurchaseService.cs
  2. 59
      BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs
  3. 8
      BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml
  4. 2
      BBWY.Client/Views/MainWindow.xaml
  5. 72
      BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs
  6. 9
      BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase/BatchPurchaseCreateOrderRequest.cs
  7. 34
      BBWY.Server.Model/Dto/Request/QiKu/PackSkuConfigRequest.cs
  8. 9
      BBWY.Server.Model/Dto/Request/Stock/StoreRequest.cs

10
BBWY.Client/APIServices/BatchPurchaseService.cs

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

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

@ -1,5 +1,6 @@
using BBWY.Client.APIServices; using BBWY.Client.APIServices;
using BBWY.Client.Models; using BBWY.Client.Models;
using BBWY.Client.Models.QiKu;
using BBWY.Client.Views.BatchPurchase; using BBWY.Client.Views.BatchPurchase;
using BBWY.Common.Trigger; using BBWY.Common.Trigger;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
@ -76,8 +77,6 @@ namespace BBWY.Client.ViewModels
public ICommand SubtractQuantityCommand { get; set; } public ICommand SubtractQuantityCommand { get; set; }
public ICommand NextCommand { get; set; }
public BatchPurchaseCreateNewOrderViewModel(PurchaseProductAPIService purchaseProductAPIService, public BatchPurchaseCreateNewOrderViewModel(PurchaseProductAPIService purchaseProductAPIService,
PurchaseService purchaseService, PurchaseService purchaseService,
GlobalContext globalContext, GlobalContext globalContext,
@ -90,7 +89,6 @@ namespace BBWY.Client.ViewModels
ProductSkuWithSchemeList = new ObservableCollection<ProductSkuWithScheme>(); ProductSkuWithSchemeList = new ObservableCollection<ProductSkuWithScheme>();
FastCreateOrderCommand = new RelayCommand(FastCreateOrder); FastCreateOrderCommand = new RelayCommand(FastCreateOrder);
NextCommand = new RelayCommand(Next);
PreviewOrderCommand = new RelayCommand(PreviewOrder); PreviewOrderCommand = new RelayCommand(PreviewOrder);
AddProductSkuCommand = new RelayCommand(AddProductSku); AddProductSkuCommand = new RelayCommand(AddProductSku);
DeleteProductSkuWithSchemeCommand = new RelayCommand<ProductSkuWithScheme>(DeleteProductSkuWithScheme); DeleteProductSkuWithSchemeCommand = new RelayCommand<ProductSkuWithScheme>(DeleteProductSkuWithScheme);
@ -197,6 +195,22 @@ namespace BBWY.Client.ViewModels
return; 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; IsLoading = true;
Task.Factory.StartNew(() => batchPurchaseService.CreateOrder(ProductSkuWithSchemeList, Task.Factory.StartNew(() => batchPurchaseService.CreateOrder(ProductSkuWithSchemeList,
@ -214,7 +228,8 @@ namespace BBWY.Client.ViewModels
this.PurchaseOrderMode, this.PurchaseOrderMode,
globalContext.User.Shop.PurchaseAccountList, globalContext.User.Shop.PurchaseAccountList,
this.extensions, this.extensions,
this.PurchaseRemark)).ContinueWith(t => this.PurchaseRemark,
packSkuConfigList)).ContinueWith(t =>
{ {
IsLoading = false; IsLoading = false;
var response = t.Result; var response = t.Result;
@ -379,40 +394,6 @@ namespace BBWY.Client.ViewModels
purchaseSchemeProductSku.ItemTotal--; purchaseSchemeProductSku.ItemTotal--;
} }
private void Next()
{
if (IsLoading)
return;
if (TotalAmount == 0)
{
MessageBox.Show("总金额为0不能提交订单", "提示");
return;
}
if (string.IsNullOrEmpty(Mobile) ||
string.IsNullOrEmpty(Address) ||
string.IsNullOrEmpty(City) ||
string.IsNullOrEmpty(Province) ||
string.IsNullOrEmpty(County) ||
string.IsNullOrEmpty(Town) ||
string.IsNullOrEmpty(ContactName))
{
MessageBox.Show("收货人信息不全", "下单");
return;
}
var packWindow = new PackSkuConfigWindow(ProductSkuWithSchemeList.Select(ps => new Models.QiKu.PackSkuConfig()
{
Logo = ps.Logo,
SkuId = ps.SkuId,
Title = ps.Title,
PurchaseCount = ps.Quantity
}).ToList());
if (packWindow.ShowDialog() != true)
return;
var packSkuConfigList = packWindow.GetPackSkuConfigList();
Console.WriteLine(packSkuConfigList);
}
} }
} }

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

@ -345,10 +345,10 @@
<StackPanel Orientation="Horizontal" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right">
<c:BButton Content="预览订单" Width="80" HorizontalAlignment="Right" Margin="5,0,0,0" <c:BButton Content="预览订单" Width="80" HorizontalAlignment="Right" Margin="5,0,0,0"
Command="{Binding PreviewOrderCommand}" Background="#1CC2A2"/> Command="{Binding PreviewOrderCommand}" Background="#1CC2A2"/>
<!--<c:BButton Content="提交订单" Width="80" HorizontalAlignment="Right" <c:BButton Content="提交订单" Width="80" HorizontalAlignment="Right"
Command="{Binding FastCreateOrderCommand}" Margin="0,0,5,0"/>--> Command="{Binding FastCreateOrderCommand}" Margin="0,0,5,0"/>
<c:BButton Content="下一步" Width="80" HorizontalAlignment="Right" <!--<c:BButton Content="下一步" Width="80" HorizontalAlignment="Right"
Command="{Binding NextCommand}" Margin="0,0,5,0"/> Command="{Binding NextCommand}" Margin="0,0,5,0"/>-->
</StackPanel> </StackPanel>
</Grid> </Grid>
</c:BWindow> </c:BWindow>

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.TeamName}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" 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="{Binding GlobalContext.User.Shop.ShopName}" Margin="5,0,0,0"/>
<TextBlock Text="v10105" Margin="5,0,0,0"/> <TextBlock Text="v10106" Margin="5,0,0,0"/>
</StackPanel> </StackPanel>
</Border> </Border>
<Grid Grid.Row="1"> <Grid Grid.Row="1">

72
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;
using BBWY.Server.Model.Db; using BBWY.Server.Model.Db;
using BBWY.Server.Model.Db.QK; using BBWY.Server.Model.Db.QK;
@ -9,6 +10,7 @@ using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yitter.IdGenerator; using Yitter.IdGenerator;
@ -19,18 +21,19 @@ namespace BBWY.Server.Business
{ {
private ProductBusiness productBusiness; private ProductBusiness productBusiness;
private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList; private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
//private TaskSchedulerManager taskSchedulerManager;
private RestApiService restApiService;
public BatchPurchaseBusiness(IFreeSql fsql, public BatchPurchaseBusiness(IFreeSql fsql,
NLogManager nLogManager, NLogManager nLogManager,
IIdGenerator idGenerator, IIdGenerator idGenerator,
ProductBusiness productBusiness, ProductBusiness productBusiness,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator) IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
RestApiService restApiService) : base(fsql, nLogManager, idGenerator)
{ {
this.productBusiness = productBusiness; this.productBusiness = productBusiness;
this.platformSDKBusinessList = platformSDKBusinessList; this.platformSDKBusinessList = platformSDKBusinessList;
this.restApiService = restApiService;
} }
/// <summary> /// <summary>
@ -218,6 +221,7 @@ namespace BBWY.Server.Business
var successSkuIdList = new List<string>(); var successSkuIdList = new List<string>();
var failSkuList = new List<BatchCreareOrderFailDetail>(); var failSkuList = new List<BatchCreareOrderFailDetail>();
var qikuPackSkuConfigRequestList = new List<object>();
var extJArray = JsonConvert.DeserializeObject<JArray>(request.Extensions); var extJArray = JsonConvert.DeserializeObject<JArray>(request.Extensions);
var purchaseGroups = request.ProductParamList.GroupBy(p => p.PurchaserId); var purchaseGroups = request.ProductParamList.GroupBy(p => p.PurchaserId);
@ -279,6 +283,10 @@ namespace BBWY.Server.Business
List<long> updatePurchaseTimeSchemeIdList = productParamList.Select(p => p.BelongPurchaseSchemeId).Distinct().ToList(); List<long> updatePurchaseTimeSchemeIdList = productParamList.Select(p => p.BelongPurchaseSchemeId).Distinct().ToList();
List<PurchaseOrderSku> insertPurchaseOrderSkuList = new List<PurchaseOrderSku>(); List<PurchaseOrderSku> insertPurchaseOrderSkuList = new List<PurchaseOrderSku>();
List<object> skuPackConfigList = null;
if (purchasePlatform == Enums.Platform.)
skuPackConfigList = new List<object>();
foreach (var belongSkuGroup in belongSkuGroups) foreach (var belongSkuGroup in belongSkuGroups)
{ {
var firstProductParam = belongSkuGroup.FirstOrDefault(); var firstProductParam = belongSkuGroup.FirstOrDefault();
@ -308,6 +316,23 @@ namespace BBWY.Server.Business
CreateTime = DateTime.Now CreateTime = DateTime.Now
}; };
insertPurchaseOrderSkuList.Add(purchaseOrderSku); insertPurchaseOrderSkuList.Add(purchaseOrderSku);
if (purchasePlatform == Enums.Platform.)
{
var skuPackConfig = request.PackSkuConfigList.FirstOrDefault(s => s.SkuId == firstProductParam.BelongSkuId);
skuPackConfigList.Add(new
{
skuId = firstProductParam.BelongSkuId,
skuCount = skuPackConfig.PurchaseCount,
markMessage = string.Empty,
wareHourses = skuPackConfig.PackSkuSplitConfigList.Select(x => new
{
wareId = x.Store.Id,
wareName = x.Store.Name,
count = x.PackCount
})
});
}
} }
var purchaseOrderV2 = new PurchaseOrderV2() var purchaseOrderV2 = new PurchaseOrderV2()
@ -345,6 +370,19 @@ namespace BBWY.Server.Business
fsql.Update<PurchaseScheme>(updatePurchaseTimeSchemeIdList).Set(p => p.LastPurchaseTime, DateTime.Now).ExecuteAffrows(); fsql.Update<PurchaseScheme>(updatePurchaseTimeSchemeIdList).Set(p => p.LastPurchaseTime, DateTime.Now).ExecuteAffrows();
}); });
successSkuIdList.AddRange(belongSkuGroups.Select(g => g.Key)); successSkuIdList.AddRange(belongSkuGroups.Select(g => g.Key));
if (purchasePlatform == Enums.Platform.)
{
qikuPackSkuConfigRequestList.Add(new
{
orderId = purchaseOrderV2.Id,
shopId = request.ShopId.ToString(),
originShopName = request.ShopName,
userName = purchaseAccount.AccountName,
platform = Enums.Platform.,
purchaseTaskModels = skuPackConfigList
});
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -357,6 +395,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/PublicPurchaseTask",
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() return new BatchCreareOrderResponse()
{ {
FailSkuList = failSkuList, FailSkuList = failSkuList,

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 public class BatchPurchaseCreateOrderRequest : BatchPurchasePreviewOrderRequest
{ {
@ -18,6 +20,9 @@
public string AutoPay { get; set; } public string AutoPay { get; set; }
/// <summary>
/// 打包设置
/// </summary>
public IList<PackSkuConfigRequest> PackSkuConfigList { get; set; }
} }
} }

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

@ -0,0 +1,34 @@
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
public class PackSkuConfigRequest
{
public PackSkuConfigRequest()
{
}
/// <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; }
}
}
Loading…
Cancel
Save