Browse Source

提交

master
gwbvipvip 9 months ago
parent
commit
aaf2392792
69 changed files with 3611 additions and 0 deletions
  1. +18
    -0
      BPA.KitChen.StoreManagement.Application/BPA.KitChen.StoreManagementOrder.Application.csproj
  2. +19
    -0
      BPA.KitChen.StoreManagement.Application/BaseDto/DtoValidator.cs
  3. +116
    -0
      BPA.KitChen.StoreManagement.Application/BaseDto/IXnInputBase.cs
  4. +23
    -0
      BPA.KitChen.StoreManagement.Application/BaseDto/PageUtil.cs
  5. +46
    -0
      BPA.KitChen.StoreManagement.Application/BaseDto/ResultEntity.cs
  6. +7
    -0
      BPA.KitChen.StoreManagement.Application/Class1.cs
  7. +68
    -0
      BPA.KitChen.StoreManagement.Application/Service/BaseDtos.cs
  8. +200
    -0
      BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderFlowQuery.cs
  9. +66
    -0
      BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderQueryInputDto.cs
  10. +20
    -0
      BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/ThirdOrderDto.cs
  11. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Order/IOrderService.cs
  12. +531
    -0
      BPA.KitChen.StoreManagement.Application/Service/Order/OrderService.cs
  13. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/Test/ITestService.cs
  14. +44
    -0
      BPA.KitChen.StoreManagement.Application/Service/Test/TestService.cs
  15. +14
    -0
      BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/Dtos/ThirdAuthorizeInfoDto.cs
  16. +12
    -0
      BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/IThirdAuthorize.cs
  17. +101
    -0
      BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/ThirdAuthorize.cs
  18. +21
    -0
      BPA.KitChen.StoreManagement.Core/BPA.KitChen.StoreManagementOrder.Core.csproj
  19. +7
    -0
      BPA.KitChen.StoreManagement.Core/Class1.cs
  20. +57
    -0
      BPA.KitChen.StoreManagement.Core/Common/Const/ClaimConst.cs
  21. +14
    -0
      BPA.KitChen.StoreManagement.Core/Common/CosConfig.cs
  22. +26
    -0
      BPA.KitChen.StoreManagement.Core/Common/CosInfoOptions.cs
  23. +25
    -0
      BPA.KitChen.StoreManagement.Core/Common/CurrentUser.cs
  24. +100
    -0
      BPA.KitChen.StoreManagement.Core/Common/HttpHelper.cs
  25. +28
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/AcceptEntity.cs
  26. +13
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/IAccept.cs
  27. +26
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQEnum.cs
  28. +111
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQFactory.cs
  29. +26
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushEntity.cs
  30. +81
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushManage.cs
  31. +73
    -0
      BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Publisher/ServiceQueryPush.cs
  32. +130
    -0
      BPA.KitChen.StoreManagement.Core/Entity/BPA_Order.cs
  33. +172
    -0
      BPA.KitChen.StoreManagement.Core/Entity/BPA_OrderRefundLog.cs
  34. +19
    -0
      BPA.KitChen.StoreManagement.Core/Entity/BPA_ShopAuthorize.cs
  35. +107
    -0
      BPA.KitChen.StoreManagement.Core/Entity/BPA_SubOrder.cs
  36. +22
    -0
      BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrder.cs
  37. +24
    -0
      BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrderInfo.cs
  38. +23
    -0
      BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseEntity.cs
  39. +19
    -0
      BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseGroupIdEntity.cs
  40. +128
    -0
      BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseOPEntity.cs
  41. +21
    -0
      BPA.KitChen.StoreManagement.Core/Entity/Base/IEntity.cs
  42. +12
    -0
      BPA.KitChen.StoreManagement.Core/Entity/Class1.cs
  43. +27
    -0
      BPA.KitChen.StoreManagement.Core/Enum/AccountType.cs
  44. +95
    -0
      BPA.KitChen.StoreManagement.Core/Enum/CommonStatus.cs
  45. +21
    -0
      BPA.KitChen.StoreManagement.Core/Enum/CouponUseType.cs
  46. +42
    -0
      BPA.KitChen.StoreManagement.Core/Enum/DataScopeType.cs
  47. +36
    -0
      BPA.KitChen.StoreManagement.Core/Enum/GoodsAttribute.cs
  48. +44
    -0
      BPA.KitChen.StoreManagement.Core/Enum/IntegralEnum.cs
  49. +34
    -0
      BPA.KitChen.StoreManagement.Core/Enum/MenuOpenType.cs
  50. +25
    -0
      BPA.KitChen.StoreManagement.Core/Enum/MenuType.cs
  51. +21
    -0
      BPA.KitChen.StoreManagement.Core/Enum/OrderEnum.cs
  52. +35
    -0
      BPA.KitChen.StoreManagement.Core/Enum/OrgType.cs
  53. +39
    -0
      BPA.KitChen.StoreManagement.Core/Enum/SRDUserType.cs
  54. +24
    -0
      BPA.KitChen.StoreManagement.Core/Enum/StatusEntity.cs
  55. +24
    -0
      BPA.KitChen.StoreManagement.Core/Enum/TransactionType.cs
  56. +21
    -0
      BPA.KitChen.StoreManagement.Core/RequestAnalysis/UserAnalysis.cs
  57. +13
    -0
      BPA.KitChen.StoreManagement.SqlSugar/BPA.KitChen.StoreManagementOrder.SqlSugar.csproj
  58. +201
    -0
      BPA.KitChen.StoreManagement.SqlSugar/SqlSugarDb.cs
  59. +31
    -0
      BPA.KitChen.StoreManagement.SqlSugar/SqlsugarSetup.cs
  60. +26
    -0
      BPA.KitChen.StoreManagement.SqlSugar/SupperRepository.cs
  61. +21
    -0
      BPA.KitChen.StoreManagement/BPA.KitChen.StoreManagementOrder.csproj
  62. +33
    -0
      BPA.KitChen.StoreManagement/Controllers/WeatherForecastController.cs
  63. +25
    -0
      BPA.KitChen.StoreManagement/Dockerfile
  64. +80
    -0
      BPA.KitChen.StoreManagement/Handlers/JwtHandler.cs
  65. +29
    -0
      BPA.KitChen.StoreManagement/Program.cs
  66. +38
    -0
      BPA.KitChen.StoreManagement/Properties/launchSettings.json
  67. +13
    -0
      BPA.KitChen.StoreManagement/WeatherForecast.cs
  68. +8
    -0
      BPA.KitChen.StoreManagement/appsettings.Development.json
  69. +11
    -0
      BPA.KitChen.StoreManagement/appsettings.json

+ 18
- 0
BPA.KitChen.StoreManagement.Application/BPA.KitChen.StoreManagementOrder.Application.csproj View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NPOI" Version="2.6.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPA.KitChen.GroupMealOrder.Core\BPA.KitChen.StoreManagementOrder.Core.csproj" />
<ProjectReference Include="..\BPA.KitChen.GroupMealOrder.SqlSugar\BPA.KitChen.StoreManagementOrder.SqlSugar.csproj" />
</ItemGroup>

</Project>

+ 19
- 0
BPA.KitChen.StoreManagement.Application/BaseDto/DtoValidator.cs View File

@@ -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
{
/// <summary>
/// Dto参数验证
/// </summary>
public class DtoValidator
{

}
}

+ 116
- 0
BPA.KitChen.StoreManagement.Application/BaseDto/IXnInputBase.cs View File

@@ -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
{
/// <summary>
/// 通用输入扩展参数(带权限)
/// </summary>
public class XnInputBase : PageInputBase
{
/// <summary>
/// 授权菜单
/// </summary>
public List<string> GrantMenuIdList { get; set; } = new List<string>();

/// <summary>
/// 授权角色
/// </summary>
public List<string> GrantRoleIdList { get; set; } = new List<string>();

/// <summary>
/// 授权数据
/// </summary>
public List<string> GrantOrgIdList { get; set; } = new List<string>();

/// <summary>
/// 搜索值
/// </summary>
public virtual string SearchValue { get; set; }

/// <summary>
/// 搜索开始时间
/// </summary>
public virtual string SearchBeginTime { get; set; }

/// <summary>
/// 搜索结束时间
/// </summary>
public virtual string SearchEndTime { get; set; }

/// <summary>
/// 排序字段
/// </summary>
public virtual string SortField { get; set; }

/// <summary>
/// 排序方法,默认升序,否则降序(配合antd前端,约定参数为 Ascend,Dscend)
/// </summary>
public virtual string SortOrder { get; set; }

/// <summary>
/// 降序排序(不要问我为什么是descend不是desc,前端约定参数就是这样)
/// </summary>
public virtual string DescStr { get; set; } = "descend";

/// <summary>
/// 复杂查询条件
/// </summary>
// public virtual List<Condition> SearchParameters { get; set; } = new();
}

/// <summary>
/// 通用分页输入参数
/// </summary>
public class PageInputBase
{
public string bomId { get; set; }
public string chnologyId { get; set; }
/// <summary>
/// 当前页码
/// </summary>
private int current;
public virtual int Current
{
get
{
return current;
}
set
{

current = value;
if (current <= 0)
{
current = 1;
}
}
}
//public int? Status { get; set; }
/// <summary>
/// 页码容量
/// </summary>

private int pagesize;
public virtual int PageSize
{
get
{
return pagesize;
}
set
{

pagesize = value;
if (pagesize <= 0)
{
pagesize = 20;
}
}
}
}
}

+ 23
- 0
BPA.KitChen.StoreManagement.Application/BaseDto/PageUtil.cs View File

@@ -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
{

/// <summary>
/// Data
/// </summary>

public object Data { get; set; }
/// <summary>
/// Total
/// </summary>

public int Total { get; set; }
}
}

+ 46
- 0
BPA.KitChen.StoreManagement.Application/BaseDto/ResultEntity.cs View File

@@ -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<T>
{

public bool IsSuccess { get; set; }

public string Msg { get; set; }

public T Data { get; set; }
}


public class Result<T>
{
public int StatusCode { get; set; }

public ResultEntity<T> Data { get; set; }

public string Succeeded { get; set; }

public object Errors { get; set; }

public object Extras { get; set; }

public string Timestamp { get; set; }

}

}

+ 7
- 0
BPA.KitChen.StoreManagement.Application/Class1.cs View File

@@ -0,0 +1,7 @@
namespace BPA.KitChen.StoreManagementOrder.Application
{
public class Class1
{

}
}

+ 68
- 0
BPA.KitChen.StoreManagement.Application/Service/BaseDtos.cs View File

@@ -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
{
/// <summary>
/// 当前页码
/// </summary>
private int current;
public virtual int Current
{
get
{
return current;
}
set
{

current = value;
if (current <= 0)
{
current = 1;
}
}
}
//public int? Status { get; set; }
/// <summary>
/// 页码容量
/// </summary>

private int pagesize;
public virtual int PageSize
{
get
{
return pagesize;
}
set
{

pagesize = value;
if (pagesize <= 0)
{
pagesize = 20;
}
}
}
}

public class PageOutDto
{
/// <summary>
/// Data
/// </summary>

public object Data { get; set; }
/// <summary>
/// Total
/// </summary>

public int Total { get; set; }
}
}

+ 200
- 0
BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderFlowQuery.cs View File

@@ -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
{
/// <summary>
/// 订单流水查询
/// </summary>
public class OrderFlowQuery : PageInputBase
{
/// <summary>
/// 订单Id
/// </summary>
public string Id { get; set; }
public string orderFlowId { get; set; }
/// <summary>
/// 加盟商编号
/// </summary>
public string FranchiseeId { get; set; }
/// <summary>
/// 加盟商名称
/// </summary>
public string FranchiseeName { get; set; }
/// <summary>
/// 店铺名称编号(设备名称编号)
/// </summary>
public string StoreId { get; set; }
/// <summary>
/// 店铺名称
/// </summary>
public string StoreName { get; set; }
/// <summary>
/// 商品key
/// </summary>
public string GoodsId { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 商品类型编号
/// </summary>
public string GoodsTypeId { get; set; }
/// <summary>
/// 商品类型名称
/// </summary>
public string GoodsTypeName { get; set; }
/// <summary>
/// 店铺分类编号(设备类型关联值)
/// </summary>
public string StoreTypeId { get; set; }
/// <summary>
/// 店铺分类名称(设备类型名称)
/// </summary>
public string StoreTypeName { get; set; }
/// <summary>
/// 订单编号
/// </summary>

public string Order_Number { get; set; }
/// <summary>
/// 应付金额
/// </summary>
public decimal? Order_OriginalMoney { get; set; }
/// <summary>
/// 实付金额
/// </summary>
public decimal? Order_RealMoney { get; set; }
public decimal? RefundOriginalMoney { get; set; }
public decimal? RefundRealMoney { get; set; }
/// <summary>
/// 支付方式(微信支付)
/// </summary>
public int PayMode { get; set; }
public int Order_Status { get; set; }
/// <summary>
/// 订单汇总数量
/// </summary>
public int Order_Count { get; set; }
/// <summary>
/// 订单开始时间
/// </summary>
public DateTime Order_CreateTime { get; set; }
/// <summary>
/// 订单结束时间
/// </summary>
public DateTime? Order_EndTime { get; set; }
/// <summary>
/// 订单类型
/// 0-->正常
/// 1--立即吃面
/// 2-->其他
/// </summary>
public int PlaceMode { get; set; }
/// <summary>
///
/// </summary>
public string Customer_Name { get; set; }

/// <summary>
///
/// </summary>
public string Customer_Tel { get; set; }
public int CountNumber { get; set; }
public int WechatIsCheck { get; set; }
}
public class OrderSumQuery : PageInputBase
{
/// <summary>
/// 订单Id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 加盟商编号
/// </summary>
public string FranchiseeId { get; set; }
/// <summary>
/// 加盟商名称
/// </summary>
public string FranchiseeName { get; set; }
/// <summary>
/// 店铺名称编号(设备名称编号)
/// </summary>
public string StoreId { get; set; }
/// <summary>
/// 店铺名称
/// </summary>
public string StoreName { get; set; }
/// <summary>
/// 商品key
/// </summary>
public string GoodsId { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 商品类型编号
/// </summary>
public string GoodsTypeId { get; set; }
/// <summary>
/// 商品类型名称
/// </summary>
public string GoodsTypeName { get; set; }
/// <summary>
/// 店铺分类编号(设备类型关联值)
/// </summary>
public string StoreTypeId { get; set; }
/// <summary>
/// 店铺分类名称(设备类型名称)
/// </summary>
public string StoreTypeName { get; set; }
/// <summary>
/// 订单编号
/// </summary>

public string Order_Number { get; set; }
/// <summary>
/// 应付金额
/// </summary>
public decimal? Order_OriginalMoney { get; set; }
/// <summary>
/// 实付金额
/// </summary>
public decimal? Order_RealMoney { get; set; }
public decimal? DiscountMoney { get; set; }
/// <summary>
/// 支付方式(微信支付)
/// </summary>
public int PayMode { get; set; }
/// <summary>
/// 订单汇总数量
/// </summary>

public int SumOrder { get; set; }
public int OrderNum { get; set; }
public int BoxNum { get; set; }
public int NowNum { get; set; }
public int Abandoned { get; set; }
public int Refund { get; set; }
public decimal refundMoney { get; set; }
public int refundNum { get; set; }
public int Customer { get; set; }
public int CountDetail { get; set; }
/// <summary>
/// 订单开始时间
/// </summary>
public DateTime? Order_CreateTime { get; set; }
/// <summary>
/// 订单结束时间
/// </summary>
public DateTime? Order_EndTime { get; set; }
}
}

+ 66
- 0
BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/OrderQueryInputDto.cs View File

@@ -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
{
/// <summary>
/// 订单Id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 加盟商编号
/// </summary>
public string FranchiseeId { get; set; }
/// <summary>
/// 订单号
/// </summary>
public string order_Number { get; set; }

public string Customer_Tel { get; set; }
/// <summary>
/// 店铺名称编号(设备名称编号)
/// </summary>
public string[] StoreId { get; set; }
/// <summary>
/// <summary>
/// 商品key
/// </summary>
public string[] GoodsId { get; set; }
/// <summary>
/// 商品类型编号
/// </summary>
public string[] GoodsTypeId { get; set; }
/// <summary>
/// 店铺分类编号(设备类型关联值)
/// </summary>
public string StoreTypeId { get; set; }
/// <summary>
/// 订单开始时间
/// </summary>
public DateTime? Order_CreateTime { get; set; }
/// <summary>
/// 订单结束时间
/// </summary>
public DateTime? Order_EndTime { get; set; }

public bool isreport { get; set; } = false;
public bool IsExport { get; set; } = false;
/// <summary>
/// 订单状态
/// </summary>
public int? OrderStatus { get; set; }

/// <summary>
/// 支付渠道 0微信 1支付宝 2 余额 3银联
/// </summary>
public int? PayMode { get; set; }
}
}

+ 20
- 0
BPA.KitChen.StoreManagement.Application/Service/Order/Dtos/ThirdOrderDto.cs View File

@@ -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<BPA_ThirdOrderInfo> ThirdOrderInfos { get; set; }
}

public class ThirdOrderInputDto: PageInputBase
{
public string OrderNum { get; set; }
}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Order/IOrderService.cs View File

@@ -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
{
}
}

+ 531
- 0
BPA.KitChen.StoreManagement.Application/Service/Order/OrderService.cs View File

@@ -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
{
/// <summary>
/// 核心对象:拥有完整的SqlSugar全部功能
/// </summary>
private readonly SqlSugarScope db;
private readonly string CustomerIds = "omwji4jSSh6o-I0UPLGrxKEio73Y,omwji4lFXTPD6SoCQLMexKoWdWY4";
private readonly string StoreId = "3b007e32-f1cc-4021-b4e0-f4764fa90f12";
IWebHostEnvironment _hostingEnvironment;

/// <summary>
/// construct
/// </summary>
/// <param name="sqlSugarRepository"></param>
public OrderService(IWebHostEnvironment hostingEnvironment)
{
db = SqlSugarDb.Db;
_hostingEnvironment=hostingEnvironment;
}

/// <summary>
/// 订单明细
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/Order/PostDetail")]
public PageUtil PostDetail(OrderQueryInputDto dto)
{
//根据对应的条件查询和排序
string strWhere = string.Empty;
int total = 0;
List<OrderFlowQuery> res = new List<OrderFlowQuery>();
//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<OrderFlowQuery>(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<BPA_Order>().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<OrderFlowQuery> 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<OrderFlowQuery> OrderDetailFlowExportData(OrderQueryInputDto dto)
{
//根据对应的条件查询和排序
string strWhere = string.Empty;
int total = 0;
List<OrderFlowQuery> res = new List<OrderFlowQuery>();
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<OrderFlowQuery>(sql)
.WhereIF(dto.PayMode.HasValue, (b) => b.PayMode == dto.PayMode)
.OrderBy(a => a.Order_CreateTime, OrderByType.Desc).ToList();

return res;

}


#region 第三方订单

/// <summary>
/// 获取第三方
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/Order/ThirdOrderPage")]
public async Task<PageUtil> ThirdOrderPageAsync(ThirdOrderInputDto inputDto)
{
var total = new RefAsync<int>();
var data = await db.Queryable<BPA_ThirdOrder>()
.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<BPA_ThirdOrderInfo>()
.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

};
}

/// <summary>
/// 获取第三方订单详情
/// </summary>
/// <param name="thirdOrderId"></param>
/// <returns></returns>
[HttpGet("/api/Order/GetThirdOrderInfo")]
public async Task<ThirdOrderDto> GetThirdOrderInfo(string thirdOrderId)
{
var data = await db.Queryable<BPA_ThirdOrder>()
.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<BPA_ThirdOrderInfo>()
.Where(x => x.ThirdOrderId==thirdOrderId)
.ToListAsync();
data.ThirdOrderInfos = thirdOrderInfos;
return data;
}

#endregion

}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/Test/ITestService.cs View File

@@ -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
{
}
}

+ 44
- 0
BPA.KitChen.StoreManagement.Application/Service/Test/TestService.cs View File

@@ -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
{
/// <summary>
/// CodeFirst
/// </summary>
/// <param name="tableNames"></param>
public void CodeFirst()
{
try
{
var types = Assembly.Load("BPA.KitChen.StoreManagementOrder.Core").GetTypes()
.Where(x => x.Namespace != null
&& x.GetCustomAttribute<SugarTable>() != null
&& x.Namespace.Contains("BPA.KitChen.StoreManagementOrder.Core.Entity"))
.ToArray();
SqlSugarDb.Db.CodeFirst.InitTables(types);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}

}
}
}

+ 14
- 0
BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/Dtos/ThirdAuthorizeInfoDto.cs View File

@@ -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
{

}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/IThirdAuthorize.cs View File

@@ -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
{
}
}

+ 101
- 0
BPA.KitChen.StoreManagement.Application/Service/ThirdAuthorize/ThirdAuthorize.cs View File

@@ -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;
}

/// <summary>
/// 获取第三方
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/ThirdAuthorize/Page")]
public async Task<PageUtil> Page(ThirdAuthorizeInfoDto inputDto)
{
var total = new RefAsync<int>();
var data = await db.Queryable<BPA_ShopAuthorize>()
.OrderBy(a => a.CreateAt, OrderByType.Desc)
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);

return new PageUtil()
{
Data = data,
Total = total

};
}


/// <summary>
/// 创建 授权
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/ThirdAuthorize/Create")]
public async Task<bool> Create(BPA_ShopAuthorize inputDto)
{
var data=await db.Queryable<BPA_ShopAuthorize>().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;
}

/// <summary>
/// 修改 重新赋值授权码
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/ThirdAuthorize/Update")]
public async Task<bool> Update(BPA_ShopAuthorize inputDto)
{
var data = await db.Queryable<BPA_ShopAuthorize>().Where(x =>x.Id==inputDto.Id).FirstAsync();
data.AuthorizeCode = Guid.NewGuid().ToString();
var res=await db.Updateable(data).ExecuteCommandAsync();
return res > 0;
}

/// <summary>
/// 修改 重新赋值授权码
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/ThirdAuthorize/Del")]
public async Task<bool> Del(string id)
{
var res = await SqlSugarDb.Db.Updateable<BPA_ShopAuthorize>()
.SetColumns(it => new BPA_ShopAuthorize { IsDeleted = 1 })//类只能在表达示里面不能提取
.Where(it => it.Id == id)
.ExecuteCommandAsync();
return res > 0;
}
}
}

+ 21
- 0
BPA.KitChen.StoreManagement.Core/BPA.KitChen.StoreManagementOrder.Core.csproj View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EasyNetQ" Version="7.8.0" />
<PackageReference Include="Furion" Version="4.9.1.20" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.20" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.134" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.7" />
</ItemGroup>

<ItemGroup>
<Folder Include="Common\Enum\" />
</ItemGroup>

</Project>

+ 7
- 0
BPA.KitChen.StoreManagement.Core/Class1.cs View File

@@ -0,0 +1,7 @@
namespace BPA.KitChen.StoreManagementOrder.Core
{
public class Class1
{

}
}

+ 57
- 0
BPA.KitChen.StoreManagement.Core/Common/Const/ClaimConst.cs View File

@@ -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
{
/// <summary>
/// 用户Id
/// </summary>
public const string CLAINM_USERID = "UserId";

/// <summary>
/// 账号
/// </summary>
public const string CLAINM_ACCOUNT = "Account";

/// <summary>
/// 名称
/// </summary>
public const string CLAINM_NAME = "Name";

/// <summary>
/// 是否超级管理
/// </summary>
public const string CLAINM_SUPERADMIN = "SuperAdmin";

/// <summary>
/// 登录类型1平台用户登录,0加盟商登录
/// </summary>
public const string LoginType = "LoginType";
/// <summary>
/// 加盟商编号
/// </summary>
public const string FranchID = "FranchID";
/// <summary>
/// 加盟商通知手机号
/// </summary>
public const string FranchTel = "18782023833";

/// <summary>
/// 加盟商组id
/// </summary>
public const string GroupId = "GroupId";

/// <summary>
/// 权限
/// </summary>
public const string RoleId = "RoleId";
public const string OrgId = "";

public const string SupplyPlatformId = "SupplyPlatformId";
}
}

+ 14
- 0
BPA.KitChen.StoreManagement.Core/Common/CosConfig.cs View File

@@ -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;
}
}

+ 26
- 0
BPA.KitChen.StoreManagement.Core/Common/CosInfoOptions.cs View File

@@ -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;
}
}
}

+ 25
- 0
BPA.KitChen.StoreManagement.Core/Common/CurrentUser.cs View File

@@ -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
{
/// <summary>
/// 当前用户
/// </summary>
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;

}
}

+ 100
- 0
BPA.KitChen.StoreManagement.Core/Common/HttpHelper.cs View File

@@ -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();

/// <summary>
/// Get 请求
/// </summary>
/// <param name="url"></param>
/// <param name="postDataStr"></param>
/// <param name="headers"></param>
/// <param name="platform"></param>
/// <param name="contentType"></param>
/// <returns></returns>
public static string HttpGet(string url, string postDataStr, Dictionary<string, string> 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<string, string> 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<string, string> 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<string, string> 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;
}
}
}
}

+ 28
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/AcceptEntity.cs View File

@@ -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
{
/// <summary>
/// 队列名称
/// </summary>
public String QueeName { get; set; }
/// <summary>
/// 推送模式
/// </summary>
public MQEnum SendType { get; set; }
/// <summary>
/// 管道名称
/// </summary>
public String ExchangeName { get; set; }
/// <summary>
/// 路由名称
/// </summary>
public String RouteName { get; set; }
}
}

+ 13
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/IAccept.cs View File

@@ -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<T>(string msg);
}
}

+ 26
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQEnum.cs View File

@@ -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
{
/// <summary>
/// 订阅模式
/// </summary>
[Description("订阅模式")]
Sub = 10,
/// <summary>
/// 推送模式
/// </summary>
[Description("推送模式")]
Push = 20,
/// <summary>
/// 主路由模式
/// </summary>
[Description("主路由模式")]
Top = 30
}
}

+ 111
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/MQFactory.cs View File

@@ -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;
/// <summary>
/// 创建链接
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 释放链接
/// </summary>
public static void DisposeBus()
{
Bus?.Dispose();
}
/// <summary>
/// 同步执行
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Param"></param>
/// <returns></returns>
public static bool SendMQ<T>(PushEntity<T> 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;
}
}
/// <summary>
/// 推荐异步执行
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Param"></param>
/// <returns></returns>
public static async Task SendMQAsync<T>(PushEntity<T> Param) where T : class
{

if (Bus == null)
CreateMQ();
await new PushManage().SendMQAsync(Param, Bus);
}
/// <summary>
/// 订阅消息
/// </summary>
/// <typeparam name="TAccept"></typeparam>
/// <param name="Args"></param>
public static void Subscriber<TAccept, T>(AcceptEntity Args) where TAccept : IAccept, new() where T : new()
{
//if (Bus == null)
// CreateMQ();
//if (string.IsNullOrEmpty(Args.ExchangeName))
// return;
//Expression<Action<IAccept>> 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<T>(message);
// methodCall.Compile()(new TAccept());
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}));
}
}
}

+ 26
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushEntity.cs View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace BPA.Kitchen.Core.RabbitMq.Config
{
public class PushEntity<T>
{
/// <summary>
/// 推送内容
/// </summary>
public T BodyData { get; set; }
/// <summary>
/// 推送模式
/// </summary>
public MQEnum SendType { get; set; }
/// <summary>
/// 管道名称
/// </summary>
public String ExchangeName { get; set; }
/// <summary>
/// 路由名称
/// </summary>
public String RouteName { get; set; }
}
}

+ 81
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Config/PushManage.cs View File

@@ -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
{
/// <summary>
/// 发布消息队列异步
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Param"></param>
/// <param name="Bus"></param>
/// <returns></returns>
public async Task SendMQAsync<T>(PushEntity<T> Param, IBus Bus)
{
////one to one
//var msg = new Message<T>(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);
// }
//});
}
/// <summary>
/// 发布消息队列同步
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Param"></param>
/// <param name="Bus"></param>
public void SendMQ<T>(PushEntity<T> Param, IBus Bus)
{
////one to one
//var msg = new Message<T>(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);
}
}
}

+ 73
- 0
BPA.KitChen.StoreManagement.Core/Common/RabbitMq/Publisher/ServiceQueryPush.cs View File

@@ -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<ServiceQueryPush>().Value;
public async Task<bool> PushMQAsync<T>(T Entity,string Key, MQEnum MQType = MQEnum.Push) where T : class, new()
{
//推送模式
//推送模式下需指定管道名称和路由键值名称
//消息只会被发送到指定的队列中去
//订阅模式
//订阅模式下只需指定管道名称
//消息会被发送到该管道下的所有队列中
//主题路由模式
//路由模式下需指定管道名称和路由值
//消息会被发送到该管道下,和路由值匹配的队列中去
PushEntity<T> entity = new PushEntity<T>();
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>(T Entity, string Key, MQEnum MQType = MQEnum.Push)
{
//推送模式
//推送模式下需指定管道名称和路由键值名称
//消息只会被发送到指定的队列中去
//订阅模式
//订阅模式下只需指定管道名称
//消息会被发送到该管道下的所有队列中
//主题路由模式
//路由模式下需指定管道名称和路由值
//消息会被发送到该管道下,和路由值匹配的队列中去
PushEntity<T> entity = new PushEntity<T>();
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);
}
}
}

+ 130
- 0
BPA.KitChen.StoreManagement.Core/Entity/BPA_Order.cs View File

@@ -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
{
/// <summary>
///
/// </summary>
public string Id { get; set; }
/// <summary>
/// 排序号 (按加盟商区分)
/// </summary>
public string SortId { get; set; }
/// <summary>
/// 用户Id
/// </summary>
public string CustomerId { get; set; }
/// <summary>
/// 订单状态 0未付款,1已付款,-1退单申请,-2退单中,-3已退单,-4取消交易 -5撤销申请
/// </summary>
public int OrderStatus { get; set; }
/// <summary>
/// 用户售后状态 -1 售后已取消 0 未发起售后 1 申请售后 2 处理中 200 处理完毕
/// </summary>
public int AfterStatus { get; set; }
/// <summary>
/// 商品数量
/// </summary>
public int OrderCount { get; set; }
/// <summary>
/// 商品总价
/// </summary>
public decimal OrderOriginalMoney { get; set; }
/// <summary>
/// 折扣价格
/// </summary>
public decimal DiscountMoney { get; set; }
/// <summary>
/// 实际支付价格
/// </summary>
public decimal OrderRealMoney { get; set; }
/// <summary>
/// 支付渠道 0微信 1支付宝 2 余额 3银联 4.现金
/// </summary>
public int PayMode { get; set; }
/// <summary>
/// 订单号(本系统)
/// </summary>
public string OrderNumber { get; set; }
/// <summary>
/// 订单号(第三方)
/// </summary>
public string TradeNo { get; set; }
/// <summary>
/// 交易号
/// </summary>
public string TransactionId { get; set; }
/// <summary>
/// 订单结算状态 0未结算 1已结算
/// </summary>
public int OrderSettlementStatus { get; set; }
/// <summary>
/// 订单结算时间
/// </summary>
public string OrderSettlementTime { get; set; }
/// <summary>
/// 订单类型 0->正常 1->立即吃面2->盲盒3->其他
/// </summary>
public int OrderType { get; set; }
/// <summary>
/// 创建于
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreatedBy { get; set; }
/// <summary>
/// 更新于
/// </summary>
public DateTime UpdatedAt { get; set; }
/// <summary>
/// 更新人
/// </summary>
public string UpdatedBy { get; set; }
/// <summary>
/// 自动修改 记录最新的修改时间
/// </summary>
public string UpdatedTs { get; set; }
/// <summary>
/// 订单来源 0 小程序 1大屏点餐 etc...
/// </summary>
public string OrderSourceFrom { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 三方id
/// </summary>
public string TroikaId { get; set; }
/// <summary>
/// 店铺id
/// </summary>
public string OrgId { get; set; }
/// <summary>
/// 小票备注
/// </summary>
public string PrintRemark { get; set; }
/// <summary>
/// 就餐方式
/// </summary>
public int EatType { get; set; }

public string GroupId { get; set; }
/// <summary>
/// 优惠合集
/// </summary>
public string PriceCollection { get; set; }
public decimal CusmetMoney { get; set; }
}
}

+ 172
- 0
BPA.KitChen.StoreManagement.Core/Entity/BPA_OrderRefundLog.cs View File

@@ -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
{

/// <summary>
///
/// </summary>
public string Id { get; set; } = Guid.NewGuid().ToString();


/// <summary>
/// 订单号(自己系统)
/// </summary>
public System.String OrderNumber { get; set; }


/// <summary>
/// 订单号(第三方)
/// </summary>
public System.String TradeNo { get; set; }

/// <summary>
/// 交易号
/// </summary>
public System.String TransactionId { get; set; }


/// <summary>
/// 售后表Id(null表示为售前退款)
/// </summary>
public System.String ReturnId { get; set; }


/// <summary>
/// 主订单id
/// </summary>
public System.String OrderId { get; set; }


/// <summary>
/// 子订单id
/// </summary>
public System.String SubOrderId { get; set; }


/// <summary>
/// 退款金额()
/// </summary>
public System.Decimal RefundMoney { get; set; }


/// <summary>
/// 退款类型0:售前退款(商品未制作时退款) 1 售后退款 (商品已经开始进行制作)
/// </summary>
public System.Int32 RefundType { get; set; }


/// <summary>
/// 退款结果 0 成功 1失败
/// </summary>
public System.Int32 RefundResult { get; set; }


/// <summary>
/// 退款描述 退款成功;账户余额不足;退款金额大于订单金额..etc
/// </summary>
public System.String RefundDesc { get; set; }


/// <summary>
/// 退款来源(退款到什么地方) 0微信 1支付宝 2 余额
/// </summary>
public System.Int32 RefundSource { get; set; }


/// <summary>
/// 退款调用方式 0 小程序调用退款 1 saas调用退款 2 第三方调用退款 4.POS
/// </summary>
public System.Int32 RefundCallType { get; set; }


/// <summary>
/// 退款时间
/// </summary>
public System.DateTime? RefundTime { get; set; }


/// <summary>
/// 创建于
/// </summary>
public System.DateTime? CreatedAt { get; set; }


/// <summary>
/// 创建人
/// </summary>
public System.String CreatedBy { get; set; }


/// <summary>
/// 更新于
/// </summary>
public System.DateTime? UpdatedAt { get; set; }


/// <summary>
/// 更新人
/// </summary>
public System.String UpdatedBy { get; set; }


/// <summary>
/// 退款状态
/// </summary>
public RefundStatus Stutas { get; set; }

public string GroupId { get; set; }
}
public enum RefundStatus
{
/// <summary>
/// 申请部分退款
/// </summary>
PartRefund = 10,
/// <summary>
/// 部分退款处理中
/// </summary>
PartRefundWait = 101,
/// <summary>
/// 部分退款成功
/// </summary>
PartRefundOk = 102,
/// <summary>
/// 取消部分退款
/// </summary>
PartRefundCancel = 103,
/// <summary>
/// 部分退款失败
/// </summary>
PartRefundError = 104,
/// <summary>
/// 申请全额退款
/// </summary>
FullRefund = 20,
/// <summary>
/// 全额退款处理中
/// </summary>
FullRefundWait = 201,
/// <summary>
/// 全额退款成功
/// </summary>
FullRefundOk = 202,
/// <summary>
/// 取消全额退款
/// </summary>
FullRefundCancel = 203,
/// <summary>
/// 全额退款失败
/// </summary>
FullRefundError = 204,
}
}

+ 19
- 0
BPA.KitChen.StoreManagement.Core/Entity/BPA_ShopAuthorize.cs View File

@@ -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; }
}
}

+ 107
- 0
BPA.KitChen.StoreManagement.Core/Entity/BPA_SubOrder.cs View File

@@ -0,0 +1,107 @@
using SqlSugar;

namespace BPA.KitChen.StoreManagementOrder.Core.Entity
{
[SugarTable("BPA_SubOrder")]
public class BPA_SubOrder
{

/// <summary>
///
/// </summary>
public string Id { get; set; }
/// <summary>
/// 主订单表Id
/// </summary>
public string OrderId { get; set; }
/// <summary>
/// 商品表Id
/// </summary>
public string GoodId { get; set; }
/// <summary>
/// 设备id
/// </summary>
public string StoreId { get; set; }
/// <summary>
/// 应付款
/// </summary>
public decimal GooodOriginPrice { get; set; }
/// <summary>
/// 商品平摊价格(实付款)
/// </summary>
public decimal GoodsRealPrice { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 订单状态 1已下单(云服务将订单信息存放在redis) 2等待制作(上位机从redis取出) 3 制作中 4 制作完成待取餐 5 取餐完成
/// </summary>
public int CookingStatus { get; set; }
/// <summary>
/// 废弃状态 0 正常 1 废弃
/// </summary>
public int IsVaild { get; set; }
/// <summary>
/// 废弃时间
/// </summary>
public string VaildTime { get; set; }
/// <summary>
/// 开始制作时间 cookingStatu更新为3时更新此字段
/// </summary>
public string StartCookingTime { get; set; }
/// <summary>
/// 结束制作时间 cookingStatus跟新为4时更新此字段
/// </summary>
public string EndCookingTime { get; set; }
/// <summary>
/// 完成取餐时间 cookingStatus更新为5时更新此字段
/// </summary>
public string CompleteTakeTime { get; set; }
/// <summary>
/// 创建于
/// </summary>
public string CreatedAt { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreatedBy { get; set; }
/// <summary>
/// 更新于
/// </summary>
public string UpdatedAt { get; set; }
/// <summary>
/// 更新人
/// </summary>
public string UpdatedBy { get; set; }
/// <summary>
/// 自动修改 记录最新的修改时间
/// </summary>
public string UpdatedTs { get; set; }
/// <summary>
/// 排序
/// </summary>
public string SortNumber { get; set; }
/// <summary>
/// 后厨小票打印次数
/// </summary>
public int SalvePrintCount { get; set; }
/// <summary>
/// 做法Id
/// </summary>
public string MakeId { get; set; }
/// <summary>
/// 做法名称
/// </summary>
public string MakeName { get; set; }
/// <summary>
/// 是否设备
/// </summary>
public int IsDevice { get; set; }
/// <summary>
/// 是否赠送 true 赠送
/// </summary>
public bool IsGift { get; set; }

}
}

+ 22
- 0
BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrder.cs View File

@@ -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; }


}
}

+ 24
- 0
BPA.KitChen.StoreManagement.Core/Entity/BPA_ThirdOrderInfo.cs View File

@@ -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; }
}
}

+ 23
- 0
BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseEntity.cs View File

@@ -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
{
/// <summary>
/// 基础类型
/// </summary>
public abstract class IBaseEntity
{
/// <summary>
/// 主键 Guid
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string Id { get; set; } = Guid.NewGuid().ToString();
}
}

+ 19
- 0
BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseGroupIdEntity.cs View File

@@ -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;
}
}

+ 128
- 0
BPA.KitChen.StoreManagement.Core/Entity/Base/IBaseOPEntity.cs View File

@@ -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
{
/// <summary>
/// 修改人修改时间
/// </summary>
public class IBaseOPEntity : IBaseEntity
{
/// <summary>
/// 删除标识
/// 0=> 正常使用
/// 1=> 已经被标记删除
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "是否删除", IsNullable = false)]
public int IsDeleted { get; set; } = 0;
/// <summary>
/// 删除时间
/// </summary>
[SugarColumn(ColumnDataType = "DateTime", ColumnDescription = "删除时间", IsNullable = true)]
public DateTime? DeleteAt { get; set; }
/// <summary>
/// 删除人
/// </summary>
[SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "删除人", IsNullable = true)]
public string DeleteBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnDataType = "DateTime", ColumnDescription = "更新时间", IsNullable = true)]
public DateTime? UpdateAt { get; set; }
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "更新人", IsNullable = true)]
public string UpdateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDataType = "DateTime", ColumnDescription = "创建时间", IsNullable = true)]
public DateTime CreateAt { get; set; } = DateTime.Now;
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "创建人", IsNullable = true)]
public string CreateBy { get; set; }

/// <summary>
/// 新增
/// </summary>
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";
}
}
/// <summary>
/// 修改
/// </summary>
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";
}
}

/// <summary>
/// 删除
/// </summary>
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";
}
}
}
}

+ 21
- 0
BPA.KitChen.StoreManagement.Core/Entity/Base/IEntity.cs View File

@@ -0,0 +1,21 @@
using BPA.KitChen.StoreManagementOrder.Core.Enum;
using Furion;
using SqlSugar;
using System;

namespace BPA.KitChen.StoreManagementOrder.Core.Entity.Base
{
/// <summary>
/// 自定义实体基类
/// </summary>
public abstract class IEntity: IBaseOPEntity
{
/// <summary>
/// 状态
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;

}
}

+ 12
- 0
BPA.KitChen.StoreManagement.Core/Entity/Class1.cs View File

@@ -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
{
}
}

+ 27
- 0
BPA.KitChen.StoreManagement.Core/Enum/AccountType.cs View File

@@ -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
{
/// <summary>
/// 分账账户类型
/// </summary>
public enum AccountType
{
/// <summary>
/// 商户
/// </summary>
[Description("商户")]
MERCHANT = 0,

/// <summary>
/// 个人
/// </summary>
[Description("个人")]
PERSONAL = 1,
}
}

+ 95
- 0
BPA.KitChen.StoreManagement.Core/Enum/CommonStatus.cs View File

@@ -0,0 +1,95 @@
using System.ComponentModel;

namespace BPA.KitChen.StoreManagementOrder.Core.Enum
{
/// <summary>
/// 公共状态
/// </summary>
public enum CommonStatus
{
/// <summary>
/// 正常
/// </summary>
[Description("正常")]
ENABLE = 0,

/// <summary>
/// 停用
/// </summary>
[Description("停用")]
DISABLE = 1,

/// <summary>
/// 删除
/// </summary>
[Description("删除")]
DELETED = 2
}
public enum MenuTypeEnums
{
/// <summary>
/// 数据操作类型
/// </summary>
Handle,
/// <summary>
/// 普通菜单
/// </summary>
Normal
}
/// <summary>
/// 账号类型
/// </summary>
public enum AdminEnums
{
/// <summary>
/// 超级管理员
/// </summary>
[Description("超级管理员")]
SuperAdmin = 1,

/// <summary>
/// 管理员
/// </summary>
[Description("管理员")]
Admin = 2,

/// <summary>
/// 普通账号
/// </summary>
[Description("普通账号")]
None = 3
}
/// <summary>
/// 会员平台
/// </summary>
public enum PlatformType
{
/// <summary>
/// 默认
/// </summary>
[Description("默认")]
Default = 0,
/// <summary>
/// 微信
/// </summary>
[Description("微信")]
WeChat=1,

/// <summary>
/// 支付宝
/// </summary>
[Description("支付宝")]
Alipay = 2,
/// <summary>
/// POS
/// </summary>
[Description("pos")]
POS = 3,
/// <summary>
/// card
/// </summary>
[Description("储值卡")]
Card = 4,

}
}

+ 21
- 0
BPA.KitChen.StoreManagement.Core/Enum/CouponUseType.cs View File

@@ -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
}
}

+ 42
- 0
BPA.KitChen.StoreManagement.Core/Enum/DataScopeType.cs View File

@@ -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
{
/// <summary>
/// 全部数据
/// </summary>
[Description("全部数据")]
ALL = 1,

/// <summary>
/// 本部门及以下数据
/// </summary>
[Description("本部门及以下数据")]
DEPT_WITH_CHILD = 2,

/// <summary>
/// 本部门数据
/// </summary>
[Description("本部门数据")]
DEPT = 3,

/// <summary>
/// 仅本人数据
/// </summary>
[Description("仅本人数据")]
SELF = 4,

/// <summary>
/// 自定义数据
/// </summary>
[Description("自定义数据")]
DEFINE = 5
}
}

+ 36
- 0
BPA.KitChen.StoreManagement.Core/Enum/GoodsAttribute.cs View File

@@ -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
{
/// <summary>
/// 商品属性
/// </summary>
public enum GoodsAttribute
{
/// <summary>
/// 单品
/// </summary>
SingleGoods = 0,

/// <summary>
/// 套餐
/// </summary>
ComboGoods = 1,
}
}

+ 44
- 0
BPA.KitChen.StoreManagement.Core/Enum/IntegralEnum.cs View File

@@ -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
}

/// <summary>
/// 积分增加/减少类型
/// </summary>
public enum IntegSourceType
{

订单消费 = 1,
活动赠送 = 2,
后台补充 = 3,
积分兑换 = 4,
}

/// <summary>
/// 小类方案类型
/// </summary>
public enum allTypes
{
common = 0,
price = 1,
big = 2,
small = 3,
count = 4,
persons = 5,
number = 6
}
}
}

+ 34
- 0
BPA.KitChen.StoreManagement.Core/Enum/MenuOpenType.cs View File

@@ -0,0 +1,34 @@
using System.ComponentModel;

namespace BPA.KitChen.StoreManagementOrder.Core.Enum
{
/// <summary>
/// 系统菜单类型
/// </summary>
public enum MenuOpenType
{
/// <summary>
/// 无
/// </summary>
[Description("无")]
NONE = 0,

/// <summary>
/// 组件
/// </summary>
[Description("组件")]
COMPONENT = 1,

/// <summary>
/// 内链
/// </summary>
[Description("内链")]
INNER = 2,

/// <summary>
/// 外链
/// </summary>
[Description("外链")]
OUTER = 3
}
}

+ 25
- 0
BPA.KitChen.StoreManagement.Core/Enum/MenuType.cs View File

@@ -0,0 +1,25 @@
using System.ComponentModel;

namespace BPA.KitChen.StoreManagementOrder.Core.Enum
{
public enum MenuType
{
/// <summary>
/// 目录
/// </summary>
[Description("目录")]
DIR = 0,

/// <summary>
/// 菜单
/// </summary>
[Description("菜单")]
MENU = 1,

/// <summary>
/// 按钮
/// </summary>
[Description("按钮")]
BTN = 2
}
}

+ 21
- 0
BPA.KitChen.StoreManagement.Core/Enum/OrderEnum.cs View File

@@ -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
}
}
}

+ 35
- 0
BPA.KitChen.StoreManagement.Core/Enum/OrgType.cs View File

@@ -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
{
/// <summary>
/// 机构部门
/// </summary>
[Description("机构部门")]
ORG = 0,

/// <summary>
/// 配送中心
/// </summary>
[Description("配送中心")]
DEVLIVERY = 1,

/// <summary>
/// 门店
/// </summary>
[Description("门店")]
STORE = 2,
/// <summary>
/// 门店
/// </summary>
[Description("加盟店")]
FranchiseeSTORE = 3
}
}

+ 39
- 0
BPA.KitChen.StoreManagement.Core/Enum/SRDUserType.cs View File

@@ -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
{
/// <summary>
/// 人员
/// </summary>
[Description("人员")]
USER = 0,

/// <summary>
/// 人员分类
/// </summary>
[Description("人员分类")]
USERTYPE = 1,

}
public enum RSDGroupType
{
/// <summary>
/// 设备
/// </summary>
[Description("设备")]
RSD = 0,

/// <summary>
/// 设备分组
/// </summary>
[Description("设备分组")]
RSDGROUP = 1,
}
}

+ 24
- 0
BPA.KitChen.StoreManagement.Core/Enum/StatusEntity.cs View File

@@ -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
{
/// <summary>
/// 正常
/// </summary>
[Description("正常")]
ENABLE = 0,

/// <summary>
/// 停用
/// </summary>
[Description("停用")]
DISABLE = 1,
}
}

+ 24
- 0
BPA.KitChen.StoreManagement.Core/Enum/TransactionType.cs View File

@@ -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
{
/// <summary>
/// 充值
/// </summary>
Recharge=1,
/// <summary>
/// 消费
/// </summary>
Consume = 2,
/// <summary>
/// 退款
/// </summary>
Refund = 3,
}
}

+ 21
- 0
BPA.KitChen.StoreManagement.Core/RequestAnalysis/UserAnalysis.cs View File

@@ -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"];

}
}
}

+ 13
- 0
BPA.KitChen.StoreManagement.SqlSugar/BPA.KitChen.StoreManagementOrder.SqlSugar.csproj View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPA.KitChen.GroupMealOrder.Core\BPA.KitChen.StoreManagementOrder.Core.csproj" />
</ItemGroup>

</Project>

+ 201
- 0
BPA.KitChen.StoreManagement.SqlSugar/SqlSugarDb.cs View File

@@ -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 全局过滤器及配置
/// <summary>
/// 全局过滤
/// </summary>
private static void TableFilterItem(SqlSugarClient db)
{

//添加默认值
DataExecuting(db);

//// 配置租户过滤器
//var tenantId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
//db.QueryFilter.AddTableFilter<IBaseGroupIdEntity>(u => u.GroupId == tenantId);

//db.QueryFilter.AddTableFilter<IBaseOPEntity>(u => u.IsDeleted ==0);
var types = Assembly.Load("BPA.KitChen.StoreManagementOrder.Core").GetTypes()
.Where(x => x.GetCustomAttribute<SugarTable>() != 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<object>(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<object>(entityType, lambda, true)); //将Lambda传入过滤器
}

}


//var types = Assembly.Load("BPA.KitChen.StoreManagementOrder.Core").GetTypes()
// .Where(x => x.Namespace != null
// && x.GetCustomAttribute<SugarTable>() != 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<object>(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<object>(entityType, lambda, true)); //将Lambda传入过滤器
// }

//}

}

/// <summary>
/// 附默认值
/// </summary>
/// <param name="db"></param>
private static void DataExecuting(SqlSugarClient db)
{
//全局字段赋值
db.Aop.DataExecuting = (oldValue, entityInfo) =>
{
InsertByObject(entityInfo);
UpdateByObject(oldValue, entityInfo);
};

}
/// <summary>
///插入数据时附默认值
/// </summary>
/// <param name="entityInfo"></param>
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;
}
}

/// <summary>
/// 修改数据时附默认值
/// </summary>
/// <param name="oldValue"></param>
/// <param name="entityInfo"></param>
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
}
}

+ 31
- 0
BPA.KitChen.StoreManagement.SqlSugar/SqlsugarSetup.cs View File

@@ -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
{
/// <summary>
///
/// </summary>
/// <param name="services"></param>
public static void AddSqlsugarSetup(this IServiceCollection services)
{
//如果多个数数据库传 List<ConnectionConfig>
var configConnection = new ConnectionConfig()
{
DbType = DbType.MySql,
ConnectionString = App.Configuration["DBConnectionStr"],
IsAutoCloseConnection = true
};
var sqlSugar = SqlSugarDb.SqlSugarScope(configConnection);
services.AddSingleton<ISqlSugarClient>(sqlSugar);//这边是SqlSugarScope用AddSingleton
}
}
}

+ 26
- 0
BPA.KitChen.StoreManagement.SqlSugar/SupperRepository.cs View File

@@ -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<T> BaseAction<T>(SqlSugarClient db, Func<T> action, Func<T> 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);
}
}
}
}

+ 21
- 0
BPA.KitChen.StoreManagement/BPA.KitChen.StoreManagementOrder.csproj View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>2040c7ff-c388-467e-832b-d91b861f695a</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPA.KitChen.GroupMealOrder.Application\BPA.KitChen.StoreManagementOrder.Application.csproj" />
<ProjectReference Include="..\BPA.KitChen.GroupMealOrder.Core\BPA.KitChen.StoreManagementOrder.Core.csproj" />
<ProjectReference Include="..\BPA.KitChen.GroupMealOrder.SqlSugar\BPA.KitChen.StoreManagementOrder.SqlSugar.csproj" />
</ItemGroup>

</Project>

+ 33
- 0
BPA.KitChen.StoreManagement/Controllers/WeatherForecastController.cs View File

@@ -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<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet]
public IEnumerable<WeatherForecast> 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();
}
}
}

+ 25
- 0
BPA.KitChen.StoreManagement/Dockerfile View File

@@ -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"]

+ 80
- 0
BPA.KitChen.StoreManagement/Handlers/JwtHandler.cs View File

@@ -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
{
/// <summary>
/// 重写 Handler 添加自动刷新
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override async Task HandleAsync(AuthorizationHandlerContext context)
{
// 自动刷新Token
if (JWTEncryption.AutoRefreshToken(context, context.GetCurrentHttpContext(),
App.GetOptions<JWTSettingsOptions>().ExpiredTime))
{
await AuthorizeHandleAsync(context);
}
else
{
context.Fail(); // 授权失败
DefaultHttpContext currentHttpContext = context.GetCurrentHttpContext();
if (currentHttpContext == null)
return;
currentHttpContext.SignoutToSwagger();
}
}

/// <summary>
/// 授权判断逻辑,授权通过返回 true,否则返回 false
/// </summary>
/// <param name="context"></param>
/// <param name="httpContext"></param>
/// <returns></returns>
public override async Task<bool> PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)
{
// 此处已经自动验证 Jwt Token的有效性了,无需手动验证
return await CheckAuthorzieAsync(httpContext);
}
/// <summary>
/// 检查权限
/// </summary>
/// <param name="httpContext"></param>
/// <returns></returns>
private static async Task<bool> CheckAuthorzieAsync(DefaultHttpContext httpContext)
{
// 获取权限特性 FromHeader教研数据
//var securityDefineAttribute = httpContext.GetMetadata<SecurityDefineAttribute>();
//if (securityDefineAttribute == null) return true;

var userId = App.User?.FindFirstValue("UserId");
// 解析服务
// var userManager = httpContext.RequestServices.GetService<IUserService>();

// 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;
}
}
}

+ 29
- 0
BPA.KitChen.StoreManagement/Program.cs View File

@@ -0,0 +1,29 @@
using BPA.KitChen.StoreManagementOrder.Handlers;
using BPA.KitChen.StoreManagementOrder.SqlSugar;

var builder = WebApplication.CreateBuilder(args).Inject();

//JWT¼øȨ
builder.Services.AddJwt<JwtHandler>(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();

+ 38
- 0
BPA.KitChen.StoreManagement/Properties/launchSettings.json View File

@@ -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
}
}
}

+ 13
- 0
BPA.KitChen.StoreManagement/WeatherForecast.cs View File

@@ -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; }
}
}

+ 8
- 0
BPA.KitChen.StoreManagement/appsettings.Development.json View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

+ 11
- 0
BPA.KitChen.StoreManagement/appsettings.json View File

@@ -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": "*"
}

Loading…
Cancel
Save