|
|
@@ -44,6 +44,17 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
{ |
|
|
|
var result = new WeighOrderDto(); |
|
|
|
|
|
|
|
var diningPlateOccupyl = await GetDiningPlateOccupyInfo(inputDto.DiningPlateInfo.Select(x => x.DiningPlateId).ToList()); |
|
|
|
foreach (var item in inputDto.DiningPlateInfo) |
|
|
|
{ |
|
|
|
var thisDiningPlate = diningPlateOccupyl.FirstOrDefault(x => x.DiningPlateId == item.DiningPlateId); |
|
|
|
if (thisDiningPlate!=null&&thisDiningPlate.IsOccupy) |
|
|
|
{ |
|
|
|
throw Oops.Oh("餐盘被占用"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var order = new BPA_WeighOrder() |
|
|
|
{ |
|
|
|
CreateAt = DateTime.Now, |
|
|
@@ -141,7 +152,10 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
} |
|
|
|
|
|
|
|
var goodsList = await GetGoodsList(inputDto.Select(x => x.GoodsId).ToList()); |
|
|
|
|
|
|
|
if (goodsList==null) |
|
|
|
{ |
|
|
|
throw Oops.Oh("商品不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
var orderGoods = new List<BPA_WeighOrderGoods>(); |
|
|
|
foreach (var item in inputDto) |
|
|
@@ -160,7 +174,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
GoodsWeight = item.GoodsWeight, |
|
|
|
GroupId = CurrentUser.TenantId, |
|
|
|
OrderId = item.OrderId, |
|
|
|
TotalAmount = thisGoods.Price, |
|
|
|
TotalAmount = thisGoods.Price* item.GoodsWeight, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
|
|
|
|
}); |
|
|
@@ -191,7 +205,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
foreach (var item in inputDto) |
|
|
|
{ |
|
|
|
var thisDiningPlate = diningPlateOccupyl.FirstOrDefault(x => x.DiningPlateId == item.DiningPlateId); |
|
|
|
if (thisDiningPlate.IsOccupy) |
|
|
|
if (thisDiningPlate==null||thisDiningPlate.IsOccupy) |
|
|
|
{ |
|
|
|
throw Oops.Oh("餐盘被占用"); |
|
|
|
} |
|
|
@@ -273,6 +287,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
OrderId = x.FirstOrDefault()?.OrderId, |
|
|
|
}) |
|
|
|
.ToList(); |
|
|
|
result.TotalAmount = result.GoodsInfo.Sum(x => x.TotalAmount); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -288,7 +303,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
}).ToListAsync(); |
|
|
|
result.DiningPlateInfo = diningPlate; |
|
|
|
|
|
|
|
result.TotalAmount = result.GoodsInfo.Sum(x => x.TotalAmount); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
@@ -340,6 +355,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
GroupId = x.GroupId, |
|
|
|
Id = x.Id, |
|
|
|
OrderId = x.OrderId, |
|
|
|
TotalAmount= x.TotalAmount, |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
@@ -352,6 +368,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
GoodsWeight = x.Sum(p => p.GoodsWeight), |
|
|
|
GroupId = x.FirstOrDefault()?.GroupId, |
|
|
|
OrderId = x.FirstOrDefault()?.OrderId, |
|
|
|
TotalAmount= x.Sum(p => p.TotalAmount), |
|
|
|
}) |
|
|
|
.ToList(); |
|
|
|
|
|
|
@@ -385,9 +402,18 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
|
|
|
|
result.PayStates = inputDto.PayStates; |
|
|
|
result.States = inputDto.States; |
|
|
|
|
|
|
|
await db.Insertable(new BPA_WeighOrderStatesRecord() |
|
|
|
{ |
|
|
|
BeforeTheChange = result.States, |
|
|
|
AfterTheChange = inputDto.States, |
|
|
|
CreateAt=DateTime.Now, |
|
|
|
OrderId=inputDto.OrderId, |
|
|
|
Id=Guid.NewGuid().ToString(), |
|
|
|
GroupId= CurrentUser.TenantId |
|
|
|
|
|
|
|
}).ExecuteCommandAsync(); |
|
|
|
var res = await db.Updateable(result).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
return res > 0; |
|
|
|
} |
|
|
|
|
|
|
@@ -434,7 +460,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
.Select((a, b, c) => new DiningPlateDto() |
|
|
|
{ |
|
|
|
DiningPlateId = a.DiningPlateId, |
|
|
|
IsOccupy = c.States == 1 ? true : (b == null || b.Id == null) ? true : false, |
|
|
|
IsOccupy = c.States == 1 ? false : (b == null || b.Id == null) ? true : false, |
|
|
|
WeighOrderId = c.Id |
|
|
|
}).ToListAsync(); |
|
|
|
|
|
|
@@ -530,20 +556,17 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service |
|
|
|
{ |
|
|
|
Dictionary<string, string> dic = new Dictionary<string, string>(); |
|
|
|
dic.Add("GroupId", CurrentUser.TenantId); |
|
|
|
var url = App.Configuration["GroupMealOrderUrl"] + "api/goods/GetGoodsList"; |
|
|
|
var url = App.Configuration["GroupMealBaseUrl"] + "api/goods/GetGoodsListByIds"; |
|
|
|
var inputData = JsonConvert.SerializeObject(ids); |
|
|
|
var jsonData = HttpHelper.PostData(url, inputData, Encoding.UTF8, "application/json", dic); |
|
|
|
var data = JsonConvert.DeserializeObject<ResultSAASManageDto>(jsonData); |
|
|
|
var data = JsonConvert.DeserializeObject<ResultSAASManageDto<List<GoodsInfoBaseView>>>(jsonData); |
|
|
|
|
|
|
|
if (data.statusCode != 200) |
|
|
|
{ |
|
|
|
throw Oops.Oh(data.errors); |
|
|
|
} |
|
|
|
|
|
|
|
if (data.data != null) |
|
|
|
{ |
|
|
|
res = data.data as List<GoodsInfoBaseView>; |
|
|
|
} |
|
|
|
return data.data; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|