Browse Source

Merge branch 'master' of http://code.qiyue666.com/pengcong001/bbwy

AddValidOverTime
shanji 2 years ago
parent
commit
ea19d22d76
  1. 2
      BBWY.Client/GlobalContext.cs
  2. 15
      BBWY.Client/Helpers/MyPrintHelper.cs
  3. 5
      BBWY.Client/Models/APIModel/Request/CerRequest.cs
  4. 5
      BBWY.Client/Models/APIModel/Request/QualityTaskRequest.cs
  5. 6
      BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs
  6. 5
      BBWY.Client/Models/APIModel/Response/PackTask/PackServiceResponse.cs
  7. 4
      BBWY.Client/Models/APIModel/Response/PackTask/SearchTaskListResponse.cs
  8. 15
      BBWY.Client/Models/Enums.cs
  9. 16
      BBWY.Client/Models/PackTask/CertificateModel.cs
  10. 17
      BBWY.Client/Models/PackTask/PackTaskModel.cs
  11. 36
      BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs
  12. 8
      BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs
  13. 255
      BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs
  14. 2
      BBWY.Client/Views/PackTask/LookCerWindow.xaml
  15. 12
      BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs
  16. 24
      BBWY.Client/Views/PackTask/ServiceWindow.xaml
  17. 100
      BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs
  18. 2
      BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs
  19. 58
      BBWY.Client/Views/PackTask/WareHouseListControl.xaml
  20. 5
      BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs
  21. 21
      BBWY.Client/Views/QualityTask/QualityWindow.xaml
  22. 22
      BBWY.Server.API/Controllers/BatchPurchaseController.cs
  23. 2
      BBWY.Server.API/Controllers/PurchaseSchemeController.cs
  24. 351
      BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs
  25. 2
      BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
  26. 1
      BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase/BatchPurchasePreviewOrderRequest.cs
  27. 90
      BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase2/BatchPurchaseCargoParamRequestV2.cs
  28. 25
      BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase2/BatchPurchaseCreateOrderRequestV2.cs
  29. 22
      BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase2/BatchPurchasePreviewOrderRequestV2.cs
  30. 5
      BBWY.Server.Model/Dto/Request/PurchaseScheme/QuerySchemeRequest.cs
  31. 2
      BBWY.Server.Model/Enums.cs

2
BBWY.Client/GlobalContext.cs

@ -9,7 +9,7 @@ namespace BBWY.Client
{
ShopServiceGroupList = new List<string>();
ShopServiceGroupLowerList = new List<string>();
ClientVersion = "10118";
ClientVersion = "10125";
}
private User user;

15
BBWY.Client/Helpers/MyPrintHelper.cs

@ -9,6 +9,7 @@ using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Media.Imaging;
using WebSocketSharp;
@ -618,5 +619,19 @@ namespace BBWY.Client.Helpers
}
}
public static void SetDefaultPrint(string printName)
{
SetDefaultPrinter(printName);
}
/// <summary>
/// 调用win api将指定名称的打印机设置为默认打印机
/// </summary>
/// <param name="Name"></param>
/// <returns></returns>
[DllImport("winspool.drv")]
public static extern bool SetDefaultPrinter(string Name);
}
}

5
BBWY.Client/Models/APIModel/Request/CerRequest.cs

@ -68,11 +68,14 @@ namespace BBWY.Client.Models.APIModel.Request
/// </summary>
public string ApplyAge { get; set; }
public int GoodsNumber { get; set; }
public long GoodsNumber { get; set; }
public string ProduceDate { get; set; }
public string PurchaseSkuId { get; set; }
public SaveType? SaveType { get; set; }
}
}

5
BBWY.Client/Models/APIModel/Request/QualityTaskRequest.cs

@ -93,5 +93,10 @@ namespace BBWY.Client.Models.APIModel.Request
/// </summary>
public DateTime? PreCompeteTime { get; set; }
/// <summary>
/// 地拖摆放编号
/// </summary>
public int? FloorDragNumber { get; set; }
}
}

6
BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs

@ -93,6 +93,12 @@ namespace BBWY.Client.Models.APIModel.Response.PackPurchaseTask
/// 配件列表
/// </summary>
public PurchaseSku[] PurchaseSkus { get; set; }
/// <summary>
///
/// </summary>
public SaveType? SaveType { get; set; }
}
public class WareHourseDTO
{

5
BBWY.Client/Models/APIModel/Response/PackTask/PackServiceResponse.cs

@ -57,6 +57,11 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask
/// 增量配件数量
/// </summary>
public int? IncrementPartCount { get; set; }
/// <summary>
/// 推荐打包人(skuid)
/// </summary>
public string SuggestPackUserName { get; set; }
}
public class PackServiceDTO

4
BBWY.Client/Models/APIModel/Response/PackTask/SearchTaskListResponse.cs

@ -165,5 +165,9 @@ namespace BBWY.Client.Models.APIModel
///分箱情况
/// </summary>
public WareHourseDTO[] WareHourses { get; set; }
/// <summary>
/// 地托编号
/// </summary>
public int? FloorDragNumber { get; set; }
}
}

15
BBWY.Client/Models/Enums.cs

@ -452,4 +452,19 @@
{
= 0, = 1/*,其他=2//基础包装 增量配件*/
}
/// <summary>
/// 打包配置存放区分
/// </summary>
public enum SaveType
{
/// <summary>
/// c端
/// </summary>
C端 = 0,
/// <summary>
/// B端
/// </summary>
B端 = 1
}
}

16
BBWY.Client/Models/PackTask/CertificateModel.cs

@ -12,9 +12,6 @@ namespace BBWY.Client.Models
/// 合格证id
/// </summary>
public long Id { get; set; }
/// <summary>
/// skuid
/// </summary>
@ -142,11 +139,20 @@ namespace BBWY.Client.Models
private int goodsNumber = 1;
private long goodsNumber = 1;
/// <summary>
/// 配件序号
/// </summary>
public long GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
private int goodsNumberIndex = 1;
/// <summary>
/// 配件序号
/// </summary>
public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
public int GoodsNumberIndex { get => goodsNumberIndex; set { Set(ref goodsNumberIndex, value); } }
private string produceDate;
/// <summary>

17
BBWY.Client/Models/PackTask/PackTaskModel.cs

@ -103,7 +103,16 @@ namespace BBWY.Client.Models
// qualityViewModel.TaskId = TaskId;
qualityViewModel.OrderId = OrderId;
qualityViewModel.SkuId = SkuId;
qualityViewModel.SearchSku(this);
try
{
qualityViewModel.SearchSku(this);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.Message);
}
//qualityViewModel.LoadPackDatas();
//qualityViewModel.SetAllFees = new Action<FeesItemResponse, List<string>>((feesItem, packUsers) =>
//{
@ -124,7 +133,7 @@ namespace BBWY.Client.Models
serviceViewModel.PackTaskModel = this;
serviceViewModel.PackTaskList = new System.Collections.ObjectModel.ObservableCollection<PackTaskModel> { this};
serviceViewModel.FloorDragNumber = this.FloorDragNumber;
serviceViewModel.TaskCount = SkuCount;
serviceViewModel.TaskId = TaskId;
serviceViewModel.OrderId= OrderId;
@ -512,6 +521,8 @@ namespace BBWY.Client.Models
public IList<SkuMessage> ItemList { get; set; }
public string OrderId { get; set; }
private int? floorDragNumber;
public int? FloorDragNumber { get => floorDragNumber; set { Set(ref floorDragNumber, value); } }
}
public class SkuMessage : NotifyObject
@ -565,5 +576,7 @@ namespace BBWY.Client.Models
/// 货号
/// </summary>
public string GoodsNo { get => goodsNo; set { Set(ref goodsNo, value); } }
}
}

36
BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs

@ -35,6 +35,17 @@ namespace BBWY.Client.ViewModels.PackTask
public class PackServiceViewModel : BaseVM, IDenpendency
{
private string suggestPackUserName;
/// <summary>
/// 打包人
/// </summary>
public string SuggestPackUserName { get => suggestPackUserName; set { Set(ref suggestPackUserName, value); } }
private int? floorDragNumber;
public int? FloorDragNumber { get => floorDragNumber; set { Set(ref floorDragNumber, value); } }
private string packUserName;
/// <summary>
/// 打包人
@ -179,9 +190,6 @@ namespace BBWY.Client.ViewModels.PackTask
public void InitPrintList()
{
TaskImage = MyPrintHelper.GetBarcodeImage(TaskId.ToString(), 300, 60);
BarcodeImage = MyPrintHelper.GetBarcodeImage(SkuId, 300, 60);
@ -287,6 +295,7 @@ namespace BBWY.Client.ViewModels.PackTask
if (res.Success)
{
SuggestPackUserName = res.Data.SuggestPackUserName;
IncrementPartCount = res.Data.IncrementPartCount == null ? 0 : res.Data.IncrementPartCount.Value;
if (res.Data != null && res.Data.IncrementItemList.Count() > 0)
@ -316,7 +325,7 @@ namespace BBWY.Client.ViewModels.PackTask
BasicPackServiceList.Add(packService);
if (packService.Name != "贴条码")
PackServiceList.Add(packService);//加载工序服务列表
});
}
}
@ -586,8 +595,8 @@ namespace BBWY.Client.ViewModels.PackTask
if (disIncrementProcessList == null) return;
if (disBasicPackProcessList.Select(d=>d.ItemName).Distinct().Count()==1&& disBasicPackProcessList.Select(d => d.ItemName).Contains("贴条码")
&& disIncrementProcessList.Count>0)
if (disBasicPackProcessList.Select(d => d.ItemName).Distinct().Count() == 1 && disBasicPackProcessList.Select(d => d.ItemName).Contains("贴条码")
&& disIncrementProcessList.Count > 0)
{
System.Windows.MessageBox.Show("只有一道贴码工序,无法添加增值包装工序");
return;
@ -606,14 +615,25 @@ namespace BBWY.Client.ViewModels.PackTask
packTaskDetail.ConsumableList = disConsumableServiceList;
var res = packDetailService.SetPackTaskDetail(packTaskDetail);
if (res != null && res.Success)
if (res==null)
{
System.Windows.MessageBox.Show("网络异常!");
return;
}
if (!res.Success)
{
System.Windows.MessageBox.Show(res.Msg);
return;
}
// new TipsWindow("上传成功!").Show();
var win = obj as System.Windows.Window;
if (SetAllFees != null)
SetAllFees();
win.Close();
}
}
/// <summary>
/// 更新 打包员 和费用数据

8
BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs

@ -360,7 +360,10 @@ namespace BBWY.Client.ViewModels.PackTask
System.Windows.MessageBox.Show("请先设置打包费用!");
return;
}
if (System.Windows.MessageBox.Show("是否完成打包?", "提示",
MessageBoxButton.YesNo,
MessageBoxImage.Warning) != MessageBoxResult.Yes)
return;
res = packTaskService.SetPackTaskState(taskId, PackTaskState.);
break;
case PackTaskState.:
@ -499,7 +502,6 @@ namespace BBWY.Client.ViewModels.PackTask
});
else
Task.Factory.StartNew(() =>
{
PackTaskList = new ObservableCollection<PackTaskModel>();//初始化数据
@ -540,6 +542,8 @@ namespace BBWY.Client.ViewModels.PackTask
OrderId = item.OrderId,
SkuId = item.SkuId,
SkuName = item.SkuName,
FloorDragNumber=item.FloorDragNumber,
};
if (item.BarCodeDTO != null && item.BarCodeDTO.Id > 0)

255
BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs

@ -20,6 +20,7 @@ using Org.BouncyCastle.Asn1.Crmf;
using System.Runtime.InteropServices.WindowsRuntime;
using NPOI.Util;
using BBWY.Controls;
using WebSocketSharp;
namespace BBWY.Client.ViewModels
{
@ -95,6 +96,18 @@ namespace BBWY.Client.ViewModels
public ObservableCollection<string> AvailabilityList { get => availabilityList; set { Set(ref availabilityList, value); } }
private int floorDragNumber;
public int FloorDragNumber { get => floorDragNumber; set { Set(ref floorDragNumber, value); } }
private ObservableCollection<int> floorDragNumberList = new ObservableCollection<int>
{
};
public ObservableCollection<int> FloorDragNumberList { get => floorDragNumberList; set { Set(ref floorDragNumberList, value); } }
private ObservableCollection<string> preCompeteTimeDayList = new ObservableCollection<string>
{
@ -103,7 +116,7 @@ namespace BBWY.Client.ViewModels
private ObservableCollection<string> preCompeteTimeHourList = new ObservableCollection<string> {
"12点前","18点前","21点前"
"12点前","18点前","22点前"
};
public ObservableCollection<string> PreCompeteTimeHourList { get => preCompeteTimeHourList; set { Set(ref preCompeteTimeHourList, value); } }
@ -394,6 +407,11 @@ namespace BBWY.Client.ViewModels
private void CompeteQualityTask(object obj)
{
if (FloorDragNumber <= 0)
{
MessageBox.Show($"请选择摆放地拖编号");
return;
}
if (GoodProductQuantity > ArrivalQuantity)
{
@ -423,29 +441,36 @@ namespace BBWY.Client.ViewModels
SkuId = SkuId,
IsNeedBar = IsNeedBarCode == Need.,
IsNeedCer = IsNeedCertificateModel == Need.,
TaskId = TaskId
TaskId = TaskId,
FloorDragNumber = FloorDragNumber
};
if (IsNeedBarCode == Need.)
{
if (BarCodeModel.Id <= 0)
if (BarCodeModel == null || BarCodeModel.Id <= 0)
{
MessageBox.Show("条形码不能为空");
return;
}
request.BarcodeId = BarCodeModel.Id;
}
if (IsNeedCertificateModel == Need.)
if(PurchaseSkuList != null && PurchaseSkuList.Count > 0&&purchaseSkuList.Any(p=> p.IsNeedCer)) //(IsNeedCertificateModel == Need.需要)
{
if (PurchaseSkuList == null && PurchaseSkuList.Count <= 0)
{
MessageBox.Show("无可用的合格证打印!");
return;
}
//if (PurchaseSkuList.Where(p => p.IsSetCertificate).Count() > 0)
//if ()
//{
// MessageBox.Show("存在未确认的合格证,请先完成确认!");
// MessageBox.Show("无可用的合格证打印!");
// return;
//}
if (PurchaseSkuList.Where(p => p.IsSetCertificate).Count() > 0)
{
MessageBox.Show("存在未确认的合格证,请先完成确认!");
return;
}
if (purchaseSkuList.Any(p => p.IsNeedCer && p.CerDTO == null))
{
MessageBox.Show("有未设置的合格证,请设置完所有的合格证再保存");
return;
}
if (PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Count() <= 0)
{
MessageBox.Show("无可选的合格证打印!");
@ -457,45 +482,111 @@ namespace BBWY.Client.ViewModels
int hour = Convert.ToInt32(PreCompeteTimeHour.Replace("点前", ""));
var date = Convert.ToDateTime(PreCompeteTimeDay);
request.PreCompeteTime = date.AddHours(hour);
DateTime date = DateTime.Now;
var competeRes = packPurchaseTaskService.CompeteQualityTask(request);
if (competeRes == null)
switch (preCompeteTimeDay)
{
MessageBox.Show("网络异常");
return;
case "今天":
date = DateTime.Now;
break;
case "明天":
date = DateTime.Now.AddDays(1);
break;
case "后天":
date = DateTime.Now.AddDays(2);
break;
default:
break;
}
if (!competeRes.Success)
//date = Convert.ToDateTime(PreCompeteTimeDay);
var competeTime = date.Date.AddHours(hour);
if (competeTime < DateTime.Now)
{
MessageBox.Show(competeRes.Msg);
MessageBox.Show($"预计完成时间不能小于当前时间,请重新选择预计完成时间");
return;
}
BatchPrintWindow batchPrint = new BatchPrintWindow();
batchPrint.SetData(GoodProductQuantity,
PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Select(p => p.CerDTO).ToArray()
, BarCodeModel);
batchPrint.ShowDialog();
try
var now = DateTime.Now;
if (now.Hour < 12)
{
if (competeTime > now.AddDays(1).Date.AddHours(12))
{
MessageBox.Show($"预计完成时间不能超过明天12点,请重新选择预计完成时间");
return;
}
}
catch
else if (now.Hour < 18)
{
if (competeTime > now.AddDays(1).Date.AddHours(18))
{
MessageBox.Show($"预计完成时间不能超过明天18点,请重新选择预计完成时间");
return;
}
}
else if (now.Hour < 22)
{
if (competeTime > now.AddDays(1).Date.AddHours(22))
{
MessageBox.Show($"预计完成时间不能超过明天22点,请重新选择预计完成时间");
return;
}
}
else
{
if (competeTime > now.AddDays(2).Date.AddHours(12))
{
MessageBox.Show($"预计完成时间不能超过后天12点,请重新选择预计完成时间");
return;
}
}
request.PreCompeteTime = competeTime;
try
{
var competeRes = packPurchaseTaskService.CompeteQualityTask(request);
if (competeRes == null)
{
MessageBox.Show("网络异常");
return;
}
if (!competeRes.Success)
{
MessageBox.Show(competeRes.Msg);
return;
}
BatchPrintWindow batchPrint = new BatchPrintWindow();
batchPrint.SetData(GoodProductQuantity,
PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Select(p => p.CerDTO).ToArray()
, BarCodeModel);
batchPrint.ShowDialog();
if (ReflashWindow != null) ReflashWindow();
var window = obj as BWindow;
App.Current.Dispatcher.Invoke(new Action(() =>
{
window.Close();
}));
if (ReflashWindow != null) ReflashWindow();
var window = obj as BWindow;
}
catch (Exception ex)
{
window.Close();
System.Windows.MessageBox.Show(ex.Message);
}
}
@ -560,7 +651,7 @@ namespace BBWY.Client.ViewModels
model.CerDTO.BrandName = BrandName;
QualitySetCerWindow setCerWindow = new QualitySetCerWindow();
setCerWindow.LoadData(model.IsNeedCer, model.CerDTO, packPurchaseTaskService, spuCertificateModel, IsSetSpuCertificate);
setCerWindow.LoadData(model.IsNeedCer, model.CerDTO, packPurchaseTaskService, spuCertificateModel, IsSetSpuCertificate, saveType);
setCerWindow.SaveResult = (s, PackCerState) =>
{
if (string.IsNullOrEmpty(s.PurchaseSkuId))
@ -601,11 +692,15 @@ namespace BBWY.Client.ViewModels
look.Show();
}
SaveType? saveType;
/// <summary>
/// 搜索 skuId(todo:)
/// </summary>
public void SearchSku(PackTaskModel model)
{
InitData();
TaskId = model.TaskId;
OrderId = model.OrderId;
@ -623,6 +718,7 @@ namespace BBWY.Client.ViewModels
BasicPack = model.BasicPack;
CertificatePosition = model.CertificatePosition;
ArrivalQuantity = 0;
GoodProductQuantity = 0;
@ -649,10 +745,30 @@ namespace BBWY.Client.ViewModels
var packTaskRes = packPurchaseTaskService.GetQualityTask(model.TaskId);
if (packTaskRes==null)
{
MessageBox.Show("网络异常!");
return;
}
if (!packTaskRes.Success || packTaskRes.Data==null)
{
MessageBox.Show(packTaskRes.Msg);
return;
}
SkuPurchaseSchemeId = packTaskRes.Data.SkuPurchaseSchemeId;
saveType = packTaskRes.Data.SaveType;
if (saveType == null)
{
saveType = OrderId.IsNullOrEmpty() ? SaveType.C端 : SaveType.B端;
}
if (packTaskRes == null || !packTaskRes.Success) return;
BarCodeModel = packTaskRes.Data.BarCodeDTO;
IsNeedBarCode = packTaskRes.Data.IsNeedBar ? Need. : Need.;
IsSetBarCode = packTaskRes.Data.IsNeedBar ? false : true;
IsSetBarCode = packTaskRes.Data.BarCodeDTO == null ? true : false;
IsNeedCertificateModel = packTaskRes.Data.IsNeedCer ? Need. : Need.;
if (packTaskRes.Data.WareHourses != null)
packTaskRes.Data.WareHourses.ToList().ForEach(w =>
@ -663,9 +779,11 @@ namespace BBWY.Client.ViewModels
if (packTaskRes.Data.PurchaseSkus != null)
{
int goodsIndex = 0;
foreach (var item in packTaskRes.Data.PurchaseSkus)
{
goodsIndex++;
if (item.CerDTO != null) item.CerDTO.GoodsNumberIndex = goodsIndex;
item.IsSetCertificate = true;
if (string.IsNullOrEmpty(item.PurchaseProductId))
{
@ -677,18 +795,20 @@ namespace BBWY.Client.ViewModels
{
PurchaseSkuList.Add(item); continue;
}
PurchaseSkuItemBasicInfoResponse skuItem = null;
if (list.Data != null) skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId);
var skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId);
App.Current.Dispatcher.Invoke(new Action(() =>
{
PurchaseSkuList.Add(new PurchaseSku
{
Logo = skuItem.Logo,
Title = skuItem.Title,
Logo = skuItem?.Logo,
Title = skuItem?.Title,
IsNeedCer = item.IsNeedCer,
PurchaseSkuId = item.PurchaseSkuId,
CerDTO = item.CerDTO,
IsSetCertificate = item.IsSetCertificate,
IsSetCertificate = item.IsNeedCer,
});
}));
//PurchaseSkuList.Add(item);
@ -706,17 +826,62 @@ namespace BBWY.Client.ViewModels
public Action ReflashWindow { get; set; }
public void InitData()
{
FloorDragNumber = 0;
PurchaseSkuList = new ObservableCollection<PurchaseSku>();
WareHourseList = new ObservableCollection<WareHourseDTO>();
PreCompeteTimeDayList = new ObservableCollection<string>();
FloorDragNumberList = new ObservableCollection<int>();
for (int i = 0; i < 30; i++)
{
App.Current.Dispatcher.Invoke((Action)(() =>
{
FloorDragNumberList.Add(i + 1);
}));
}
var nowTime = DateTime.Now;
var hour = nowTime.Hour;
var date = DateTime.Now.Date;
for (int i = 0; i < 7; i++)
if (hour < 12)
{
PreCompeteTimeDayList.Add("今天");
PreCompeteTimeDayList.Add("明天");
PreCompeteTimeDay = "今天";
PreCompeteTimeHour = "12点前";
}
else if (hour < 18)
{
PreCompeteTimeDayList.Add("今天");
PreCompeteTimeDayList.Add("明天");
PreCompeteTimeDay = "今天";
PreCompeteTimeHour = "18点前";
}
else if (hour < 22)
{
PreCompeteTimeDayList.Add(date.AddDays(i).ToString("yyyy-MM-dd"));
PreCompeteTimeDayList.Add("今天");
PreCompeteTimeDayList.Add("明天");
PreCompeteTimeDay = "今天";
PreCompeteTimeHour = "22点前";
}
else
{
PreCompeteTimeDayList.Add("今天");
PreCompeteTimeDayList.Add("明天");
PreCompeteTimeDayList.Add("后天");
PreCompeteTimeDay = "明天";
PreCompeteTimeHour = "12点前";
}
PreCompeteTimeDay = date.ToString("yyyy-MM-dd");
IsSetBarCode = true;
SkuTitle = "";
@ -724,11 +889,7 @@ namespace BBWY.Client.ViewModels
GoodsNumber = 0;
PackType = PackType.;
BasicPack = BasicPack.;
// Availability = (TaskState.)config.Availability;
//MarkMessage = config.MarkMessage;
CertificatePosition = CertificatePosition.;
// Increment1 = config.Increment1;
IsNeedBarCode = Need.;
IsNeedCertificateModel = Need.;
}

2
BBWY.Client/Views/PackTask/LookCerWindow.xaml

@ -44,7 +44,7 @@
</hc:TabControl.Resources>
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center" Text="{Binding CertificateModel.GoodsNumber,StringFormat=配件{0}}"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding CertificateModel.GoodsNumberIndex,StringFormat=配件{0}}"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>

12
BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs

@ -29,11 +29,23 @@ namespace BBWY.Client.Views.PackTask
InitializeComponent();
GoodsNumberCerList = new ObservableCollection<GoodsNumberCer>();
int goodsNumberIndex = 0;
foreach (CertificateModel certificateModel in certificate)
{
if (certificateModel==null)
{
continue;
}
goodsNumberIndex++;
certificateModel.GoodsNumberIndex = goodsNumberIndex;
GoodsNumberCerList.Add(new GoodsNumberCer
{
CertificateModel = certificateModel.Copy(),
});
}
this.DataContext = this;
}

24
BBWY.Client/Views/PackTask/ServiceWindow.xaml

@ -70,19 +70,26 @@
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="80"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="定向收费:" HorizontalAlignment="Left" Margin="19 0 0 0" VerticalAlignment="Center"/>
<c:BTextBox Text="{Binding DirectionalFees,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="100"/>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="0 5 0 0">
<TextBlock Text="定向收费:" HorizontalAlignment="Left" Margin="19 0 0 0" VerticalAlignment="Center"/>
<c:BTextBox Text="{Binding DirectionalFees,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="100"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Height="40" Margin="0 5 0 0">
<TextBlock Text="推荐打包人: " HorizontalAlignment="Left" Margin="19 0 0 0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding SuggestPackUserName}" Foreground="Red" HorizontalAlignment="Left" Margin="0 0 0 0" VerticalAlignment="Center"/>
</StackPanel>
</StackPanel>
<ScrollViewer x:Name="scrolls" Grid.Row="1" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" Height="640">
<ScrollViewer x:Name="scrolls" Grid.Row="1" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" Height="650">
<ScrollViewer.Content>
<StackPanel Orientation="Vertical" Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="增值服务" Margin="20,0,10,0" VerticalAlignment="Center" />
<Border Background="Black" VerticalAlignment="Center" Width="217" Height="1"/>
@ -415,9 +422,6 @@
<Grid Grid.Row="1" Grid.Column="1" Visibility="Hidden">
<StackPanel Orientation="Vertical" Name="printArea" Width="1065" Height="800">
<StackPanel Orientation="Horizontal">
@ -429,6 +433,8 @@
<Image Height="60" Width="200" Source="{Binding TaskImage}"/>
<TextBlock Grid.Row="1" FontSize="18" Style="{StaticResource middleTextBlock}" Text="{Binding TaskId}"/>
</Grid>
<TextBlock Text="摆放地托编号:" FontSize="24" FontWeight="Bold" Style="{StaticResource middleTextBlock}" Margin="20 0 0 0"/>
<TextBlock Text="{Binding FloorDragNumber}" FontSize="24" FontWeight="Bold" Style="{StaticResource middleTextBlock}" Margin="20 0 0 0"/>
<TextBlock Text="打包人:" FontSize="24" FontWeight="Bold" Style="{StaticResource middleTextBlock}" Margin="20 0 0 0"/>
<TextBlock Text="{Binding PackUserName}" FontSize="24" FontWeight="Bold" Style="{StaticResource middleTextBlock}" Margin="20 0 0 0"/>
</StackPanel>

100
BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs

@ -1,5 +1,6 @@
using BarcodeLib;
using BBWY.Client.APIServices;
using BBWY.Client.Helpers;
using BBWY.Client.ViewModels;
using BBWY.Client.ViewModels.PackTask;
using BBWY.Controls;
@ -50,9 +51,8 @@ namespace BBWY.Client.Views.PackTask
MessageBox.Show("打印机处于错误状态");
return;
}
//Print(this.printArea, cbPrintName.Text, "打印任务",1);
MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机
this.printArea.Arrange(new Rect(new Point(0, 0), new Size(printArea.ActualWidth, printArea.ActualHeight)));
PrintDialog printDialog = new PrintDialog();
@ -76,99 +76,7 @@ namespace BBWY.Client.Views.PackTask
/// <summary>
/// 打印
/// </summary>
/// <param name="document">流文档</param>
/// <param name="printer">打印机名称</param>
/// <param name="description">打印描述</param>
/// <param name="copyCount">打印个数</param>
public static void Print(Visual document, string printer, string description, int copyCount)
{
var localPrintServer = new LocalPrintServer();
var printQueue = localPrintServer.GetPrintQueue(printer);
if (printQueue.IsInError)
{
throw new Exception("打印机处于错误状态");
}
var printDialog = new PrintDialog
{
PrintQueue = printQueue, //打印队列
PrintTicket = { CopyCount = copyCount } //打印个数
};
//设置纸张大小
var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); //小标签:114
var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); //小标签:227
printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight);
//设置纸张边距
var paperSize = GetPaperSize(printer); //小标签:118*246
//var offsetX = (int)Math.Ceiling((paperSize.Width - pageWidth) / 2f);
//var offsetY = (int)Math.Ceiling((paperSize.Height - pageHeight) / 2f);
//document.PagePadding = new Thickness(offsetX, offsetY, offsetX, offsetY);
//打印
var paginator = ((IDocumentPaginatorSource)document).DocumentPaginator;
printDialog.PrintDocument(paginator, description);
var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string printNames = System.IO.Path.Combine(applicationPath, "printName.init");
File.WriteAllText(printNames, printer);
}
private static object GetPaperSize(string printer)
{
return null;
}
public interface IDocumentRenderer
{
void Render(FlowDocument doc, object data);
}
public class CommonDocumentRenderer : IDocumentRenderer
{
public void Render(FlowDocument doc, object data)
{
var model = data as PrintModel;
if (model == null)
{
throw new ArgumentException("data is not PrintModel");
}
var type = typeof(PrintModel);
var properties = type.GetProperties();
foreach (var property in properties)
{
//文本赋值
if (doc.FindName(property.Name) is TextBlock textBlock)
{
textBlock.Text = property.GetValue(model)?.ToString();
}
}
}
}
public class PrintModel
{
/// <summary>
/// 批号
/// </summary>
public string BatchNumber { get; set; }
/// <summary>
/// 订单号
/// </summary>
public string OrderNumber { get; set; }
/// <summary>
/// 物料代码
/// </summary>
public string MaterialNumber { get; set; }
}
}
}

2
BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs

@ -139,7 +139,7 @@ namespace BBWY.Client.Views.PackTask
setSpuCerWindow.Show();
}
int selectCer = -1;//tabcontrol 选中事件
long selectCer = -1;//tabcontrol 选中事件
private void InseartCer_Click(object sender, RoutedEventArgs e)
{
if (IsSetSpuCertificate)

58
BBWY.Client/Views/PackTask/WareHouseListControl.xaml

@ -60,19 +60,20 @@
<TextBlock Text="操作" Grid.Column="12" Style="{StaticResource middleTextBlock}"/>
<!--<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}"/>-->
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="8"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="9"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="10"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="11"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="1"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="2"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="3"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="4"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="5"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="6"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="7"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="8"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="9"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="10"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="11"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="12"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="12"/>
</Grid>
<!--ItemsSource="{Binding OrderList}"-->
@ -150,7 +151,7 @@
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<ListBox x:Name="listbox_orerSku" ItemsSource="{Binding ItemList}"
Style="{StaticResource NoScrollViewListBoxStyle}"
Style="{StaticResource NoScrollViewListBoxStyle}" BorderThickness="0"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" >
<ListBox.ItemTemplate>
<DataTemplate>
@ -356,10 +357,11 @@
</StackPanel>
</Grid>
<Grid Grid.Column="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<StackPanel Margin="20,0,0,0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" >
<TextBlock Text="收费:"/>
@ -385,7 +387,7 @@
</StackPanel>
<Grid Grid.Row="1" Visibility="{Binding TaskState,Converter={StaticResource objConverter},ConverterParameter=未到货|部分到货|已取消:Collapsed:Visible}">
<Grid Grid.Row="1" Visibility="{Binding TaskState,Converter={StaticResource objConverter},ConverterParameter=未到货|部分到货|待质检|已取消:Collapsed:Visible}">
<Border Grid.Row="0" VerticalAlignment="Top" Height="1" Background="{StaticResource Border.Brush}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
@ -481,20 +483,20 @@
</StackPanel>
</Grid>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="8"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="9"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="10"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="11"/>
<!--<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}"/>-->
<!--<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="1"/>-->
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="2" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="3" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="4" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="5" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="6" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="7" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="8" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="9" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="10" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="11" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Left" Background="{StaticResource Border.Brush}" Grid.Column="12" Margin="-1 0 0 0"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="12"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="13"/>
</Grid>
<Border Grid.Row="1" VerticalAlignment="Bottom" Height="1" Background="{StaticResource Border.Brush}"/>

5
BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs

@ -35,14 +35,16 @@ namespace BBWY.Client.Views.QualityTask
PackCerState = obj;
}
public void LoadData(bool isNeedCer, CertificateModel CertificateModel, PackPurchaseTaskService packTaskService, CertificateModel SpuCertificateModel, bool IsSetSpuCertificate)
public void LoadData(bool isNeedCer, CertificateModel CertificateModel, PackPurchaseTaskService packTaskService, CertificateModel SpuCertificateModel, bool IsSetSpuCertificate,SaveType? saveType)
{
this.CertificateModel = CertificateModel.Copy();
this.packTaskService = packTaskService;
PackCerState = isNeedCer ? PackCerState. : PackCerState.;
SaveType = saveType;
this.DataContext = this;
}
public SaveType? SaveType { get; set; }
public ICommand SetPackCerStateCommand { get; set; }
@ -123,6 +125,7 @@ namespace BBWY.Client.Views.QualityTask
GoodsNumber = CertificateModel.GoodsNumber,
ProduceDate = CertificateModel.ProduceDate,
PurchaseSkuId = CertificateModel.PurchaseSkuId,
SaveType = SaveType
});
if (resData == null || !resData.Success)
{

21
BBWY.Client/Views/QualityTask/QualityWindow.xaml

@ -112,7 +112,7 @@
<TextBlock Text="任务信息" Margin="20 10" FontSize="13" FontWeight="Bold" HorizontalAlignment="Left" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="480"/>
<ColumnDefinition Width="520"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Margin="20 10 " HorizontalAlignment="Left">
@ -136,7 +136,7 @@
<Run Text="份数:"/>
<Run Text="{Binding WareHourseCount,Mode=TwoWay}"/>
</TextBlock>
<StackPanel Orientation="Horizontal" Margin="45 0 0 0" Height="30">
<StackPanel Orientation="Horizontal" Margin="10 0 0 0" Height="30">
<TextBlock Text="预计完成时间: " VerticalAlignment="Center" />
<Border BorderBrush="{StaticResource Border.Brush}" Height="30" BorderThickness="1">
<hc:ComboBox BorderThickness="0" ItemsSource="{Binding PreCompeteTimeDayList}" SelectedIndex="0" Text="{Binding PreCompeteTimeDay}">
@ -149,7 +149,14 @@
</hc:ComboBox>
</Border>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource middleTextBlock}" Text="摆放地托编号:" Margin="10 0 0 0"/>
<Border BorderBrush="{StaticResource Border.Brush}" Height="30" BorderThickness="1">
<hc:ComboBox Width="80" BorderThickness="0" ItemsSource="{Binding FloorDragNumberList}" SelectedIndex="0" Text="{Binding FloorDragNumber}">
</hc:ComboBox>
</Border>
</StackPanel>
</StackPanel>
</StackPanel>
@ -205,7 +212,7 @@
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="0" Visibility="{Binding OrderId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}"
BorderThickness="0" Visibility="{Binding SkuPurchaseSchemeId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}"
Foreground="{StaticResource Text.Color}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@ -268,7 +275,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
Visibility="{Binding IsSetCertificate, Converter={StaticResource objConverter}, ConverterParameter=false:Visible:Collapsed }">
<c:BButton Content="查看" Style="{StaticResource LinkButton}" Width="35" Height="15"
CommandParameter="{Binding PurchaseSkuId}"
CommandParameter="{Binding CerDTO}"
Command="{Binding DataContext. LookCerCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
<c:BButton Content="修改" Style="{StaticResource LinkButton}" Width="35" Height="15" CommandParameter="{Binding }"
Command="{Binding DataContext.SetCertificateCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
@ -309,7 +316,7 @@
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="0" Visibility="{Binding OrderId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}"
BorderThickness="0" Visibility="{Binding SkuPurchaseSchemeId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}"
Foreground="{StaticResource Text.Color}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@ -324,7 +331,7 @@
<Border Margin="20 0 0 0" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1" Height="150" Width="150">
<StackPanel Orientation="Vertical">
<Border BorderBrush="{StaticResource Border.Brush}" BorderThickness="1" Height="30 " Margin="10 50 10 30">
<TextBlock Text="{Binding CerDTO.GoodsNumber,StringFormat=配件{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="{Binding CerDTO.GoodsNumberIndex,StringFormat=配件{0}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
@ -388,7 +395,7 @@
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="86"/>
<ColumnDefinition Width="86"/>
<ColumnDefinition Width="0" />
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>

22
BBWY.Server.API/Controllers/BatchPurchaseController.cs

@ -48,6 +48,28 @@ namespace BBWY.Server.API.Controllers
return batchPurchaseBusiness.BatchCreateOrder(request);
}
/// <summary>
/// 预览订单价格V2
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public PreviewOrderResponse PreviewOrderV2([FromBody] BatchPurchasePreviewOrderRequestV2 request)
{
return batchPurchaseBusiness.PreviewOrderV2(request);
}
/// <summary>
/// 批量创建采购单V2
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public BatchCreareOrderResponse BatchCreateOrderV2(BatchPurchaseCreateOrderRequestV2 request)
{
return batchPurchaseBusiness.BatchCreateOrderV2(request);
}
/// <summary>
/// 获取采购单列表
/// </summary>

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

@ -30,7 +30,7 @@ namespace BBWY.Server.API.Controllers
}
/// <summary>
/// 根据产品Id批量查询采购商列表
/// 批量查询采购方案列表
/// </summary>
/// <param name="querySchemeRequest"></param>
/// <returns></returns>

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

@ -2,7 +2,7 @@
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Db.QK;
using BBWY.Server.Model.Db.Mds;
using BBWY.Server.Model.Dto;
using FreeSql;
using Newtonsoft.Json;
@ -11,7 +11,6 @@ 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;
@ -24,17 +23,20 @@ namespace BBWY.Server.Business
private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
//private TaskSchedulerManager taskSchedulerManager;
private RestApiService restApiService;
private FreeSqlMultiDBManager freeSqlMultiDBManager;
public BatchPurchaseBusiness(IFreeSql fsql,
NLogManager nLogManager,
IIdGenerator idGenerator,
ProductBusiness productBusiness,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
RestApiService restApiService) : base(fsql, nLogManager, idGenerator)
RestApiService restApiService,
FreeSqlMultiDBManager freeSqlMultiDBManager) : base(fsql, nLogManager, idGenerator)
{
this.productBusiness = productBusiness;
this.platformSDKBusinessList = platformSDKBusinessList;
this.restApiService = restApiService;
this.freeSqlMultiDBManager = freeSqlMultiDBManager;
}
/// <summary>
@ -200,6 +202,85 @@ namespace BBWY.Server.Business
};
}
/// <summary>
/// 预览订单V2
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public PreviewOrderResponse PreviewOrderV2(BatchPurchasePreviewOrderRequestV2 request)
{
if (request.CargoParamGroupList == null || request.CargoParamGroupList.Count() == 0 ||
request.CargoParamGroupList.Any(g => g.CargoParamList == null || g.CargoParamList.Count() == 0 || string.IsNullOrEmpty(g.PurchaserId)))
throw new BusinessException("缺少商品参数");
if (request.Consignee == null ||
string.IsNullOrEmpty(request.Consignee.Address) ||
string.IsNullOrEmpty(request.Consignee.Mobile) ||
string.IsNullOrEmpty(request.Consignee.ContactName))
throw new BusinessException("缺少收货人信息");
if (request.PurchaseAccountList == null || request.PurchaseAccountList.Count() == 0)
throw new BusinessException("缺少采购账号");
var extJArray = new List<object>();
var errorBuilder = new StringBuilder();
var freightAmount = 0M;
var productAmount = 0M;
var totalAmount = 0M;
foreach (var purchaseGroup in request.CargoParamGroupList)
{
try
{
var purchaseAccount = request.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == purchaseGroup.PurchasePlatform);
if (purchaseAccount == null)
throw new BusinessException($"缺少{purchaseGroup.PurchasePlatform}采购平台账号,请在店铺配置中设置");
var platformSDKBusiness = platformSDKBusinessList.FirstOrDefault(p => p.Platform == purchaseGroup.PurchasePlatform);
var previewOrderResponse = platformSDKBusiness.PreviewOrder(new PreviewOrderReuqest()
{
AppKey = purchaseAccount.AppKey,
AppSecret = purchaseAccount.AppSecret,
AppToken = purchaseAccount.AppToken,
Consignee = request.Consignee,
Platform = purchaseGroup.PurchasePlatform,
PurchaseOrderMode = request.PurchaseOrderMode,
CargoParamList = purchaseGroup.CargoParamList.Select(p => new CargoParamRequest()
{
ProductId = p.ProductId,
SkuId = p.SkuId,
Quantity = p.Quantity,
SpecId = p.SpecId
}).ToList()
});
if (purchaseGroup.PurchasePlatform == Enums.Platform.)
extJArray.Add(new { purchaseGroup.PurchaserId, CardId = previewOrderResponse.Extensions });
else if (purchaseGroup.PurchasePlatform == Enums.Platform.)
extJArray.Add(new { purchaseGroup.PurchaserId, OrderTradeTypeCode = previewOrderResponse.OrderTradeType?.Code });
freightAmount += previewOrderResponse.FreightAmount;
productAmount += previewOrderResponse.ProductAmount;
totalAmount += previewOrderResponse.TotalAmount;
}
catch (Exception ex)
{
errorBuilder.AppendLine($"采购商:{purchaseGroup.PurchaserName}");
errorBuilder.AppendLine(ex.Message);
throw new BusinessException(errorBuilder.ToString());
}
}
return new PreviewOrderResponse()
{
Extensions = JsonConvert.SerializeObject(extJArray),
FreightAmount = freightAmount,
ProductAmount = productAmount,
TotalAmount = totalAmount
};
}
/// <summary>
/// 创建订单
/// </summary>
@ -455,6 +536,270 @@ namespace BBWY.Server.Business
};
}
/// <summary>
/// 创建订单
/// </summary>
/// <param name="request"></param>
public BatchCreareOrderResponse BatchCreateOrderV2(BatchPurchaseCreateOrderRequestV2 request)
{
/*
*/
var loggerName = $"批量采购-{request.ShopName}";
nLogManager.GetLogger(loggerName).Info(JsonConvert.SerializeObject(request));
if (request.CargoParamGroupList == null || request.CargoParamGroupList.Count() == 0 ||
request.CargoParamGroupList.Any(g => g.CargoParamList == null || g.CargoParamList.Count() == 0 || string.IsNullOrEmpty(g.PurchaserId)))
throw new BusinessException("缺少商品参数");
if (request.Consignee == null ||
string.IsNullOrEmpty(request.Consignee.Address) ||
string.IsNullOrEmpty(request.Consignee.Mobile) ||
string.IsNullOrEmpty(request.Consignee.ContactName))
throw new BusinessException("缺少收货人信息");
if (request.PurchaseAccountList == null || request.PurchaseAccountList.Count() == 0)
throw new BusinessException("缺少采购账号");
var shop = freeSqlMultiDBManager.MDSfsql.Select<Shops>().Where(s => s.ShopId == request.ShopId.ToString()).ToOne();
if (shop == null)
throw new BusinessException("无效的店铺Id");
var successSkuIdList = new List<string>();
var failSkuList = new List<BatchCreareOrderFailDetail>();
var qikuPackSkuConfigRequestList = new List<object>();
var extJArray = JsonConvert.DeserializeObject<JArray>(request.Extensions);
foreach (var purchaseGroup in request.CargoParamGroupList)
{
var belongSkuGroups = purchaseGroup.CargoParamList.GroupBy(p => p.BelongSkuId);
var belongSkuBasicInfoList = productBusiness.GetProductSkuList(new SearchProductSkuRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
Platform = (Enums.Platform)shop.PlatformId,
Sku = string.Join(",", belongSkuGroups.Select(x => x.Key)),
});
try
{
var purchaseAccount = request.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == purchaseGroup.PurchasePlatform);
var platformSDKBusiness = platformSDKBusinessList.FirstOrDefault(p => p.Platform == purchaseGroup.PurchasePlatform);
string tradeMode = "", cardId = "";
var extJson = extJArray.FirstOrDefault(j => j.Value<string>("PurchaserId") == purchaseGroup.PurchaserId);
if (purchaseGroup.PurchasePlatform == Enums.Platform.)
cardId = extJson.Value<string>("CardId");
else if (purchaseGroup.PurchasePlatform == Enums.Platform.)
tradeMode = extJson.Value<string>("OrderTradeTypeCode");
#region 处理JD SKU和拳探SKU的对应关系
var belongSkus_mappingList = new List<JObject>();
if (purchaseGroup.PurchasePlatform == Enums.Platform.)
{
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, firstProductParam.SkuId }));
}
}
if (belongSkus_mappingList.Count() == 0)
throw new BusinessException("缺少来源SKU信息");
}
#endregion
var createOrderResponse = platformSDKBusinessList.FirstOrDefault(p => p.Platform == purchaseGroup.PurchasePlatform)
.FastCreateOrder(new CreateOnlinePurchaseOrderRequest()
{
AppKey = purchaseAccount.AppKey,
AppSecret = purchaseAccount.AppSecret,
AppToken = purchaseAccount.AppToken,
Platform = purchaseGroup.PurchasePlatform,
Consignee = request.Consignee,
PurchaseOrderMode = request.PurchaseOrderMode,
Remark = purchaseGroup.Remark,
SourceShopName = request.ShopName,
SourceSku = belongSkus_mappingList,
CargoParamList = purchaseGroup.CargoParamList.Select(p => new CargoParamRequest()
{
ProductId = p.ProductId,
SkuId = p.SkuId,
Quantity = p.Quantity,
SpecId = p.SpecId
}).ToList(),
TradeMode = tradeMode,
Extensions = cardId,
AutoPay = request.AutoPay,
});
var purchaseOrderSimpleInfo = platformSDKBusinessList.FirstOrDefault(p => p.Platform == purchaseGroup.PurchasePlatform).GetOrderSimpleInfo(new GetOrderInfoRequest()
{
AppKey = purchaseAccount.AppKey,
AppSecret = purchaseAccount.AppSecret,
AppToken = purchaseAccount.AppToken,
OrderId = createOrderResponse.PurchaseOrderId,
Platform = purchaseGroup.PurchasePlatform
});
List<long> updatePurchaseTimeSchemeIdList = purchaseGroup.CargoParamList.Select(p => p.BelongSchemeId).Distinct().ToList();
List<PurchaseOrderSku> insertPurchaseOrderSkuList = new List<PurchaseOrderSku>();
List<object> skuPackConfigList = null;
if (purchaseGroup.PurchasePlatform == Enums.Platform.)
skuPackConfigList = new List<object>();
foreach (var belongSkuGroup in belongSkuGroups)
{
var firstProductParam = belongSkuGroup.FirstOrDefault();
var currentOrderSkuProductAmount = 0M; //采购成本
currentOrderSkuProductAmount = purchaseOrderSimpleInfo.ItemList.Where(p => belongSkuGroup.Any(p1 => p1.SkuId == p.SkuId))
?.Sum(p => p.ProductAmount) ?? 0M;
var currentOrderSkuFreightAmount = purchaseOrderSimpleInfo.FreightAmount / belongSkuGroups.Count(); //采购运费(按sku数均分)
var belongSkuBasicInfo = belongSkuBasicInfoList.FirstOrDefault(x=>x.Id == belongSkuGroup.Key);
var purchaseOrderSku = new PurchaseOrderSku()
{
Id = idGenerator.NewLong(),
ShopId = request.ShopId,
PurchaseOrderId = createOrderResponse.PurchaseOrderId,
ProductId = belongSkuBasicInfo.ProductId,
SkuId = firstProductParam.BelongSkuId,
Price = belongSkuBasicInfo.Price,
SkuTitle = belongSkuBasicInfo.Title,
Logo = belongSkuBasicInfo.Logo,
Quantity = firstProductParam.BelongQuantity,
PurchaseSchemeId = firstProductParam.BelongSchemeId,
PurchaseSkuIds = string.Join(",", belongSkuGroup.Select(p => p.SkuId).ToList()),
PurchaseAmount = currentOrderSkuProductAmount + currentOrderSkuFreightAmount,
ProductAmount = currentOrderSkuProductAmount,
PurchaseFreight = currentOrderSkuFreightAmount,
CreateTime = DateTime.Now
};
insertPurchaseOrderSkuList.Add(purchaseOrderSku);
if (purchaseGroup.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.IsJST ? "qiyuejushuitan" : x.Store.Id,
wareName = x.IsJST ? "齐越聚水潭" : x.Store.Name,
count = x.PackCount,
wareType = x.IsJST ? 3 : GetQiKuWareType(x.Store.Type)
})
});
}
}
}
var purchaseOrderV2 = new PurchaseOrderV2()
{
Id = createOrderResponse.PurchaseOrderId,
ShopId = request.ShopId,
OrderState = createOrderResponse.IsPay ? Enums.PurchaseOrderState. : Enums.PurchaseOrderState.,
PurchasePlatform = purchaseGroup.PurchasePlatform,
ConsigneeContactName = request.Consignee.ContactName,
ConsigneeMobile = request.Consignee.Mobile,
ConsigneeProvince = request.Consignee.Province,
ConsigneeCity = request.Consignee.City,
ConsigneeCounty = request.Consignee.County,
ConsigneeTown = request.Consignee.Town,
ConsigneeAddress = request.Consignee.Address,
PurchaserId = purchaseGroup.PurchaserId,
PurchaserName = purchaseGroup.PurchaserName,
PurchaseAccountId = purchaseAccount.Id,
PurchaseAmount = purchaseOrderSimpleInfo.TotalAmount,
ProductAmount = purchaseOrderSimpleInfo.ProductAmount,
PurchaseFreight = purchaseOrderSimpleInfo.FreightAmount,
Remark = purchaseGroup.Remark,
CreateTime = DateTime.Now,
PurchaseMethod = Enums.PurchaseMethod.线,
PurchaseOrderMode = request.PurchaseOrderMode
};
if (createOrderResponse.IsPay)
purchaseOrderV2.PayTime = DateTime.Now;
fsql.Transaction(() =>
{
fsql.Insert(purchaseOrderV2).ExecuteAffrows();
//fsql.Insert(purchaseOrderSku).ExecuteAffrows();
fsql.Insert(insertPurchaseOrderSkuList).ExecuteAffrows();
fsql.Update<PurchaseScheme>(updatePurchaseTimeSchemeIdList).Set(p => p.LastPurchaseTime, DateTime.Now).ExecuteAffrows();
});
successSkuIdList.AddRange(belongSkuGroups.Select(g => g.Key));
if (purchaseGroup.PurchasePlatform == Enums.Platform.)
{
qikuPackSkuConfigRequestList.Add(new
{
orderId = purchaseOrderV2.Id,
//shopId = request.ShopId.ToString(),
shopId = purchaseGroup.PurchaserId, //拳探店铺Id(商家Id)
originShopName = request.ShopName,
userName = purchaseAccount.AccountName,
platform = Enums.Platform.,
purchaseTaskModels = skuPackConfigList
});
}
}
catch (Exception ex)
{
failSkuList.AddRange(belongSkuGroups.Select(g => new BatchCreareOrderFailDetail()
{
SkuId = g.Key,
ErrorMsg = ex.Message
}));
//throw new BusinessException(errorBuilder.ToString());
}
}
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,
SuccessSkuIdList = successSkuIdList
};
}
private int GetQiKuWareType(Enums.StockType stockType)
{
if (stockType == Enums.StockType.)

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

@ -147,6 +147,8 @@ namespace BBWY.Server.Business
var select = fsql.Select<PurchaseScheme, Purchaser>().InnerJoin((ps, p) => ps.PurchaserId == p.Id);
if (querySchemeRequest.SchemeId != null && querySchemeRequest.SchemeId != 0)
select = select.Where((ps, p) => ps.Id == querySchemeRequest.SchemeId);
else if (querySchemeRequest.SchemeIdList != null && querySchemeRequest.SchemeIdList.Count() > 0)
select = select.Where((ps, p) => querySchemeRequest.SchemeIdList.Contains(ps.Id));
else
{
select = select.WhereIf(querySchemeRequest.ShopId != null && querySchemeRequest.ShopId != 0, (ps, p) => ps.ShopId == querySchemeRequest.ShopId)

1
BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase/BatchPurchasePreviewOrderRequest.cs

@ -25,7 +25,6 @@ namespace BBWY.Server.Model.Dto
public Enums.Platform PurchasePlatform { get; set; }
public string BelongSkuId { get; set; }
public string BelongProductId { get; set; }

90
BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase2/BatchPurchaseCargoParamRequestV2.cs

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BBWY.Server.Model.Dto
{
public class BatchPurchaseCargoParamRequestV2
{
/// <summary>
/// 采购商品Id
/// </summary>
public string ProductId { get; set; }
/// <summary>
/// 采购SkuId
/// </summary>
public string SkuId { get; set; }
/// <summary>
/// 采购SpecId 1688独有
/// </summary>
public string SpecId { get; set; }
/// <summary>
/// 采购SKU数量
/// </summary>
public int Quantity { get; set; }
#region BelongInfo
/// <summary>
/// 归属SKUId(JD)
/// </summary>
public string BelongSkuId { get; set; }
///// <summary>
///// 归属商品Id(JD)
///// </summary>
//public string BelongProductId { get; set; }
///// <summary>
///// 归属商品价格(JD)
///// </summary>
//public decimal BelongPrice { get; set; }
///// <summary>
///// 归属商品标题(JD)
///// </summary>
//public string BelongSkuTitle { get; set; }
///// <summary>
///// 归属商品Logo(JD)
///// </summary>
//public string BelongLogo { get; set; }
/// <summary>
/// 归属SKU数量(JD)
/// </summary>
public int BelongQuantity { get; set; }
/// <summary>
/// 采购方案Id
/// </summary>
public long BelongSchemeId { get; set; }
#endregion
}
public class BatchPurchaseCargoParamGroupRequestV2
{
/// <summary>
/// 采购商Id
/// </summary>
public string PurchaserId { get; set; }
/// <summary>
/// 采购商名称
/// </summary>
public string PurchaserName { get; set; }
public Enums.Platform PurchasePlatform { get; set; }
/// <summary>
/// 下单备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 采购商品列表
/// </summary>
public IList<BatchPurchaseCargoParamRequestV2> CargoParamList { get; set; }
}
}

25
BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase2/BatchPurchaseCreateOrderRequestV2.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BBWY.Server.Model.Dto
{
public class BatchPurchaseCreateOrderRequestV2 : BatchPurchasePreviewOrderRequestV2
{
/// <summary>
/// 扩展字段 ,格式参考报价接口返回值
/// </summary>
public string Extensions { get; set; }
public long ShopId { get; set; }
public string ShopName { get; set; }
public string AutoPay { get; set; }
/// <summary>
/// 打包设置
/// </summary>
public IList<PackSkuConfigRequest> PackSkuConfigList { get; set; }
}
}

22
BBWY.Server.Model/Dto/Request/PurchaseOrderV2/BatchPurchase2/BatchPurchasePreviewOrderRequestV2.cs

@ -0,0 +1,22 @@
using BBWY.Server.Model.Db;
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
public class BatchPurchasePreviewOrderRequestV2
{
/// <summary>
/// 采购账号列表
/// </summary>
public IList<PurchaseAccount> PurchaseAccountList { get; set; }
public Enums.PurchaseOrderMode PurchaseOrderMode { get; set; }
/// <summary>
/// 收货人信息
/// </summary>
public ConsigneeRequest Consignee { get; set; }
public IList<BatchPurchaseCargoParamGroupRequestV2> CargoParamGroupList { get; set; }
}
}

5
BBWY.Server.Model/Dto/Request/PurchaseScheme/QuerySchemeRequest.cs

@ -9,6 +9,11 @@ namespace BBWY.Server.Model.Dto
/// </summary>
public long? SchemeId { get; set; }
/// <summary>
/// 采购方案Id集合
/// </summary>
public IList<long> SchemeIdList { get; set; }
public long? ShopId { get; set; }
public IList<string> SkuIdList { get; set; }

2
BBWY.Server.Model/Enums.cs

@ -3,7 +3,7 @@
public class Enums
{
/// <summary>
/// 电商平台
/// 电商平台 淘宝 = 0,京东 = 1,阿里巴巴 = 2, 拼多多 = 3,微信 = 4,拳探 = 10
/// </summary>
public enum Platform
{

Loading…
Cancel
Save