Browse Source

提交

master
gwbvipvip 9 months ago
parent
commit
76cdb14491
3 changed files with 68 additions and 70 deletions
  1. +19
    -1
      BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Dtos/DiningPlateDto.cs
  2. +2
    -24
      BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Dtos/WeighOrderDto.cs
  3. +47
    -45
      BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Service/WeighOrderService.cs

+ 19
- 1
BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Dtos/DiningPlateDto.cs View File

@@ -1,4 +1,5 @@
using NPOI.SS.Formula.Functions;
using BPA.KitChen.GroupMealOrder.Core.Enum;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -21,4 +22,21 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Dtos
/// </summary>
public bool IsOccupy { get; set; }
}

public class DiningPlateInfoDto
{
public string Id { get; set; }

/// <summary>
/// 二维码
/// </summary>
public string QRCode { get; set; }

/// <summary>
/// 芯片码
/// </summary>
public string ChipCode { get; set; }

public int Status { get; set; }
}
}

+ 2
- 24
BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Dtos/WeighOrderDto.cs View File

@@ -138,36 +138,14 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.WeighOrder.Dtos

public class WeighOrderCreteDto
{
/// <summary>
/// 订单金额
/// </summary>
public decimal TotalAmount { get; set; }

/// <summary>
/// 订单标题
/// </summary>
[SugarColumn(IsNullable = true)]
public string Subject { get; set; }

/// <summary>
/// 场景id
/// </summary>
public string SceneId { get; set; }

/// <summary>
/// 创建人(会员Id)
/// </summary>
public string CreateId { get; set; }

/// <summary>
/// 商品
/// </summary>
public List<WeighOrderGoodsCreateDto> Goods { get; set; }

/// <summary>
/// 餐盘信息
/// </summary>
public List<WeighOrderDiningPlateCreateDto> DiningPlateInfo { get; set; }
public string QRCode { get; set; }

}



+ 47
- 45
BPA.KitChen.GroupMealOrder.Application/Service/WeighOrder/Service/WeighOrderService.cs View File

@@ -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("请求错误");
}

}
}
}

Loading…
Cancel
Save