@@ -0,0 +1,57 @@ | |||
using BPA.KitChen.GroupMealOrder.Application.BaseDto; | |||
using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos; | |||
using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Services; | |||
using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.CheckService.Services; | |||
using BPA.KitChen.GroupMealOrder.Core.Entity; | |||
using BPA.KitChen.GroupMealOrder.Core; | |||
using Furion.DatabaseAccessor; | |||
using Furion.DynamicApiController; | |||
using Furion.FriendlyException; | |||
using Microsoft.AspNetCore.Authorization; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder | |||
{ | |||
[ApiDescriptionSettings("开放平台", Tag = "小程序订单"), AllowAnonymous] | |||
public class AppletOrderServices: IDynamicApiController | |||
{ | |||
private readonly IAppletOrderService _appletOrderService; | |||
public AppletOrderServices(IAppletOrderService appletOrderService) | |||
{ | |||
_appletOrderService = appletOrderService; | |||
} | |||
[HttpPost("/api/ExternalPlatform/AppletOrder/CreateOrder")] | |||
public async Task<bool> AddOrder(OrderInsertDto dto) | |||
{ | |||
return await _appletOrderService.AddOrder(dto); | |||
} | |||
/// <summary> | |||
/// 查询订单 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/ExternalPlatform/AppletOrder/GetOrder")] | |||
public async Task<List<OrderViewDto>> GetOrder(OrderQueryDto dto) | |||
{ | |||
return await _appletOrderService.GetOrder(dto); | |||
} | |||
[HttpPost("/api/AppletOrder/GetOrderPageList")] | |||
public async Task<PageUtil> GetOrder(OrderQueryPageDto dto) | |||
{ | |||
return await _appletOrderService.GetOrder(dto); | |||
} | |||
} | |||
} |
@@ -0,0 +1,200 @@ | |||
using BPA.KitChen.GroupMealOrder.Application.BaseDto; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos | |||
{ | |||
/// <summary> | |||
/// 订单流水查询 | |||
/// </summary> | |||
public class OrderFlowQuery : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string Id { get; set; } | |||
public string orderFlowId { get; set; } | |||
/// <summary> | |||
/// 加盟商编号 | |||
/// </summary> | |||
public string FranchiseeId { get; set; } | |||
/// <summary> | |||
/// 加盟商名称 | |||
/// </summary> | |||
public string FranchiseeName { get; set; } | |||
/// <summary> | |||
/// 店铺名称编号(设备名称编号) | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 店铺名称 | |||
/// </summary> | |||
public string StoreName { get; set; } | |||
/// <summary> | |||
/// 商品key | |||
/// </summary> | |||
public string GoodsId { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 商品类型编号 | |||
/// </summary> | |||
public string GoodsTypeId { get; set; } | |||
/// <summary> | |||
/// 商品类型名称 | |||
/// </summary> | |||
public string GoodsTypeName { get; set; } | |||
/// <summary> | |||
/// 店铺分类编号(设备类型关联值) | |||
/// </summary> | |||
public string StoreTypeId { get; set; } | |||
/// <summary> | |||
/// 店铺分类名称(设备类型名称) | |||
/// </summary> | |||
public string StoreTypeName { get; set; } | |||
/// <summary> | |||
/// 订单编号 | |||
/// </summary> | |||
public string Order_Number { get; set; } | |||
/// <summary> | |||
/// 应付金额 | |||
/// </summary> | |||
public decimal? Order_OriginalMoney { get; set; } | |||
/// <summary> | |||
/// 实付金额 | |||
/// </summary> | |||
public decimal? Order_RealMoney { get; set; } | |||
public decimal? RefundOriginalMoney { get; set; } | |||
public decimal? RefundRealMoney { get; set; } | |||
/// <summary> | |||
/// 支付方式(微信支付) | |||
/// </summary> | |||
public int PayMode { get; set; } | |||
public int Order_Status { get; set; } | |||
/// <summary> | |||
/// 订单汇总数量 | |||
/// </summary> | |||
public int Order_Count { get; set; } | |||
/// <summary> | |||
/// 订单开始时间 | |||
/// </summary> | |||
public DateTime Order_CreateTime { get; set; } | |||
/// <summary> | |||
/// 订单结束时间 | |||
/// </summary> | |||
public DateTime? Order_EndTime { get; set; } | |||
/// <summary> | |||
/// 订单类型 | |||
/// 0-->正常 | |||
/// 1--立即吃面 | |||
/// 2-->其他 | |||
/// </summary> | |||
public int PlaceMode { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string Customer_Name { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string Customer_Tel { get; set; } | |||
public int CountNumber { get; set; } | |||
public int WechatIsCheck { get; set; } | |||
} | |||
public class OrderSumQuery : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 加盟商编号 | |||
/// </summary> | |||
public string FranchiseeId { get; set; } | |||
/// <summary> | |||
/// 加盟商名称 | |||
/// </summary> | |||
public string FranchiseeName { get; set; } | |||
/// <summary> | |||
/// 店铺名称编号(设备名称编号) | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 店铺名称 | |||
/// </summary> | |||
public string StoreName { get; set; } | |||
/// <summary> | |||
/// 商品key | |||
/// </summary> | |||
public string GoodsId { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 商品类型编号 | |||
/// </summary> | |||
public string GoodsTypeId { get; set; } | |||
/// <summary> | |||
/// 商品类型名称 | |||
/// </summary> | |||
public string GoodsTypeName { get; set; } | |||
/// <summary> | |||
/// 店铺分类编号(设备类型关联值) | |||
/// </summary> | |||
public string StoreTypeId { get; set; } | |||
/// <summary> | |||
/// 店铺分类名称(设备类型名称) | |||
/// </summary> | |||
public string StoreTypeName { get; set; } | |||
/// <summary> | |||
/// 订单编号 | |||
/// </summary> | |||
public string Order_Number { get; set; } | |||
/// <summary> | |||
/// 应付金额 | |||
/// </summary> | |||
public decimal? Order_OriginalMoney { get; set; } | |||
/// <summary> | |||
/// 实付金额 | |||
/// </summary> | |||
public decimal? Order_RealMoney { get; set; } | |||
public decimal? DiscountMoney { get; set; } | |||
/// <summary> | |||
/// 支付方式(微信支付) | |||
/// </summary> | |||
public int PayMode { get; set; } | |||
/// <summary> | |||
/// 订单汇总数量 | |||
/// </summary> | |||
public int SumOrder { get; set; } | |||
public int OrderNum { get; set; } | |||
public int BoxNum { get; set; } | |||
public int NowNum { get; set; } | |||
public int Abandoned { get; set; } | |||
public int Refund { get; set; } | |||
public decimal refundMoney { get; set; } | |||
public int refundNum { get; set; } | |||
public int Customer { get; set; } | |||
public int CountDetail { get; set; } | |||
/// <summary> | |||
/// 订单开始时间 | |||
/// </summary> | |||
public DateTime? Order_CreateTime { get; set; } | |||
/// <summary> | |||
/// 订单结束时间 | |||
/// </summary> | |||
public DateTime? Order_EndTime { get; set; } | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos | |||
{ | |||
public class OrderInsertDto | |||
{ | |||
/// <summary> | |||
///场景id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 商户订单号,由商家自定义 | |||
/// </summary> | |||
public string TradeNo { get; set; } | |||
///// <summary> | |||
///// 订单状态 0未付款,1已付款,-1退单申请,-2退单中,-3已退单,-4取消交易 -5撤销申请 | |||
///// </summary> | |||
//public int OrderStatus { get; set; } | |||
/// <summary> | |||
/// 订单总金额 | |||
/// </summary> | |||
public decimal TotalAmount { get; set; } | |||
/// <summary> | |||
/// 订单数量 | |||
/// </summary> | |||
public int OrderCount { get; set; } | |||
/// <summary> | |||
/// 订单标题 | |||
/// </summary> | |||
public string Subject { get; set; } | |||
public List<Orderdetail> Orderdetail { get; set; } | |||
} | |||
public class Orderdetail | |||
{ | |||
public string GoodsNumber { get; set; } | |||
public string GoodsId { get; set; } | |||
public string GoodsName { get; set; } | |||
public List<GoodsAttr> GoodsAttr { get; set; } | |||
/// <summary> | |||
/// 是否自定义配方 | |||
/// </summary> | |||
public bool isCustom { get; set; } | |||
/// <summary> | |||
/// 工艺配方详情 | |||
/// </summary> | |||
public List<FormulaDetail> FormulaDetail { get; set; } | |||
} | |||
public class GoodsAttr | |||
{ | |||
public string GoodsId { get; set; } | |||
public string AttributeId { get; set; } | |||
public string AttributeName { get; set; } | |||
public int Count { get; set; } | |||
public decimal Price { get; set; } | |||
} | |||
public class FormulaDetail | |||
{ | |||
public string DeviceId { get; set; } | |||
public string GoodsId { get; set; } | |||
public string TechnologyId { get; set; } | |||
public string ActionName { get; set; } | |||
public string ActionValue { get; set; } | |||
public int Sort { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos | |||
{ | |||
public class OrderQueryDto | |||
{ | |||
public string TradeNo { get; set; } | |||
public string OrderNumber { get; set; } | |||
public string GoodsName { get; set; } | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
using BPA.KitChen.GroupMealOrder.Application.BaseDto; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos | |||
{ | |||
public class OrderQueryInputDto : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 加盟商编号 | |||
/// </summary> | |||
public string FranchiseeId { get; set; } | |||
/// <summary> | |||
/// 订单号 | |||
/// </summary> | |||
public string order_Number { get; set; } | |||
public string Customer_Tel { get; set; } | |||
/// <summary> | |||
/// 店铺名称编号(设备名称编号) | |||
/// </summary> | |||
public string[] StoreId { get; set; } | |||
/// <summary> | |||
/// <summary> | |||
/// 商品key | |||
/// </summary> | |||
public string[] GoodsId { get; set; } | |||
/// <summary> | |||
/// 商品类型编号 | |||
/// </summary> | |||
public string[] GoodsTypeId { get; set; } | |||
/// <summary> | |||
/// 店铺分类编号(设备类型关联值) | |||
/// </summary> | |||
public string StoreTypeId { get; set; } | |||
/// <summary> | |||
/// 订单开始时间 | |||
/// </summary> | |||
public DateTime? Order_CreateTime { get; set; } | |||
/// <summary> | |||
/// 订单结束时间 | |||
/// </summary> | |||
public DateTime? Order_EndTime { get; set; } | |||
public bool isreport { get; set; } = false; | |||
public bool IsExport { get; set; } = false; | |||
/// <summary> | |||
/// 订单状态 | |||
/// </summary> | |||
public int? OrderStatus { get; set; } | |||
/// <summary> | |||
/// 支付渠道 0微信 1支付宝 2 余额 3银联 | |||
/// </summary> | |||
public int? PayMode { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos | |||
{ | |||
public class OrderQueryPageDto | |||
{ | |||
public int Current { get; set; } | |||
public int PageSize { get; set; } | |||
public string TradeNo { get; set; } | |||
public string OrderNumber { get; set; } | |||
public string GoodsName { get; set; } | |||
public string StoreId { get; set; } | |||
public string Subject { get; set; } | |||
public DateTime? CreateAt { get; set; } | |||
} | |||
} |
@@ -0,0 +1,84 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos | |||
{ | |||
public class OrderViewDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
///场景id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 平台订单号 | |||
/// </summary> | |||
public string OrderNumber { get; set; } | |||
/// <summary> | |||
/// 商户订单号,由商家自定义 | |||
/// </summary> | |||
public string TradeNo { get; set; } | |||
/// <summary> | |||
/// 订单状态 0成功,1失败 | |||
/// </summary> | |||
public int OrderStatus { get; set; } | |||
/// <summary> | |||
/// 订单总金额 | |||
/// </summary> | |||
public decimal TotalAmount { get; set; } | |||
/// <summary> | |||
/// 订单数量 | |||
/// </summary> | |||
public int OrderCount { get; set; } | |||
/// <summary> | |||
/// 订单标题 | |||
/// </summary> | |||
public string Subject { get; set; } | |||
public DateTime CreatedAt { get; set; } | |||
public List<OrderdetaiViewDto> Orderdetail { get; set; } | |||
} | |||
public class OrderdetaiViewDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 主订单表Id | |||
/// </summary> | |||
public string OrderId { get; set; } | |||
public string GoodsNumber { get; set; } | |||
public string GoodsId { get; set; } | |||
public string GoodsName { get; set; } | |||
public List<GoodsAttrViewDto> GoodsAttr { get; set; } | |||
/// <summary> | |||
/// 是否自定义配方 | |||
/// </summary> | |||
public bool isCustom { get; set; } | |||
/// <summary> | |||
/// 工艺配方详情 | |||
/// </summary> | |||
public List<FormulaDetailViewDto> FormulaDetail { get; set; } | |||
} | |||
public class GoodsAttrViewDto | |||
{ | |||
public string Id { get; set; } | |||
public string GoodsId { get; set; } | |||
public string SuborderId { get; set; } | |||
public string AttributeId { get; set; } | |||
public string AttributeName { get; set; } | |||
public int Count { get; set; } | |||
public decimal Price { get; set; } | |||
} | |||
public class FormulaDetailViewDto | |||
{ | |||
public string Id { get; set; } | |||
public string SuborderId { get; set; } | |||
public string DeviceId { get; set; } | |||
public string GoodsId { get; set; } | |||
public string TechnologyId { get; set; } | |||
public string ActionName { get; set; } | |||
public string ActionValue { get; set; } | |||
public int Sort { get; set; } | |||
} | |||
} |
@@ -0,0 +1,167 @@ | |||
using BPA.KitChen.GroupMealOrder.Application.BaseDto; | |||
using BPA.KitChen.GroupMealOrder.Core.Entity; | |||
using BPA.KitChen.GroupMealOrder.Core; | |||
using Furion.DependencyInjection; | |||
using Furion.FriendlyException; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Services | |||
{ | |||
public class AppletOrderService : IAppletOrderService, ITransient | |||
{ | |||
/// <summary> | |||
/// 核心对象:拥有完整的SqlSugar全部功能 | |||
/// </summary> | |||
private readonly ISqlSugarClient db; | |||
/// <summary> | |||
/// construct | |||
/// </summary> | |||
/// <param name="sqlSugarRepository"></param> | |||
public AppletOrderService(ISqlSugarClient _db) | |||
{ | |||
db = _db; | |||
} | |||
public async Task<bool> AddOrder(OrderInsertDto dto) | |||
{ | |||
try | |||
{ | |||
db.Ado.BeginTran(); | |||
var check = db.Queryable<BPA_AppletOrder>().Where(x => x.TradeNo == dto.TradeNo).Any(); | |||
if (check) throw Oops.Oh("订单已存在"); | |||
BPA_AppletOrder _order = new(); | |||
_order.Id = Guid.NewGuid().ToString(); | |||
_order.StoreId = dto.StoreId; | |||
_order.TradeNo = dto.TradeNo; | |||
_order.TotalAmount = dto.TotalAmount; | |||
_order.OrderCount = dto.OrderCount; | |||
_order.Subject = dto.Subject; | |||
_order.OrderNumber = DateTime.Now.ToString("yyyMMddhhmmss"); | |||
_order.CreateAt = DateTime.Now; | |||
_order.GroupId = CurrentUser.TenantId; | |||
List<BPA_AppletSubOrder> SubOrdeList = new(); | |||
List<BPA_AppletOrderGoodsArrt> OrderGoodsArrtList = new(); | |||
List<BPA_AppletOrderGoodsTechnology> OrderGoodsTechnologyList = new(); | |||
if (dto.Orderdetail != null) | |||
{ | |||
for (int i = 0; i < dto.Orderdetail.Count; i++) | |||
{ | |||
BPA_AppletSubOrder _subOrder = new(); | |||
_subOrder.Id = Guid.NewGuid().ToString(); | |||
_subOrder.OrderId = _order.Id; | |||
_subOrder.GoodsNumber = dto.Orderdetail[i].GoodsNumber; | |||
_subOrder.GoodsId = dto.Orderdetail[i].GoodsId; | |||
_subOrder.GoodsName = dto.Orderdetail[i].GoodsName; | |||
_subOrder.GoodsId = dto.Orderdetail[i].GoodsId; | |||
_subOrder.isCustom = dto.Orderdetail[i].isCustom; | |||
_subOrder.CreateAt = DateTime.Now; | |||
SubOrdeList.Add(_subOrder); | |||
for (int t = 0; t < dto.Orderdetail[i].GoodsAttr.Count(); t++) | |||
{ | |||
BPA_AppletOrderGoodsArrt goodsAttr = new(); | |||
goodsAttr.Id = Guid.NewGuid().ToString(); | |||
goodsAttr.SuborderId = _subOrder.Id; | |||
goodsAttr.GoodsId = dto.Orderdetail[i].GoodsAttr[t].GoodsId; | |||
goodsAttr.AttributeId = dto.Orderdetail[i].GoodsAttr[t].AttributeId; | |||
goodsAttr.AttributeName = dto.Orderdetail[i].GoodsAttr[t].AttributeName; | |||
goodsAttr.Count = dto.Orderdetail[i].GoodsAttr[t].Count; | |||
goodsAttr.Price = dto.Orderdetail[i].GoodsAttr[t].Price; | |||
goodsAttr.CreateAt = DateTime.Now; | |||
OrderGoodsArrtList.Add(goodsAttr); | |||
} | |||
for (int y = 0; y < dto.Orderdetail[i].FormulaDetail.Count; y++) | |||
{ | |||
BPA_AppletOrderGoodsTechnology orderGoodsTechnology = new(); | |||
orderGoodsTechnology.Id = Guid.NewGuid().ToString(); | |||
orderGoodsTechnology.SuborderId = _subOrder.Id; | |||
orderGoodsTechnology.DeviceId = dto.Orderdetail[i].FormulaDetail[y].DeviceId; | |||
orderGoodsTechnology.GoodsId = dto.Orderdetail[i].FormulaDetail[y].GoodsId; | |||
orderGoodsTechnology.TechnologyId = dto.Orderdetail[i].FormulaDetail[y].TechnologyId; | |||
orderGoodsTechnology.ActionName = dto.Orderdetail[i].FormulaDetail[y].ActionName; | |||
orderGoodsTechnology.ActionValue = dto.Orderdetail[i].FormulaDetail[y].ActionValue; | |||
orderGoodsTechnology.Sort = dto.Orderdetail[i].FormulaDetail[y].Sort; | |||
orderGoodsTechnology.CreateAt = DateTime.Now; | |||
OrderGoodsTechnologyList.Add(orderGoodsTechnology); | |||
} | |||
} | |||
} | |||
await db.Insertable(_order).ExecuteCommandAsync(); | |||
await db.Insertable(SubOrdeList).ExecuteCommandAsync(); | |||
await db.Insertable(OrderGoodsArrtList).ExecuteCommandAsync(); | |||
await db.Insertable(OrderGoodsTechnologyList).ExecuteCommandAsync(); | |||
db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.Ado.RollbackTran(); | |||
throw Oops.Oh("创建订单失败,失败信息:" + ex.Message); | |||
} | |||
} | |||
/// <summary> | |||
/// 查询订单 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
public async Task<List<OrderViewDto>> GetOrder(OrderQueryDto dto) | |||
{ | |||
var list = await db.Queryable<BPA_AppletOrder>() | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.TradeNo), x => x.TradeNo == dto.TradeNo) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.OrderNumber), x => x.OrderNumber == dto.OrderNumber) | |||
.Select(x => new OrderViewDto() { Id = x.Id.SelectAll() }) | |||
.Mapper(x => | |||
{ | |||
var de = db.Queryable<BPA_AppletSubOrder>().Where(p => p.OrderId == x.Id) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.GoodsName), x => x.GoodsName.Contains(dto.GoodsName)) | |||
.Select(x => new OrderdetaiViewDto() { Id = x.Id.SelectAll() }) | |||
.Mapper(g => | |||
{ | |||
var GoodsAttr = db.Queryable<BPA_AppletOrderGoodsArrt>().Where(x => x.SuborderId == g.Id).Select(x => new GoodsAttrViewDto() { Id = x.Id.SelectAll() }).ToList(); | |||
g.GoodsAttr = GoodsAttr; | |||
var FormulaDetail = db.Queryable<BPA_AppletOrderGoodsTechnology>().Where(x => x.SuborderId == g.Id).Select(x => new FormulaDetailViewDto() { Id = x.Id.SelectAll() }).ToList(); | |||
g.FormulaDetail = FormulaDetail; | |||
}).ToList(); | |||
x.Orderdetail = de; | |||
}).ToListAsync(); | |||
return list; | |||
} | |||
public async Task<PageUtil> GetOrder(OrderQueryPageDto dto) | |||
{ | |||
RefAsync<int> total = 0; | |||
var list = await db.Queryable<BPA_AppletOrder>() | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.TradeNo), x => x.TradeNo == dto.TradeNo) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.OrderNumber), x => x.OrderNumber == dto.OrderNumber) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.StoreId), x => x.StoreId == dto.StoreId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.Subject), x => x.Subject == dto.Subject) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.CreateAt.ToString()), x => x.CreateAt == dto.CreateAt) | |||
.Select(x => new OrderViewDto() { Id = x.Id.SelectAll(), CreatedAt = x.CreateAt }) | |||
.Mapper(x => | |||
{ | |||
var de = db.Queryable<BPA_AppletSubOrder>().Where(p => p.OrderId == x.Id) | |||
.WhereIF(!string.IsNullOrWhiteSpace(dto.GoodsName), x => x.GoodsName.Contains(dto.GoodsName)) | |||
.Select(x => new OrderdetaiViewDto() { Id = x.Id.SelectAll() }) | |||
.Mapper(g => | |||
{ | |||
var GoodsAttr = db.Queryable<BPA_AppletOrderGoodsArrt>().Where(x => x.SuborderId == g.Id).Select(x => new GoodsAttrViewDto() { Id = x.Id.SelectAll() }).ToList(); | |||
g.GoodsAttr = GoodsAttr; | |||
var FormulaDetail = db.Queryable<BPA_AppletOrderGoodsTechnology>().Where(x => x.SuborderId == g.Id).Select(x => new FormulaDetailViewDto() { Id = x.Id.SelectAll() }).ToList(); | |||
g.FormulaDetail = FormulaDetail; | |||
}).ToList(); | |||
x.Orderdetail = de; | |||
}).ToPageListAsync(dto.Current, dto.PageSize, total); | |||
PageUtil util = new PageUtil() | |||
{ | |||
Total = total, | |||
Data = list | |||
}; | |||
return util; | |||
} | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
using BPA.KitChen.GroupMealOrder.Application.BaseDto; | |||
using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Dtos; | |||
using BPA.KitChen.GroupMealOrder.Core.Entity; | |||
using BPA.KitChen.GroupMealOrder.Core; | |||
using Furion.DatabaseAccessor; | |||
using Furion.FriendlyException; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.AppletOrder.Services | |||
{ | |||
public interface IAppletOrderService | |||
{ | |||
[HttpPost("/api/ExternalPlatform/AppletOrder/CreateOrder")] | |||
Task<bool> AddOrder(OrderInsertDto dto); | |||
/// <summary> | |||
/// 查询订单 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/ExternalPlatform/AppletOrder/GetOrder")] | |||
Task<List<OrderViewDto>> GetOrder(OrderQueryDto dto); | |||
[HttpPost("/api/AppletOrder/GetOrderPageList")] | |||
Task<PageUtil> GetOrder(OrderQueryPageDto dto); | |||
} | |||
} |
@@ -31,7 +31,8 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.TestService | |||
&& x.Namespace.Contains("BPA.KitChen.GroupMealOrder.Core.Entity")) | |||
.ToArray(); | |||
types = types.Where(x => x.Name != "BPA_Order"&&x.Name!= "BPA_SubOrder").ToArray(); | |||
SqlSugarDb.Db.CodeFirst.InitTables(types); | |||
types = types.Where(x => x.Name.Contains("BPA_Applet")).ToArray(); | |||
SqlSugarDb.Db.CodeFirst.InitTables(types); | |||
} | |||
catch (Exception e) | |||
{ | |||
@@ -0,0 +1,49 @@ | |||
using BPA.KitChen.GroupMealOrder.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Core.Entity | |||
{ | |||
[SugarTable("BPA_AppletOrder")] | |||
public class BPA_AppletOrder: IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
///场景id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
public string OrderNumber { get; set; } | |||
/// <summary> | |||
/// 商户订单号,由商家自定义 | |||
/// </summary> | |||
public string TradeNo { get; set; } | |||
/// <summary> | |||
/// 订单状态 0成功 1失败 | |||
/// </summary> | |||
public int OrderStatus { get; set; } | |||
/// <summary> | |||
/// 订单总金额 | |||
/// </summary> | |||
public decimal TotalAmount { get; set; } | |||
/// <summary> | |||
/// 订单数量 | |||
/// </summary> | |||
public int OrderCount { get; set; } | |||
/// <summary> | |||
/// 订单标题 | |||
/// </summary> | |||
public string Subject { get; set; } | |||
public string GroupId { get; set; } | |||
/// <summary> | |||
/// 主键 Guid | |||
/// </summary> | |||
[SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Id { get; set; } = Guid.NewGuid().ToString(); | |||
public DateTime CreateAt { get; set; } = DateTime.Now; | |||
public string CreateBy { get; set; } | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Core.Entity | |||
{ | |||
[SugarTable("BPA_AppletOrderGoodsArrt")] | |||
public class BPA_AppletOrderGoodsArrt | |||
{ | |||
public string Id { get; set; } | |||
public string SuborderId { get; set; } | |||
public string GoodsId { get; set; } | |||
public string AttributeId { get; set; } | |||
public string AttributeName { get; set; } | |||
public int Count { get; set; } | |||
public decimal Price { get; set; } | |||
public DateTime CreateAt { get; set; } | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Core.Entity | |||
{ | |||
[SugarTable("BPA_AppletOrderGoodsTechnology")] | |||
public class BPA_AppletOrderGoodsTechnology | |||
{ | |||
public string Id { get; set; } | |||
public string SuborderId { get; set; } | |||
public string DeviceId { get; set; } | |||
public string GoodsId { get; set; } | |||
public string TechnologyId { get; set; } | |||
public string ActionName { get; set; } | |||
public string ActionValue { get; set; } | |||
public int Sort { get; set; } | |||
public DateTime CreateAt { get; set; } | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
using BPA.KitChen.GroupMealOrder.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.GroupMealOrder.Core.Entity | |||
{ | |||
[SugarTable("BPA_AppletSubOrder")] | |||
public class BPA_AppletSubOrder : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 主键 Guid | |||
/// </summary> | |||
[SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Id { get; set; } = Guid.NewGuid().ToString(); | |||
public DateTime CreateAt { get; set; } = DateTime.Now; | |||
public string CreateBy { get; set; } | |||
/// <summary> | |||
/// 主订单表Id | |||
/// </summary> | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 商品表Id | |||
/// </summary> | |||
public string GoodsId { get; set; } | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 是否自定义配方 | |||
/// </summary> | |||
public bool isCustom { get; set; } | |||
/// <summary> | |||
/// 商品编号(第三方商品编号) | |||
/// </summary> | |||
public string GoodsNumber { get; set; } | |||
public string GroupId { get; set; } | |||
} | |||
} |