Browse Source

提交

master
gwbvipvip 9 months ago
parent
commit
4ab7191169
1 changed files with 36 additions and 13 deletions
  1. +36
    -13
      BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Service/WeighOrderService.cs

+ 36
- 13
BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Service/WeighOrderService.cs View File

@@ -44,6 +44,17 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
{ {
var result = new WeighOrderDto(); 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() var order = new BPA_WeighOrder()
{ {
CreateAt = DateTime.Now, 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()); var goodsList = await GetGoodsList(inputDto.Select(x => x.GoodsId).ToList());

if (goodsList==null)
{
throw Oops.Oh("商品不存在");
}


var orderGoods = new List<BPA_WeighOrderGoods>(); var orderGoods = new List<BPA_WeighOrderGoods>();
foreach (var item in inputDto) foreach (var item in inputDto)
@@ -160,7 +174,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
GoodsWeight = item.GoodsWeight, GoodsWeight = item.GoodsWeight,
GroupId = CurrentUser.TenantId, GroupId = CurrentUser.TenantId,
OrderId = item.OrderId, OrderId = item.OrderId,
TotalAmount = thisGoods.Price,
TotalAmount = thisGoods.Price* item.GoodsWeight,
Id = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(),


}); });
@@ -191,7 +205,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
foreach (var item in inputDto) foreach (var item in inputDto)
{ {
var thisDiningPlate = diningPlateOccupyl.FirstOrDefault(x => x.DiningPlateId == item.DiningPlateId); var thisDiningPlate = diningPlateOccupyl.FirstOrDefault(x => x.DiningPlateId == item.DiningPlateId);
if (thisDiningPlate.IsOccupy)
if (thisDiningPlate==null||thisDiningPlate.IsOccupy)
{ {
throw Oops.Oh("餐盘被占用"); throw Oops.Oh("餐盘被占用");
} }
@@ -273,6 +287,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
OrderId = x.FirstOrDefault()?.OrderId, OrderId = x.FirstOrDefault()?.OrderId,
}) })
.ToList(); .ToList();
result.TotalAmount = result.GoodsInfo.Sum(x => x.TotalAmount);
} }




@@ -288,7 +303,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
}).ToListAsync(); }).ToListAsync();
result.DiningPlateInfo = diningPlate; result.DiningPlateInfo = diningPlate;


result.TotalAmount = result.GoodsInfo.Sum(x => x.TotalAmount);


return result; return result;
} }
@@ -340,6 +355,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
GroupId = x.GroupId, GroupId = x.GroupId,
Id = x.Id, Id = x.Id,
OrderId = x.OrderId, OrderId = x.OrderId,
TotalAmount= x.TotalAmount,
}).ToList(); }).ToList();




@@ -352,6 +368,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
GoodsWeight = x.Sum(p => p.GoodsWeight), GoodsWeight = x.Sum(p => p.GoodsWeight),
GroupId = x.FirstOrDefault()?.GroupId, GroupId = x.FirstOrDefault()?.GroupId,
OrderId = x.FirstOrDefault()?.OrderId, OrderId = x.FirstOrDefault()?.OrderId,
TotalAmount= x.Sum(p => p.TotalAmount),
}) })
.ToList(); .ToList();


@@ -385,9 +402,18 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service


result.PayStates = inputDto.PayStates; result.PayStates = inputDto.PayStates;
result.States = inputDto.States; 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(); var res = await db.Updateable(result).ExecuteCommandAsync();

return res > 0; return res > 0;
} }


@@ -434,7 +460,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
.Select((a, b, c) => new DiningPlateDto() .Select((a, b, c) => new DiningPlateDto()
{ {
DiningPlateId = a.DiningPlateId, 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 WeighOrderId = c.Id
}).ToListAsync(); }).ToListAsync();


@@ -530,20 +556,17 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Service
{ {
Dictionary<string, string> dic = new Dictionary<string, string>(); Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("GroupId", CurrentUser.TenantId); 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 inputData = JsonConvert.SerializeObject(ids);
var jsonData = HttpHelper.PostData(url, inputData, Encoding.UTF8, "application/json", dic); 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) if (data.statusCode != 200)
{ {
throw Oops.Oh(data.errors); throw Oops.Oh(data.errors);
} }


if (data.data != null)
{
res = data.data as List<GoodsInfoBaseView>;
}
return data.data;
} }
catch (Exception e) catch (Exception e)
{ {


Loading…
Cancel
Save