|
|
@@ -42,16 +42,19 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<WeighOrderDto> CreateWeighOrder(WeighOrderCreteDto inputDto) |
|
|
|
{ |
|
|
|
var diningPlateInfo =await GetDiningPlateInfoByQRCode(inputDto.QRCode); |
|
|
|
if (diningPlateInfo==null|| diningPlateInfo.Status!=0) |
|
|
|
{ |
|
|
|
throw Oops.Oh("餐盘不存在或者被停用"); |
|
|
|
} |
|
|
|
var result = new WeighOrderDto(); |
|
|
|
|
|
|
|
var diningPlateOccupyl = await GetDiningPlateOccupyInfo(inputDto.DiningPlateInfo.Select(x => x.DiningPlateId).ToList()); |
|
|
|
foreach (var item in inputDto.DiningPlateInfo) |
|
|
|
var diningPlateOccupyl = await GetDiningPlateOccupyInfo(new List<string>() { inputDto.QRCode}); |
|
|
|
|
|
|
|
var thisDiningPlate = diningPlateOccupyl.FirstOrDefault(x => x.DiningPlateId == diningPlateInfo.Id); |
|
|
|
if (thisDiningPlate != null && thisDiningPlate.IsOccupy) |
|
|
|
{ |
|
|
|
var thisDiningPlate = diningPlateOccupyl.FirstOrDefault(x => x.DiningPlateId == item.DiningPlateId); |
|
|
|
if (thisDiningPlate != null && thisDiningPlate.IsOccupy) |
|
|
|
{ |
|
|
|
throw Oops.Oh("餐盘被占用"); |
|
|
|
} |
|
|
|
throw Oops.Oh("餐盘被占用"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -65,49 +68,23 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
PayStates = 0, |
|
|
|
SceneId = CurrentUser.StoreId, |
|
|
|
States = 0, |
|
|
|
TotalAmount = inputDto.TotalAmount, |
|
|
|
Subject = inputDto.Subject, |
|
|
|
TotalAmount =0, |
|
|
|
Subject ="", |
|
|
|
}; |
|
|
|
//添加订单 |
|
|
|
var res = await db.Insertable(order).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
var orderGoods = new List<BPA_WeighOrderGoods>(); |
|
|
|
if (inputDto.Goods != null) |
|
|
|
{ |
|
|
|
foreach (var item in inputDto.Goods) |
|
|
|
{ |
|
|
|
orderGoods.Add(new BPA_WeighOrderGoods() |
|
|
|
{ |
|
|
|
GoodsAttribute = "", |
|
|
|
GoodsId = item.GoodsId, |
|
|
|
GoodsName = item.GoodsName, |
|
|
|
GoodsWeight = item.GoodsWeight, |
|
|
|
GroupId = CurrentUser.TenantId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
OrderId = order.Id |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var diningPlate = new List<BPA_WeighOrderDiningPlate>(); |
|
|
|
if (inputDto.DiningPlateInfo != null) |
|
|
|
diningPlate.Add(new BPA_WeighOrderDiningPlate() |
|
|
|
{ |
|
|
|
foreach (var item in inputDto.DiningPlateInfo) |
|
|
|
{ |
|
|
|
diningPlate.Add(new BPA_WeighOrderDiningPlate() |
|
|
|
{ |
|
|
|
DiningPlateId = item.DiningPlateId, |
|
|
|
GroupId = CurrentUser.TenantId, |
|
|
|
WeighOrderId = order.Id, |
|
|
|
ChipCode = item.ChipCode, |
|
|
|
QRCode = item.QRCode, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DiningPlateId = diningPlateInfo.Id, |
|
|
|
GroupId = CurrentUser.TenantId, |
|
|
|
WeighOrderId = order.Id, |
|
|
|
ChipCode = diningPlateInfo.ChipCode, |
|
|
|
QRCode = diningPlateInfo.QRCode, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
}); |
|
|
|
|
|
|
|
//添加子订单 |
|
|
|
if (res > 0) |
|
|
@@ -122,10 +99,9 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
PayStates = order.PayStates, |
|
|
|
SceneId = order.SceneId, |
|
|
|
States = order.States, |
|
|
|
Subject = inputDto.Subject, |
|
|
|
Subject ="", |
|
|
|
TotalAmount = order.TotalAmount, |
|
|
|
}; |
|
|
|
await db.Insertable(orderGoods).ExecuteCommandAsync(); |
|
|
|
await db.Insertable(diningPlate).ExecuteCommandAsync(); |
|
|
|
} |
|
|
|
|
|
|
@@ -137,6 +113,8 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 添加订单商品 |
|
|
|
/// </summary> |
|
|
@@ -717,5 +695,29 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<DiningPlateInfoDto> GetDiningPlateInfoByQRCode(string qrCode) |
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
Dictionary<string, string> dic = new Dictionary<string, string>(); |
|
|
|
dic.Add("GroupId", CurrentUser.TenantId); |
|
|
|
var url = App.Configuration["GroupMealUrl"] + "api/DiningPlate/GetDiningPlateInfoByQRCode?qrCode="+ qrCode; |
|
|
|
var jsonData = HttpHelper.PostData(url, "",Encoding.UTF8,"application/json", dic); |
|
|
|
var data = JsonConvert.DeserializeObject<ResultSAASManageDto<DiningPlateInfoDto>>(jsonData); |
|
|
|
|
|
|
|
if (data.statusCode != 200) |
|
|
|
{ |
|
|
|
throw Oops.Oh(data.errors); |
|
|
|
} |
|
|
|
return data.data; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
throw Oops.Oh("请求错误"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |