diff --git a/BPA.KitChen.StoreManagement.Application/BPA.KitChen.StoreManagementOrder.Application.csproj b/BPA.KitChen.StoreManagement.Application/BPA.KitChen.StoreManagementOrder.Application.csproj new file mode 100644 index 0000000..3821eba --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/BPA.KitChen.StoreManagementOrder.Application.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/BPA.KitChen.StoreManagement.Application/BaseDto/DtoValidator.cs b/BPA.KitChen.StoreManagement.Application/BaseDto/DtoValidator.cs new file mode 100644 index 0000000..2c9cef7 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/BaseDto/DtoValidator.cs @@ -0,0 +1,19 @@ + +using BPA.KitChen.StoreManagementOrder.Core.Entity; +using BPA.KitChen.StoreManagementOrder.Core.Enum; +using BPA.KitChen.StoreManagementOrder.SqlSugar; +using MySqlConnector; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace BPA.KitChen.StoreManagementOrder.Application.BaseDto +{ + /// + /// Dto参数验证 + /// + public class DtoValidator + { + + + } +} diff --git a/BPA.KitChen.StoreManagement.Application/BaseDto/IXnInputBase.cs b/BPA.KitChen.StoreManagement.Application/BaseDto/IXnInputBase.cs new file mode 100644 index 0000000..be21113 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/BaseDto/IXnInputBase.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.BaseDto +{ + /// + /// 通用输入扩展参数(带权限) + /// + public class XnInputBase : PageInputBase + { + /// + /// 授权菜单 + /// + public List GrantMenuIdList { get; set; } = new List(); + + /// + /// 授权角色 + /// + public List GrantRoleIdList { get; set; } = new List(); + + /// + /// 授权数据 + /// + public List GrantOrgIdList { get; set; } = new List(); + + /// + /// 搜索值 + /// + public virtual string SearchValue { get; set; } + + /// + /// 搜索开始时间 + /// + public virtual string SearchBeginTime { get; set; } + + /// + /// 搜索结束时间 + /// + public virtual string SearchEndTime { get; set; } + + /// + /// 排序字段 + /// + public virtual string SortField { get; set; } + + /// + /// 排序方法,默认升序,否则降序(配合antd前端,约定参数为 Ascend,Dscend) + /// + public virtual string SortOrder { get; set; } + + /// + /// 降序排序(不要问我为什么是descend不是desc,前端约定参数就是这样) + /// + public virtual string DescStr { get; set; } = "descend"; + + /// + /// 复杂查询条件 + /// + // public virtual List SearchParameters { get; set; } = new(); + } + + /// + /// 通用分页输入参数 + /// + public class PageInputBase + { + public string bomId { get; set; } + public string chnologyId { get; set; } + /// + /// 当前页码 + /// + private int current; + public virtual int Current + { + get + { + return current; + } + set + { + + current = value; + if (current <= 0) + { + current = 1; + } + } + } + //public int? Status { get; set; } + /// + /// 页码容量 + /// + + private int pagesize; + public virtual int PageSize + { + get + { + return pagesize; + } + set + { + + pagesize = value; + if (pagesize <= 0) + { + pagesize = 20; + } + } + } + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Application/BaseDto/PageUtil.cs b/BPA.KitChen.StoreManagement.Application/BaseDto/PageUtil.cs new file mode 100644 index 0000000..d7942d2 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/BaseDto/PageUtil.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.BaseDto +{ + public class PageUtil + { + + /// + /// Data + /// + + public object Data { get; set; } + /// + /// Total + /// + + public int Total { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Application/BaseDto/ResultEntity.cs b/BPA.KitChen.StoreManagement.Application/BaseDto/ResultEntity.cs new file mode 100644 index 0000000..0275a5a --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/BaseDto/ResultEntity.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.BaseDto +{ + + public class ResultEntity + { + + public bool IsSuccess { get; set; } + + public string Msg { get; set; } + public Object Data { get; set; } + } + + public class ResultEntity + { + + public bool IsSuccess { get; set; } + + public string Msg { get; set; } + + public T Data { get; set; } + } + + + public class Result + { + public int StatusCode { get; set; } + + public ResultEntity Data { get; set; } + + public string Succeeded { get; set; } + + public object Errors { get; set; } + + public object Extras { get; set; } + + public string Timestamp { get; set; } + + } + +} diff --git a/BPA.KitChen.StoreManagement.Application/Class1.cs b/BPA.KitChen.StoreManagement.Application/Class1.cs new file mode 100644 index 0000000..3978afd --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Class1.cs @@ -0,0 +1,7 @@ +namespace BPA.KitChen.StoreManagementOrder.Application +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Application/Service/BaseDtos.cs b/BPA.KitChen.StoreManagement.Application/Service/BaseDtos.cs new file mode 100644 index 0000000..0a3e0c8 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/BaseDtos.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service +{ + public class PageInputDto + { + /// + /// 当前页码 + /// + private int current; + public virtual int Current + { + get + { + return current; + } + set + { + + current = value; + if (current <= 0) + { + current = 1; + } + } + } + //public int? Status { get; set; } + /// + /// 页码容量 + /// + + private int pagesize; + public virtual int PageSize + { + get + { + return pagesize; + } + set + { + + pagesize = value; + if (pagesize <= 0) + { + pagesize = 20; + } + } + } + } + + public class PageOutDto + { + /// + /// Data + /// + + public object Data { get; set; } + /// + /// Total + /// + + public int Total { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderFlowQuery.cs b/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderFlowQuery.cs new file mode 100644 index 0000000..4cf1554 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderFlowQuery.cs @@ -0,0 +1,200 @@ +using BPA.KitChen.StoreManagementOrder.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.StoreManagement.Application.Service.OrderManage.Dtos +{ + /// + /// 订单流水查询 + /// + public class OrderFlowQuery : PageInputBase + { + /// + /// 订单Id + /// + public string Id { get; set; } + public string orderFlowId { get; set; } + /// + /// 加盟商编号 + /// + public string FranchiseeId { get; set; } + /// + /// 加盟商名称 + /// + public string FranchiseeName { get; set; } + /// + /// 店铺名称编号(设备名称编号) + /// + public string StoreId { get; set; } + /// + /// 店铺名称 + /// + public string StoreName { get; set; } + /// + /// 商品key + /// + public string GoodsId { get; set; } + /// + /// 商品名称 + /// + public string GoodsName { get; set; } + /// + /// 商品类型编号 + /// + public string GoodsTypeId { get; set; } + /// + /// 商品类型名称 + /// + public string GoodsTypeName { get; set; } + /// + /// 店铺分类编号(设备类型关联值) + /// + public string StoreTypeId { get; set; } + /// + /// 店铺分类名称(设备类型名称) + /// + public string StoreTypeName { get; set; } + /// + /// 订单编号 + /// + + public string Order_Number { get; set; } + /// + /// 应付金额 + /// + public decimal? Order_OriginalMoney { get; set; } + /// + /// 实付金额 + /// + public decimal? Order_RealMoney { get; set; } + public decimal? RefundOriginalMoney { get; set; } + public decimal? RefundRealMoney { get; set; } + /// + /// 支付方式(微信支付) + /// + public int PayMode { get; set; } + public int Order_Status { get; set; } + + /// + /// 订单汇总数量 + /// + public int Order_Count { get; set; } + /// + /// 订单开始时间 + /// + public DateTime Order_CreateTime { get; set; } + /// + /// 订单结束时间 + /// + public DateTime? Order_EndTime { get; set; } + /// + /// 订单类型 + /// 0-->正常 + /// 1--立即吃面 + /// 2-->其他 + /// + public int PlaceMode { get; set; } + /// + /// + /// + public string Customer_Name { get; set; } + + /// + /// + /// + public string Customer_Tel { get; set; } + public int CountNumber { get; set; } + public int WechatIsCheck { get; set; } + } + public class OrderSumQuery : PageInputBase + { + /// + /// 订单Id + /// + public string Id { get; set; } + /// + /// 加盟商编号 + /// + public string FranchiseeId { get; set; } + /// + /// 加盟商名称 + /// + public string FranchiseeName { get; set; } + /// + /// 店铺名称编号(设备名称编号) + /// + public string StoreId { get; set; } + /// + /// 店铺名称 + /// + public string StoreName { get; set; } + /// + /// 商品key + /// + public string GoodsId { get; set; } + /// + /// 商品名称 + /// + public string GoodsName { get; set; } + /// + /// 商品类型编号 + /// + public string GoodsTypeId { get; set; } + /// + /// 商品类型名称 + /// + public string GoodsTypeName { get; set; } + /// + /// 店铺分类编号(设备类型关联值) + /// + public string StoreTypeId { get; set; } + /// + /// 店铺分类名称(设备类型名称) + /// + public string StoreTypeName { get; set; } + /// + /// 订单编号 + /// + + public string Order_Number { get; set; } + /// + /// 应付金额 + /// + public decimal? Order_OriginalMoney { get; set; } + /// + /// 实付金额 + /// + public decimal? Order_RealMoney { get; set; } + public decimal? DiscountMoney { get; set; } + /// + /// 支付方式(微信支付) + /// + public int PayMode { get; set; } + /// + /// 订单汇总数量 + /// + + 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; } + /// + /// 订单开始时间 + /// + public DateTime? Order_CreateTime { get; set; } + /// + /// 订单结束时间 + /// + public DateTime? Order_EndTime { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderQueryInputDto.cs b/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderQueryInputDto.cs new file mode 100644 index 0000000..b91fe6b --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderQueryInputDto.cs @@ -0,0 +1,66 @@ +using BPA.KitChen.StoreManagementOrder.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.StoreManagement.Application.Service.OrderManage.Dtos +{ + public class OrderQueryInputDto : PageInputBase + { + /// + /// 订单Id + /// + public string Id { get; set; } + /// + /// 加盟商编号 + /// + public string FranchiseeId { get; set; } + /// + /// 订单号 + /// + public string order_Number { get; set; } + + public string Customer_Tel { get; set; } + /// + /// 店铺名称编号(设备名称编号) + /// + public string[] StoreId { get; set; } + /// + /// + /// 商品key + /// + public string[] GoodsId { get; set; } + + /// + /// 商品类型编号 + /// + public string[] GoodsTypeId { get; set; } + /// + /// 店铺分类编号(设备类型关联值) + /// + public string StoreTypeId { get; set; } + /// + /// 订单开始时间 + /// + public DateTime? Order_CreateTime { get; set; } + /// + /// 订单结束时间 + /// + public DateTime? Order_EndTime { get; set; } + + public bool isreport { get; set; } = false; + public bool IsExport { get; set; } = false; + /// + /// 订单状态 + /// + public int? OrderStatus { get; set; } + + /// + /// 支付渠道 0微信 1支付宝 2 余额 3银联 + /// + public int? PayMode { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/ThirdOrderDto.cs b/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/ThirdOrderDto.cs new file mode 100644 index 0000000..8b88c55 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/ThirdOrderDto.cs @@ -0,0 +1,20 @@ +using BPA.KitChen.StoreManagementOrder.Application.BaseDto; +using BPA.KitChen.StoreManagementOrder.Core.Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.Order.Dtos +{ + public class ThirdOrderDto: BPA_ThirdOrder + { + public List ThirdOrderInfos { get; set; } + } + + public class ThirdOrderInputDto: PageInputBase + { + public string OrderNum { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Order/IOrderService.cs b/BPA.KitChen.StoreManagement.Application/Service/Order/IOrderService.cs new file mode 100644 index 0000000..1cce868 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Order/IOrderService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.Order +{ + public interface IOrderService + { + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Order/OrderService.cs b/BPA.KitChen.StoreManagement.Application/Service/Order/OrderService.cs new file mode 100644 index 0000000..278b20a --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Order/OrderService.cs @@ -0,0 +1,531 @@ +using BPA.KitChen.StoreManagementOrder.Application.BaseDto; +using BPA.KitChen.StoreManagementOrder.Application.Service.TestService; +using BPA.KitChen.StoreManagementOrder.Core.Common.Const; +using BPA.KitChen.StoreManagement.Application.Service.OrderManage.Dtos; +using Furion.DatabaseAccessor; +using Furion; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BPA.KitChen.StoreManagementOrder.SqlSugar; +using BPA.KitChen.StoreManagementOrder.Core.Entity; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using BPA.KitChen.StoreManagementOrder.Application.Service.Order.Dtos; +using Org.BouncyCastle.Crypto; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.Order +{ + + [ApiDescriptionSettings("订单管理", Tag = "订单管理", SplitCamelCase = false)] + public class OrderService : IDynamicApiController, ITransient, IOrderService + { + /// + /// 核心对象:拥有完整的SqlSugar全部功能 + /// + private readonly SqlSugarScope db; + private readonly string CustomerIds = "omwji4jSSh6o-I0UPLGrxKEio73Y,omwji4lFXTPD6SoCQLMexKoWdWY4"; + private readonly string StoreId = "3b007e32-f1cc-4021-b4e0-f4764fa90f12"; + IWebHostEnvironment _hostingEnvironment; + + /// + /// construct + /// + /// + public OrderService(IWebHostEnvironment hostingEnvironment) + { + db = SqlSugarDb.Db; + _hostingEnvironment=hostingEnvironment; + } + + /// + /// 订单明细 + /// + /// + /// + [HttpPost("/api/Order/PostDetail")] + public PageUtil PostDetail(OrderQueryInputDto dto) + { + //根据对应的条件查询和排序 + string strWhere = string.Empty; + int total = 0; + List res = new List(); + //if (!string.IsNullOrEmpty(dto.StoreTypeId))//店铺分类 + //{ + // strWhere += $" and d.Id='{dto.StoreTypeId}'"; + //} + if (dto.StoreId != null && dto.StoreId.Length > 0)//店铺名称 + { + strWhere += $" and a.StoreId in ("; + for (int i = 0; i < dto.StoreId.Length; i++) + { + strWhere += $"'{dto.StoreId[i]}',"; + } + strWhere = strWhere.Substring(0, strWhere.LastIndexOf(',')); + strWhere += ")"; + } + if (dto.GoodsId != null && dto.GoodsId.Length > 0)//商品名称 + { + strWhere += $" and a.GoodId in ("; + for (int i = 0; i < dto.GoodsId.Length; i++) + { + strWhere += $"'{dto.GoodsId[i]}',"; + } + strWhere = strWhere.Substring(0, strWhere.LastIndexOf(',')); + strWhere += ")"; + } + if (!dto.isreport) + { + if (!string.IsNullOrWhiteSpace(CustomerIds))//屏蔽查询人 + { + string key = ""; + string[] CustomerId = CustomerIds.Split(','); + for (int i = 0; i < CustomerId.Length; i++) + { + key += $"'{CustomerId[i]}',"; + } + key = key.Substring(0, key.LastIndexOf(',')); + + strWhere += $" and a.Customer_ID not in (" + key + ")"; + } + strWhere += $" and a.StoreId not in ('" + StoreId + "')"; + } + //if (!string.IsNullOrEmpty(dto.Customer_Tel)) + //{ + // strWhere += $" and g.Phone='{dto.Customer_Tel}'"; + //} + + if (dto.GoodsTypeId != null && dto.GoodsTypeId.Length > 0)//商品类型 + { + strWhere += $" and e.Goods_TypeID in ("; + for (int i = 0; i < dto.GoodsTypeId.Length; i++) + { + strWhere += $"'{dto.GoodsTypeId[i]}',"; + } + strWhere = strWhere.Substring(0, strWhere.LastIndexOf(',')); + strWhere += ")"; + } + //默认当天时间 + if (string.IsNullOrEmpty(dto.Order_CreateTime.ToString())) + { + dto.Order_CreateTime = DateTime.Now; + } + + if (string.IsNullOrEmpty(dto.Order_EndTime.ToString())) + { + dto.Order_EndTime = DateTime.Now; + } + var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + if (!string.IsNullOrWhiteSpace(GroupId)) + { + strWhere += $" and a.GroupId = '" + GroupId + "'"; + } + if (dto.OrderStatus != null) + { + strWhere += $" and a.Order_Status = " + dto.OrderStatus; + } + var temp1 = Convert.ToDateTime(dto.Order_CreateTime.Value.ToString("yyyy-MM-dd")); + var temp2 = Convert.ToDateTime(dto.Order_EndTime.Value.AddDays(1).ToString("yyyy-MM-dd")); + if (!dto.isreport) + { + var lastDay = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(-1).Date; + if (temp1 < lastDay) + { + temp1 = lastDay; + + } + if (temp2 < lastDay) + { + temp2 = lastDay; + } + } + string sql = @"SELECT +UUID() as orderFlowId, + a.OrderInfo_Id AS Id, + a.RefundStatus, + a.StoreId, + a.StoreName, + (case when a.RefundStatus<0 then a.Order_RealMoney else 0 end ) AS Order_RealMoney, + (case when a.RefundStatus<0 then a.Order_OriginalMoney else 0 end ) AS Order_OriginalMoney, + (case when a.RefundStatus>=0 then a.Order_RealMoney else 0 end ) AS RefundRealMoney, + (case when a.RefundStatus>=0 then a.Order_OriginalMoney else 0 end ) AS RefundOriginalMoney, + a.Transaction_ID AS Order_Number, + a.Order_CreateTime AS Order_CreateTime, + a.PlaceMode AS PayMode, + a.Order_Status AS Order_Status, + a.Customer_ID AS Customer_Name, + a.Customer_ID AS Customer_Tel, + 1 as order_Count + FROM + (SELECT + c.`OrderInfo_Id` AS `OrderInfo_Id`, + c.`Order_Status` AS `Order_Status`, + c.`Order_CreateTime` AS `Order_CreateTime`, + c.`StoreId` AS `StoreId`, + c.`StoreName` AS `StoreName`, + c.`Order_OriginalMoney` AS `Order_OriginalMoney`, + c.`Order_RealMoney` AS `Order_RealMoney`, + c.`PlaceMode` AS `PlaceMode`, + c.`Customer_ID` AS `Customer_ID`, + c.`Transaction_ID` AS `Transaction_ID`, + c.`RefundStatus` AS `RefundStatus`, + c.`GroupId` AS `GroupId`, + c.`order_Count` AS `order_Count` +FROM + ( + SELECT + `a`.`Id` AS `OrderInfo_Id`, + `a`.`OrderStatus` AS `Order_Status`, + `a`.`CreatedAt` AS `Order_CreateTime`, + `a`.`OrgId` AS `StoreId`, + `a`.`OrgId` AS `StoreName`, + `a`.`OrderOriginalMoney` AS `Order_OriginalMoney`, + `a`.`OrderRealMoney` AS `Order_RealMoney`,(((( + `a`.`OrderRealMoney` + ifnull( `a`.`DiscountMoney`, 0 )) + ifnull( json_extract( `a`.`PriceCollection`, '$.CouponPrice' ), 0 )) + ifnull( json_extract( `a`.`PriceCollection`, '$.ActivityPrice' ), 0 )) + ifnull( json_extract( `a`.`PriceCollection`, '$.Vip' ), 0 )) AS `OrderRealMoney`, + `a`.`OrderType` AS `PlaceMode`, + `a`.`CustomerId` AS `Customer_ID`, + `a`.`OrderCount` AS `order_Count`, + `a`.`TransactionId` AS `Transaction_ID`,-( + 1 + ) AS `RefundStatus`, + `a`.`GroupId` AS `GroupId` + FROM + `bpa_order` `a` + WHERE + ( length( `a`.`TransactionId` ) > 1 )) AS c UNION ALL +SELECT + `a`.`OrderInfo_Id` AS `OrderInfo_Id`, + `a`.`Order_Status` AS `Order_Status`, + `b`.`RefundTime` AS `Order_CreateTime`, + `a`.`StoreId` AS `StoreId`, + `a`.`StoreName` AS `StoreName`, + `a`.`Order_OriginalMoney` AS `Order_OriginalMoney`, + `a`.`Order_RealMoney` AS `Order_RealMoney`, + `a`.`PlaceMode` AS `PlaceMode`, + `a`.`Customer_ID` AS `Customer_ID`, + `a`.`Transaction_ID` AS `Transaction_ID`, + `b`.`RefundResult` AS `RefundStatus`, + `a`.`GroupId` AS `GroupId`, + `a`.`order_Count` AS `order_Count` +FROM + ( + `bpa_orderrefundlog` `b` + LEFT JOIN ( + SELECT + `a`.`Id` AS `OrderInfo_Id`, + `a`.`OrderStatus` AS `Order_Status`, + `a`.`CreatedAt` AS `Order_CreateTime`, + `a`.`OrgId` AS `StoreId`, + `a`.`OrgId` AS `StoreName`, + `a`.`OrderOriginalMoney` AS `Order_OriginalMoney`, + `a`.`OrderRealMoney` AS `Order_RealMoney`,(((( + `a`.`OrderRealMoney` + ifnull( `a`.`DiscountMoney`, 0 )) + ifnull( json_extract( `a`.`PriceCollection`, '$.CouponPrice' ), 0 )) + ifnull( json_extract( `a`.`PriceCollection`, '$.ActivityPrice' ), 0 )) + ifnull( json_extract( `a`.`PriceCollection`, '$.Vip' ), 0 )) AS `OrderRealMoney`, + `a`.`OrderType` AS `PlaceMode`, + `a`.`CustomerId` AS `Customer_ID`, + `a`.`OrderCount` AS `order_Count`, + `a`.`TransactionId` AS `Transaction_ID`,-( + 1 + ) AS `RefundStatus`, + `a`.`GroupId` AS `GroupId` + FROM + `bpa_order` `a` + WHERE + ( length( `a`.`TransactionId` ) > 1 )) `a` ON (( + `a`.`OrderInfo_Id` = `b`.`OrderId` + ))) +WHERE + ( + `b`.`Stutas` = 202)) a + where a.RefundStatus is not NULL and + a.Order_CreateTime >='" + temp1.ToString("yyyy-MM-dd HH:mm:ss") + @"' and a.Order_CreateTime <'" + temp2.ToString("yyyy-MM-dd HH:mm:ss") + @"' + " + strWhere + ""; + + res = db.SqlQueryable(sql) + .WhereIF(dto.PayMode.HasValue, (b) => b.PayMode == dto.PayMode) + .OrderBy(a => a.Order_CreateTime, OrderByType.Desc).ToPageList(dto.Current, dto.PageSize, ref total); + + + var ids = res.Select(x => x.Id).ToList(); + + var orders = db.Queryable().Where(x => ids.Contains(x.Id)).ToList(); + + foreach (var item in res) + { + item.PayMode = orders.FirstOrDefault(x => x.Id == item.Id)?.PayMode ?? 0; + } + + PageUtil unit = new PageUtil() + { + Data = res, + Total = total, + }; + return unit; + + } + + [HttpPost("/api/Order/GetFlowExport"), ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] + public ResultEntity OrderDetailFlowExport([FromBody] OrderQueryInputDto dto) + { + List orderFlows = OrderDetailFlowExportData(dto); + return new ResultEntity() + { + Data = orderFlows, + IsSuccess = orderFlows.Count > 0, + + }; + string fielName = DateTime.Now.ToString("yyyyMMddHHmmss"); + var currentUseId = "OrderFlow"; + + var rootPath = _hostingEnvironment.ContentRootPath + "orderExcels\\"; + if (System.IO.Directory.Exists(rootPath) == false) + System.IO.Directory.CreateDirectory(rootPath); + + var newFile = rootPath + "\\" + fielName + ".xlsx"; + if (System.IO.File.Exists(newFile)) + { + System.IO.File.Delete(newFile); + } + using (var fs = new FileStream(newFile, FileMode.Create, FileAccess.Write)) + { + + IWorkbook workbook = new XSSFWorkbook(); + var sheet = workbook.CreateSheet("orders"); + var header = sheet.CreateRow(0); + header.CreateCell(1).SetCellValue("店铺名称 "); + header.CreateCell(2).SetCellValue("交易单号"); + header.CreateCell(3).SetCellValue("应付金额"); + header.CreateCell(4).SetCellValue("实付金额 "); + header.CreateCell(5).SetCellValue("应退金额"); + header.CreateCell(6).SetCellValue("实退金额"); + header.CreateCell(7).SetCellValue("菜品数量"); + header.CreateCell(8).SetCellValue("下单时间"); + var rowIndex = 1; + foreach (var item in orderFlows) + { + var datarow = sheet.CreateRow(rowIndex); + datarow.CreateCell(0).SetCellValue(item.StoreName); + datarow.CreateCell(1).SetCellValue(item.Order_Number); + datarow.CreateCell(2).SetCellValue(item.Order_OriginalMoney.Value.ToString("#0.00")); + datarow.CreateCell(3).SetCellValue(item.Order_RealMoney.Value.ToString("#0.00")); + datarow.CreateCell(4).SetCellValue(item.RefundOriginalMoney.Value.ToString("#0.00")); + datarow.CreateCell(5).SetCellValue(item.RefundRealMoney.Value.ToString("#0.00")); + datarow.CreateCell(6).SetCellValue(item.Order_Count); + datarow.CreateCell(7).SetCellValue(item.Order_CreateTime.ToString("yyyy-MM-dd HH:mm:ss")); + rowIndex++; + } + workbook.Write(fs); + } + var memory = new MemoryStream(); + using (var stream = new FileStream(newFile, FileMode.Open)) + { + stream.CopyTo(memory); + } + memory.Position = 0; + var result = new FileStreamResult(memory, "application/octet-stream") + { + FileDownloadName = fielName + ".xlsx" + }; + // return result; + } + + private List OrderDetailFlowExportData(OrderQueryInputDto dto) + { + //根据对应的条件查询和排序 + string strWhere = string.Empty; + int total = 0; + List res = new List(); + if (!string.IsNullOrEmpty(dto.StoreTypeId))//店铺分类 + { + strWhere += $" and d.Id='{dto.StoreTypeId}'"; + } + if (dto.StoreId != null && dto.StoreId.Length > 0)//店铺名称 + { + strWhere += $" and a.StoreId in ("; + for (int i = 0; i < dto.StoreId.Length; i++) + { + strWhere += $"'{dto.StoreId[i]}',"; + } + strWhere = strWhere.Substring(0, strWhere.LastIndexOf(',')); + strWhere += ")"; + } + if (dto.GoodsId != null && dto.GoodsId.Length > 0)//商品名称 + { + strWhere += $" and a.GoodId in ("; + for (int i = 0; i < dto.GoodsId.Length; i++) + { + strWhere += $"'{dto.GoodsId[i]}',"; + } + strWhere = strWhere.Substring(0, strWhere.LastIndexOf(',')); + strWhere += ")"; + } + if (!dto.isreport) + { + if (!string.IsNullOrWhiteSpace(CustomerIds))//屏蔽查询人 + { + string key = ""; + string[] CustomerId = CustomerIds.Split(','); + for (int i = 0; i < CustomerId.Length; i++) + { + key += $"'{CustomerId[i]}',"; + } + key = key.Substring(0, key.LastIndexOf(',')); + + strWhere += $" and a.Customer_ID not in (" + key + ")"; + } + strWhere += $" and a.StoreId not in ('" + StoreId + "')"; + } + if (!string.IsNullOrEmpty(dto.Customer_Tel)) + { + strWhere += $" and g.Phone='{dto.Customer_Tel}'"; + } + + if (dto.GoodsTypeId != null && dto.GoodsTypeId.Length > 0)//商品类型 + { + strWhere += $" and e.Goods_TypeID in ("; + for (int i = 0; i < dto.GoodsTypeId.Length; i++) + { + strWhere += $"'{dto.GoodsTypeId[i]}',"; + } + strWhere = strWhere.Substring(0, strWhere.LastIndexOf(',')); + strWhere += ")"; + } + //默认当天时间 + if (string.IsNullOrEmpty(dto.Order_CreateTime.ToString())) + { + dto.Order_CreateTime = DateTime.Now; + } + + if (string.IsNullOrEmpty(dto.Order_EndTime.ToString())) + { + dto.Order_EndTime = DateTime.Now; + } + var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + if (!string.IsNullOrWhiteSpace(GroupId)) + { + strWhere += $" and a.GroupId = '" + GroupId + "'"; + } + if (dto.OrderStatus != null) + { + strWhere += $" and a.OrderStatus = " + dto.OrderStatus; + } + var temp1 = Convert.ToDateTime(dto.Order_CreateTime.Value.ToString("yyyy-MM-dd")); + var temp2 = Convert.ToDateTime(dto.Order_EndTime.Value.AddDays(1).ToString("yyyy-MM-dd")); + if (!dto.isreport) + { + var lastDay = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(-1).Date; + if (temp1 < lastDay) + { + temp1 = lastDay; + + } + if (temp2 < lastDay) + { + temp2 = lastDay; + } + } + string sql = @"SELECT + a.OrderInfo_Id AS Id, + a.RefundStatus, + a.StoreId, + a.StoreName, + (case when a.RefundStatus<0 then a.Order_RealMoney else 0 end ) AS Order_RealMoney, + (case when a.RefundStatus<0 then a.Order_OriginalMoney else 0 end ) AS Order_OriginalMoney, + (case when a.RefundStatus>=0 then a.Order_RealMoney else 0 end ) AS RefundRealMoney, + (case when a.RefundStatus>=0 then a.Order_OriginalMoney else 0 end ) AS RefundOriginalMoney, + a.Transaction_ID AS Order_Number, + a.Order_CreateTime AS Order_CreateTime, + a.PlaceMode AS PayMode, + a.Order_Status AS Order_Status, + g.NickName AS Customer_Name, + g.Phone AS Customer_Tel, + 1 as order_Count + FROM + V_AllOrder a + LEFT JOIN BPA_MemberInfo g ON ( a.Customer_ID = LOWER(g.Id) ) + where a.RefundStatus is not NULL and + a.Order_CreateTime >='" + temp1.ToString("yyyy-MM-dd HH:mm:ss") + @"' and a.Order_CreateTime <'" + temp2.ToString("yyyy-MM-dd HH:mm:ss") + @"' + " + strWhere + ""; + + res = db.SqlQueryable(sql) + .WhereIF(dto.PayMode.HasValue, (b) => b.PayMode == dto.PayMode) + .OrderBy(a => a.Order_CreateTime, OrderByType.Desc).ToList(); + + return res; + + } + + + #region 第三方订单 + + /// + /// 获取第三方 + /// + /// + /// + [HttpPost("/api/Order/ThirdOrderPage")] + public async Task ThirdOrderPageAsync(ThirdOrderInputDto inputDto) + { + var total = new RefAsync(); + var data = await db.Queryable() + .OrderBy(a => a.CreateAt, OrderByType.Desc) + .WhereIF(!string.IsNullOrEmpty(inputDto.OrderNum),x=>x.OrderNum.Contains(inputDto.OrderNum)) + .Select(x=>new ThirdOrderDto() + { + Id = x.Id.SelectAll() + }) + .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); + + var ids = data.Select(x => x.Id).ToList(); + + var thirdOrderInfos = await db.Queryable() + .Where(x=>ids.Contains(x.ThirdOrderId)) + .ToListAsync(); + + foreach (var item in data) + { + var thisData = thirdOrderInfos.Where(x => x.ThirdOrderId == item.Id).ToList(); + item.ThirdOrderInfos= thisData; + } + + return new PageUtil() + { + Data = data, + Total = total + + }; + } + + /// + /// 获取第三方订单详情 + /// + /// + /// + [HttpGet("/api/Order/GetThirdOrderInfo")] + public async Task GetThirdOrderInfo(string thirdOrderId) + { + var data = await db.Queryable() + .Where(x=>x.Id==thirdOrderId) + .OrderBy(a => a.CreateAt, OrderByType.Desc) + .Select(x => new ThirdOrderDto() + { + Id = x.Id.SelectAll() + }).FirstAsync(); + var thirdOrderInfos = await db.Queryable() + .Where(x => x.ThirdOrderId==thirdOrderId) + .ToListAsync(); + data.ThirdOrderInfos = thirdOrderInfos; + return data; + } + + #endregion + + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Test/ITestService.cs b/BPA.KitChen.StoreManagement.Application/Service/Test/ITestService.cs new file mode 100644 index 0000000..3c84cee --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Test/ITestService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.TestService +{ + public interface ITestService + { + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/Test/TestService.cs b/BPA.KitChen.StoreManagement.Application/Service/Test/TestService.cs new file mode 100644 index 0000000..14646c6 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/Test/TestService.cs @@ -0,0 +1,44 @@ +using BPA.KitChen.StoreManagementOrder.SqlSugar; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.TestService +{ + [ApiDescriptionSettings("测试", Tag = "测试", SplitCamelCase = false)] + [AllowAnonymous] + public class TestService: IDynamicApiController, ITransient, ITestService + { + /// + /// CodeFirst + /// + /// + public void CodeFirst() + { + try + { + var types = Assembly.Load("BPA.KitChen.StoreManagementOrder.Core").GetTypes() + .Where(x => x.Namespace != null + && x.GetCustomAttribute() != null + && x.Namespace.Contains("BPA.KitChen.StoreManagementOrder.Core.Entity")) + .ToArray(); + SqlSugarDb.Db.CodeFirst.InitTables(types); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + + + } + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/Dtos/ThirdAuthorizeInfoDto.cs b/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/Dtos/ThirdAuthorizeInfoDto.cs new file mode 100644 index 0000000..a370819 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/Dtos/ThirdAuthorizeInfoDto.cs @@ -0,0 +1,14 @@ +using BPA.KitChen.StoreManagementOrder.Application.BaseDto; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.ThirdAuthorize.Dtos +{ + public class ThirdAuthorizeInfoDto: PageInputBase + { + + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/IThirdAuthorize.cs b/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/IThirdAuthorize.cs new file mode 100644 index 0000000..a4c7964 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/IThirdAuthorize.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Application.Service.ThirdAuthorize +{ + public interface IThirdAuthorize + { + } +} diff --git a/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/ThirdAuthorize.cs b/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/ThirdAuthorize.cs new file mode 100644 index 0000000..0cecfc2 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/ThirdAuthorize.cs @@ -0,0 +1,101 @@ +using BPA.KitChen.StoreManagementOrder.Application.BaseDto; +using BPA.KitChen.StoreManagementOrder.Application.Service.Order; +using BPA.KitChen.StoreManagementOrder.Application.Service.Order.Dtos; +using BPA.KitChen.StoreManagementOrder.Application.Service.ThirdAuthorize.Dtos; +using BPA.KitChen.StoreManagementOrder.Core.Entity; +using BPA.KitChen.StoreManagementOrder.SqlSugar; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Microsoft.AspNetCore.Hosting; +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.StoreManagementOrder.Application.Service.ThirdAuthorize +{ + + [ApiDescriptionSettings("订单管理", Tag = "第三方授权", SplitCamelCase = false)] + public class ThirdAuthorize : IDynamicApiController, ITransient, IThirdAuthorize + { + private readonly SqlSugarScope db; + + public ThirdAuthorize(IWebHostEnvironment hostingEnvironment) + { + db = SqlSugarDb.Db; + } + + /// + /// 获取第三方 + /// + /// + /// + [HttpPost("/api/ThirdAuthorize/Page")] + public async Task Page(ThirdAuthorizeInfoDto inputDto) + { + var total = new RefAsync(); + var data = await db.Queryable() + .OrderBy(a => a.CreateAt, OrderByType.Desc) + .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); + + return new PageUtil() + { + Data = data, + Total = total + + }; + } + + + /// + /// 创建 授权 + /// + /// + /// + [HttpPost("/api/ThirdAuthorize/Create")] + public async Task Create(BPA_ShopAuthorize inputDto) + { + var data=await db.Queryable().Where(x=>x.StoreId==inputDto.StoreId).FirstAsync(); + if (data != null) + { + throw Oops.Oh($"店铺已授权"); + } + inputDto.AuthorizeCode=Guid.NewGuid().ToString(); + var res=await db.Insertable(inputDto).ExecuteCommandAsync(); + return res > 0; + } + + /// + /// 修改 重新赋值授权码 + /// + /// + /// + [HttpPost("/api/ThirdAuthorize/Update")] + public async Task Update(BPA_ShopAuthorize inputDto) + { + var data = await db.Queryable().Where(x =>x.Id==inputDto.Id).FirstAsync(); + data.AuthorizeCode = Guid.NewGuid().ToString(); + var res=await db.Updateable(data).ExecuteCommandAsync(); + return res > 0; + } + + /// + /// 修改 重新赋值授权码 + /// + /// + /// + [HttpPost("/api/ThirdAuthorize/Del")] + public async Task Del(string id) + { + var res = await SqlSugarDb.Db.Updateable() + .SetColumns(it => new BPA_ShopAuthorize { IsDeleted = 1 })//类只能在表达示里面不能提取 + .Where(it => it.Id == id) + .ExecuteCommandAsync(); + return res > 0; + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/BPA.KitChen.StoreManagementOrder.Core.csproj b/BPA.KitChen.StoreManagement.Core/BPA.KitChen.StoreManagementOrder.Core.csproj new file mode 100644 index 0000000..366f07e --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/BPA.KitChen.StoreManagementOrder.Core.csproj @@ -0,0 +1,21 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/BPA.KitChen.StoreManagement.Core/Class1.cs b/BPA.KitChen.StoreManagement.Core/Class1.cs new file mode 100644 index 0000000..c1eeb71 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Class1.cs @@ -0,0 +1,7 @@ +namespace BPA.KitChen.StoreManagementOrder.Core +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Common/Const/ClaimConst.cs b/BPA.KitChen.StoreManagement.Core/Common/Const/ClaimConst.cs new file mode 100644 index 0000000..72fe4ec --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/Const/ClaimConst.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Common.Const +{ + public class ClaimConst + { + /// + /// 用户Id + /// + public const string CLAINM_USERID = "UserId"; + + /// + /// 账号 + /// + public const string CLAINM_ACCOUNT = "Account"; + + /// + /// 名称 + /// + public const string CLAINM_NAME = "Name"; + + /// + /// 是否超级管理 + /// + public const string CLAINM_SUPERADMIN = "SuperAdmin"; + + /// + /// 登录类型1平台用户登录,0加盟商登录 + /// + public const string LoginType = "LoginType"; + /// + /// 加盟商编号 + /// + public const string FranchID = "FranchID"; + /// + /// 加盟商通知手机号 + /// + public const string FranchTel = "18782023833"; + + /// + /// 加盟商组id + /// + public const string GroupId = "GroupId"; + + /// + /// 权限 + /// + public const string RoleId = "RoleId"; + public const string OrgId = ""; + + public const string SupplyPlatformId = "SupplyPlatformId"; + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Common/CosConfig.cs b/BPA.KitChen.StoreManagement.Core/Common/CosConfig.cs new file mode 100644 index 0000000..80ec3c3 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/CosConfig.cs @@ -0,0 +1,14 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Common +{ + public class CosConfig + { + public static CosInfoOptions cosInfoOptions; + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/CosInfoOptions.cs b/BPA.KitChen.StoreManagement.Core/Common/CosInfoOptions.cs new file mode 100644 index 0000000..3afd16c --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/CosInfoOptions.cs @@ -0,0 +1,26 @@ +using Furion.ConfigurableOptions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Common +{ + public class CosInfoOptions : IConfigurableOptions + { + public string AppId { get; set; } + public string Region { get; set; } + public string Bucket { get; set; } + public string SecretId { get; set; } + public string SecretKey { get; set; } + public CosInfoOptions(string appid, string region, string bucket, string secretId, string secretKey) + { + AppId = appid; + Region = region; + Bucket = bucket; + SecretId = secretId; + SecretKey = secretKey; + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/CurrentUser.cs b/BPA.KitChen.StoreManagement.Core/Common/CurrentUser.cs new file mode 100644 index 0000000..f7eaf7c --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/CurrentUser.cs @@ -0,0 +1,25 @@ +using BPA.KitChen.StoreManagementOrder.Core.Common.Const; +using Furion; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Common +{ + /// + /// 当前用户 + /// + public class CurrentUser + { + public static string? UserId => App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + + public static string? TenantId => App.User?.FindFirst(ClaimConst.GroupId)?.Value; + + public static string? Account => App.User?.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + public static string? RoleId => App.User?.FindFirst(ClaimConst.RoleId)?.Value; + + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/HttpHelper.cs b/BPA.KitChen.StoreManagement.Core/Common/HttpHelper.cs new file mode 100644 index 0000000..8ff1102 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/HttpHelper.cs @@ -0,0 +1,100 @@ +using Furion; +using Furion.FriendlyException; +using Furion.Templates; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Microsoft.IdentityModel.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Reflection.PortableExecutable; +using System.Security.Policy; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Common +{ + public static class HttpHelper + { + private static readonly HttpClient client = new HttpClient(); + + /// + /// Get 请求 + /// + /// + /// + /// + /// + /// + /// + public static string HttpGet(string url, string postDataStr, Dictionary headers, string contentType = "") + { + var result = string.Empty; + try + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + postDataStr); + + request.ServicePoint.Expect100Continue = false; //加了这一行代码 就OK了 + request.Method = "GET"; + request.ContentType = contentType; + foreach (KeyValuePair kv in headers) + { + request.Headers.Add(kv.Key, kv.Value); + } + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + Stream myResponseStream = response.GetResponseStream(); + StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); + result = myStreamReader.ReadToEnd(); + myStreamReader.Close(); + myResponseStream.Close(); + + } + catch (Exception ex) + { + throw Oops.Oh( ex.Message); + } + return result; + } + + + public static string PostData(string url, string postData, Encoding encoding, string ContentType, Dictionary headers) + { + + try + { + HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(url); + + myReq.Method = "POST"; + myReq.Timeout = 600 * 60; + byte[] byteArray = encoding.GetBytes(postData); + myReq.ContentType = ContentType; + //对键值对进行遍历 + foreach (KeyValuePair kv in headers) + { + myReq.Headers.Add(kv.Key, kv.Value); + } + Stream dataStream = myReq.GetRequestStream(); + dataStream.Write(byteArray, 0, byteArray.Length); + dataStream.Close(); + + HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse(); + dataStream = HttpWResp.GetResponseStream(); + string result = ""; + using (StreamReader myStreamReader = new StreamReader(dataStream, encoding)) + { + result = myStreamReader.ReadToEnd(); + myStreamReader.Close(); + } + dataStream.Close(); + HttpWResp.Close(); + return result; + } + catch (System.Exception ex) + { + throw ex; + } + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/AcceptEntity.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/AcceptEntity.cs new file mode 100644 index 0000000..68f5f25 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/AcceptEntity.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.Kitchen.Core.RabbitMq.Config +{ + public class AcceptEntity + { + /// + /// 队列名称 + /// + public String QueeName { get; set; } + /// + /// 推送模式 + /// + public MQEnum SendType { get; set; } + /// + /// 管道名称 + /// + public String ExchangeName { get; set; } + /// + /// 路由名称 + /// + public String RouteName { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/IAccept.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/IAccept.cs new file mode 100644 index 0000000..17914bb --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/IAccept.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.Kitchen.Core.RabbitMq.Config +{ + public interface IAccept + { + void AcceptMQ(string msg); + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQEnum.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQEnum.cs new file mode 100644 index 0000000..c704cc4 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQEnum.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace BPA.Kitchen.Core.RabbitMq.Config +{ + public enum MQEnum + { + /// + /// 订阅模式 + /// + [Description("订阅模式")] + Sub = 10, + /// + /// 推送模式 + /// + [Description("推送模式")] + Push = 20, + /// + /// 主路由模式 + /// + [Description("主路由模式")] + Top = 30 + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQFactory.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQFactory.cs new file mode 100644 index 0000000..111922b --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQFactory.cs @@ -0,0 +1,111 @@ + +using EasyNetQ; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using System.Linq.Expressions; + +namespace BPA.Kitchen.Core.RabbitMq.Config +{ + public class MQFactory + { + private volatile static IBus Bus = null; + /// + /// 创建链接 + /// + /// + public static IBus CreateMQ() + { + Console.WriteLine("MQ地址:" + Furion.App.Configuration["RabbitMQ"].ToString()); + if (Bus == null) + Bus = RabbitHutch.CreateBus(Furion.App.Configuration["RabbitMQ"].ToString()); + return Bus; + } + /// + /// 释放链接 + /// + public static void DisposeBus() + { + Bus?.Dispose(); + } + /// + /// 同步执行 + /// + /// + /// + /// + public static bool SendMQ(PushEntity Param) + { + try + { + if (Bus == null) + CreateMQ(); + new PushManage().SendMQ(Param, Bus); + return true; + } + catch (Exception ex) + { + Console.WriteLine(ex); + //BPALog.WriteLog(ex.Message, LogEnum.Error, ex: ex); + return false; + } + } + /// + /// 推荐异步执行 + /// + /// + /// + /// + public static async Task SendMQAsync(PushEntity Param) where T : class + { + + if (Bus == null) + CreateMQ(); + await new PushManage().SendMQAsync(Param, Bus); + } + /// + /// 订阅消息 + /// + /// + /// + public static void Subscriber(AcceptEntity Args) where TAccept : IAccept, new() where T : new() + { + //if (Bus == null) + // CreateMQ(); + //if (string.IsNullOrEmpty(Args.ExchangeName)) + // return; + //Expression> methodCall; + //IExchange EX = null; + //if (Args.SendType == MQEnum.Sub) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Args.ExchangeName, ExchangeType.Fanout); + //} + //if (Args.SendType == MQEnum.Push) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Args.ExchangeName, ExchangeType.Direct); + //} + //if (Args.SendType == MQEnum.Top) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Args.ExchangeName, ExchangeType.Topic); + //} + //IQueue queue = Bus.Advanced.QueueDeclare(Args.QueeName ?? null); + //Bus.Advanced.Bind(EX, queue, Args.RouteName); + //Bus.Advanced.Consume(queue, (body, properties, info) => Task.Factory.StartNew(() => + //{ + // try + // { + // var message = Encoding.UTF8.GetString(body); + // //处理消息 + // methodCall = job => job.AcceptMQ(message); + // methodCall.Compile()(new TAccept()); + // } + // catch (Exception ex) + // { + // throw ex; + // } + //})); + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushEntity.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushEntity.cs new file mode 100644 index 0000000..a219fe7 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushEntity.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BPA.Kitchen.Core.RabbitMq.Config +{ + public class PushEntity + { + /// + /// 推送内容 + /// + public T BodyData { get; set; } + /// + /// 推送模式 + /// + public MQEnum SendType { get; set; } + /// + /// 管道名称 + /// + public String ExchangeName { get; set; } + /// + /// 路由名称 + /// + public String RouteName { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushManage.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushManage.cs new file mode 100644 index 0000000..0da0b5c --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushManage.cs @@ -0,0 +1,81 @@ +using EasyNetQ; +using EasyNetQ.Topology; +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using System.Threading.Tasks; + +namespace BPA.Kitchen.Core.RabbitMq.Config +{ + public class PushManage + { + /// + /// 发布消息队列异步 + /// + /// + /// + /// + /// + public async Task SendMQAsync(PushEntity Param, IBus Bus) + { + ////one to one + //var msg = new Message(Param.BodyData); + //IExchange EX = null; + //if (Param.SendType == MQEnum.Sub) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Param.ExchangeName, ExchangeType.Fanout); + //} + //if (Param.SendType == MQEnum.Push) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Param.ExchangeName, ExchangeType.Direct); + //} + //if (Param.SendType == MQEnum.Top) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Param.ExchangeName, ExchangeType.Topic); + //} + //await Bus.Advanced.PublishAsync(EX, Param.RouteName, false, msg).ContinueWith(t => + //{ + // //消息投递失败 + // if (!t.IsCompleted && t.IsFaulted) + // { + // // //将消息记录到数据库轮询 + // // IRepository Repository = new Repository(); + // // SystemLog Log = new SystemLog + // // { + // // LogName = "消息队列", + // // Source = "发布队列", + // // EventData = JsonConvert.SerializeObject(Param.BodyData) + // // }; + // // Repository.Insert(Log); + + // } + //}); + } + /// + /// 发布消息队列同步 + /// + /// + /// + /// + public void SendMQ(PushEntity Param, IBus Bus) + { + ////one to one + //var msg = new Message(Param.BodyData); + //IExchange EX = null; + //if (Param.SendType == MQEnum.Sub) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Param.ExchangeName, ExchangeType.Fanout); + //} + //if (Param.SendType == MQEnum.Push) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Param.ExchangeName, ExchangeType.Direct); + //} + //if (Param.SendType == MQEnum.Top) + //{ + // EX = Bus.Advanced.ExchangeDeclare(Param.ExchangeName, ExchangeType.Topic); + //} + //Bus.Advanced.Publish(EX, Param.RouteName, false, msg); + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Publisher/ServiceQueryPush.cs b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Publisher/ServiceQueryPush.cs new file mode 100644 index 0000000..fd42202 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Publisher/ServiceQueryPush.cs @@ -0,0 +1,73 @@ +using BPA.Kitchen.Core.RabbitMq.Config; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.Kitchen.Core.RabbitMq.Publisher +{ + public class ServiceQueryPush + { + public static ServiceQueryPush QueryPush => new Lazy().Value; + public async Task PushMQAsync(T Entity,string Key, MQEnum MQType = MQEnum.Push) where T : class, new() + { + //推送模式 + //推送模式下需指定管道名称和路由键值名称 + //消息只会被发送到指定的队列中去 + //订阅模式 + //订阅模式下只需指定管道名称 + //消息会被发送到该管道下的所有队列中 + //主题路由模式 + //路由模式下需指定管道名称和路由值 + //消息会被发送到该管道下,和路由值匹配的队列中去 + PushEntity entity = new PushEntity(); + entity.BodyData = Entity; + entity.SendType = MQType; + if (MQType == MQEnum.Push) + { + entity.ExchangeName = "Message.Direct"; + entity.RouteName = Key; + } + else if (MQType == MQEnum.Sub) + { + entity.ExchangeName = "Message.Fanout"; + } + else + { + entity.ExchangeName = "Message.Topic"; + entity.RouteName = Key; + } + return await MQFactory.SendMQAsync(entity).ContinueWith(t => { return t.IsCompleted ? true : false; }); + } + public bool PushMQ(T Entity, string Key, MQEnum MQType = MQEnum.Push) + { + //推送模式 + //推送模式下需指定管道名称和路由键值名称 + //消息只会被发送到指定的队列中去 + //订阅模式 + //订阅模式下只需指定管道名称 + //消息会被发送到该管道下的所有队列中 + //主题路由模式 + //路由模式下需指定管道名称和路由值 + //消息会被发送到该管道下,和路由值匹配的队列中去 + PushEntity entity = new PushEntity(); + entity.BodyData = Entity; + entity.SendType = MQType; + if (MQType == MQEnum.Push) + { + entity.ExchangeName = "Message.Direct"; + entity.RouteName = Key; + } + else if (MQType == MQEnum.Sub) + { + entity.ExchangeName = "Message.Fanout"; + } + else + { + entity.ExchangeName = "Message.Topic"; + entity.RouteName = Key; + } + return MQFactory.SendMQ(entity); + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/BPA_Order.cs b/BPA.KitChen.StoreManagement.Core/Entity/BPA_Order.cs new file mode 100644 index 0000000..429098c --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/BPA_Order.cs @@ -0,0 +1,130 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + + [SugarTable("BPA_Order")] + public class BPA_Order + { + /// + /// + /// + public string Id { get; set; } + /// + /// 排序号 (按加盟商区分) + /// + public string SortId { get; set; } + /// + /// 用户Id + /// + public string CustomerId { get; set; } + /// + /// 订单状态 0未付款,1已付款,-1退单申请,-2退单中,-3已退单,-4取消交易 -5撤销申请 + /// + public int OrderStatus { get; set; } + /// + /// 用户售后状态 -1 售后已取消 0 未发起售后 1 申请售后 2 处理中 200 处理完毕 + /// + public int AfterStatus { get; set; } + /// + /// 商品数量 + /// + public int OrderCount { get; set; } + /// + /// 商品总价 + /// + public decimal OrderOriginalMoney { get; set; } + /// + /// 折扣价格 + /// + public decimal DiscountMoney { get; set; } + /// + /// 实际支付价格 + /// + public decimal OrderRealMoney { get; set; } + /// + /// 支付渠道 0微信 1支付宝 2 余额 3银联 4.现金 + /// + public int PayMode { get; set; } + /// + /// 订单号(本系统) + /// + public string OrderNumber { get; set; } + /// + /// 订单号(第三方) + /// + public string TradeNo { get; set; } + /// + /// 交易号 + /// + public string TransactionId { get; set; } + /// + /// 订单结算状态 0未结算 1已结算 + /// + public int OrderSettlementStatus { get; set; } + /// + /// 订单结算时间 + /// + public string OrderSettlementTime { get; set; } + /// + /// 订单类型 0->正常 1->立即吃面2->盲盒3->其他 + /// + public int OrderType { get; set; } + /// + /// 创建于 + /// + public DateTime CreatedAt { get; set; } + /// + /// 创建人 + /// + public string CreatedBy { get; set; } + /// + /// 更新于 + /// + public DateTime UpdatedAt { get; set; } + /// + /// 更新人 + /// + public string UpdatedBy { get; set; } + /// + /// 自动修改 记录最新的修改时间 + /// + public string UpdatedTs { get; set; } + /// + /// 订单来源 0 小程序 1大屏点餐 etc... + /// + public string OrderSourceFrom { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 三方id + /// + public string TroikaId { get; set; } + /// + /// 店铺id + /// + public string OrgId { get; set; } + /// + /// 小票备注 + /// + public string PrintRemark { get; set; } + /// + /// 就餐方式 + /// + public int EatType { get; set; } + + public string GroupId { get; set; } + /// + /// 优惠合集 + /// + public string PriceCollection { get; set; } + public decimal CusmetMoney { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/BPA_OrderRefundLog.cs b/BPA.KitChen.StoreManagement.Core/Entity/BPA_OrderRefundLog.cs new file mode 100644 index 0000000..4c17a26 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/BPA_OrderRefundLog.cs @@ -0,0 +1,172 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + + [SugarTable("BPA_OrderRefundLog")] + public class BPA_OrderRefundLog + { + + /// + /// + /// + public string Id { get; set; } = Guid.NewGuid().ToString(); + + + /// + /// 订单号(自己系统) + /// + public System.String OrderNumber { get; set; } + + + /// + /// 订单号(第三方) + /// + public System.String TradeNo { get; set; } + + /// + /// 交易号 + /// + public System.String TransactionId { get; set; } + + + /// + /// 售后表Id(null表示为售前退款) + /// + public System.String ReturnId { get; set; } + + + /// + /// 主订单id + /// + public System.String OrderId { get; set; } + + + /// + /// 子订单id + /// + public System.String SubOrderId { get; set; } + + + /// + /// 退款金额() + /// + public System.Decimal RefundMoney { get; set; } + + + /// + /// 退款类型0:售前退款(商品未制作时退款) 1 售后退款 (商品已经开始进行制作) + /// + public System.Int32 RefundType { get; set; } + + + /// + /// 退款结果 0 成功 1失败 + /// + public System.Int32 RefundResult { get; set; } + + + /// + /// 退款描述 退款成功;账户余额不足;退款金额大于订单金额..etc + /// + public System.String RefundDesc { get; set; } + + + /// + /// 退款来源(退款到什么地方) 0微信 1支付宝 2 余额 + /// + public System.Int32 RefundSource { get; set; } + + + /// + /// 退款调用方式 0 小程序调用退款 1 saas调用退款 2 第三方调用退款 4.POS + /// + public System.Int32 RefundCallType { get; set; } + + + /// + /// 退款时间 + /// + public System.DateTime? RefundTime { get; set; } + + + /// + /// 创建于 + /// + public System.DateTime? CreatedAt { get; set; } + + + /// + /// 创建人 + /// + public System.String CreatedBy { get; set; } + + + /// + /// 更新于 + /// + public System.DateTime? UpdatedAt { get; set; } + + + /// + /// 更新人 + /// + public System.String UpdatedBy { get; set; } + + + /// + /// 退款状态 + /// + public RefundStatus Stutas { get; set; } + + public string GroupId { get; set; } + } + public enum RefundStatus + { + /// + /// 申请部分退款 + /// + PartRefund = 10, + /// + /// 部分退款处理中 + /// + PartRefundWait = 101, + /// + /// 部分退款成功 + /// + PartRefundOk = 102, + /// + /// 取消部分退款 + /// + PartRefundCancel = 103, + /// + /// 部分退款失败 + /// + PartRefundError = 104, + /// + /// 申请全额退款 + /// + FullRefund = 20, + /// + /// 全额退款处理中 + /// + FullRefundWait = 201, + /// + /// 全额退款成功 + /// + FullRefundOk = 202, + /// + /// 取消全额退款 + /// + FullRefundCancel = 203, + /// + /// 全额退款失败 + /// + FullRefundError = 204, + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/BPA_ShopAuthorize.cs b/BPA.KitChen.StoreManagement.Core/Entity/BPA_ShopAuthorize.cs new file mode 100644 index 0000000..07f48cd --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/BPA_ShopAuthorize.cs @@ -0,0 +1,19 @@ +using BPA.KitChen.StoreManagementOrder.Core.Entity.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + + [SugarTable("BPA_ShopAuthorize")] + public class BPA_ShopAuthorize: IBaseGroupIdEntity + { + public string StoreId { get; set; } + + public string AuthorizeCode { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/BPA_SubOrder.cs b/BPA.KitChen.StoreManagement.Core/Entity/BPA_SubOrder.cs new file mode 100644 index 0000000..0b7f804 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/BPA_SubOrder.cs @@ -0,0 +1,107 @@ +using SqlSugar; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + [SugarTable("BPA_SubOrder")] + public class BPA_SubOrder + { + + /// + /// + /// + public string Id { get; set; } + /// + /// 主订单表Id + /// + public string OrderId { get; set; } + /// + /// 商品表Id + /// + public string GoodId { get; set; } + /// + /// 设备id + /// + public string StoreId { get; set; } + /// + /// 应付款 + /// + public decimal GooodOriginPrice { get; set; } + /// + /// 商品平摊价格(实付款) + /// + public decimal GoodsRealPrice { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 订单状态 1已下单(云服务将订单信息存放在redis) 2等待制作(上位机从redis取出) 3 制作中 4 制作完成待取餐 5 取餐完成 + /// + public int CookingStatus { get; set; } + /// + /// 废弃状态 0 正常 1 废弃 + /// + public int IsVaild { get; set; } + /// + /// 废弃时间 + /// + public string VaildTime { get; set; } + /// + /// 开始制作时间 cookingStatu更新为3时更新此字段 + /// + public string StartCookingTime { get; set; } + /// + /// 结束制作时间 cookingStatus跟新为4时更新此字段 + /// + public string EndCookingTime { get; set; } + /// + /// 完成取餐时间 cookingStatus更新为5时更新此字段 + /// + public string CompleteTakeTime { get; set; } + /// + /// 创建于 + /// + public string CreatedAt { get; set; } + /// + /// 创建人 + /// + public string CreatedBy { get; set; } + /// + /// 更新于 + /// + public string UpdatedAt { get; set; } + /// + /// 更新人 + /// + public string UpdatedBy { get; set; } + /// + /// 自动修改 记录最新的修改时间 + /// + public string UpdatedTs { get; set; } + /// + /// 排序 + /// + public string SortNumber { get; set; } + /// + /// 后厨小票打印次数 + /// + public int SalvePrintCount { get; set; } + /// + /// 做法Id + /// + public string MakeId { get; set; } + /// + /// 做法名称 + /// + public string MakeName { get; set; } + /// + /// 是否设备 + /// + public int IsDevice { get; set; } + /// + /// 是否赠送 true 赠送 + /// + public bool IsGift { get; set; } + + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrder.cs b/BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrder.cs new file mode 100644 index 0000000..affe8ea --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrder.cs @@ -0,0 +1,22 @@ +using BPA.KitChen.StoreManagementOrder.Core.Entity.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + + [SugarTable("BPA_ThirdOrder")] + public class BPA_ThirdOrder: IBaseGroupIdEntity + { + + public string OrderNum { get; set; } + + public string ThirdName { get; set; } + + + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrderInfo.cs b/BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrderInfo.cs new file mode 100644 index 0000000..e68beec --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrderInfo.cs @@ -0,0 +1,24 @@ +using BPA.KitChen.StoreManagementOrder.Core.Entity.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + + [SugarTable("BPA_ThirdOrderInfo")] + public class BPA_ThirdOrderInfo: IBaseGroupIdEntity + { + + public string ThirdOrderId { get; set; } + + public string GoodsForeignKeyId { get; set; } + + public string GoodsName { get; set; } + + public decimal Count { get; set; } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseEntity.cs b/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseEntity.cs new file mode 100644 index 0000000..c32c06c --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseEntity.cs @@ -0,0 +1,23 @@ +using Furion; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity.Base +{ + /// + /// 基础类型 + /// + public abstract class IBaseEntity + { + + /// + /// 主键 Guid + /// + [SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string Id { get; set; } = Guid.NewGuid().ToString(); + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseGroupIdEntity.cs b/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseGroupIdEntity.cs new file mode 100644 index 0000000..ae89d7b --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseGroupIdEntity.cs @@ -0,0 +1,19 @@ + +using BPA.KitChen.StoreManagementOrder.Core.Common.Const; +using Furion; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity.Base +{ + public class IBaseGroupIdEntity: IEntity + { + + [SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "GroupId", IsNullable = true)] + public string GroupId { get; set; } = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseOPEntity.cs b/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseOPEntity.cs new file mode 100644 index 0000000..67a6305 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseOPEntity.cs @@ -0,0 +1,128 @@ +using BPA.KitChen.StoreManagementOrder.Core.Common.Const; +using Furion; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity.Base +{ + /// + /// 修改人修改时间 + /// + public class IBaseOPEntity : IBaseEntity + { + /// + /// 删除标识 + /// 0=> 正常使用 + /// 1=> 已经被标记删除 + /// + [SugarColumn(ColumnDataType = "int", ColumnDescription = "是否删除", IsNullable = false)] + public int IsDeleted { get; set; } = 0; + /// + /// 删除时间 + /// + [SugarColumn(ColumnDataType = "DateTime", ColumnDescription = "删除时间", IsNullable = true)] + public DateTime? DeleteAt { get; set; } + /// + /// 删除人 + /// + [SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "删除人", IsNullable = true)] + public string DeleteBy { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(ColumnDataType = "DateTime", ColumnDescription = "更新时间", IsNullable = true)] + public DateTime? UpdateAt { get; set; } + /// + /// 更新人 + /// + [SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "更新人", IsNullable = true)] + public string UpdateBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnDataType = "DateTime", ColumnDescription = "创建时间", IsNullable = true)] + public DateTime CreateAt { get; set; } = DateTime.Now; + /// + /// 创建人 + /// + [SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "创建人", IsNullable = true)] + public string CreateBy { get; set; } + + /// + /// 新增 + /// + public virtual void Create() + { + var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + var userName = App.User?.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + this.Id = Guid.NewGuid().ToString(); + this.CreateAt = DateTime.Now; + if (!string.IsNullOrEmpty(userId)) + { + this.CreateBy = userId; + } + else + { + + this.CreateBy = "admin"; + } + } + public virtual void Create(DateTime data) + { + var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + var userName = App.User?.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + this.Id = Guid.NewGuid().ToString(); + this.CreateAt = data; + if (!string.IsNullOrEmpty(userId)) + { + this.CreateBy = userId; + } + else + { + + this.CreateBy = "admin"; + } + } + /// + /// 修改 + /// + public void Modify() + { + var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + var userName = App.User?.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + this.UpdateAt = DateTime.Now; + if (!string.IsNullOrEmpty(userId)) + { + this.UpdateBy = userId; + } + else + { + + this.UpdateBy = "admin"; + } + } + + /// + /// 删除 + /// + public void Delete() + { + var userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + var userName = App.User?.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value; + this.DeleteAt = DateTime.Now; + if (!string.IsNullOrEmpty(userId)) + { + this.DeleteBy = userId; + } + else + { + + this.DeleteBy = "admin"; + } + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/Base/IEntity.cs b/BPA.KitChen.StoreManagement.Core/Entity/Base/IEntity.cs new file mode 100644 index 0000000..70f59db --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/Base/IEntity.cs @@ -0,0 +1,21 @@ +using BPA.KitChen.StoreManagementOrder.Core.Enum; +using Furion; +using SqlSugar; +using System; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity.Base +{ + /// + /// 自定义实体基类 + /// + public abstract class IEntity: IBaseOPEntity + { + /// + /// 状态 + /// + [SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)] + public CommonStatus Status { get; set; } = CommonStatus.ENABLE; + + + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Entity/Class1.cs b/BPA.KitChen.StoreManagement.Core/Entity/Class1.cs new file mode 100644 index 0000000..db5bb53 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Entity/Class1.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Entity +{ + internal class Class1 + { + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/AccountType.cs b/BPA.KitChen.StoreManagement.Core/Enum/AccountType.cs new file mode 100644 index 0000000..8021e7c --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/AccountType.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + /// + /// 分账账户类型 + /// + public enum AccountType + { + /// + /// 商户 + /// + [Description("商户")] + MERCHANT = 0, + + /// + /// 个人 + /// + [Description("个人")] + PERSONAL = 1, + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/CommonStatus.cs b/BPA.KitChen.StoreManagement.Core/Enum/CommonStatus.cs new file mode 100644 index 0000000..9670aae --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/CommonStatus.cs @@ -0,0 +1,95 @@ +using System.ComponentModel; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + /// + /// 公共状态 + /// + public enum CommonStatus + { + /// + /// 正常 + /// + [Description("正常")] + ENABLE = 0, + + /// + /// 停用 + /// + [Description("停用")] + DISABLE = 1, + + /// + /// 删除 + /// + [Description("删除")] + DELETED = 2 + } + public enum MenuTypeEnums + { + /// + /// 数据操作类型 + /// + Handle, + /// + /// 普通菜单 + /// + Normal + } + /// + /// 账号类型 + /// + public enum AdminEnums + { + /// + /// 超级管理员 + /// + [Description("超级管理员")] + SuperAdmin = 1, + + /// + /// 管理员 + /// + [Description("管理员")] + Admin = 2, + + /// + /// 普通账号 + /// + [Description("普通账号")] + None = 3 + } + /// + /// 会员平台 + /// + public enum PlatformType + { + /// + /// 默认 + /// + [Description("默认")] + Default = 0, + /// + /// 微信 + /// + [Description("微信")] + WeChat=1, + + /// + /// 支付宝 + /// + [Description("支付宝")] + Alipay = 2, + /// + /// POS + /// + [Description("pos")] + POS = 3, + /// + /// card + /// + [Description("储值卡")] + Card = 4, + + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Enum/CouponUseType.cs b/BPA.KitChen.StoreManagement.Core/Enum/CouponUseType.cs new file mode 100644 index 0000000..d7f64b2 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/CouponUseType.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum CouponUseType + { + [Description("未使用")] + NoUse=1, + [Description("已核销")] + WriteOff=2, + [Description("占用中")] + Occupied=3, + [Description("已失效")] + Invalidation=4 + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/DataScopeType.cs b/BPA.KitChen.StoreManagement.Core/Enum/DataScopeType.cs new file mode 100644 index 0000000..3f2532b --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/DataScopeType.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum DataScopeType + { + /// + /// 全部数据 + /// + [Description("全部数据")] + ALL = 1, + + /// + /// 本部门及以下数据 + /// + [Description("本部门及以下数据")] + DEPT_WITH_CHILD = 2, + + /// + /// 本部门数据 + /// + [Description("本部门数据")] + DEPT = 3, + + /// + /// 仅本人数据 + /// + [Description("仅本人数据")] + SELF = 4, + + /// + /// 自定义数据 + /// + [Description("自定义数据")] + DEFINE = 5 + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Enum/GoodsAttribute.cs b/BPA.KitChen.StoreManagement.Core/Enum/GoodsAttribute.cs new file mode 100644 index 0000000..e0317dd --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/GoodsAttribute.cs @@ -0,0 +1,36 @@ +/** +* 命名空间: BPA.Kitchen.Core.Common.Enum +* +* 功 能: N/A +* 类 名: GoodsAttribute +* +* Ver 变更日期 负责人 变更内容 +* ─────────────────────────────────── +* V0.01 2022/6/24 10:04:06 唐学波 初版 +* +* Copyright (c) 2022 BlackB Corporation. All rights reserved. +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + /// + /// 商品属性 + /// + public enum GoodsAttribute + { + /// + /// 单品 + /// + SingleGoods = 0, + + /// + /// 套餐 + /// + ComboGoods = 1, + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Enum/IntegralEnum.cs b/BPA.KitChen.StoreManagement.Core/Enum/IntegralEnum.cs new file mode 100644 index 0000000..b1ce599 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/IntegralEnum.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public class IntegralEnum + { + public enum CalculateType + { + 积分方案 = 1, + 多倍积分 = 2, + 独立计算 = 3 + } + + /// + /// 积分增加/减少类型 + /// + public enum IntegSourceType + { + + 订单消费 = 1, + 活动赠送 = 2, + 后台补充 = 3, + 积分兑换 = 4, + } + + /// + /// 小类方案类型 + /// + public enum allTypes + { + common = 0, + price = 1, + big = 2, + small = 3, + count = 4, + persons = 5, + number = 6 + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/MenuOpenType.cs b/BPA.KitChen.StoreManagement.Core/Enum/MenuOpenType.cs new file mode 100644 index 0000000..ed4f5b0 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/MenuOpenType.cs @@ -0,0 +1,34 @@ +using System.ComponentModel; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + /// + /// 系统菜单类型 + /// + public enum MenuOpenType + { + /// + /// 无 + /// + [Description("无")] + NONE = 0, + + /// + /// 组件 + /// + [Description("组件")] + COMPONENT = 1, + + /// + /// 内链 + /// + [Description("内链")] + INNER = 2, + + /// + /// 外链 + /// + [Description("外链")] + OUTER = 3 + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Enum/MenuType.cs b/BPA.KitChen.StoreManagement.Core/Enum/MenuType.cs new file mode 100644 index 0000000..676c118 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/MenuType.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum MenuType + { + /// + /// 目录 + /// + [Description("目录")] + DIR = 0, + + /// + /// 菜单 + /// + [Description("菜单")] + MENU = 1, + + /// + /// 按钮 + /// + [Description("按钮")] + BTN = 2 + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement.Core/Enum/OrderEnum.cs b/BPA.KitChen.StoreManagement.Core/Enum/OrderEnum.cs new file mode 100644 index 0000000..bea85fa --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/OrderEnum.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public class OrderEnum + { + public enum SubOrderCookingStutas + { + WaitMake = 0, + Making = 1, + WaitTake = 2, + TakeCompleted = 3, + Normal = 99998, + Error = 99999 + } + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/OrgType.cs b/BPA.KitChen.StoreManagement.Core/Enum/OrgType.cs new file mode 100644 index 0000000..1ae98b2 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/OrgType.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum OrgType + { + /// + /// 机构部门 + /// + [Description("机构部门")] + ORG = 0, + + /// + /// 配送中心 + /// + [Description("配送中心")] + DEVLIVERY = 1, + + /// + /// 门店 + /// + [Description("门店")] + STORE = 2, + /// + /// 门店 + /// + [Description("加盟店")] + FranchiseeSTORE = 3 + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/SRDUserType.cs b/BPA.KitChen.StoreManagement.Core/Enum/SRDUserType.cs new file mode 100644 index 0000000..bb961e9 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/SRDUserType.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum SRDUserType + { + /// + /// 人员 + /// + [Description("人员")] + USER = 0, + + /// + /// 人员分类 + /// + [Description("人员分类")] + USERTYPE = 1, + + } + public enum RSDGroupType + { + /// + /// 设备 + /// + [Description("设备")] + RSD = 0, + + /// + /// 设备分组 + /// + [Description("设备分组")] + RSDGROUP = 1, + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/StatusEntity.cs b/BPA.KitChen.StoreManagement.Core/Enum/StatusEntity.cs new file mode 100644 index 0000000..c3af65b --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/StatusEntity.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum StatusEntity + { + /// + /// 正常 + /// + [Description("正常")] + ENABLE = 0, + + /// + /// 停用 + /// + [Description("停用")] + DISABLE = 1, + } +} diff --git a/BPA.KitChen.StoreManagement.Core/Enum/TransactionType.cs b/BPA.KitChen.StoreManagement.Core/Enum/TransactionType.cs new file mode 100644 index 0000000..c1708c1 --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/Enum/TransactionType.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.Enum +{ + public enum TransactionType + { + /// + /// 充值 + /// + Recharge=1, + /// + /// 消费 + /// + Consume = 2, + /// + /// 退款 + /// + Refund = 3, + } +} diff --git a/BPA.KitChen.StoreManagement.Core/RequestAnalysis/UserAnalysis.cs b/BPA.KitChen.StoreManagement.Core/RequestAnalysis/UserAnalysis.cs new file mode 100644 index 0000000..89744fc --- /dev/null +++ b/BPA.KitChen.StoreManagement.Core/RequestAnalysis/UserAnalysis.cs @@ -0,0 +1,21 @@ +using Furion; +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Core.RequestAnalysis +{ + public class UserAnalysis + { + public UserAnalysis() + { + + //CurrentUser.AppId = App.HttpContext.Request.Headers["AppId"]; + //CurrentUser.TenantId = App.HttpContext.Request.Headers["TenantId"]; + + } + } +} diff --git a/BPA.KitChen.StoreManagement.SqlSugar/BPA.KitChen.StoreManagementOrder.SqlSugar.csproj b/BPA.KitChen.StoreManagement.SqlSugar/BPA.KitChen.StoreManagementOrder.SqlSugar.csproj new file mode 100644 index 0000000..9a95caf --- /dev/null +++ b/BPA.KitChen.StoreManagement.SqlSugar/BPA.KitChen.StoreManagementOrder.SqlSugar.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/BPA.KitChen.StoreManagement.SqlSugar/SqlSugarDb.cs b/BPA.KitChen.StoreManagement.SqlSugar/SqlSugarDb.cs new file mode 100644 index 0000000..68d63e6 --- /dev/null +++ b/BPA.KitChen.StoreManagement.SqlSugar/SqlSugarDb.cs @@ -0,0 +1,201 @@ +using BPA.KitChen.StoreManagementOrder.Core.Common; +using BPA.KitChen.StoreManagementOrder.Core.Common.Const; +using BPA.KitChen.StoreManagementOrder.Core.Entity.Base; +using Furion; +using Furion.DatabaseAccessor; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Linq.Expressions; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.SqlSugar +{ + public class SqlSugarDb + { + public static SqlSugarScope Db { get; set; } + + public static SqlSugarScope SqlSugarScope(ConnectionConfig configConnection) + { + //全局过滤 + + Db = new SqlSugarScope(configConnection, db => + { + //全局过滤 + TableFilterItem(db); + db.Aop.OnLogExecuting = (sql, pars) => + { + Console.WriteLine(sql); + + //sql 执行前 + }; + db.Aop.OnLogExecuted = (sql, pars) => + { + //sql 执行后 + }; + db.Aop.OnError = ex => + { + //sql 异常 + }; + }); + + return Db; + } + + #region 全局过滤器及配置 + /// + /// 全局过滤 + /// + private static void TableFilterItem(SqlSugarClient db) + { + + //添加默认值 + DataExecuting(db); + + //// 配置租户过滤器 + //var tenantId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + //db.QueryFilter.AddTableFilter(u => u.GroupId == tenantId); + + //db.QueryFilter.AddTableFilter(u => u.IsDeleted ==0); + var types = Assembly.Load("BPA.KitChen.StoreManagementOrder.Core").GetTypes() + .Where(x => x.GetCustomAttribute() != null); + + foreach (var entityType in types) + { + + if (entityType.GetProperty("GroupId") != null)//判断实体类中包含属性 + { + var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) + ? App.User?.FindFirst(ClaimConst.GroupId)?.Value + : CurrentUser.TenantId; + //构建动态Lambda + var lambda = DynamicExpressionParser.ParseLambda + (new[] { Expression.Parameter(entityType, "it") }, + typeof(bool), $"{nameof(IBaseGroupIdEntity.GroupId)} == @0", + groupId); + db.QueryFilter.Add(new TableFilterItem(entityType, lambda, true)); //将Lambda传入过滤器 + } + + if (entityType.GetProperty("IsDeleted") != null) //判断实体类中包含属性 + { + //构建动态Lambda + var lambda = DynamicExpressionParser.ParseLambda + (new[] { Expression.Parameter(entityType, "it") }, + typeof(bool), $"{nameof(IBaseOPEntity.IsDeleted)} == @0", + 0); + db.QueryFilter.Add(new TableFilterItem(entityType, lambda, true)); //将Lambda传入过滤器 + } + + } + + + //var types = Assembly.Load("BPA.KitChen.StoreManagementOrder.Core").GetTypes() + // .Where(x => x.Namespace != null + // && x.GetCustomAttribute() != null + // && x.Namespace.Contains("BPA.KitChen.StoreManagementOrder.Core.Entity")); + + //foreach (var entityType in types) + //{ + // if (entityType.GetProperty("GroupId") != null)//判断实体类中包含属性 + // { + // //构建动态Lambda + // var lambda = DynamicExpressionParser.ParseLambda + // (new[] { Expression.Parameter(entityType, "it") }, + // typeof(bool), $"{nameof(ITenantIdFilter.GroupId)} == @0", + // CurrentUser.GroupId); + // db.QueryFilter.Add(new TableFilterItem(entityType, lambda, true)); //将Lambda传入过滤器 + // } + + // if (entityType.GetProperty("IsDelete") != null) //判断实体类中包含属性 + // { + // //构建动态Lambda + // var lambda = DynamicExpressionParser.ParseLambda + // (new[] { Expression.Parameter(entityType, "it") }, + // typeof(bool), $"{nameof(IDeletedFilter.IsDelete)} == @0", + // false); + // db.QueryFilter.Add(new TableFilterItem(entityType, lambda, true)); //将Lambda传入过滤器 + // } + + //} + + } + + /// + /// 附默认值 + /// + /// + private static void DataExecuting(SqlSugarClient db) + { + //全局字段赋值 + db.Aop.DataExecuting = (oldValue, entityInfo) => + { + InsertByObject(entityInfo); + UpdateByObject(oldValue, entityInfo); + }; + + } + /// + ///插入数据时附默认值 + /// + /// + private static void InsertByObject(DataFilterModel entityInfo) + { + if (entityInfo.OperationType != DataFilterType.InsertByObject) return; + switch (entityInfo.PropertyName) + { + case "CreateAt": + entityInfo.SetValue(DateTime.Now); + break; + case "CreateBy": + entityInfo.SetValue(CurrentUser.Account); + break; + case "GroupId": + entityInfo.SetValue(CurrentUser.TenantId); + break; + } + } + + /// + /// 修改数据时附默认值 + /// + /// + /// + private static void UpdateByObject(object oldValue, DataFilterModel entityInfo) + { + if (entityInfo.OperationType != DataFilterType.UpdateByObject) return; + + switch (entityInfo.PropertyName) + { + case "UpdateAt": + entityInfo.SetValue(DateTime.Now); + break; + case "UpdateBy": + entityInfo.SetValue(CurrentUser.Account); + break; + } + + //if (entityInfo.PropertyName == "IsDelete" && (bool)oldValue) + //{ + // switch (entityInfo.PropertyName) + // { + // case "DeleteAt": + // entityInfo.SetValue(DateTime.Now); + // break; + // case "DeleteBy": + // entityInfo.SetValue(CurrentUser.Account); + // break; + // } + //} + //else + //{ + + //} + + } + #endregion + } +} diff --git a/BPA.KitChen.StoreManagement.SqlSugar/SqlsugarSetup.cs b/BPA.KitChen.StoreManagement.SqlSugar/SqlsugarSetup.cs new file mode 100644 index 0000000..9803c89 --- /dev/null +++ b/BPA.KitChen.StoreManagement.SqlSugar/SqlsugarSetup.cs @@ -0,0 +1,31 @@ +using Furion; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.SqlSugar +{ + public static class SqlsugarSetup + { + /// + /// + /// + /// + public static void AddSqlsugarSetup(this IServiceCollection services) + { + //如果多个数数据库传 List + var configConnection = new ConnectionConfig() + { + DbType = DbType.MySql, + ConnectionString = App.Configuration["DBConnectionStr"], + IsAutoCloseConnection = true + }; + var sqlSugar = SqlSugarDb.SqlSugarScope(configConnection); + services.AddSingleton(sqlSugar);//这边是SqlSugarScope用AddSingleton + } + } +} diff --git a/BPA.KitChen.StoreManagement.SqlSugar/SupperRepository.cs b/BPA.KitChen.StoreManagement.SqlSugar/SupperRepository.cs new file mode 100644 index 0000000..6f24c29 --- /dev/null +++ b/BPA.KitChen.StoreManagement.SqlSugar/SupperRepository.cs @@ -0,0 +1,26 @@ +using BPA.KitChen.StoreManagementOrder.Core.RequestAnalysis; +using Furion.FriendlyException; +using SqlSugar; + +namespace BPA.KitChen.StoreManagementOrder.SqlSugar +{ + public class SupperRepository: UserAnalysis + { + public async Task BaseAction(SqlSugarClient db, Func action, Func defualtActoion, string msg) + { + try + { + db.BeginTran(); + var res = action.Invoke(); + db.CommitTran(); + return await Task.FromResult(res); + } + catch (Exception ex) + { + db.RollbackTran(); + //BPALog.WriteLog(msg + ":" + ex.Message, LogEnum.Error, null, ex); + throw Oops.Oh(ex.Message); + } + } + } +} diff --git a/BPA.KitChen.StoreManagement/BPA.KitChen.StoreManagementOrder.csproj b/BPA.KitChen.StoreManagement/BPA.KitChen.StoreManagementOrder.csproj new file mode 100644 index 0000000..639909b --- /dev/null +++ b/BPA.KitChen.StoreManagement/BPA.KitChen.StoreManagementOrder.csproj @@ -0,0 +1,21 @@ + + + + net6.0 + enable + enable + 2040c7ff-c388-467e-832b-d91b861f695a + Linux + + + + + + + + + + + + + diff --git a/BPA.KitChen.StoreManagement/Controllers/WeatherForecastController.cs b/BPA.KitChen.StoreManagement/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..1006bae --- /dev/null +++ b/BPA.KitChen.StoreManagement/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace BPA.KitChen.StoreManagementOrder.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement/Dockerfile b/BPA.KitChen.StoreManagement/Dockerfile new file mode 100644 index 0000000..d125a77 --- /dev/null +++ b/BPA.KitChen.StoreManagement/Dockerfile @@ -0,0 +1,25 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["BPA.KitChen.GroupMealOrder/BPA.KitChen.StoreManagementOrder.csproj", "BPA.KitChen.GroupMealOrder/"] +COPY ["BPA.KitChen.GroupMealOrder.Application/BPA.KitChen.StoreManagementOrder.Application.csproj", "BPA.KitChen.GroupMealOrder.Application/"] +COPY ["BPA.KitChen.GroupMealOrder.Core/BPA.KitChen.StoreManagementOrder.Core.csproj", "BPA.KitChen.GroupMealOrder.Core/"] +COPY ["BPA.KitChen.GroupMealOrder.SqlSugar/BPA.KitChen.StoreManagementOrder.SqlSugar.csproj", "BPA.KitChen.GroupMealOrder.SqlSugar/"] +RUN dotnet restore "BPA.KitChen.GroupMealOrder/BPA.KitChen.StoreManagementOrder.csproj" +COPY . . +WORKDIR "/src/BPA.KitChen.GroupMealOrder" +RUN dotnet build "BPA.KitChen.StoreManagementOrder.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "BPA.KitChen.StoreManagementOrder.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "BPA.KitChen.StoreManagementOrder.dll"] \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement/Handlers/JwtHandler.cs b/BPA.KitChen.StoreManagement/Handlers/JwtHandler.cs new file mode 100644 index 0000000..1304d26 --- /dev/null +++ b/BPA.KitChen.StoreManagement/Handlers/JwtHandler.cs @@ -0,0 +1,80 @@ +using Furion; +using Furion.Authorization; +using Furion.DataEncryption; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System.Security.Claims; +using System.Threading.Tasks; + +namespace BPA.KitChen.StoreManagementOrder.Handlers +{ + public class JwtHandler : AppAuthorizeHandler + { + /// + /// 重写 Handler 添加自动刷新 + /// + /// + /// + + public override async Task HandleAsync(AuthorizationHandlerContext context) + { + // 自动刷新Token + if (JWTEncryption.AutoRefreshToken(context, context.GetCurrentHttpContext(), + App.GetOptions().ExpiredTime)) + { + await AuthorizeHandleAsync(context); + } + else + { + context.Fail(); // 授权失败 + DefaultHttpContext currentHttpContext = context.GetCurrentHttpContext(); + if (currentHttpContext == null) + return; + currentHttpContext.SignoutToSwagger(); + } + } + + /// + /// 授权判断逻辑,授权通过返回 true,否则返回 false + /// + /// + /// + /// + public override async Task PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext) + { + // 此处已经自动验证 Jwt Token的有效性了,无需手动验证 + return await CheckAuthorzieAsync(httpContext); + } + /// + /// 检查权限 + /// + /// + /// + private static async Task CheckAuthorzieAsync(DefaultHttpContext httpContext) + { + // 获取权限特性 FromHeader教研数据 + //var securityDefineAttribute = httpContext.GetMetadata(); + //if (securityDefineAttribute == null) return true; + + var userId = App.User?.FindFirstValue("UserId"); + // 解析服务 + // var userManager = httpContext.RequestServices.GetService(); + + // var loginType = App.User?.FindFirstValue("LoginType"); + //登录认证服务 + return true; + //if ("0".Equals(loginType)) { + // var securities = await userManager.CheckUser(userId); + // // 检查授权 + // return securities; + //} + //if ("1".Equals(loginType)) { + // var securities = await userManager.CheckUser(userId); + // // 检查授权 + // return securities; + //} + //return false; + } + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement/Program.cs b/BPA.KitChen.StoreManagement/Program.cs new file mode 100644 index 0000000..986038f --- /dev/null +++ b/BPA.KitChen.StoreManagement/Program.cs @@ -0,0 +1,29 @@ +using BPA.KitChen.StoreManagementOrder.Handlers; +using BPA.KitChen.StoreManagementOrder.SqlSugar; + +var builder = WebApplication.CreateBuilder(args).Inject(); + +//JWTȨ +builder.Services.AddJwt(enableGlobalAuthorize: true); + + +//÷ʽ +builder.Services.AddUnifyResult(); + +builder.Services.AddControllers().AddInject(); +builder.Services.AddSqlsugarSetup(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. + +app.UseHttpsRedirection(); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.UseInject(); + +app.MapControllers(); + +app.Run(); diff --git a/BPA.KitChen.StoreManagement/Properties/launchSettings.json b/BPA.KitChen.StoreManagement/Properties/launchSettings.json new file mode 100644 index 0000000..d1348ce --- /dev/null +++ b/BPA.KitChen.StoreManagement/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "profiles": { + "BPA.KitChen.StoreManagementOrder": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/index.html", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5003" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast", + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:41386", + "sslPort": 44336 + } + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement/WeatherForecast.cs b/BPA.KitChen.StoreManagement/WeatherForecast.cs new file mode 100644 index 0000000..b2f4040 --- /dev/null +++ b/BPA.KitChen.StoreManagement/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace BPA.KitChen.StoreManagementOrder +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} \ No newline at end of file diff --git a/BPA.KitChen.StoreManagement/appsettings.Development.json b/BPA.KitChen.StoreManagement/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/BPA.KitChen.StoreManagement/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/BPA.KitChen.StoreManagement/appsettings.json b/BPA.KitChen.StoreManagement/appsettings.json new file mode 100644 index 0000000..3071472 --- /dev/null +++ b/BPA.KitChen.StoreManagement/appsettings.json @@ -0,0 +1,11 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "SAAS_Manage": "http://10.2.1.26:21995/saasbase/", + "DBConnectionStr": "server=10.2.1.21;Port=3306;Database=bpa_kitchen_storemanageorder;Uid=root;Pwd=cygadmin;", + "AllowedHosts": "*" +}