@@ -0,0 +1,83 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Core.Entity; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using MySqlConnector; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
namespace BPA.KitChen.StoreManagement.Application.BaseDto | |||
{ | |||
/// <summary> | |||
/// Dto参数验证 | |||
/// </summary> | |||
public class DtoValidator | |||
{ | |||
/// <summary> | |||
/// 验证会员 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public static ValidationResult Member(string id) | |||
{ | |||
var data = SqlSugarDb.Db.Queryable<BPA_MemberInfo>().First(x => x.Id == id&&x.IsDeleted==0); | |||
return data == null ? new ValidationResult("会员不存在") : ValidationResult.Success; | |||
} | |||
/// <summary> | |||
/// 验证会员标签的合法性 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public static ValidationResult MemberTag(string id) | |||
{ | |||
var data = SqlSugarDb.Db.Queryable<BPA_MemberTag>().First(x=>x.Id==id); | |||
return data == null ? new ValidationResult("会员标签不存在") : ValidationResult.Success; | |||
} | |||
/// <summary> | |||
/// 验证会员标签的合法性 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public static ValidationResult MemberTagList(List<string> ids) | |||
{ | |||
var data = SqlSugarDb.Db.Queryable<BPA_MemberTag>().Where(x => ids.Contains(x.Id) && x.IsDeleted == 0&&x.Status== CommonStatus.ENABLE).ToList(); | |||
return data.Count<=0 ? new ValidationResult("会员标签不存在") : ValidationResult.Success; | |||
} | |||
/// <summary> | |||
/// 会员平台 | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <returns></returns> | |||
public static ValidationResult MemberPlatformType(int type) | |||
{ | |||
return !System.Enum.IsDefined(typeof(PlatformType), type) ? new ValidationResult("平台类型不存在") : ValidationResult.Success; | |||
} | |||
/// <summary> | |||
/// 会员平台 | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <returns></returns> | |||
public static ValidationResult Status(int type) | |||
{ | |||
return !System.Enum.IsDefined(typeof(CommonStatus), type) ? new ValidationResult("状态错误") : ValidationResult.Success; | |||
} | |||
/// <summary> | |||
/// 优惠券使用 | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <returns></returns> | |||
public static ValidationResult CouponUseType(int type) | |||
{ | |||
return !System.Enum.IsDefined(typeof(CouponUseType), type) ? new ValidationResult("状态错误") : ValidationResult.Success; | |||
} | |||
} | |||
} |
@@ -37,7 +37,18 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos | |||
{ | |||
return await _devicePushRecodeService.Add(input); | |||
} | |||
/// <summary> | |||
/// 修改 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
[HttpGet("/api/devicepushrecode/update")] | |||
public async Task<bool> Update(string id) | |||
{ | |||
return await _devicePushRecodeService.Update(id); | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
@@ -72,11 +72,27 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos | |||
data.Topic= Topic; | |||
data.DataResore = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<dynamic>(input.Data.ToString())); | |||
var res=await Push(Topic, new PushData() { Data=input.Data, DeviceId= input.DeviceAutoKey }); | |||
data.Status = res ? CommonStatus.ENABLE : CommonStatus.DISABLE; | |||
data.Status = res == "success" ? CommonStatus.ENABLE : CommonStatus.DISABLE; | |||
await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); | |||
return res; | |||
return res == "success"; | |||
} | |||
public async Task<bool> Update(string id) | |||
{ | |||
var data = _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Id == id).First(); | |||
data.Status = CommonStatus.ENABLE; | |||
var respush = await Push(data.Topic, new PushData() { Data = data.DataResore, DeviceId = data.DeviceAutoKey }); | |||
if (respush != "success") | |||
{ | |||
data.Description = respush; | |||
data.Status = CommonStatus.DISABLE; | |||
} | |||
var res = await _db.Updateable(data).ExecuteCommandAsync(); | |||
return res > 0; | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
@@ -97,7 +113,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos | |||
throw Oops.Oh("删除失败"); | |||
} | |||
} | |||
private async Task<bool> Push(string Topic,PushData data) | |||
private async Task<string> Push(string Topic,PushData data) | |||
{ | |||
try | |||
{ | |||
@@ -117,11 +133,11 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos | |||
//string aa = bPAPackage.Serialize(false); | |||
var applictionmessage = new MqttApplicationMessageBuilder().WithTopic(Topic).WithPayload(bPAPackage.Serialize(false)).WithAtLeastOnceQoS().Build(); | |||
await _mqttClient.PublishAsync(applictionmessage); | |||
return true; | |||
return "success"; | |||
} | |||
catch (Exception e) | |||
{ | |||
throw Oops.Oh("下发错误,错误信息:"+e.Message); | |||
return "下发错误,错误信息:" + e.Message; | |||
} | |||
} | |||
private string GetTopic(int type,string deviceKey) | |||
@@ -22,6 +22,8 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos | |||
/// <returns></returns> | |||
Task<bool> Add(DevicePushRecodeDtoInput input); | |||
Task<bool> Update(string id); | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.Shop.Dtos | |||
{ | |||
public class StoreInfoQueryInputDto | |||
{ | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.Shop.Dtos | |||
{ | |||
public class StoreQueryDto | |||
{ | |||
public string Id { get; set; } | |||
public string Name { get; set; } | |||
} | |||
} |
@@ -1,8 +1,12 @@ | |||
using BPA.KitChen.StoreManagement.Application.Service.Shop.Dtos; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.Shop.Dtos; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.FoodMenu.Dtos; | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using BPA.Models.BPA_Kitchen; | |||
using Furion; | |||
using Furion.DatabaseAccessor; | |||
using Furion.DependencyInjection; | |||
using Furion.DynamicApiController; | |||
using Furion.FriendlyException; | |||
@@ -78,7 +82,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Shop | |||
{ | |||
throw Oops.Oh($"数据不存在"); | |||
} | |||
var data2= await SqlSugarDb.Db.Queryable<ShopEntity>().FirstAsync(x => x.Id != inputDto.Id&&x.Name==inputDto.Name); | |||
var data2= await SqlSugarDb.Db.Queryable<ShopEntity>().FirstAsync(x => x.Id != inputDto.Id&&x.Name==inputDto.Name); | |||
if (data2 != null) | |||
{ | |||
throw Oops.Oh($"名称存在"); | |||
@@ -102,5 +106,57 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Shop | |||
return res > 0; | |||
} | |||
/// <summary> | |||
/// 获取店铺列表 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/Store/GetStoreList")] | |||
public async Task<List<StoreQueryDto>> GetStoreList(StoreInfoQueryInputDto inputDto) | |||
{ | |||
return await SqlSugarDb.Db.Queryable<ShopEntity>().Where(x => x.IsDeleted == 0) | |||
.OrderBy(a => a.CreateAt, OrderByType.Desc) | |||
.Select(a => new StoreQueryDto | |||
{ | |||
Id = a.Id, | |||
Name = a.Name | |||
}) | |||
.ToListAsync(); | |||
} | |||
/// <summary> | |||
/// 获取店铺商品 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/Store/GetStoreGoods")] | |||
public async Task<PageUtil> GetStoreGoodsAsync(StoreGoodsQueryInputDto inputDto) | |||
{ | |||
var total = new RefAsync<int>(); | |||
var data = await SqlSugarDb.Db | |||
.Queryable<BPA_StoreFoodMenu>() | |||
.Where((s) => s.IsDeleted == 0 ) | |||
.Where((s) => s.StoreId == inputDto.StoreId) | |||
.WhereIF(!string.IsNullOrEmpty(inputDto.FoodMenuId), (s) => s.FoodMenuId == inputDto.FoodMenuId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.GoodsName), (s) => s.FoodName.Contains(inputDto.GoodsName)) | |||
.WhereIF(inputDto.IsDevice != null, (s) => s.IsDevice == inputDto.IsDevice) | |||
.WhereIF(inputDto.Status != null, (s) => s.Status == inputDto.Status) | |||
.WhereIF(inputDto.StopSales != null, (s) => s.StopSales == inputDto.StopSales) | |||
.OrderBy((s) => s.IsDevice, OrderByType.Asc) | |||
.Select((s) => new StoreGoodsBaseDto() | |||
{ | |||
Id = s.Id.SelectAll(), | |||
GoodsId = s.FoodId, | |||
Goods_Name = s.FoodName | |||
}) | |||
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | |||
return new PageUtil() | |||
{ | |||
Data = data, | |||
Total = total | |||
}; | |||
} | |||
} | |||
} |
@@ -0,0 +1,767 @@ | |||
using Furion; | |||
using Furion.DependencyInjection; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Kitchen.Core.Common; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Core.Entity; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Coupon; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos; | |||
using BPA.KitChen.StoreManagement.Core.Common; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class CouponHelperServices : SupperRepository, ICouponHelperServices, ITransient | |||
{ | |||
private readonly SqlSugarScope db; // 核心对象:拥有完整的SqlSugar全部功能 | |||
public CouponHelperServices() | |||
{ | |||
db = SqlSugarDb.Db; | |||
} | |||
#region 检查项 | |||
/// <summary> | |||
/// 检查是否领取过优惠券(判断是否新人) | |||
/// </summary> | |||
/// <param name="phone"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> IsGetCouponCheck(string memberId) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
var data = db.Queryable<BPA_CustomerCoupon, BPA_MemberInfo>((a, b) => new JoinQueryInfos( | |||
JoinType.Left, a.Customer_Id == b.Id)) | |||
.Where((a, b) => b.Id == memberId) | |||
.ToList(); | |||
if (data.Count > 0) | |||
{ | |||
result.IsSuccess = true; | |||
} | |||
else | |||
{ | |||
result.Msg = "当前用户领取过优惠券"; | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 检查优惠券是否可用 | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> IsUseCouponCheck(string couponId) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
var data = await db.Queryable<BPA_Coupon>() | |||
.Where(x => x.Id == couponId && x.IsDeleted == 0 && x.ValidStatus == 1 && x.ValidStatus == 1).ToListAsync(); | |||
if (data.Count > 0) | |||
{ | |||
result.IsSuccess = true; | |||
} | |||
else | |||
{ | |||
result.Msg = "当前优惠券不存在或不可用"; | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 检查优惠券用户是否可用 | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <param name="memberId"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> IsMemberUseCouponCheck(string couponId, string memberId) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
result = await IsUseCouponCheck(couponId); | |||
if (result.IsSuccess) | |||
{ | |||
var customerCoupon = db.Queryable<BPA_CustomerCoupon>() | |||
.Where(x => x.IsDeleted == 0 && x.State == 1 && x.Coupon_Id == couponId && x.Customer_Id == memberId && x.Valid_EndTime > DateTime.Now) | |||
.ToList(); | |||
if (customerCoupon.Count <= 0) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "当前用户的优惠券不存在或不可用"; | |||
} | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
///检查用户是否瞒足优惠券领取数量限制(是否还能在领取此券) | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <param name="memberId"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> IsSatisfyCouponGetLimitCheck(string couponId, string memberId) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
//1.查询优惠券 | |||
var coupon = db.Queryable<BPA_Coupon>().First(x => x.Id == couponId); | |||
if (coupon.GetLimit == 0) | |||
{ | |||
result.IsSuccess = true; | |||
} | |||
else | |||
{ | |||
//2.查询优惠券用户领取记录 | |||
var customerCoupons = await db.Queryable<BPA_CustomerCoupon>().Where(x => x.Coupon_Id == couponId && x.Customer_Id == memberId).ToListAsync(); | |||
//判断领取记录是否满足优惠券领取限制 | |||
if (customerCoupons.Count < coupon.GetLimit) | |||
{ | |||
result.IsSuccess = true; | |||
} | |||
else | |||
{ | |||
result.Msg = "已达到优惠券最大领取数量"; | |||
} | |||
} | |||
return result; | |||
} | |||
#endregion | |||
/// <summary>s | |||
/// (导入)验证会员优惠券领取限制 | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <param name="listCustomer"></param> | |||
/// <returns></returns> | |||
public async Task<MemberInfoOutDto> CouponGetLimitCheck(string couponId, List<MemberInfoDto> memberInfoDtos) | |||
{ | |||
var notAvailable = new List<MemberInfoDto>(); | |||
var available = new List<MemberInfoDto>(); | |||
var result = await IsUseCouponCheck(couponId); | |||
if (!result.IsSuccess) | |||
{ | |||
foreach (var item in memberInfoDtos) | |||
{ | |||
notAvailable.Add(new MemberInfoDto() | |||
{ | |||
MemberId = item.MemberId, | |||
Phone = item.Phone, | |||
Msg = result.Msg | |||
}); | |||
} | |||
} | |||
else | |||
{ | |||
//1.查询生效的优惠券信息 | |||
var couponInfo = await db.Queryable<BPA_Coupon>().Where(x => x.Id == couponId && x.ValidStatus == 1).FirstAsync(); | |||
//2.查询会员领取的优惠券 | |||
var customerCoupon = db.Queryable<BPA_CustomerCoupon>() | |||
.Where(x => x.Coupon_Id == couponId && memberInfoDtos.Select(y => y.MemberId).Contains(x.Customer_Id)) | |||
.ToList(); | |||
//3.筛选出没有领取过优惠券的会员 | |||
available = memberInfoDtos.Where(x => !customerCoupon.Select(y => y.Customer_Id).Contains(x.MemberId)).ToList(); | |||
//4.赛选满足条件的会员 | |||
foreach (var item in customerCoupon.GroupBy(x => x.Customer_Id)) | |||
{ | |||
var phone = memberInfoDtos.FirstOrDefault(x => x.MemberId == item.First().Customer_Id).Phone; | |||
//领取数量限制 | |||
if (item.Count() <= couponInfo.GetLimit) | |||
{ | |||
//优惠券是否过期 | |||
if (couponInfo.TimeType == 1 && couponInfo.ValidEndTime < DateTime.Now) | |||
{ | |||
notAvailable.Add(new MemberInfoDto() | |||
{ | |||
MemberId = item.First().Customer_Id, | |||
Phone = phone, | |||
Msg = "优惠券已过期" | |||
}); | |||
} | |||
else | |||
{ | |||
available.Add(new MemberInfoDto() | |||
{ | |||
MemberId = item.First().Customer_Id, | |||
Phone = phone, | |||
}); | |||
} | |||
} | |||
else | |||
{ | |||
notAvailable.Add(new MemberInfoDto() | |||
{ | |||
MemberId = item.First().Customer_Id, | |||
Phone = phone, | |||
Msg = "会员超出领卷数量限制" | |||
}); ; | |||
} | |||
} | |||
} | |||
return new MemberInfoOutDto() | |||
{ | |||
Available = available, | |||
NotAvailable = notAvailable | |||
}; | |||
} | |||
/// <summary> | |||
/// 获取所有可用优惠券(附加剩余数量和使用限制) | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<List<CouponCanUseCountAndLimitOutDto>> GetCouponCanUseCountAndLimit(string couponId = null) | |||
{ | |||
var result = new List<CouponCanUseCountAndLimitOutDto>(); | |||
// 查询出可以可以使用的优惠券 | |||
var couponList = await db.Queryable<BPA_Coupon>().Where(x => x.IsDeleted == 0 && x.ValidStatus == 1) | |||
.WhereIF(!string.IsNullOrWhiteSpace(couponId), x => x.Id == couponId) | |||
.ToListAsync(); | |||
var couponListData = new List<BPA_Coupon>(); | |||
//去掉过期优惠券 | |||
foreach (var item in couponList) | |||
{ | |||
if (item.TimeType == 1 && item.ValidEndTime <= DateTime.Now) | |||
{ | |||
couponListData.Add(item); | |||
} | |||
} | |||
couponList = couponList.Where(x => !couponListData.Contains(x)).ToList(); | |||
var couponIds = couponList.Select(x => x.Id).ToList(); | |||
////查询出优惠券下的所有批次 | |||
var batchNoList = await db.Queryable<BPA_CouponRange>().Where(x => couponIds.Contains(x.Coupon_Id)).ToListAsync(); | |||
//查询所有领取过得优惠券 | |||
var GetCouponList = await db.Queryable<BPA_CustomerCoupon>().Where(x => couponIds.Contains(x.Coupon_Id)).ToListAsync(); | |||
foreach (var item in couponList) | |||
{ | |||
var list = new List<BatchInfo>(); | |||
//所有发送批次 | |||
var couponRange = batchNoList.Where(x => x.Coupon_Id == item.Id).ToList(); | |||
foreach (var entity in couponRange) | |||
{ | |||
//此批的领取情况 | |||
var GetCount = GetCouponList.Where(x => x.Coupon_Id == item.Id && x.Coupon_Range_Id == entity.Id).ToList(); | |||
list.Add(new BatchInfo() | |||
{ | |||
Id = entity.Id, | |||
BatchNo = entity.BatchNo, | |||
SendNum = entity.SendNum, | |||
GetNum = GetCount.Count | |||
}); | |||
} | |||
result.Add(new CouponCanUseCountAndLimitOutDto() | |||
{ | |||
CouponId = item.Id, | |||
CouponName = item.CouponTitle, | |||
Limit = item.GetLimit == 0 ? list.Sum(x => x.SendNum) : item.GetLimit, | |||
CanUseCount = list.Sum(x => x.SendNum) - list.Sum(x => x.GetNum), | |||
BatchInfo = list | |||
}); | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 发送优惠券(同时记录发送记录) | |||
/// </summary> | |||
/// <param name="couponId">优惠券</param> | |||
/// <param name="couponRangeId">批次信息</param> | |||
/// <param name="memberId">会员</param> | |||
/// <param name="type">类型</param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> SendCoupon(string couponId, string couponRangeId, int sendCount, string memberId, E_CouponGitType type, SqlSugarScope sqlSugarClient = null) | |||
{ | |||
if (sqlSugarClient == null) | |||
{ | |||
sqlSugarClient = db; | |||
} | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
var coupon = new BPA_Coupon(); | |||
//查询会员 | |||
var member = sqlSugarClient.Queryable<BPA_MemberInfo>().Where(x => x.IsDeleted == 0 && x.Status == 0 && x.Id == memberId).ToList().FirstOrDefault(); | |||
if (member != null) | |||
{ | |||
//2.检查优惠券 | |||
result = await IsUseCouponCheck(couponId); | |||
if (result.IsSuccess) | |||
{ | |||
//查询优惠券 | |||
coupon = db.Queryable<BPA_Coupon>().First(x => x.Id == couponId); | |||
//3.检查用户是是否满足优惠券领取数量限制 | |||
result = await IsSatisfyCouponGetLimitCheck(couponId, memberId); | |||
if (result.IsSuccess) | |||
{ | |||
var list = new List<BPA_CustomerCoupon>(); | |||
//发券 | |||
for (int i = 0; i < sendCount; i++) | |||
{ | |||
var temp = new BPA_CustomerCoupon | |||
{ | |||
Customer_Id = memberId, | |||
Coupon_Id = couponId, | |||
Receive_Type = (int)type, | |||
Coupon_Range_Id = couponRangeId, | |||
State = 1, | |||
CustomerPhone = member.Phone, | |||
Valid_StartTime = coupon.TimeType == 1 ? coupon.ValidStartTime : DateTime.Now, | |||
Valid_EndTime = coupon.TimeType == 1 ? coupon.ValidEndTime : DateTime.Now.AddDays(coupon.ValidFixedTerm), | |||
IsDeleted = 0, | |||
}; | |||
list.Add(temp); | |||
} | |||
result.IsSuccess = db.Insertable(list).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0; ; | |||
if (!result.IsSuccess) | |||
{ | |||
result.Msg = "修改失败"; | |||
} | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
result.Msg = "会员被停用或不存在此会员"; | |||
} | |||
return result; | |||
} | |||
#region 对外 | |||
/// <summary> | |||
/// 获取优惠券使用范围 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> GetCouponUseScope(string customerCouponId) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = true }; | |||
var couponUseScope = new CouponUseScopeOutDto() { }; | |||
var customerCoupon = await db.Queryable<BPA_CustomerCoupon>().Where(x => x.Id == customerCouponId).FirstAsync(); | |||
if (customerCoupon == null) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "用户没有此优惠券"; | |||
} | |||
else if (customerCoupon.State != 1) | |||
{ | |||
couponUseScope.CouponId = customerCoupon.Coupon_Id; | |||
result.IsSuccess = false; | |||
result.Msg = $"优惠券不可以用:{(customerCoupon.State == 2 ? "已核销" : (customerCoupon.State == 3 ? "被占用" : "失效"))}"; | |||
} | |||
else | |||
{ | |||
couponUseScope.CouponId = customerCoupon.Coupon_Id; | |||
var coupon = await db.Queryable<BPA_Coupon>().Where(x => x.Id == customerCoupon.Coupon_Id && x.IsDeleted == 0).FirstAsync(); | |||
if (coupon == null) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "优惠券不存在"; | |||
} | |||
else if (coupon.ValidStatus != 1) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "优惠券被作废或者停用"; | |||
} | |||
else | |||
{ | |||
//批次信息 | |||
var couponRange = await db.Queryable<BPA_CouponRange>().Where(x => x.Id == customerCoupon.Coupon_Range_Id && x.IsDeleted == 0).FirstAsync(); | |||
if (couponRange == null) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "当前批次信息不可用"; | |||
} | |||
//适用店铺 | |||
var storeList = new List<UseScopeListOutDto>(); | |||
var couponRangeRelations = await db.Queryable<BPA_CouponRangeRelations>().Where(x => x.Coupon_Range_Id == couponRange.Id && x.IsDeleted == 0 && x.Status == CommonStatus.ENABLE).ToListAsync(); | |||
if (couponRangeRelations.Count > 0) | |||
{ | |||
var ids = couponRangeRelations.Select(x => x.RangeTypeId).ToList(); | |||
if (couponRange.RangeType == 1) | |||
{ | |||
foreach (var item in couponRangeRelations) | |||
{ | |||
storeList.Add(new UseScopeListOutDto() | |||
{ | |||
Id = item.RangeTypeId | |||
}); | |||
} | |||
} | |||
} | |||
//适用商品 | |||
var goodsList = new List<UseScopeListOutDto>(); | |||
var couponGoodsRelations = await db.Queryable<BPA_CouponGoodsRelations>().Where(x => x.Coupon_Range_Id == couponRange.Id && x.IsDeleted == 0 && x.Status == CommonStatus.ENABLE).ToListAsync(); | |||
if (couponGoodsRelations.Count > 0) | |||
{ | |||
foreach (var item in couponGoodsRelations) | |||
{ | |||
goodsList.Add(new UseScopeListOutDto() | |||
{ | |||
Id = item.GoodsId | |||
}); | |||
} | |||
} | |||
couponUseScope.StoreList = storeList; | |||
couponUseScope.GoodsList = goodsList; | |||
result.Data = couponUseScope; | |||
} | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 查看领取的优惠券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil> WacthCoupon(CustomerCouponPageDto input) | |||
{ | |||
var total = new RefAsync<int>(); | |||
var data = await db.Queryable<BPA_CustomerCoupon, BPA_Coupon>((t, x) => t.Coupon_Id == x.Id) | |||
.Where(t => t.IsDeleted == 0) | |||
.Where(t => t.State == input.State) | |||
//.Where((t, x) => x.ValidStatus == input.State) | |||
.Where(t => t.Valid_EndTime >= DateTime.Now) | |||
.Where(t => t.CustomerPhone == input.CustomerPhone || t.Customer_Id == input.CustomerId) | |||
.Select((t, x) => new CustomerCouponOutputDto | |||
{ | |||
CustomerId = t.Customer_Id, | |||
CouponTitle = x.CouponTitle, | |||
CouponId = t.Coupon_Id, | |||
Id = t.Id, | |||
State = t.State, | |||
CouponRangeId = t.Coupon_Range_Id, | |||
OrderId = t.Order_Id, | |||
ReceiveType = t.Receive_Type, | |||
ValidStartTime = t.Valid_StartTime, | |||
ValidEndTime = t.Valid_EndTime, | |||
CouponValue = x.CouponValue, | |||
Condition = x.Condition | |||
}).ToPageListAsync(input.Current, input.PageSize, total); | |||
return new PageUtil | |||
{ | |||
Data = data, | |||
Total = total | |||
}; | |||
} | |||
/// <summary> | |||
/// 获取能使用的优惠券 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> GetCanUseCouponByWeChat(WeChatCanUseCouponQueryInputDto inputDto) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = true }; | |||
//1.查询会员 | |||
var member = db.Queryable<BPA_PlatformMemberInfo>().Where(x => x.PlatformMemberId == inputDto.OpenId).ToList().FirstOrDefault(); | |||
if (member == null) | |||
{ | |||
result.Msg = "会员不存在"; | |||
return result; | |||
} | |||
var StoreGoodss = db.Queryable<ShopEntity>().Where(x => inputDto.StoreGoodsIds.Contains(x.Id)).ToList(); | |||
//店铺 | |||
var storeIds = StoreGoodss.Select(x => x.Id).ToList(); | |||
//商品 | |||
var GoodsIds = db.Queryable<BPA_FoodMenu, BPA_StoreFoodMenu>((a, b) => | |||
new JoinQueryInfos(JoinType.Left, a.Id == b.FoodMenuId)) | |||
.Where((a, b) => storeIds.Contains(b.StoreId)) | |||
.Select((a, b) => a.GoodsId).ToList(); | |||
//2.查询当前会员的所有库用优惠券 | |||
var customerCoupon = db.Queryable<BPA_CustomerCoupon>() | |||
.Where(x => x.Customer_Id == member.MemberInfo_Id && x.IsDeleted == 0 && x.State == 1 && x.Valid_EndTime > DateTime.Now) | |||
.ToList(); | |||
var couponRangeId = customerCoupon.Select(x => x.Coupon_Range_Id).ToList(); | |||
//店铺判定 | |||
var batchScopeLimit = db.Queryable<BPA_CouponRangeRelations, BPA_CouponRange>((a, b) => new JoinQueryInfos(JoinType.Left, a.Coupon_Range_Id == b.Id)) | |||
.Where((a, b) => couponRangeId.Contains(a.Coupon_Range_Id)) | |||
.Select((a, b) => new BatchScopeLimitDto() | |||
{ | |||
Coupon_Id = b.Coupon_Id, | |||
Coupon_Range_Id = a.Coupon_Range_Id, | |||
RangeType = b.RangeType, | |||
StoreId = b.RangeType == 1 ? a.RangeTypeId : "", | |||
}) | |||
.ToList(); | |||
var rangeId = new List<string>(); | |||
foreach (var item in batchScopeLimit) | |||
{ | |||
var coupon_Range_Id = ""; | |||
if (item.RangeType == 1 && storeIds.Contains(item.StoreId)) | |||
{ | |||
coupon_Range_Id = item.Coupon_Range_Id; | |||
} | |||
//商品判定 | |||
var goodsrange = db.Queryable<BPA_CouponGoodsRelations>() | |||
.Where(x => x.Coupon_Range_Id == item.Coupon_Range_Id) | |||
.ToList(); | |||
if (goodsrange.Count > 0) | |||
{ | |||
if (goodsrange.Where(x => GoodsIds.Contains(x.GoodsId)).Select(x => x.Coupon_Range_Id).ToList().Count <= 0) | |||
{ | |||
coupon_Range_Id = ""; | |||
} | |||
} | |||
if (!string.IsNullOrWhiteSpace(coupon_Range_Id)) | |||
{ | |||
rangeId.Add(coupon_Range_Id); | |||
} | |||
} | |||
var date = db.Queryable<BPA_CustomerCoupon, BPA_Coupon>((a, b) => new JoinQueryInfos(JoinType.Left, a.Coupon_Id == b.Id)) | |||
.Where((a, b) => rangeId.Contains(a.Coupon_Range_Id) && b.Condition <= inputDto.totalPrice) | |||
.Where((a, b) => a.IsDeleted == 0 && a.State == 1 && a.Valid_EndTime > DateTime.Now && b.IsDeleted == 0 && b.ValidStatus == 1) | |||
.Where((a, b) => a.Customer_Id == member.MemberInfo_Id) | |||
.Select((a, b) => new CustomerCouponOutputDto | |||
{ | |||
Id = a.Id.SelectAll(), | |||
Condition = b.Condition, | |||
CouponTitle = b.CouponTitle, | |||
CouponValue = b.CouponValue, | |||
Remark = b.Remarks, | |||
}).ToList(); | |||
result.Data = date; | |||
if (date.Count <= 0) | |||
{ | |||
result.IsSuccess = false; | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 扫码领券 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> ScanCodeGetCoupon(ScanCodeGetCouponInputDto inputDto) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
var member = await db.Queryable<BPA_MemberInfo>().FirstAsync(x => x.Id == inputDto.MemberId); | |||
if (member == null) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "会员不存在"; | |||
return result; | |||
} | |||
//查询优惠券可用批次 | |||
var couponRanges = db.Queryable<BPA_CouponRange>().Where(x => x.IsDeleted == 0 && x.Coupon_Id == inputDto.CouponId).ToList(); | |||
if (couponRanges.Count > 0) | |||
{ | |||
var groupId = couponRanges.First().GroupId; | |||
if (groupId != member.GroupId) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "供应商错误"; | |||
return result; | |||
} | |||
} | |||
//查询优惠券的使用情况 | |||
var customerCoupons = db.Queryable<BPA_CustomerCoupon>() | |||
.Where(x => couponRanges.Select(y => y.Coupon_Id).Contains(x.Coupon_Id)) | |||
.GroupBy(x => x.Coupon_Id) | |||
.Select(x => new { Count = SqlFunc.AggregateCount(x.Coupon_Id), Coupon_Id = x.Coupon_Id }).ToList(); | |||
var data = (from a in couponRanges | |||
join b in customerCoupons on a.Coupon_Id equals b.Coupon_Id into ab | |||
from abinfo in ab.DefaultIfEmpty() | |||
where a.SendNum > (abinfo?.Count ?? 0) | |||
select a).ToList(); | |||
if (data.Count <= 0) | |||
{ | |||
result.IsSuccess = false; | |||
result.Msg = "没有可用批次"; | |||
return result; | |||
} | |||
result.IsSuccess = await App.GetService<ICouponServices>().ReceiveCouponByInput(new CustomerCouponInputDto() | |||
{ | |||
CouponId = inputDto.CouponId, | |||
MemberId = new List<string>() { inputDto.MemberId }, | |||
CouponRangeId = data.First().Id, | |||
CouponGitType = E_CouponGitType.线下门店扫码 | |||
}); | |||
return result; | |||
} | |||
#endregion | |||
#region 优惠券核销 | |||
/// <summary> | |||
/// 优惠券核销 | |||
/// </summary> | |||
/// <param name="customerCouponId"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> CouponWriteoff(CouponWriteoffInputDto inputDto) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = false }; | |||
if (string.IsNullOrWhiteSpace(CurrentUser.TenantId)) | |||
{ | |||
result.Msg = "加盟商不能为空"; | |||
return result; | |||
} | |||
try | |||
{ | |||
db.Ado.BeginTran(); | |||
if (inputDto.Type == 1)//第三方优惠券 | |||
{ | |||
foreach (var item in inputDto.CouponId) | |||
{ | |||
var paperCoupon = await db.Queryable<BPA_PaperCoupon>().FirstAsync(x => x.Id == item); | |||
if (paperCoupon == null) | |||
{ | |||
result.Msg = "优惠券不存在"; | |||
return result; | |||
} | |||
var res = await db.Insertable(new BPA_PaperCouponWriteoffLog() | |||
{ | |||
CreateAt = DateTime.Now, | |||
GroupId = CurrentUser.TenantId, | |||
OrderId = inputDto.OrderId, | |||
PaperCouponId = item, | |||
}).ExecuteCommandAsync(); | |||
result.IsSuccess = res > 0; | |||
if (!result.IsSuccess) | |||
{ | |||
throw new Exception("优惠券核销错误"); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
foreach (var item in inputDto.CouponId) | |||
{ | |||
var goodsoupon = await db.Queryable<BPA_GoodsCoupon>().FirstAsync(x => x.Id == item); | |||
if (goodsoupon == null) | |||
{ | |||
result.Msg = "优惠券不存在"; | |||
return result; | |||
} | |||
var res = await db.Insertable(new BPA_GoodsCouponWriteoffLog() | |||
{ | |||
CreateAt = DateTime.Now, | |||
GroupId = CurrentUser.TenantId, | |||
OrderId = inputDto.OrderId, | |||
GoodsCouponId = item, | |||
}).ExecuteCommandAsync(); | |||
result.IsSuccess = res > 0; | |||
if (!result.IsSuccess) | |||
{ | |||
throw new Exception("抵扣券核销错误"); | |||
} | |||
} | |||
} | |||
db.Ado.CommitTran(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.Ado.RollbackTran(); | |||
result.Msg=ex.ToString(); | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
///获取 优惠群核销记录 | |||
/// </summary> | |||
/// <param name="orderId"></param> | |||
/// <returns></returns> | |||
public async Task<ResultEntity> GetPOSCouponWriteoffRecord(string orderId) | |||
{ | |||
var result = new ResultEntity() { IsSuccess = true }; | |||
var data = new POSCouponWriteoffRecordOutDto(); | |||
data.GoodsCouponWriteoffLogs = await db.Queryable<BPA_GoodsCouponWriteoffLog>().Where(x => x.OrderId == orderId).ToListAsync(); | |||
data.PaperCouponWriteoffLogs = await db.Queryable<BPA_PaperCouponWriteoffLog>().Where(x => x.OrderId == orderId).ToListAsync(); | |||
result.Data = data; | |||
return result; | |||
} | |||
public Task<ResultEntity> SendCoupon(string couponId, string couponRangeId, int sendCount, string memberId, E_CouponGitType type, SqlSugarClient sqlSugarClient = null) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
#endregion | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class BatchScopeLimitDto | |||
{ | |||
public string Coupon_Id { get; set; } | |||
public string Coupon_Range_Id { get; set; } | |||
public int RangeType { get; set; } | |||
public string StoreId { get; set; } | |||
public string StoreTypeId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
internal class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,53 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class CouponCanUseCountAndLimitOutDto | |||
{ | |||
/// <summary> | |||
/// 优惠券id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
public string CouponName { get; set; } | |||
/// <summary> | |||
/// 能使数量 | |||
/// </summary> | |||
public int CanUseCount { get; set; } | |||
/// <summary> | |||
/// 领取限制 0无限制 | |||
/// </summary> | |||
public int Limit { get; set; } | |||
public List<BatchInfo> BatchInfo { get; set; } | |||
} | |||
public class BatchInfo | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 批次号 | |||
/// </summary> | |||
public string BatchNo { get; set; } | |||
/// <summary> | |||
/// 发送数量 | |||
/// </summary> | |||
public int SendNum { get; set; } | |||
/// <summary> | |||
/// 领取数量 | |||
/// </summary> | |||
public int GetNum { get; set; } | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class CouponUseScopeOutDto | |||
{ | |||
public string CouponId { get; set; } | |||
public List<UseScopeListOutDto> StoreList { get; set; } | |||
public List<UseScopeListOutDto> GoodsList { get; set; } | |||
} | |||
public class UseScopeListOutDto | |||
{ | |||
public string Id { get; set; } | |||
public string Name { get; set; } | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class CouponWriteoffInputDto | |||
{ | |||
/// <summary> | |||
/// 订单ID | |||
/// </summary> | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 优惠券ID | |||
/// </summary> | |||
public List<string> CouponId { get; set; } | |||
// 1 第三方抵扣券 2 商品抵扣券 | |||
public int Type { get; set; } | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using BPA.KitChen.StoreManagement.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.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class GetCouponInputDto : PageInputBase | |||
{ | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class MemberInfoDto | |||
{ | |||
[DisplayName("手机号")] | |||
public string Phone { get; set; } | |||
public string MemberId { get; set; } | |||
public string Msg { get; set; } | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class MemberInfoOutDto | |||
{ | |||
/// <summary> | |||
/// 不可用 | |||
/// </summary> | |||
public List<MemberInfoDto> NotAvailable { get; set; } | |||
//可用 | |||
public List<MemberInfoDto> Available { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Coupon; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class POSCouponWriteoffRecordOutDto | |||
{ | |||
public List<BPA_PaperCouponWriteoffLog> PaperCouponWriteoffLogs { get; set; } | |||
public List<BPA_GoodsCouponWriteoffLog> GoodsCouponWriteoffLogs { get; set; } | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class ScanCodeGetCouponInputDto | |||
{ | |||
public string CouponId { get; set; } | |||
public string MemberId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public class WeChatCanUseCouponQueryInputDto | |||
{ | |||
public List<string> StoreGoodsIds { get; set; } | |||
public string OpenId { get; set; } | |||
public decimal totalPrice { get; set; } | |||
} | |||
} |
@@ -0,0 +1,118 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponHelperServices.Dtos | |||
{ | |||
public interface ICouponHelperServices | |||
{ | |||
#region 检查项 | |||
/// <summary> | |||
/// 检查是否领取过优惠券 | |||
/// </summary> | |||
/// <param name="phone"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> IsGetCouponCheck(string memberId); | |||
/// <summary> | |||
/// 检查优惠券是否可用 | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> IsUseCouponCheck(string couponId); | |||
/// <summary> | |||
/// 检查优惠券用户是否可用 | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <param name="memberId"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> IsMemberUseCouponCheck(string couponId, string memberId); | |||
/// <summary> | |||
///检查用户是否瞒足优惠券领取数量限制(是否还能在领取此券) | |||
/// </summary> | |||
/// <param name="couponId"></param> | |||
/// <param name="memberId"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> IsSatisfyCouponGetLimitCheck(string couponId, string memberId); | |||
#endregion | |||
/// <summary> | |||
///(导入)验证会员优惠券领取限制 | |||
/// </summary> | |||
/// <param name="CouponId"></param> | |||
/// <param name="listCustomer"></param> | |||
/// <returns></returns> | |||
Task<MemberInfoOutDto> CouponGetLimitCheck(string CouponId, List<MemberInfoDto> memberInfoDtos); | |||
/// <summary> | |||
/// 获取所有可用优惠券(附加剩余数量和使用限制) | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<List<CouponCanUseCountAndLimitOutDto>> GetCouponCanUseCountAndLimit(string couponId = null); | |||
/// <summary> | |||
/// 发送优惠券(同时记录发送记录) | |||
/// </summary> | |||
/// <param name="couponId">优惠券</param> | |||
/// <param name="couponRangeId">批次信息</param> | |||
/// <param name="memberId">会员</param> | |||
/// <param name="type">类型</param> | |||
/// <returns></returns> | |||
Task<ResultEntity> SendCoupon(string couponId, string couponRangeId, int sendCount, string memberId, E_CouponGitType type, SqlSugarScope sqlSugarClient = null); | |||
#region 对外 | |||
/// <summary> | |||
/// 获取优惠券使用范围 | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<ResultEntity> GetCouponUseScope(string customerCouponId); | |||
/// <summary> | |||
/// 获取能使用的优惠券 | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<ResultEntity> GetCanUseCouponByWeChat(WeChatCanUseCouponQueryInputDto inputDto); | |||
/// <summary> | |||
/// 扫码领券 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> ScanCodeGetCoupon(ScanCodeGetCouponInputDto inputDto); | |||
#endregion | |||
#region 优惠券核销 | |||
/// <summary> | |||
/// 优惠券核销 | |||
/// </summary> | |||
/// <param name="customerCouponId"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> CouponWriteoff(CouponWriteoffInputDto inputDto); | |||
/// <summary> | |||
///获取 优惠群核销记录 | |||
/// </summary> | |||
/// <param name="orderId"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> GetPOSCouponWriteoffRecord(string orderId); | |||
#endregion | |||
} | |||
} |
@@ -0,0 +1,337 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos.member; | |||
using Furion.DependencyInjection; | |||
using Furion.DynamicApiController; | |||
using Furion.RemoteRequest; | |||
using Microsoft.AspNetCore.Authorization; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using Microsoft.AspNetCore.Mvc; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon | |||
{ | |||
/// <summary> | |||
/// 优惠卷 | |||
/// </summary> | |||
[ApiDescriptionSettings("优惠券", Tag = "优惠卷管理", SplitCamelCase = false)] | |||
public class CouponService : IDynamicApiController, ITransient | |||
{ | |||
readonly ICouponServices _couponServices; | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="couponServices"></param> | |||
public CouponService(ICouponServices couponServices) | |||
{ | |||
_couponServices = couponServices; | |||
} | |||
/// <summary> | |||
/// 获取商品类型 | |||
/// </summary> | |||
/// <returns></returns> | |||
[Get("/api/coupon/goodstype")] | |||
public async Task<Dictionary<string, string>> GetGoodsType() | |||
{ | |||
return await _couponServices.GetGoodsType(); | |||
} | |||
/// <summary> | |||
/// 获取商品 | |||
/// </summary> | |||
/// <param name="GoodsTypeId"></param> | |||
/// <returns></returns> | |||
[Get("/api/coupon/goods")] | |||
public async Task<Dictionary<string, string>> GetGoods(string GoodsTypeId) | |||
{ | |||
return await _couponServices.GetGoods(GoodsTypeId); | |||
} | |||
/// <summary> | |||
/// 获取会员信息 | |||
/// </summary> | |||
/// <param name="Phone"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/coupon/GetCustomerInfo")] | |||
public async Task<List<MemberInfoOutputDto>> GetCustomerInfo(CustomerInfoInputDto input) | |||
{ | |||
return await _couponServices.GetCustomerInfo(input); | |||
} | |||
/// <summary> | |||
/// 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<PageUtil> CouponPgage([FromBody] PageCouponInputDto inputDto) | |||
{ | |||
return await _couponServices.GetCouponPgageAsync(inputDto); | |||
} | |||
/// <summary> | |||
/// 获取优惠卷状态和类型 1.优惠卷状态 2.优惠卷类型 | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/coupon/getCouponStatusOrType")] | |||
public async Task<List<StatusOrTypeOutDto>> GetCouponStatusOrTypeAsync(int type) | |||
{ | |||
return await _couponServices.GetCouponStatusOrTypeAsync(type); | |||
} | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/coupon/addCoupon")] | |||
public async Task<bool> AddCoupon(CouponBasetDto inputDto) | |||
{ | |||
return await _couponServices.AddCoupon(inputDto); | |||
} | |||
/// <summary> | |||
/// 删除优惠卷 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/coupon/deleteCoupon")] | |||
public async Task<bool> DeleteCoupon(List<string> Ids) | |||
{ | |||
return await _couponServices.DeleteCoupon(Ids); | |||
} | |||
/// <summary> | |||
/// 修改优惠券状态 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdateCouponStatus(CouponBasetDto inputDto) | |||
{ | |||
return await _couponServices.UpdateCouponStatus(inputDto); | |||
} | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/coupon/updateCoupon")] | |||
public async Task<bool> UpdateCoupon(CouponBasetDto inputDto) | |||
{ | |||
return await _couponServices.UpdateCoupon(inputDto); | |||
} | |||
/// <summary> | |||
/// 作废优惠卷 | |||
/// </summary> | |||
/// <param name="Id"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/coupon/abolishcoupon")] | |||
public async Task<bool> AbolishCoupon(string Id) | |||
{ | |||
return await _couponServices.AbolishCoupon(Id); | |||
} | |||
#region 优惠券领取 | |||
/// <summary> | |||
/// 指定客户领取 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPut, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<bool> ReceiveCouponByInput(CustomerCouponInputDto input) | |||
{ | |||
return await _couponServices.ReceiveCouponByInput(input); | |||
} | |||
/// <summary> | |||
/// 领券分页查看SAAS用 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<PageUtil> GetCustomerPage(CustomerCouponPageExDto input) | |||
{ | |||
return await _couponServices.GetCustomerPage(input); | |||
} | |||
/// <summary> | |||
/// 失效顾客优惠券 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpDelete, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<bool> AbolishCustomerCoupon(string Id) | |||
{ | |||
return await _couponServices.AbolishCustomerCoupon(Id); | |||
} | |||
#endregion | |||
#region 对小程序暴露接口 | |||
/// <summary> | |||
/// 领券(支持批量领取) | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPut, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<bool> ReceiveCoupon([FromBody] List<CustomerCouponDto> input) | |||
{ | |||
return await _couponServices.ReceiveCoupon(input); | |||
} | |||
/// <summary> | |||
/// 退单退券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<ResultEntity> RebackCoupon([FromBody] RebackDto input) | |||
{ | |||
return await _couponServices.RebackCoupon(input.Id); | |||
} | |||
/// <summary> | |||
/// 优惠券的使用 | |||
/// </summary> | |||
/// <returns>false券无效或者失效或有错误</returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<CouponUseMsgDto> CustomerCouponOff([FromBody] CustomerCouponBaseDto input) | |||
{ | |||
return await _couponServices.CustomerCouponOff(input); | |||
} | |||
/// <summary> | |||
/// 查看领取的优惠券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<PageUtil> WacthCoupon([FromBody] CustomerCouponPageDto input) | |||
{ | |||
return await _couponServices.WacthCoupon(input); | |||
} | |||
/// <summary> | |||
/// 回调写入优惠券状态f | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<bool> UpdateState(UpdateStateDto input) | |||
{ | |||
return await _couponServices.UpdateState(input.OdrerId, input.State); | |||
} | |||
/// <summary> | |||
/// 客户查询领券的详情 | |||
/// </summary> | |||
/// <param name="Id"></param> | |||
/// <returns></returns> | |||
[HttpGet, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<CustomerCouponOutputDto> CustomerCouponDetail(string Id) | |||
{ | |||
return await _couponServices.CustomerCouponDetail(Id); | |||
} | |||
/// <summary> | |||
/// 查询流水日志 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpGet, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<List<CouponLogOutputDto>> GetCouponLog(string CouponCustomerId) | |||
{ | |||
return await _couponServices.GetCouponLog(CouponCustomerId); | |||
} | |||
/// <summary> | |||
/// 查询可用券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<List<CustomerCouponOutputDto>> SelectCanUseCoupon(CustomerCouponCanUseDto input) | |||
{ | |||
return await _couponServices.SelectCanUseCoupon(input); | |||
} | |||
/// <summary> | |||
/// 根据订单号获取用户的优惠券使用状态 | |||
/// </summary> | |||
/// <param name="OrderId"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify] | |||
public async Task<List<CusomterCouponDTO>> GetCouponStutasByOrderId(List<string> OrderId) | |||
=> await _couponServices.GetCouponStutasByOrderId(OrderId); | |||
#endregion | |||
#region 优惠券记录 | |||
/// <summary> | |||
/// 获取发券的管理记录 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<PageUtil> GetCouponRecordById([FromBody] CouponRecordPageDto input) | |||
{ | |||
return await _couponServices.GetCouponRecordById(input); | |||
} | |||
/// <summary> | |||
/// 记录汇总 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, AllowAnonymous, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<PageUtil> GetCouponRecordPage(CouponRecordPageDto input) | |||
{ | |||
return await _couponServices.GetCouponRecordPage(input); | |||
} | |||
/// <summary> | |||
/// 新增发券记录 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPut, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<bool> AddCouponSendRecord([FromBody] CouponRecordDto input) | |||
{ | |||
return await _couponServices.AddCouponSendRecord(input); | |||
} | |||
/// <summary> | |||
/// 召回优惠券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<bool> RecallCoupon(CouponRecordDto input) | |||
{ | |||
return await _couponServices.RecallCoupon(input); | |||
} | |||
/// <summary> | |||
/// 召回禁用优惠卷商品 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<bool> RecallCouponGoods(CouponRecordDto input) | |||
{ | |||
return await _couponServices.RecallCouponGoods(input); | |||
} | |||
/// <summary> | |||
/// 获取发券的管理记录商品 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost, ApiDescriptionSettings(SplitCamelCase = false)] | |||
public async Task<PageUtil> GetCouponRecordGoods(CouponRecordPageDto input) | |||
{ | |||
return await _couponServices.GetCouponRecordGoods(input); | |||
} | |||
#endregion | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.FoodMenu.Dtos; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class BaseResultGoodsTypeDto | |||
{ | |||
public int statusCode { get; set; } | |||
public List<GoodsTypeDataItem> data { get; set; } | |||
public string succeeded { get; set; } | |||
public string errors { get; set; } | |||
public string extras { get; set; } | |||
public int timestamp { get; set; } | |||
} | |||
public class GoodsTypeDataItem | |||
{ | |||
public int type { get; set; } | |||
public string key { get; set; } | |||
public string parentId { get; set; } | |||
public string title { get; set; } | |||
public string value { get; set; } | |||
public int weight { get; set; } | |||
public List<GoodsTypeDataItem> children { get; set; } | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
internal class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,106 @@ | |||
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.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
/// <summary> | |||
/// 优惠卷基础信息 | |||
/// </summary> | |||
public class CouponBasetDto | |||
{ | |||
/// <summary> | |||
/// Id | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 优惠券标题 | |||
/// </summary> | |||
[Required] | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 优惠券类型(1.满减优惠卷 2.代金优惠卷 3.无门槛优惠卷) | |||
/// </summary> | |||
[Range(1, 3, ErrorMessage = "优惠卷类型错误")] | |||
public int CouponType { get; set; } | |||
/// <summary> | |||
/// 优惠券值(优惠金额) | |||
/// </summary> | |||
public decimal CouponValue { get; set; } | |||
/// <summary> | |||
/// 使用条件 | |||
/// </summary> | |||
public decimal Condition { get; set; } | |||
/// <summary> | |||
/// 使用时间的类型 1.时间范围内 2.固定期限 | |||
/// </summary> | |||
[Range(1, 2, ErrorMessage = "时间类型错误")] | |||
public int TimeType { get; set; } | |||
/// <summary> | |||
/// 固定期限值(如领取后10内有效) | |||
/// </summary> | |||
public int ValidFixedTerm { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public DateTime ValidStartTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime ValidEndTime { get; set; } | |||
/// <summary> | |||
/// 状态(1:生效、2:失效 3:作废) | |||
/// </summary> | |||
[Range(1, 4, ErrorMessage = "状态错误")] | |||
public int ValidStatus { get; set; } | |||
/// <summary> | |||
/// 每人可领取数量 | |||
/// </summary> | |||
[Range(0,999999)] | |||
public int GetLimit { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public string Remarks { get; set; } | |||
/// <summary> | |||
/// 是否删除 | |||
/// </summary> | |||
public int IsDeleted { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime CreateAt { get; set; } | |||
/// <summary> | |||
/// 创建人 | |||
/// </summary> | |||
public string CreateBy { get; set; } | |||
/// <summary> | |||
/// 修改时间 | |||
/// </summary> | |||
public DateTime UpdateAt { get; set; } | |||
/// <summary> | |||
/// 修改人 | |||
/// </summary> | |||
public string UpdateBy { get; set; } | |||
/// <summary> | |||
/// 删除时间 | |||
/// </summary> | |||
public DateTime DeleteAt { get; set; } | |||
/// <summary> | |||
/// 删除人 | |||
/// </summary> | |||
public string DeleteBy { get; set; } | |||
/// <summary> | |||
/// 创建人类型(0.供应商 1.平台 ) | |||
/// </summary> | |||
public int CreateType { get; set; } | |||
public bool IsAllowUpdate { get; set; } | |||
public int SendNum { get; set; } | |||
public int GetNum { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CouponCanNumAndSendNum | |||
{ | |||
public string Coupon_Id { get; set; } | |||
public int SendNum { get; set; } | |||
public int GetNum { get; set; } | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
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.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CouponLogOutputDto | |||
{ | |||
/// <summary> | |||
/// 主键 | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 客户Id -- 微信的OpenId | |||
/// </summary> | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 客户手机 | |||
/// </summary> | |||
public string Phone { get; set; } | |||
/// <summary> | |||
/// 0表示退单反券 1表示订单完成 | |||
/// </summary> | |||
public int OrderType { get; set; } | |||
/// <summary> | |||
/// 订单流转 | |||
/// </summary> | |||
public string OrderTypeStr => OrderType == 0 ? "退单反券" : "订单完成"; | |||
/// <summary> | |||
/// 券Id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 优惠券标题 | |||
/// </summary> | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 优惠券券值 | |||
/// </summary> | |||
public decimal CouponValue { get; set; } | |||
/// <summary> | |||
/// 类型 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public int? CouponType { get; set; } | |||
/// <summary> | |||
/// 优惠券类型 | |||
/// </summary> | |||
public string CouponTypeStr => !CouponType.HasValue ? "" : (CouponType == 1 ? "满减优惠卷" : (CouponType == 2 ? "代金优惠卷" : "无门槛优惠卷")); | |||
/// <summary> | |||
/// 订单时间 | |||
/// </summary> | |||
public DateTime OrderTime { get; set; } | |||
} | |||
} |
@@ -0,0 +1,53 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CouponRecordDto | |||
{ | |||
/// <summary> | |||
/// 主键 | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 发放时间 | |||
/// </summary> | |||
public DateTime SendTime { get; set; } | |||
/// <summary> | |||
/// 发放数量 | |||
/// </summary> | |||
[Range(0, int.MaxValue)] | |||
public int SendNum { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
public string Coupon_Id { get; set; } | |||
/// <summary> | |||
/// 适用范围类型 1.店铺 2.供应商 3.区域 | |||
/// </summary> | |||
public int RangeType { get; set; } | |||
/// <summary> | |||
/// 是否启用 0 禁用 1.启用 | |||
/// </summary> | |||
[Range(0, 1, ErrorMessage = "状态错误")] | |||
public int Status { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 店铺区域或供应商管理关系 | |||
/// </summary> | |||
public List<string> Relation { get; set; } | |||
/// <summary> | |||
/// 商品Id | |||
/// </summary> | |||
public List<string> GoodsRelation { get; set; } | |||
/// <summary> | |||
/// 区域 或者 供应商 或者店铺名称 | |||
/// </summary> | |||
public string Supplier { get; set; } | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
using BPA.KitChen.StoreManagement.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.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class BasicDto : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 适用范围类型 1.店铺 2.供应商 3.区域 | |||
/// </summary> | |||
public int? RangeType { get; set; } | |||
} | |||
public class CouponRecordPageDto : BasicDto | |||
{ | |||
/// <summary> | |||
/// 是否启用 0 禁用 1.启用 | |||
/// </summary> | |||
public int? Status { get; set; } | |||
/// <summary> | |||
/// 优惠卷Id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 批次号 | |||
/// </summary> | |||
public string? BatchNo { get; set; } | |||
public string CouponTitle { get; set; } | |||
public DateTime? CreateAt { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CouponUseMsgDto | |||
{ | |||
/// <summary> | |||
/// 是否成功 | |||
/// </summary> | |||
public bool IsSuccess { get; set; } | |||
/// <summary> | |||
/// 消息 | |||
/// </summary> | |||
public string Msg { get; set; } | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
using BPA.Kitchen.Core.Common; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
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.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CustomerCouponBaseDto | |||
{ | |||
/// <summary> | |||
/// 顾客优惠劵Id | |||
/// </summary> | |||
[Required] | |||
public string CustomerCouponId { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
[Required] | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 店铺Id | |||
/// </summary> | |||
[Required] | |||
public List<string> StoreId { get; set; } | |||
/// <summary> | |||
/// 商品Id | |||
/// </summary> | |||
public List<string> GoodsId { get; set; } | |||
/// <summary> | |||
/// 优惠券状态 | |||
/// </summary> | |||
[Required] | |||
[CustomValidation(typeof(DtoValidator), "CouponUseType")] | |||
public CouponUseType UseType { get; set; } | |||
/// <summary> | |||
/// 下单时间 | |||
/// </summary> | |||
[Required] | |||
public DateTime OrderTime { get; set; } | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CustomerCouponDto | |||
{ | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public string Customer_Id { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string Order_Id { get; set; } | |||
/// <summary> | |||
/// 领取方式(1.小程序领取 2.线下门店扫码 3.活动自动下发 4.好友分享领取) | |||
/// </summary> | |||
public int Receive_Type { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
public string Coupon_Id { get; set; } | |||
/// <summary> | |||
/// 店铺Id 领券的时候不用填写 | |||
/// </summary> | |||
public string Store_Id { get; set; } | |||
/// <summary> | |||
/// 状态(1:未使用 2.已核销 3.占用中 4.失效)领取的时候不填写 | |||
/// </summary> | |||
public int State { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public DateTime Valid_StartTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime Valid_EndTime { get; set; } | |||
/// <summary> | |||
/// 核销时间 | |||
/// </summary> | |||
public DateTime? WriteOffTime { get; set; } | |||
/// <summary> | |||
/// 范围Id | |||
/// </summary> | |||
public string Coupon_Range_Id { get; set; } | |||
/// <summary> | |||
/// 用户手机号 | |||
/// </summary> | |||
public string CustomerPhone { get; set; } | |||
} | |||
public class CustomerCouponInputDto | |||
{ | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public List<string> MemberId { get; set; } | |||
/// <summary> | |||
/// 优惠卷Id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 范围ID(批次号信息) | |||
/// </summary> | |||
public string CouponRangeId { get; set; } | |||
public E_CouponGitType? CouponGitType { get; set; } = E_CouponGitType.指定领取; | |||
} | |||
} |
@@ -0,0 +1,148 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CustomerCouponOutputDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 优惠券名称 | |||
/// </summary> | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 优惠券值(优惠金额) | |||
/// </summary> | |||
public decimal CouponValue { get; set; } | |||
/// <summary> | |||
/// 使用条件 | |||
/// </summary> | |||
public decimal Condition { get; set; } | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 领取方式(1.小程序领取 2.线下门店扫码 3.活动自动下发 4.好友分享领取 5.指定发放) | |||
/// </summary> | |||
public int ReceiveType { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 店铺Id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 状态(1:未使用 2.已核销 3.占用中 4.失效) | |||
/// </summary> | |||
public int State { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public DateTime ValidStartTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime ValidEndTime { get; set; } | |||
/// <summary> | |||
/// 核销时间 | |||
/// </summary> | |||
public DateTime? WriteOffTime { get; set; } | |||
/// <summary> | |||
/// 范围Id | |||
/// </summary> | |||
public string CouponRangeId { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public List<string> Remarks { get; set; } | |||
/// <summary> | |||
/// 类型 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public int? CouponType { get; set; } | |||
/// <summary> | |||
/// 优惠券类型 | |||
/// </summary> | |||
public string CouponTypeStr => !CouponType.HasValue ? "" : (CouponType == 1 ? "满减优惠卷" : (CouponType == 2 ? "代金优惠卷" : "无门槛优惠卷")); | |||
/// <summary> | |||
/// 适用条件 | |||
/// </summary> | |||
public string ConditionStr => !CouponType.HasValue ? "" : (CouponType == 1 ? $"满{Condition}元减{CouponValue}元" : (CouponType == 2 ? $"可抵扣{CouponValue}元" : "无门槛优惠卷")); | |||
/// <summary> | |||
/// 适用范围 | |||
/// </summary> | |||
public List<string> UseRange { get; set; } | |||
/// <summary> | |||
/// 适用商品 | |||
/// </summary> | |||
public List<string> UseGoods { get; set; } | |||
/// <summary> | |||
/// 适用范围 | |||
/// </summary> | |||
public string RangeTypeStr { get; set; } | |||
} | |||
public class Temp | |||
{ | |||
public string Coupon_Range_Id { get; set; } | |||
} | |||
public class CusomterCouponDTO | |||
{ | |||
/// <summary> | |||
/// wx号 | |||
/// </summary> | |||
public string OpenId { get; set; } | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 优惠券名称 | |||
/// </summary> | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 状态(1:未使用 2.已核销 3.占用中 4.失效) | |||
/// </summary> | |||
public int Stutas { get; set; } | |||
/// <summary> | |||
/// 状态汉字描述 | |||
/// </summary> | |||
public string StutasDes | |||
{ | |||
get | |||
{ | |||
if (Stutas == 1) | |||
return "未使用"; | |||
else if (Stutas == 2) | |||
return "已核销"; | |||
else if (Stutas == 3) | |||
return "占用中"; | |||
else | |||
return "已失效"; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,89 @@ | |||
using BPA.KitChen.StoreManagement.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.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CustomerCouponPageDto : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 状态(1:未使用 2.已核销 3.占用中 4.失效) 不传就是全部 | |||
/// </summary> | |||
public int? State { get; set; } | |||
/// <summary> | |||
/// 手机号 | |||
/// </summary> | |||
public string CustomerPhone { get; set; } | |||
/// <summary> | |||
/// 可用商品 | |||
/// </summary> | |||
public List<string> GoodsId { get; set; } | |||
/// <summary> | |||
/// 总价 | |||
/// </summary> | |||
public decimal? TotalPrice { get; set; } | |||
} | |||
public class CustomerCouponCanUseDto { | |||
/// <summary> | |||
/// 可用商品 | |||
/// </summary> | |||
[Required] | |||
public List<string> GoodsId { get; set; } | |||
/// <summary> | |||
/// 总价 | |||
/// </summary> | |||
public decimal? TotalPrice { get; set; } | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
[Required] | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 店铺Id | |||
/// </summary> | |||
[Required] | |||
public List<string> StoreId { get; set; } | |||
} | |||
public class CustomerCouponPageExDto : CustomerCouponPageDto | |||
{ | |||
/// <summary> | |||
/// 优惠券名称 | |||
/// </summary> | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 领取方式(1.小程序领取 2.线下门店扫码 3.活动自动下发 4.好友分享领取 5.指定发放) | |||
/// </summary> | |||
public int? ReceiveType { get; set; } | |||
/// <summary> | |||
/// 批次号 | |||
/// </summary> | |||
public string BatchNo { get; set; } | |||
public string StoreName { get; set; } | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime? CreateAt { get; set; } | |||
/// <summary> | |||
/// 核销时间 | |||
/// </summary> | |||
public DateTime? WriteOffTime { get; set; } | |||
/// <summary> | |||
/// 客户手机号 | |||
/// </summary> | |||
public string CustomerPhone { get; set; } | |||
} | |||
} |
@@ -0,0 +1,61 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class CustomerCouponPageResultOutputDto | |||
{ | |||
public string? Id { get; set; } | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
public string? CustomerId { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
public string? OrderId { get; set; } | |||
/// <summary> | |||
/// 领取方式(1.小程序领取 2.线下门店扫码 3.活动自动下发 4.好友分享领取 5.指定发放) | |||
/// </summary> | |||
public int? ReceiveType { get; set; } | |||
/// <summary> | |||
/// 状态(1:未使用 2.已核销 3.占用中 4.失效) | |||
/// </summary> | |||
public int? State { get; set; } | |||
/// <summary> | |||
/// 优惠券名称 | |||
/// </summary> | |||
public string? CouponTitle { get; set; } | |||
/// <summary> | |||
/// 适用范围类型 1.店铺 2.供应商 3.区域 | |||
/// </summary> | |||
public int? RangeType { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime? ValidEndTime { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public DateTime? ValidStartTime { get; set; } | |||
/// <summary> | |||
/// 核销时间 | |||
/// </summary> | |||
public DateTime? WriteOffTime { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime? CreateAt { get; set; } | |||
/// <summary> | |||
/// 店铺名称 | |||
/// </summary> | |||
public string? StoreName { get; set; } | |||
/// <summary> | |||
/// 客户手机号 | |||
/// </summary> | |||
public string? Phone { get; set; } | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public class PageCouponInputDto : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 优惠卷名称 | |||
/// </summary> | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 优惠卷类型 | |||
/// </summary> | |||
public int CouponType { get; set; } | |||
/// <summary> | |||
/// 优惠卷金额 | |||
/// </summary> | |||
public decimal CouponValue { get; set; } | |||
/// <summary> | |||
///使用金额 | |||
/// </summary> | |||
public decimal Condition { get; set; } | |||
/// <summary> | |||
/// 时间类型 | |||
/// </summary> | |||
public int TimeType { get; set; } | |||
public int GetLimit { get; set; } | |||
/// <summary> | |||
/// 固定期限 | |||
/// </summary> | |||
public int ValidFixedTerm { get; set; } | |||
public DateTime? ValidStartTime { get; set; } | |||
public DateTime? ValidEndTime { get; set; } | |||
public DateTime? CreateAt { get; set; } | |||
/// <summary> | |||
/// 状态 | |||
/// </summary> | |||
public int ValidStatus { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public decimal Remarks { get; set; } | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class RebackDto | |||
{ | |||
public string Id { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class StatusOrTypeOutDto | |||
{ | |||
public int Key { get; set; } | |||
public string Value { get; set; } | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
public class UpdateStateDto | |||
{ | |||
public string OdrerId { get; set; } | |||
public int State { get; set; } | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos.member | |||
{ | |||
internal class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos.member | |||
{ | |||
public class CustomerInfoInputDto | |||
{ | |||
public int CurrentPage { get; set; } | |||
public int PageSize { get; set; } | |||
public string Phone { get; set; } | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos.member | |||
{ | |||
public class MemberInfoOutputDto | |||
{ | |||
public string Phone { get; set; } | |||
public string MemberId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,194 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos.member; | |||
using Microsoft.AspNetCore.Mvc; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.CouponServices.Dtos | |||
{ | |||
/// <summary> | |||
/// 优惠卷接口 | |||
/// </summary> | |||
public interface ICouponServices | |||
{ | |||
/// <summary> | |||
///获取优惠卷状态和类型 1.优惠卷状态 2.优惠卷类型 | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <returns></returns> | |||
Task<List<StatusOrTypeOutDto>> GetCouponStatusOrTypeAsync(int type); | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
Task<bool> AddCoupon(CouponBasetDto inputDto); | |||
/// <summary> | |||
/// 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetCouponPgageAsync(PageCouponInputDto inputDto); | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
Task<bool> UpdateCoupon(CouponBasetDto inputDto); | |||
/// <summary> | |||
/// 修改优惠券状态 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateCouponStatus( CouponBasetDto inputDto); | |||
/// <summary> | |||
/// 删除优惠卷 | |||
/// </summary> | |||
Task<bool> DeleteCoupon(List<string> Ids); | |||
/// <summary> | |||
/// 作废 | |||
/// </summary> | |||
Task<bool> AbolishCoupon(string Id); | |||
/// <summary> | |||
/// 领券支持批量领取 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<bool> ReceiveCoupon(List<CustomerCouponDto> input); | |||
/// <summary> | |||
/// 指定客户领取 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<bool> ReceiveCouponByInput(CustomerCouponInputDto input); | |||
/// <summary> | |||
/// 领券分页查看SAAS用 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetCustomerPage(CustomerCouponPageExDto input); | |||
/// <summary> | |||
/// 退单退券 | |||
/// </summary> | |||
/// <param name="OrderId"></param> | |||
/// <returns></returns> | |||
Task<ResultEntity> RebackCoupon(string OrderId); | |||
/// <summary> | |||
/// 优惠券使用状态 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<CouponUseMsgDto> CustomerCouponOff(CustomerCouponBaseDto input); | |||
/// <summary> | |||
/// 失效优惠卷 | |||
/// </summary> | |||
/// <param name="Id"></param> | |||
/// <returns></returns> | |||
Task<bool> AbolishCustomerCoupon(string Id); | |||
/// <summary> | |||
/// 查看领取的优惠券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> WacthCoupon(CustomerCouponPageDto input); | |||
/// <summary> | |||
/// 回调写入优惠券状态 | |||
/// </summary> | |||
/// <param name="OdrerId"></param> | |||
/// <param name="State"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateState(string OdrerId, int State); | |||
/// <summary> | |||
/// 查看优惠券流水 | |||
/// </summary> | |||
/// <param name="couponCustomerId"></param> | |||
/// <returns></returns> | |||
Task<List<CouponLogOutputDto>> GetCouponLog(string couponCustomerId); | |||
/// <summary> | |||
/// 根据订单号获取用户的优惠券使用状态 | |||
/// </summary> | |||
/// <param name="OrderId"></param> | |||
/// <returns></returns> | |||
Task<List<CusomterCouponDTO>> GetCouponStutasByOrderId(List<string> OrderId); | |||
/// <summary> | |||
/// 领券详情 | |||
/// </summary> | |||
/// <param name="Id"></param> | |||
/// <returns></returns> | |||
Task<CustomerCouponOutputDto> CustomerCouponDetail(string Id); | |||
/// <summary> | |||
/// 新增发券记录 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<bool> AddCouponSendRecord(CouponRecordDto input); | |||
/// <summary> | |||
/// 获取发券记录 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetCouponRecordById(CouponRecordPageDto input); | |||
/// <summary> | |||
/// 记录汇总 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetCouponRecordPage(CouponRecordPageDto input); | |||
/// <summary> | |||
/// 召回禁用优惠卷 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<bool> RecallCoupon(CouponRecordDto input); | |||
/// <summary> | |||
/// 召回禁用优惠卷商品 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<bool> RecallCouponGoods(CouponRecordDto input); | |||
/// <summary> | |||
/// 获取发券的管理记录商品 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetCouponRecordGoods(CouponRecordPageDto input); | |||
/// <summary> | |||
/// 查询可用券 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<List<CustomerCouponOutputDto>> SelectCanUseCoupon(CustomerCouponCanUseDto input); | |||
/// <summary> | |||
/// 获取商品类型 | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<Dictionary<string, string>> GetGoodsType(); | |||
/// <summary> | |||
/// 获取商品 | |||
/// </summary> | |||
/// <param name="GoodsTypeId"></param> | |||
/// <returns></returns> | |||
Task<Dictionary<string, string>> GetGoods(string GoodsTypeId); | |||
/// <summary> | |||
/// 获取会员信息 | |||
/// </summary> | |||
/// <param name="Phone"></param> | |||
/// <returns></returns> | |||
Task<List<MemberInfoOutputDto>> GetCustomerInfo(CustomerInfoInputDto input); | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos | |||
{ | |||
internal class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos | |||
{ | |||
public class GoodsCouponBasetDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 商品id | |||
/// </summary> | |||
public string GoodsId { get; set; } | |||
/// <summary> | |||
/// 店铺id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 标题 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 类型(平台)id | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
/// <summary> | |||
/// 原始金额 | |||
/// </summary> | |||
public decimal? Money { get; set; } | |||
/// <summary> | |||
/// 平台金额 | |||
/// </summary> | |||
public decimal SoureMoney { get; set; } | |||
/// <summary> | |||
/// 加盟商id | |||
/// </summary> | |||
public string GroupId { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime CrateTimeAt { get; set; } | |||
/// <summary> | |||
/// 是否启用 | |||
/// </summary> | |||
public bool? Enable { get; set; } | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos | |||
{ | |||
public class GoodsCouponReportDatadto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 标题 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 类型 | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 平台金额 | |||
/// </summary> | |||
public decimal SoureMoney { get; set; } | |||
public string CTypeName { get; set; } | |||
/// <summary> | |||
/// 金额 | |||
/// </summary> | |||
public decimal? Money { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime CrateTimeAt { get; set; } | |||
/// <summary> | |||
/// 数量 | |||
/// </summary> | |||
public int Allcount { get; set; } | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos | |||
{ | |||
public class PageGoodsCouponInputDto:PageInputBase | |||
{ | |||
/// <summary> | |||
/// 优惠卷名称 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 优惠卷类型 | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
/// <summary> | |||
/// 优惠卷金额 | |||
/// </summary> | |||
public decimal Money { get; set; } | |||
/// <summary> | |||
/// 店铺名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 店铺id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 是否启用 | |||
/// </summary> | |||
public bool? Enable { get; set; } | |||
} | |||
} |
@@ -0,0 +1,192 @@ | |||
using Furion.FriendlyException; | |||
using Furion; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
using Mapster; | |||
using Furion.DependencyInjection; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos; | |||
using BPA.KitChen.StoreManagement.Core.Common; | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Coupon; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using BPA.Models.BPA_Kitchen; | |||
using BPA.KitChen.StoreManagement.Core.Entity; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon | |||
{ | |||
public class GoodsCouponServices : SupperRepository, IGoodsCouponServices, ITransient | |||
{ | |||
private readonly SqlSugarScope db; // 核心对象:拥有完整的SqlSugar全部功能 | |||
public GoodsCouponServices() | |||
{ | |||
db = SqlSugarDb.Db; | |||
} | |||
/// <summary> | |||
/// / 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil> GetGoodsCouponPgageAsync(PageGoodsCouponInputDto inputDto) | |||
{ | |||
var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) | |||
? App.User?.FindFirst(ClaimConst.GroupId)?.Value | |||
: CurrentUser.TenantId; | |||
if (string.IsNullOrWhiteSpace(groupId)) throw Oops.Oh("加盟商不能为空"); | |||
var result = new List<PaperCouponBasetDto>(); | |||
var total = new RefAsync<int>(); | |||
var queryable = await db.Queryable<BPA_GoodsCoupon, BPA_PaperCouponType, ShopEntity>((a, b,c) => | |||
new JoinQueryInfos( | |||
JoinType.Left, a.CTypeId == b.Id, | |||
JoinType.Left, a.StoreId == c.Id)) | |||
.Where((a, b,c) => a.GroupId == groupId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.CTypeId), a => a.CTypeId == inputDto.CTypeId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Title), a => a.Title.Contains(inputDto.Title)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.GoodsName), a => a.GoodsName.Contains(inputDto.GoodsName)) | |||
.WhereIF(inputDto.Money > 0, a => a.Money == inputDto.Money) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.StoreId),a=>a.StoreId== inputDto.StoreId) | |||
.WhereIF(inputDto.Enable != null, a => a.Enable == inputDto.Enable) | |||
.Select((a, b,c) => new PaperCouponBasetDto() | |||
{ | |||
Id = a.Id, | |||
CTypeId = a.CTypeId, | |||
Title = a.Title, | |||
SoureMoney=a.SoureMoney, | |||
GoodsId= a.GoodsId, | |||
StoreId= a.StoreId, | |||
StoreName=c.Name, | |||
Money = a.Money, | |||
GoodsName=a.GoodsName, | |||
CTypeName = b.Name, | |||
CrateTimeAt = a.CrateTimeAt, | |||
Enable=a.Enable, | |||
}).ToPagedListAsync(inputDto.Current, inputDto.PageSize); | |||
result = queryable.Items.ToList(); | |||
return new PageUtil | |||
{ | |||
Total = queryable.TotalCount, | |||
Data = result | |||
}; | |||
} | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> AddGoodsCoupon(GoodsCouponBasetDto inputDto) | |||
{ | |||
if (string.IsNullOrWhiteSpace(inputDto.GoodsId)) | |||
{ | |||
throw Oops.Oh("商品不能为空"); | |||
} | |||
if (string.IsNullOrWhiteSpace(inputDto.Title)) | |||
{ | |||
throw Oops.Oh("标题参数不能为空"); | |||
} | |||
if (string.IsNullOrWhiteSpace(inputDto.CTypeId)) | |||
{ | |||
throw Oops.Oh("平台参数不能为空"); | |||
} | |||
if (inputDto.Money == null) | |||
{ | |||
throw Oops.Oh("原始金额参数不能为空"); | |||
} | |||
if (inputDto.SoureMoney == null) | |||
{ | |||
throw Oops.Oh("平台金额参数不能为空"); | |||
} | |||
var checkMoneyType = db.Queryable<BPA_GoodsCoupon>().Any(x => x.CTypeId == inputDto.CTypeId && x.SoureMoney== inputDto.SoureMoney && x.Money == inputDto.Money && x.GoodsId == inputDto.GoodsId && x.StoreId== inputDto.StoreId); | |||
if (checkMoneyType) throw Oops.Oh("已存在相同平台金额的商品优惠卷"); | |||
inputDto.Id= Guid.NewGuid().ToString(); | |||
inputDto.CrateTimeAt = DateTime.Now; | |||
inputDto.Enable = true; | |||
var result = await db.Insertable<BPA_GoodsCoupon>(inputDto.Adapt<BPA_GoodsCoupon>()).ExecuteCommandAsync(); | |||
return await Task.FromResult(result > 0); | |||
} | |||
/// <summary> | |||
/// 更新优惠卷启用状态 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdateGoodsCouponEnable(string Ids) | |||
{ | |||
var model = db.Queryable<BPA_GoodsCoupon>().First(x => Ids.Contains(x.Id)); | |||
if (model == null) throw Oops.Oh("数据不存在"); | |||
model.Enable = !model.Enable; | |||
var result = db.Updateable<BPA_GoodsCoupon>(model).ExecuteCommand(); | |||
return result > 0; | |||
} | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdateGoodsCoupon([FromBody] GoodsCouponBasetDto inputDto) | |||
{ | |||
if (string.IsNullOrWhiteSpace(inputDto.Title)) | |||
{ | |||
throw Oops.Oh("标题参数不能为空"); | |||
} | |||
if (string.IsNullOrWhiteSpace(inputDto.CTypeId)) | |||
{ | |||
throw Oops.Oh("类型参数不能为空"); | |||
} | |||
if (inputDto.Money == null) | |||
{ | |||
throw Oops.Oh("金额参数不能为空"); | |||
} | |||
if (inputDto.Money < 0) | |||
{ | |||
throw Oops.Oh("金额不能小于0"); | |||
} | |||
var result = db.Updateable<BPA_GoodsCoupon>(inputDto.Adapt<BPA_GoodsCoupon>()).UpdateColumns(it => | |||
new { it.Title, it.Money, it.CTypeId,it.GoodsId,it.GoodsName,it.SoureMoney }).ExecuteCommand(); | |||
return await Task.FromResult(result > 0); | |||
} | |||
/// <summary> | |||
/// 统计报表F | |||
/// </summary> | |||
/// <param name="paperCouponReportdto"></param> | |||
/// <returns></returns> | |||
public async Task<List<GoodsCouponReportDatadto>> GetGoodsCouponReport(PaperCouponReportdto paperCouponReportdto) | |||
{ | |||
var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) | |||
? App.User?.FindFirst(ClaimConst.GroupId)?.Value | |||
: CurrentUser.TenantId; | |||
if (string.IsNullOrWhiteSpace(groupId)) throw Oops.Oh("加盟商不能为空"); | |||
var queryable = await db.Queryable<BPA_GoodsCoupon, BPA_PaperCouponType>((a, b) => a.CTypeId == b.Id) | |||
.Where((a,b)=>a.GroupId== groupId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(paperCouponReportdto.CTypeId), a => a.CTypeId == paperCouponReportdto.CTypeId) | |||
.WhereIF(paperCouponReportdto.Money > 0, a => a.Money == paperCouponReportdto.Money) | |||
.Select((a, b) => new GoodsCouponReportDatadto() | |||
{ | |||
Id = a.Id, | |||
CTypeId = a.CTypeId, | |||
Title = a.Title, | |||
Money = a.Money, | |||
SoureMoney= a.SoureMoney, | |||
GoodsName= a.GoodsName, | |||
CTypeName = b.Name, | |||
CrateTimeAt = a.CrateTimeAt | |||
}).Mapper(p => | |||
{ | |||
p.Allcount = db.Queryable<BPA_GoodsCouponWriteoffLog>() | |||
.Where(x => x.GoodsCouponId == p.Id && x.GroupId == groupId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(paperCouponReportdto.StartDateStr), c => c.CreateAt >= Convert.ToDateTime(paperCouponReportdto.StartDateStr)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(paperCouponReportdto.EndDateStr), c => c.CreateAt <= Convert.ToDateTime(paperCouponReportdto.EndDateStr)) | |||
.Count(); | |||
}) | |||
.ToListAsync(); | |||
return queryable; | |||
} | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos; | |||
using Microsoft.AspNetCore.Mvc; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon | |||
{ | |||
/// <summary> | |||
/// 接口服务 | |||
/// </summary> | |||
public interface IGoodsCouponServices | |||
{ | |||
/// <summary> | |||
/// 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetGoodsCouponPgageAsync(PageGoodsCouponInputDto inputDto); | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> AddGoodsCoupon(GoodsCouponBasetDto inputDto); | |||
/// <summary> | |||
/// 更新优惠卷启用状态 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateGoodsCouponEnable(string Ids); | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateGoodsCoupon([FromBody] GoodsCouponBasetDto inputDto); | |||
/// <summary> | |||
/// 统计报表 | |||
/// </summary> | |||
/// <param name="paperCouponReportdto"></param> | |||
/// <returns></returns> | |||
Task<List<GoodsCouponReportDatadto>> GetGoodsCouponReport(PaperCouponReportdto paperCouponReportdto); | |||
} | |||
} |
@@ -0,0 +1,86 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.GoodsCoupon.Dtos; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos; | |||
using Furion.DependencyInjection; | |||
using Furion.DynamicApiController; | |||
using Microsoft.AspNetCore.Authorization; | |||
using Microsoft.AspNetCore.Mvc; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon | |||
{ | |||
/// <summary> | |||
/// 商品优惠卷管理 | |||
/// </summary> | |||
[ApiDescriptionSettings("商品优惠券", Tag = "商品优惠卷管理")] | |||
public class GoodsCouponService : IDynamicApiController, ITransient | |||
{ | |||
IGoodsCouponServices _goodsCouponServices; | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="goodsCouponServices"></param> | |||
public GoodsCouponService(IGoodsCouponServices goodsCouponServices) | |||
{ | |||
_goodsCouponServices=goodsCouponServices; | |||
} | |||
/// <summary> | |||
/// 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/goodscoupon/getGoodsCouponPgage")] | |||
[AllowAnonymous] | |||
public async Task<PageUtil> GetGoodsCouponPgage([FromBody] PageGoodsCouponInputDto inputDto) | |||
{ | |||
return await _goodsCouponServices.GetGoodsCouponPgageAsync(inputDto); | |||
} | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/goodscoupon/addGoodsCoupon")] | |||
public async Task<bool> AddGoodsCoupon(GoodsCouponBasetDto inputDto) | |||
{ | |||
return await _goodsCouponServices.AddGoodsCoupon(inputDto); | |||
} | |||
/// <summary> | |||
/// 更新优惠卷启用状态 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
[HttpGet("/api/goodscoupon/updateGoodsCouponEnable")] | |||
public async Task<bool> UpdateGoodsCouponEnable(string Ids) | |||
{ | |||
return await _goodsCouponServices.UpdateGoodsCouponEnable(Ids); | |||
} | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/goodscoupon/updateGoodsCoupon")] | |||
public async Task<bool> UpdateGoodsCoupon(GoodsCouponBasetDto inputDto) | |||
{ | |||
return await _goodsCouponServices.UpdateGoodsCoupon(inputDto); | |||
} | |||
/// <summary> | |||
/// 优惠卷报表统计 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/goodscoupon/getGoodsCouponReport")] | |||
[AllowAnonymous] | |||
public async Task<List<GoodsCouponReportDatadto>> GetPaperCouponReport(PaperCouponReportdto inputDto) | |||
{ | |||
return await _goodsCouponServices.GetGoodsCouponReport(inputDto); | |||
} | |||
} | |||
} |
@@ -0,0 +1,103 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos; | |||
using Furion.DependencyInjection; | |||
using Furion.DynamicApiController; | |||
using Microsoft.AspNetCore.Authorization; | |||
using Microsoft.AspNetCore.Mvc; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.Kitchen.CRM.CouponCenter | |||
{ | |||
[ApiDescriptionSettings("纸质优惠券", Tag = "纸质优惠券管理")] | |||
public class PaperCouponsService: IDynamicApiController, ITransient | |||
{ | |||
readonly IPaperCouponsServices _paperCouponsServices; | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="couponServices"></param> | |||
public PaperCouponsService(IPaperCouponsServices paperCouponsServices) | |||
{ | |||
_paperCouponsServices = paperCouponsServices; | |||
} | |||
/// <summary> | |||
/// 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/papercoupon/paperCouponPgage")] | |||
[AllowAnonymous] | |||
public async Task<PageUtil> PaperCouponPgage([FromBody] PagePaperCouponInputDto inputDto) | |||
{ | |||
return await _paperCouponsServices.GetPaperCouponPgageAsync(inputDto); | |||
} | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/papercoupon/addPaperCoupon")] | |||
public async Task<bool> AddPaperCoupon(PaperCouponBasetDto inputDto) | |||
{ | |||
return await _paperCouponsServices.AddPaperCoupon(inputDto); | |||
} | |||
/// <summary> | |||
/// 删除优惠卷 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
[HttpGet("/api/papercoupon/updatePaperCouponEnable")] | |||
public async Task<bool> UpdatePaperCouponEnable(string Ids) | |||
{ | |||
return await _paperCouponsServices.UpdatePaperCouponEnable(Ids); | |||
} | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/papercoupon/updatePaperCoupon")] | |||
public async Task<bool> UpdateCoupon(PaperCouponBasetDto inputDto) | |||
{ | |||
return await _paperCouponsServices.UpdatePaperCoupon(inputDto); | |||
} | |||
/// <summary> | |||
/// 新增优惠卷类型 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/papercoupon/addPaperCouponType")] | |||
public async Task<bool> AddPaperCouponType(PaperCouponTypeBasetDto inputDto) | |||
{ | |||
return await _paperCouponsServices.AddPaperCouponType(inputDto); | |||
} | |||
/// <summary> | |||
/// 查询所有优惠卷类型 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpGet("/api/papercoupon/getPaperCouponType")] | |||
[AllowAnonymous] | |||
public async Task<List<PaperCouponTypeSelectDto>> GetPaperCouponType() | |||
{ | |||
return await _paperCouponsServices.GetPaperCouponType(); | |||
} | |||
/// <summary> | |||
/// 优惠卷报表统计 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/papercoupon/getPaperCouponReport")] | |||
[AllowAnonymous] | |||
public async Task<List<PaperCouponReportDatadto>> GetPaperCouponReport(PaperCouponReportdto inputDto) | |||
{ | |||
return await _paperCouponsServices.GetPaperCouponReport(inputDto); | |||
} | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos | |||
{ | |||
public class PagePaperCouponInputDto: PageInputBase | |||
{ | |||
/// <summary> | |||
/// 优惠卷名称 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 优惠卷类型 | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
/// <summary> | |||
/// 优惠卷金额 | |||
/// </summary> | |||
public decimal Money { get; set; } | |||
/// <summary> | |||
/// 是否启用 | |||
/// </summary> | |||
public bool? Enable { get; set; } | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos | |||
{ | |||
public class PaperCouponBasetDto | |||
{ | |||
public string Id { get; set; } | |||
public string GoodsId { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 店铺id | |||
/// </summary> | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 店铺 | |||
/// </summary> | |||
public string StoreName { get; set; } | |||
/// <summary> | |||
/// 标题 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 类型 | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
public string CTypeName { get; set; } | |||
/// <summary> | |||
/// 金额 | |||
/// </summary> | |||
public decimal? Money { get; set; } | |||
/// <summary> | |||
/// 平台金额 | |||
/// </summary> | |||
public decimal SoureMoney { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime CrateTimeAt { get; set; } | |||
public bool? Enable { get; set; } | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos | |||
{ | |||
public class PaperCouponReportDatadto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 标题 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 类型 | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
public string CTypeName { get; set; } | |||
/// <summary> | |||
/// 金额 | |||
/// </summary> | |||
public decimal? Money { get; set; } | |||
/// <summary> | |||
/// 平台金额 | |||
/// </summary> | |||
public decimal? SoureMoney { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime CrateTimeAt { get; set; } | |||
/// <summary> | |||
/// 数量 | |||
/// </summary> | |||
public int Allcount { get; set; } | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos | |||
{ | |||
public class PaperCouponReportdto | |||
{ | |||
public string StartDateStr { get; set; } | |||
public string EndDateStr { get; set; } | |||
public string CTypeId { get; set; } | |||
public decimal Money { get; set; } | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos | |||
{ | |||
public class PaperCouponTypeBasetDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 类型名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using Microsoft.AspNetCore.Http; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos | |||
{ | |||
public class PaperCouponTypeSelectDto | |||
{ | |||
public string Key { get; set; } | |||
public string Value { get; set; } | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos; | |||
using Microsoft.AspNetCore.Mvc; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices | |||
{ | |||
public interface IPaperCouponsServices | |||
{ | |||
/// <summary> | |||
/// 分页查询数据 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> GetPaperCouponPgageAsync(PagePaperCouponInputDto inputDto); | |||
/// <summary> | |||
/// 添加数据 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> AddPaperCoupon(PaperCouponBasetDto inputDto); | |||
/// <summary> | |||
/// 删除数据 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdatePaperCouponEnable(string Ids); | |||
/// <summary> | |||
/// 更新数据 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdatePaperCoupon([FromBody] PaperCouponBasetDto inputDto); | |||
/// <summary> | |||
/// 添加优惠卷类型 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<bool> AddPaperCouponType(PaperCouponTypeBasetDto inputDto); | |||
/// <summary> | |||
/// 查询所有优惠卷类型 | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<List<PaperCouponTypeSelectDto>> GetPaperCouponType(); | |||
/// <summary> | |||
/// 统计 | |||
/// </summary> | |||
/// <param name="paperCouponReportdto"></param> | |||
/// <returns></returns> | |||
Task<List<PaperCouponReportDatadto>> GetPaperCouponReport(PaperCouponReportdto paperCouponReportdto); | |||
} | |||
} |
@@ -0,0 +1,193 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices.Dtos; | |||
using BPA.KitChen.StoreManagement.Core.Common; | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Coupon; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using Furion; | |||
using Furion.DependencyInjection; | |||
using Furion.FriendlyException; | |||
using Mapster; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Coupon.PaperCouponsServices | |||
{ | |||
/// <summary> | |||
/// 纸质优惠卷服务 | |||
/// </summary> | |||
public class PaperCouponsServices: SupperRepository, IPaperCouponsServices, ITransient | |||
{ | |||
private readonly SqlSugarScope db; // 核心对象:拥有完整的SqlSugar全部功能 | |||
public PaperCouponsServices() | |||
{ | |||
db = SqlSugarDb.Db; | |||
} | |||
/// <summary> | |||
/// / 获取优惠卷_分页 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil> GetPaperCouponPgageAsync(PagePaperCouponInputDto inputDto) | |||
{ | |||
var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) | |||
? App.User?.FindFirst(ClaimConst.GroupId)?.Value | |||
: CurrentUser.TenantId; | |||
if (string.IsNullOrWhiteSpace(groupId)) throw Oops.Oh("加盟商不能为空"); | |||
var result = new List<PaperCouponBasetDto>(); | |||
var total = new RefAsync<int>(); | |||
var queryable =await db.Queryable<BPA_PaperCoupon, BPA_PaperCouponType>((a, b) => a.CTypeId == b.Id) | |||
.Where((a,b)=>a.GroupId== groupId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.CTypeId), a => a.CTypeId == inputDto.CTypeId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Title), a => a.Title.Contains(inputDto.Title)) | |||
.WhereIF(inputDto.Money > 0, a => a.Money == inputDto.Money) | |||
.WhereIF(inputDto.Enable!=null,a=>a.Enable== inputDto.Enable) | |||
.Select((a,b)=>new PaperCouponBasetDto() | |||
{ | |||
Id=a.Id, CTypeId=a.CTypeId, Title=a.Title,Money=a.Money,CTypeName=b.Name,CrateTimeAt=a.CrateTimeAt,Enable=a.Enable,SoureMoney=a.SoureMoney | |||
}).ToPagedListAsync(inputDto.Current, inputDto.PageSize); | |||
result = queryable.Items.ToList(); | |||
return new PageUtil | |||
{ | |||
Total = queryable.TotalCount, | |||
Data = result | |||
}; | |||
} | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> AddPaperCoupon(PaperCouponBasetDto inputDto) | |||
{ | |||
if (string.IsNullOrWhiteSpace(inputDto.Title)) | |||
{ | |||
throw Oops.Oh("标题参数不能为空"); | |||
} | |||
if (string.IsNullOrWhiteSpace(inputDto.CTypeId)) | |||
{ | |||
throw Oops.Oh("类型参数不能为空"); | |||
} | |||
if (inputDto.Money==null) | |||
{ | |||
throw Oops.Oh("金额参数不能为空"); | |||
} | |||
var checkMoneyType=db.Queryable<BPA_PaperCoupon>().Any(x => x.CTypeId == inputDto.CTypeId && x.Money == inputDto.Money); | |||
if(checkMoneyType) throw Oops.Oh("已存在相同类型金额的优惠卷"); | |||
inputDto.Id = Guid.NewGuid().ToString(); | |||
inputDto.CrateTimeAt = DateTime.Now; | |||
inputDto.Enable= true; | |||
var result = await db.Insertable<BPA_PaperCoupon>(inputDto.Adapt<BPA_PaperCoupon>()).ExecuteCommandAsync(); | |||
return await Task.FromResult(result > 0); | |||
} | |||
/// <summary> | |||
/// 删除优惠卷 | |||
/// </summary> | |||
/// <param name="Ids"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdatePaperCouponEnable(string Ids) | |||
{ | |||
var model = db.Queryable<BPA_PaperCoupon>().First(x => Ids.Contains(x.Id)); | |||
if (model == null) throw Oops.Oh("数据不存在"); | |||
model.Enable = !model.Enable; | |||
var result = db.Updateable<BPA_PaperCoupon>(model).ExecuteCommand(); | |||
return result > 0; | |||
} | |||
/// <summary> | |||
/// 修改优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdatePaperCoupon([FromBody] PaperCouponBasetDto inputDto) | |||
{ | |||
if (string.IsNullOrWhiteSpace(inputDto.Title)) | |||
{ | |||
throw Oops.Oh("标题参数不能为空"); | |||
} | |||
if (string.IsNullOrWhiteSpace(inputDto.CTypeId)) | |||
{ | |||
throw Oops.Oh("类型参数不能为空"); | |||
} | |||
if (inputDto.Money == null) | |||
{ | |||
throw Oops.Oh("金额参数不能为空"); | |||
} | |||
if (inputDto.Money<0) | |||
{ | |||
throw Oops.Oh("金额不能小于0"); | |||
} | |||
if (inputDto.SoureMoney < 0) | |||
{ | |||
throw Oops.Oh("金额不能小于0"); | |||
} | |||
var result = db.Updateable<BPA_PaperCoupon>(inputDto.Adapt<BPA_PaperCoupon>()).UpdateColumns(it => | |||
new { it.Title,it.Money,it.CTypeId }).ExecuteCommand(); | |||
return await Task.FromResult(result > 0); | |||
} | |||
/// <summary> | |||
/// 新增优惠卷 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> AddPaperCouponType(PaperCouponTypeBasetDto inputDto) | |||
{ | |||
if (string.IsNullOrWhiteSpace(inputDto.Name)) | |||
{ | |||
throw Oops.Oh("标题参数不能为空"); | |||
} | |||
var checkMoneyType = db.Queryable<BPA_PaperCouponType>().Any(x => x.Name == inputDto.Name); | |||
if (checkMoneyType) throw Oops.Oh("已存在相同名称的类型"); | |||
inputDto.Id = Guid.NewGuid().ToString(); | |||
var result = await db.Insertable<BPA_PaperCouponType>(inputDto.Adapt<BPA_PaperCouponType>()).ExecuteCommandAsync(); | |||
return await Task.FromResult(result > 0); | |||
} | |||
/// <summary> | |||
/// 查询所有优惠卷类型 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<List<PaperCouponTypeSelectDto>> GetPaperCouponType() | |||
{ | |||
var list= await db.Queryable<BPA_PaperCouponType>().Select(x=>new PaperCouponTypeSelectDto() | |||
{ | |||
Key=x.Id,Value=x.Name | |||
}).ToListAsync(); | |||
return list; | |||
} | |||
public async Task<List<PaperCouponReportDatadto>> GetPaperCouponReport(PaperCouponReportdto paperCouponReportdto) | |||
{ | |||
var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) | |||
? App.User?.FindFirst(ClaimConst.GroupId)?.Value | |||
: CurrentUser.TenantId; | |||
var queryable = await db.Queryable<BPA_PaperCoupon, BPA_PaperCouponType>((a, b) => a.CTypeId == b.Id) | |||
.WhereIF(!string.IsNullOrWhiteSpace(paperCouponReportdto.CTypeId), a => a.CTypeId == paperCouponReportdto.CTypeId) | |||
.WhereIF(paperCouponReportdto.Money > 0, a => a.Money == paperCouponReportdto.Money) | |||
.Select((a, b) => new PaperCouponReportDatadto() | |||
{ | |||
Id = a.Id, | |||
CTypeId = a.CTypeId, | |||
Title = a.Title, | |||
Money = a.Money, | |||
SoureMoney= a.SoureMoney, | |||
CTypeName = b.Name, | |||
CrateTimeAt = a.CrateTimeAt | |||
}).Mapper(p => | |||
{ | |||
p.Allcount= db.Queryable<BPA_PaperCouponWriteoffLog>() | |||
.Where(x => x.PaperCouponId == p.Id && x.GroupId== groupId) | |||
.WhereIF(!string.IsNullOrWhiteSpace(paperCouponReportdto.StartDateStr),c=>c.CreateAt>=Convert.ToDateTime(paperCouponReportdto.StartDateStr)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(paperCouponReportdto.EndDateStr), c => c.CreateAt <=Convert.ToDateTime(paperCouponReportdto.EndDateStr)) | |||
.Count(); | |||
}) | |||
.ToListAsync(); | |||
return queryable; | |||
} | |||
} | |||
} |
@@ -1,4 +1,7 @@ | |||
using System; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.FoodMenu.Dtos; | |||
using Microsoft.AspNetCore.Mvc; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -8,5 +11,13 @@ namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.FoodMenu | |||
{ | |||
public interface IFoodMenuServices | |||
{ | |||
/// <summary> | |||
/// 获取菜品列表 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/FoodMenu/GetGoodsByMenuIdPage")] | |||
Task<PageUtil> GetGoodsByMenuIdPage(FoodMenuQueryInputDto inputDto); | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberInfo.Dtos | |||
{ | |||
internal class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,85 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using Furion.DataValidation; | |||
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.OneCard.StoredValueCard.Dto | |||
{ | |||
public class CreateOrUpdateMemberInfoInputDto | |||
{ | |||
public string MemberInfo_Id { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string NickName { get; set; } | |||
/// <summary> | |||
/// 0=未知 1=男 2=女 | |||
/// </summary> | |||
[Range(0, 2, ErrorMessage = "性别错误")] | |||
public int Sex { get; set; } | |||
/// <summary> | |||
/// 头像 | |||
/// </summary> | |||
public string HeadImgUrl { get; set; } | |||
/// <summary> | |||
/// 国家 | |||
/// </summary> | |||
public string Country { get; set; } | |||
/// <summary> | |||
/// 省 | |||
/// </summary> | |||
public string Province { get; set; } | |||
/// <summary> | |||
/// 市 | |||
/// </summary> | |||
public string City { get; set; } | |||
/// <summary> | |||
/// 县(区) | |||
/// </summary> | |||
public string County { get; set; } | |||
/// <summary> | |||
/// 具体地址 | |||
/// </summary> | |||
public string Address { get; set; } | |||
/// <summary> | |||
/// 出生日期 | |||
/// </summary> | |||
public DateTime Birthday { get; set; } | |||
/// <summary> | |||
/// 电话 | |||
/// </summary> | |||
[RegularExpression("^1[3|4|5|7|8][0-9]{9}$")] | |||
public string Phone { get; set; } | |||
/// <summary> | |||
/// 真实姓名 | |||
/// </summary> | |||
public string RealName { get; set; } | |||
/// <summary> | |||
/// 身份证号码 | |||
/// </summary> | |||
[RegularExpression("^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$")] | |||
public string CardNum { get; set; } | |||
/// <summary> | |||
/// 等级 | |||
/// </summary> | |||
public string Level_Id { get; set; } | |||
/// <summary> | |||
/// 向外展示那个平台的信息 0:默认 1.微信 2.支付宝 3.POS 4.卡会员 | |||
/// </summary> | |||
[CustomValidation(typeof(DtoValidator), "MemberPlatformType")] | |||
public PlatformType ShowPlatformType { get; set; } | |||
public int PlatformType { get; set; } | |||
[CustomValidation(typeof(DtoValidator), "Status")] | |||
public CommonStatus Status { get; set; } | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using BPA.KitChen.StoreManagement.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.ShopManage.Member.MemberInfo.Dtos | |||
{ | |||
public class GetMemberInfoQueryInputDto : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 昵称 | |||
/// </summary> | |||
public string NickName { get; set; } | |||
/// <summary> | |||
/// 真实姓名 | |||
/// </summary> | |||
public string RealName { get; set; } | |||
/// <summary> | |||
/// 电话 | |||
/// </summary> | |||
public string Phone { get; set; } | |||
/// <summary> | |||
/// Status | |||
/// </summary> | |||
public string Status { get; set; } | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.OneCard.StoredValueCard.Dto | |||
{ | |||
public class MemberAccountPageInputDto: PageInputBase | |||
{ | |||
public string MemberInfoId { get; set; } | |||
public string Name { get; set; } | |||
public string CardNum { get; set; } | |||
} | |||
} |
@@ -0,0 +1,121 @@ | |||
using BPA.Kitchen.Core.Common; | |||
using BPA.KitChen.StoreManagement.Application.Service.OneCard.StoredValueCard.Dto; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
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.ShopManage.Member.MemberInfo.Dtos | |||
{ | |||
public class MemberInfoBaseDto | |||
{ | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string NickName { get; set; } | |||
/// <summary> | |||
/// 0=未知 1=男 2=女 | |||
/// </summary> | |||
public int Sex { get; set; } | |||
/// <summary> | |||
/// 头像 | |||
/// </summary> | |||
public string HeadImgUrl { get; set; } | |||
/// <summary> | |||
/// 国家 | |||
/// </summary> | |||
public string Country { get; set; } | |||
/// <summary> | |||
/// 省 | |||
/// </summary> | |||
public string Province { get; set; } | |||
/// <summary> | |||
/// 市 | |||
/// </summary> | |||
public string City { get; set; } | |||
/// <summary> | |||
/// 县(区) | |||
/// </summary> | |||
public string County { get; set; } | |||
/// <summary> | |||
/// 具体地址 | |||
/// </summary> | |||
public string Address { get; set; } | |||
/// <summary> | |||
/// 出生日期 | |||
/// </summary> | |||
public DateTime Birthday { get; set; } | |||
/// <summary> | |||
/// 电话 | |||
/// </summary> | |||
public string Phone { get; set; } | |||
/// <summary> | |||
/// 真实姓名 | |||
/// </summary> | |||
public string RealName { get; set; } | |||
/// <summary> | |||
/// 身份证号码 | |||
/// </summary> | |||
public string CardNum { get; set; } | |||
/// <summary> | |||
/// 等级 | |||
/// </summary> | |||
public string Level_Id { get; set; } | |||
/// <summary> | |||
/// 0:正常 1停用 | |||
/// </summary> | |||
//[CustomValidation(typeof(DtoValidator), "Status")] | |||
public CommonStatus Status { get; set; } | |||
/// <summary> | |||
/// 向外展示那个平台的信息 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
public int ShowPlatformType { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public int IsDeleted { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public DateTime CreateAt { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string CreateBy { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public DateTime DeleteAt { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string DeleteBy { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public DateTime UpdateAt { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string UpdateBy { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string GroupId { get; set; } | |||
public List<MemberTagOutDto> MemberTag { get; set; } | |||
public List<PlatformMemberInfoBaseDto> PlatformMemberInfos { get; set; } | |||
/// <summary> | |||
/// 平台 | |||
/// </summary> | |||
public int PlatformType { get; set; } | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
| |||
using BPA.KitChen.StoreManagement.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.ShopManage.Member.MemberInfo.Dtos.MemberTag | |||
{ | |||
/// <summary> | |||
/// 会员标签查询类 | |||
/// </summary> | |||
public class MemberTagQueryDto : PageInputBase | |||
{ | |||
/// <summary> | |||
/// 编号 | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 会员标签名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 平台标签 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
public string PlatformType { get; set; } | |||
/// <summary> | |||
/// 排序 | |||
/// </summary> | |||
public int Sort { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime? CreateAt { get; set; } | |||
/// <summary> | |||
/// 状态 | |||
/// </summary> | |||
public int? Status { get; set; } | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.OneCard.StoredValueCard.Dto | |||
{ | |||
public class MemberTagAndInfoOutDto | |||
{ | |||
public string Id { get; set; } | |||
public string Name { get; set; } | |||
public string MemberTagInfoId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.OneCard.StoredValueCard.Dto | |||
{ | |||
public class MemberTagOutDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 会员标签名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 排序 | |||
/// </summary> | |||
public int Sort { get; set; } | |||
/// <summary> | |||
/// 向外展示那个平台的信息 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
public PlatformType PlatformType { get; set; } | |||
public string MemberId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,121 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.OneCard.StoredValueCard.Dto | |||
{ | |||
public class PlatformMemberInfoBaseDto | |||
{ | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string NickName { get; set; } | |||
/// <summary> | |||
/// 0=未知 1=男 2=女 | |||
/// </summary> | |||
public int Sex { get; set; } | |||
/// <summary> | |||
/// 头像 | |||
/// </summary> | |||
public string HeadImgUrl { get; set; } | |||
/// <summary> | |||
/// 国家 | |||
/// </summary> | |||
public string Country { get; set; } | |||
/// <summary> | |||
/// 省 | |||
/// </summary> | |||
public string Province { get; set; } | |||
/// <summary> | |||
/// 市 | |||
/// </summary> | |||
public string City { get; set; } | |||
/// <summary> | |||
/// 县(区) | |||
/// </summary> | |||
public string County { get; set; } | |||
/// <summary> | |||
/// 具体地址 | |||
/// </summary> | |||
public string Address { get; set; } | |||
/// <summary> | |||
/// 出生日期 | |||
/// </summary> | |||
public DateTime Birthday { get; set; } | |||
/// <summary> | |||
/// 电话 | |||
/// </summary> | |||
public string Phone { get; set; } | |||
/// <summary> | |||
/// 真实姓名 | |||
/// </summary> | |||
public string RealName { get; set; } | |||
/// <summary> | |||
/// 身份证号码 | |||
/// </summary> | |||
public string CardNum { get; set; } | |||
/// <summary> | |||
/// 等级 | |||
/// </summary> | |||
public string Level_Id { get; set; } | |||
/// <summary> | |||
/// 0:正常 1停用 | |||
/// </summary> | |||
public int Status { get; set; } | |||
/// <summary> | |||
/// 1.微信 2.支付宝 | |||
/// </summary> | |||
public PlatformType PlatformType { get; set; } | |||
/// <summary> | |||
/// 平台会员ID | |||
/// </summary> | |||
public string PlatformMemberId { get; set; } | |||
/// <summary> | |||
/// 基础会员表ID | |||
/// </summary> | |||
public string MemberInfo_Id { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public int IsDeleted { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public DateTime CreateAt { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string CreateBy { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public DateTime DeleteAt { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string DeleteBy { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public DateTime UpdateAt { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string UpdateBy { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public string GroupId { get; set; } | |||
public List<MemberTagOutDto> MemberTag { get; set; } | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
using BPA.Kitchen.Core.Common; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
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.ShopManage.Member.MemberInfo.Dtos | |||
{ | |||
public class UpdateMemberTagInputDto | |||
{ | |||
[CustomValidation(typeof(DtoValidator), "Member")] | |||
public string MemberInfo_Id { get; set; } | |||
[CustomValidation(typeof(DtoValidator), "MemberPlatformType")] | |||
public PlatformType PlatformType { get; set; } | |||
[CustomValidation(typeof(DtoValidator), "MemberTagList")] | |||
public List<string> Tags { get; set; } | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberInfo | |||
{ | |||
public interface IMemberInfoService | |||
{ | |||
} | |||
} |
@@ -0,0 +1,469 @@ | |||
using Furion.DatabaseAccessor; | |||
using Furion.FriendlyException; | |||
using Furion; | |||
using Microsoft.AspNetCore.Mvc; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Furion.DependencyInjection; | |||
using Furion.DynamicApiController; | |||
using Mapster; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberInfo.Dtos; | |||
using BPA.KitChen.StoreManagement.Core.Entity; | |||
using BPA.KitChen.StoreManagement.Application.Service.OneCard.StoredValueCard.Dto; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberInfo.Dtos.MemberTag; | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberInfo | |||
{ | |||
[ApiDescriptionSettings("会员管理", Tag = "会员信息")] | |||
public class MemberInfoService : SupperRepository, IDynamicApiController, IMemberInfoService, ITransient | |||
{ | |||
private readonly SqlSugarScope db; | |||
public MemberInfoService() | |||
{ | |||
db = SqlSugarDb.Db; // 推荐操作 | |||
} | |||
/// <summary> | |||
/// 查询会员 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberInfoService/GetMemberPageQuery")] | |||
public async Task<PageUtil> GetMemberPageQuery(GetMemberInfoQueryInputDto inputDto) | |||
{ | |||
List<IConditionalModel> conModels = new List<IConditionalModel>(); | |||
if (!string.IsNullOrEmpty(inputDto.NickName)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "NickName", ConditionalType = ConditionalType.Like, FieldValue = inputDto.NickName }); | |||
} | |||
if (!string.IsNullOrEmpty(inputDto.RealName)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "RealName", ConditionalType = ConditionalType.Like, FieldValue = inputDto.RealName }); | |||
} | |||
if (!string.IsNullOrEmpty(inputDto.Status)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "Status", ConditionalType = ConditionalType.Equal, FieldValue = inputDto.Status }); | |||
} | |||
var result = new List<MemberInfoBaseDto>(); | |||
int total = 0; | |||
//分页查询基础会员表 | |||
var data = db.Queryable<BPA_MemberInfo>().Where(conModels) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Phone), x => x.Phone.Contains(inputDto.Phone)) | |||
.OrderBy(x => x.CreateAt, OrderByType.Desc) | |||
.ToPageList(inputDto.Current, inputDto.PageSize, ref total); | |||
result = data.Adapt<List<MemberInfoBaseDto>>(); | |||
var tatalId = data.Select(x => x.Id).ToList(); | |||
//查询平台数据 | |||
var platformMemberInfos = await db.Queryable<BPA_PlatformMemberInfo>().Where(x => tatalId.Contains(x.MemberInfo_Id)).ToListAsync(); | |||
//查询标签 | |||
var tags = db.Queryable<BPA_MemberTagInfo, BPA_MemberTag>((a, b) => new JoinQueryInfos( | |||
JoinType.Left, b.Id == a.MemberTag_Id | |||
)).Where((a, b) => tatalId.Contains(a.MemberInfo_Id) && a.IsDeleted == 0) | |||
.OrderBy((a, b) => a.CreateAt,OrderByType.Desc) | |||
.Select((a, b) => new MemberTagOutDto() | |||
{ | |||
Id = b.Id, | |||
Name = b.Name, | |||
Sort = b.Sort, | |||
MemberId = a.MemberInfo_Id, | |||
PlatformType = a.PlatformType | |||
}) | |||
.ToList(); | |||
foreach (var item in result) | |||
{ | |||
var tag = tags.Where(x => x.MemberId == item.Id).ToList(); | |||
item.MemberTag = tag.Where(x => x.PlatformType == 0).ToList(); | |||
var re = platformMemberInfos.Where(x => x.MemberInfo_Id == item.Id).ToList(); | |||
if (re.Count > 0) | |||
{ | |||
var platformMember = re.Adapt<List<PlatformMemberInfoBaseDto>>(); | |||
platformMember.ForEach(obj => | |||
{ | |||
obj.MemberTag = tag.Where(x => x.PlatformType == obj.PlatformType).ToList(); | |||
}); | |||
item.PlatformMemberInfos = platformMember; | |||
} | |||
else | |||
{ | |||
item.PlatformMemberInfos = new List<PlatformMemberInfoBaseDto>(); | |||
} | |||
} | |||
return new PageUtil() | |||
{ | |||
Data = result, | |||
Total = total | |||
}; | |||
} | |||
/// <summary> | |||
/// 添加会员 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberInfoService/AddMember")] | |||
public async Task<bool> AddMember(CreateOrUpdateMemberInfoInputDto inputDto) | |||
{ | |||
try | |||
{ | |||
var result = true; | |||
db.Ado.BeginTran(); | |||
var memberInfo = await db.Queryable<BPA_MemberInfo>().FirstAsync(x => x.Phone == inputDto.Phone); | |||
if (memberInfo == null) | |||
{ | |||
//添加会员信息 | |||
memberInfo = inputDto.Adapt<BPA_MemberInfo>(); | |||
await db.Insertable(memberInfo).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||
} | |||
inputDto.MemberInfo_Id = memberInfo.Id; | |||
//添加平台会员 | |||
result = await AddPlatformMember(inputDto); | |||
////添加会员账户 | |||
//result = await AddMemberAccount(memberInfo.Id); | |||
db.Ado.CommitTran(); | |||
return result; | |||
} | |||
catch (Exception e) | |||
{ | |||
db.Ado.RollbackTran(); | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
/// 修改会员信息 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberInfoService/UpdateMemberInfo")] | |||
public async Task<bool> UpdateMemberInfo(CreateOrUpdateMemberInfoInputDto inputDto) | |||
{ | |||
if (inputDto.PlatformType == 0) | |||
{ | |||
var data = db.Queryable<BPA_MemberInfo>().First(x => x.Id == inputDto.MemberInfo_Id); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh($"会员不存在"); | |||
} | |||
data.Address = inputDto.Address; | |||
data.Birthday = inputDto.Birthday; | |||
data.CardNum = inputDto.CardNum; | |||
data.City = inputDto.City; | |||
data.Country = inputDto.Country; | |||
data.County = inputDto.County; | |||
data.HeadImgUrl = inputDto.HeadImgUrl; | |||
data.Level_Id = inputDto.Level_Id; | |||
data.NickName = inputDto.NickName; | |||
data.Phone = inputDto.Phone; | |||
data.Province = inputDto.Province; | |||
data.RealName = inputDto.RealName; | |||
data.Sex = inputDto.Sex; | |||
data.Status = inputDto.Status; | |||
data.ShowPlatformType = (int)inputDto.ShowPlatformType; | |||
////添加会员账户 | |||
//await AddMemberAccount(data.Id); | |||
return await db.Updateable(data).CallEntityMethod(m => m.Modify()).ExecuteCommandAsync() > 0; | |||
} | |||
else | |||
{ | |||
var data = db.Queryable<BPA_PlatformMemberInfo>().Where(x => x.MemberInfo_Id == inputDto.MemberInfo_Id && x.PlatformType == inputDto.PlatformType).First(); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh($"当前平台会员不存在"); | |||
} | |||
data.Address = inputDto.Address; | |||
data.Birthday = inputDto.Birthday; | |||
data.CardNum = inputDto.CardNum; | |||
data.City = inputDto.City; | |||
data.Country = inputDto.Country; | |||
data.County = inputDto.County; | |||
data.HeadImgUrl = inputDto.HeadImgUrl; | |||
data.Level_Id = inputDto.Level_Id; | |||
data.NickName = inputDto.NickName; | |||
data.Phone = inputDto.Phone; | |||
data.Province = inputDto.Province; | |||
data.RealName = inputDto.RealName; | |||
data.Sex = inputDto.Sex; | |||
data.Status = inputDto.Status; | |||
return await db.Updateable(data).CallEntityMethod(m => m.Modify()).ExecuteCommandAsync() > 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取所有会员标签,获取当前会员的绑定标签 | |||
/// </summary> | |||
/// <param name="memberInfoId">会员ID</param> | |||
/// <param name="PlatformType">0:系统平台 1.微信平台 2.支付宝平台 </param> | |||
/// <returns></returns> | |||
[HttpGet("/api/MemberInfoService/GetMemberTagAndInfo")] | |||
public async Task<List<MemberTagAndInfoOutDto>> GetMemberTagAndInfo(string memberInfoId, PlatformType PlatformType) | |||
{ | |||
var data = await db.Queryable<BPA_MemberTag>() | |||
.Where(x => x.IsDeleted == 0 && x.PlatformType == (int)PlatformType) | |||
.Select(x => new MemberTagAndInfoOutDto() | |||
{ | |||
Id = x.Id, | |||
Name = x.Name | |||
}).ToListAsync(); | |||
var memberTagInfo = db.Queryable<BPA_MemberTagInfo>() | |||
.Where(x => x.IsDeleted == 0 && x.MemberInfo_Id == memberInfoId && x.PlatformType == PlatformType).ToList(); | |||
foreach (var item in data) | |||
{ | |||
var entity = memberTagInfo.FirstOrDefault(x => x.MemberTag_Id == item.Id); | |||
if (entity != null) | |||
{ | |||
item.MemberTagInfoId = entity.Id; | |||
} | |||
} | |||
return data; | |||
} | |||
/// <summary> | |||
/// 根据ID获取会员其他平台的信息 | |||
/// </summary> | |||
/// <param name="memberId"></param> | |||
/// <returns></returns> | |||
[HttpGet("/api/MemberInfoService/GetPlatformMemberList")] | |||
public async Task<List<PlatformMemberInfoBaseDto>> GetPlatformMemberList(string memberId) | |||
{ | |||
var data = await db.Queryable<BPA_PlatformMemberInfo>().Where(x => x.MemberInfo_Id == memberId).ToListAsync(); | |||
var platformMember = data.Adapt<List<PlatformMemberInfoBaseDto>>(); | |||
//查询标签 | |||
var tags = db.Queryable<BPA_MemberTagInfo, BPA_MemberTag>((a, b) => new JoinQueryInfos( | |||
JoinType.Left, b.Id == a.MemberTag_Id | |||
)).Where((a, b) => memberId == a.MemberInfo_Id && a.IsDeleted == 0) | |||
.Select((a, b) => new MemberTagOutDto() | |||
{ | |||
Id = b.Id, | |||
Name = b.Name, | |||
Sort = b.Sort, | |||
MemberId = a.MemberInfo_Id, | |||
PlatformType = a.PlatformType | |||
}) | |||
.ToList(); | |||
platformMember.ForEach(obj => | |||
{ | |||
obj.MemberTag = tags.Where(x => x.PlatformType == obj.PlatformType).ToList(); | |||
}); | |||
return platformMember.Adapt<List<PlatformMemberInfoBaseDto>>(); | |||
} | |||
/// <summary> | |||
/// 查询会员标签信息 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberInfoService/GetMemberTag")] | |||
public PageUtil GetMemberTag(MemberTagQueryDto dto) | |||
{ | |||
List<IConditionalModel> conModels = new List<IConditionalModel>(); | |||
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||
if (!string.IsNullOrEmpty(dto.Name)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Equal, FieldValue = dto.Name.ToString() }); | |||
} | |||
if (!string.IsNullOrEmpty(dto.PlatformType)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "PlatformType", ConditionalType = ConditionalType.Equal, FieldValue = dto.PlatformType }); | |||
} | |||
if (!string.IsNullOrEmpty(dto.Status.ToString())) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status.ToString() }); | |||
} | |||
int total = new RefAsync<int>(); | |||
var res = db.Queryable<BPA_MemberTag>() | |||
.Where(a => a.IsDeleted == 0) | |||
.Where(conModels) | |||
.WhereIF(dto.CreateAt.HasValue, a => SqlFunc.DateIsSame(a.CreateAt, Convert.ToDateTime(dto.CreateAt), DateType.Day)) | |||
.OrderBy(x => x.CreateAt, OrderByType.Desc) | |||
.Select(t => new MemberTagQueryDto | |||
{ | |||
Id = t.Id, | |||
Name = t.Name, | |||
Sort = t.Sort, | |||
PlatformType = t.PlatformType.ToString(), | |||
CreateAt = t.CreateAt, | |||
Status = Convert.ToInt32(t.Status), | |||
}).ToPageList(dto.Current, dto.PageSize, ref total); | |||
return new PageUtil() | |||
{ | |||
Data = res, | |||
Total = total | |||
}; | |||
} | |||
/// <summary> | |||
/// 修改会员状态 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberInfoService/UpdateMemberStatus")] | |||
public async Task<bool> UpdateMemberStatus(MemberInfoBaseDto inputDto) | |||
{ | |||
if (!System.Enum.IsDefined(typeof(PlatformType), inputDto.PlatformType)) | |||
{ | |||
throw Oops.Oh($"平台错误"); | |||
} | |||
try | |||
{ | |||
db.BeginTran(); | |||
var data = db.Queryable<BPA_MemberInfo>().First(x => x.Id == inputDto.Id); | |||
var data2 = db.Queryable<BPA_PlatformMemberInfo>().Where(x => x.MemberInfo_Id == inputDto.Id).ToList(); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh($"会员不存在"); | |||
} | |||
if (inputDto.PlatformType == 0) | |||
{ | |||
data.Status = (CommonStatus)inputDto.Status; | |||
db.Updateable(data).CallEntityMethod(m => m.Modify()).ExecuteCommand(); | |||
} | |||
if (data2.Count > 0) | |||
{ | |||
//根据选择平台修改会员状态 | |||
data2 = data2.Where(x => inputDto.PlatformType == 1 ? (x.PlatformType == 1) : (x.PlatformType == 2 ? (x.PlatformType == 2) : true)).ToList(); | |||
data2.ForEach(item => | |||
{ | |||
item.Status = (CommonStatus)inputDto.Status; | |||
}); | |||
db.Updateable(data2).CallEntityMethod(m => m.Modify()).ExecuteCommand(); | |||
} | |||
db.CommitTran(); | |||
return await Task.FromResult(true); | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.RollbackTran(); | |||
//BPALog.WriteLog(msg + ":" + ex.Message, LogEnum.Error, null, ex); | |||
throw Oops.Oh(ex.Message); | |||
} | |||
} | |||
/// <summary> | |||
/// 修改会员标签 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberInfoService/UpdateMemberTag")] | |||
public async Task<bool> UpdateMemberTag(UpdateMemberTagInputDto inputDto) | |||
{ | |||
try | |||
{ | |||
db.BeginTran(); | |||
//查询当前会员绑定的标签 | |||
var data = db.Queryable<BPA_MemberTagInfo>() | |||
.Where(x => x.MemberInfo_Id == inputDto.MemberInfo_Id | |||
&& inputDto.PlatformType == x.PlatformType | |||
).ToList(); | |||
data.ForEach(item => | |||
{ | |||
item.IsDeleted = 1; | |||
}); | |||
//全部删除 | |||
db.Deleteable(data).ExecuteCommand(); | |||
//添加会员标签 | |||
foreach (var item in inputDto.Tags) | |||
{ | |||
db.Insertable(new BPA_MemberTagInfo() | |||
{ | |||
PlatformType = inputDto.PlatformType, | |||
MemberInfo_Id = inputDto.MemberInfo_Id, | |||
MemberTag_Id = item | |||
}).CallEntityMethod(m => m.Create()).ExecuteCommand(); | |||
} | |||
db.CommitTran(); | |||
return await Task.FromResult(true); | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.RollbackTran(); | |||
//BPALog.WriteLog(msg + ":" + ex.Message, LogEnum.Error, null, ex); | |||
throw Oops.Oh(ex.Message); | |||
} | |||
} | |||
/// <summary> | |||
/// 添加平台会员 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
private async Task<bool> AddPlatformMember(CreateOrUpdateMemberInfoInputDto inputDto) | |||
{ | |||
var memberInfo = db.Queryable<BPA_PlatformMemberInfo>().First(x => | |||
x.MemberInfo_Id == inputDto.MemberInfo_Id && x.PlatformType == inputDto.PlatformType); | |||
if (memberInfo != null) return false; | |||
var member = new BPA_PlatformMemberInfo() | |||
{ | |||
Address = inputDto.Address, | |||
Birthday = inputDto.Birthday, | |||
CardNum = inputDto.CardNum, | |||
City = inputDto.City, | |||
Country = inputDto.Country, | |||
County = inputDto.County, | |||
HeadImgUrl = inputDto.HeadImgUrl, | |||
Level_Id = inputDto.Level_Id, | |||
MemberInfo_Id = inputDto.MemberInfo_Id, | |||
NickName = inputDto.NickName, | |||
Phone = inputDto.Phone, | |||
PlatformMemberId = Guid.NewGuid().ToString(), | |||
PlatformType = inputDto.PlatformType, | |||
Province = inputDto.Province, | |||
RealName = inputDto.RealName, | |||
Sex = inputDto.Sex, | |||
Status = inputDto.Status, | |||
}; | |||
return await db.Insertable(member).CallEntityMethod(m => m.Create()).ExecuteCommandAsync() > 0; | |||
} | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
| |||
using System.ComponentModel.DataAnnotations; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberTag.Dtos | |||
{ | |||
/// <summary> | |||
/// MemberTagDto | |||
/// </summary> | |||
public class MemberTagDto | |||
{ | |||
/// <summary> | |||
/// 编号 | |||
/// </summary> | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 会员标签名称 | |||
/// </summary> | |||
[Required] | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 排序 | |||
/// </summary> | |||
//[Range(0, int.MaxValue, ErrorMessage = "排序必须大于0")] | |||
public int Sort { get; set; } = 0; | |||
/// <summary> | |||
/// 平台标签 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
//[Range(0, 4, ErrorMessage = "平台标签只能输入0,1,2")] | |||
public int PlatformType { get; set; } | |||
/// <summary> | |||
/// 状态 | |||
/// </summary> | |||
//[Range(0, 1, ErrorMessage = "状态只能输入0或者1")] | |||
public int Status { get; set; } | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberTag | |||
{ | |||
public interface IMemberTagService | |||
{ | |||
} | |||
} |
@@ -0,0 +1,163 @@ | |||
using BPA.KitChen.StoreManagement.Application.BaseDto; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberInfo.Dtos.MemberTag; | |||
using BPA.KitChen.StoreManagement.Application.Service.ShopManage.Member.MemberTag.Dtos; | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using BPA.KitChen.StoreManagement.SqlSugar; | |||
using Furion; | |||
using Furion.DependencyInjection; | |||
using Furion.DynamicApiController; | |||
using Furion.FriendlyException; | |||
using Furion.RemoteRequest; | |||
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.StoreManagement.Application.Service.ShopManage.Member.MemberTag | |||
{ | |||
[ApiDescriptionSettings("会员管理", Tag = "会员标签")] | |||
public class MemberTagService : SupperRepository, IDynamicApiController, IMemberTagService, ITransient | |||
{ | |||
private readonly SqlSugarScope db; | |||
public MemberTagService() | |||
{ | |||
db = SqlSugarDb.Db; // 推荐操作 | |||
} | |||
/// <summary> | |||
/// 查询会员标签信息 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberTagService/MemberTagQueryDto")] | |||
public PageUtil GetMemberTag(MemberTagQueryDto dto) | |||
{ | |||
List<IConditionalModel> conModels = new List<IConditionalModel>(); | |||
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||
if (!string.IsNullOrEmpty(dto.Name)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Like, FieldValue= dto.Name.ToString() }); | |||
} | |||
if (!string.IsNullOrEmpty(dto.PlatformType)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "PlatformType", ConditionalType = ConditionalType.Equal, FieldValue = dto.PlatformType }); | |||
} | |||
if (!string.IsNullOrEmpty(dto.Status.ToString())) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status.ToString() }); | |||
} | |||
int total = new RefAsync<int>(); | |||
var res = db.Queryable<BPA_MemberTag>() | |||
.Where(a => a.IsDeleted == 0) | |||
.Where(conModels) | |||
.WhereIF(dto.CreateAt.HasValue, a => SqlFunc.DateIsSame(a.CreateAt, Convert.ToDateTime(dto.CreateAt), DateType.Day)) | |||
.OrderBy(x => x.CreateAt, OrderByType.Desc) | |||
.Select(t => new MemberTagQueryDto | |||
{ | |||
Id = t.Id, | |||
Name = t.Name, | |||
Sort = t.Sort, | |||
PlatformType = t.PlatformType.ToString(), | |||
CreateAt = t.CreateAt, | |||
Status = Convert.ToInt32(t.Status), | |||
}).ToPageList(dto.Current, dto.PageSize, ref total); | |||
return new PageUtil() | |||
{ | |||
Data = res, | |||
Total = total | |||
}; | |||
} | |||
/// <summary> | |||
/// 添加会员标签信息 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberTagService/AddMemberTag")] | |||
public async Task<bool> AddMemberTag(MemberTagDto dto) | |||
{ | |||
var activityRecord = new BPA_MemberTag | |||
{ | |||
Name = dto.Name, | |||
Sort = dto.Sort, | |||
PlatformType =(int)dto.PlatformType, | |||
Status =(CommonStatus)dto.Status, | |||
}; | |||
var res = await db.Insertable(activityRecord).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||
return await Task.FromResult(res > 0); | |||
} | |||
/// <summary> | |||
/// 更新会员标签信息 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/MemberTagService/UpdateMemberTag")] | |||
public async Task<bool> UpdateMemberTag(MemberTagDto dto) | |||
{ | |||
try | |||
{ | |||
db.BeginTran(); | |||
var resEntity = db.Queryable<BPA_MemberTag>().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.Id); | |||
if (null == resEntity) | |||
{ | |||
return false; | |||
} | |||
resEntity.Name = dto.Name; | |||
resEntity.Sort = dto.Sort; | |||
resEntity.PlatformType = (int)dto.PlatformType; | |||
resEntity.Status =(CommonStatus) dto.Status; | |||
//if (!string.IsNullOrEmpty(dto.Status.ToString())) | |||
//{ | |||
//} | |||
var res = db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.Modify()).ExecuteCommand(); | |||
db.CommitTran(); | |||
return await Task.FromResult(res > 0); | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.RollbackTran(); | |||
//BPALog.WriteLog(msg + ":" + ex.Message, LogEnum.Error, null, ex); | |||
throw Oops.Oh(ex.Message); | |||
} | |||
} | |||
/// <summary> | |||
/// 删除会员标签信息 | |||
/// </summary> | |||
/// <param name="Id"></param> | |||
/// <returns></returns> | |||
[HttpDelete("/api/MemberTagService/DelMemberTag")] | |||
public bool DelMemberTag(string Id) | |||
{ | |||
// 查询数据库中是否存在未删除的活动参与记录信息 | |||
var resEntity = db.Queryable<BPA_MemberTag>().First(it => it.Id == Id); | |||
if (null == resEntity) | |||
{ | |||
return false; | |||
} | |||
resEntity.IsDeleted = 1; | |||
resEntity.Status = CommonStatus.DELETED; | |||
var res = db.Updateable(resEntity).CallEntityMethod(m => m.Delete()).ExecuteCommand(); | |||
return res > 0; | |||
} | |||
} | |||
} |
@@ -23,7 +23,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.TestService | |||
var types = Assembly.Load("BPA.KitChen.StoreManagement.Core").GetTypes() | |||
.Where(x => x.Namespace != null | |||
&& x.GetCustomAttribute<SugarTable>() != null | |||
&& x.Namespace.Contains("BPA.KitChen.StoreManagement.Core.Entity")) | |||
&& x.Namespace.Contains("BPA.KitChen.StoreManagement.Core.Entity.Coupon")) | |||
.ToArray(); | |||
SqlSugarDb.Db.CodeFirst.InitTables(types); | |||
} | |||
@@ -25,5 +25,9 @@ namespace BPA.KitChen.StoreManagement.Core.Entity | |||
[SugarColumn(ColumnDataType = "nvarchar(1000)")] | |||
public string DataResore { get; set; } | |||
public int DeviceAutoKey { get; set; } | |||
public string Description { get; set; } | |||
} | |||
} |
@@ -0,0 +1,91 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity | |||
{ | |||
/// <summary> | |||
/// 会员 | |||
/// </summary> | |||
[SugarTable("BPA_MemberInfo")] | |||
public class BPA_MemberInfo : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string NickName { get; set; } | |||
/// <summary> | |||
/// 0=未知 1=男 2=女 | |||
/// </summary> | |||
public int Sex { get; set; } | |||
/// <summary> | |||
/// 头像 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string HeadImgUrl { get; set; } | |||
/// <summary> | |||
/// 国家 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string Country { get; set; } | |||
/// <summary> | |||
/// 省 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string Province { get; set; } | |||
/// <summary> | |||
/// 市 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string City { get; set; } | |||
/// <summary> | |||
/// 县(区) | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string County { get; set; } | |||
/// <summary> | |||
/// 具体地址 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string Address { get; set; } | |||
/// <summary> | |||
/// 出生日期 | |||
/// </summary> | |||
public DateTime Birthday { get; set; } | |||
/// <summary> | |||
/// 电话 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string Phone { get; set; } | |||
/// <summary> | |||
/// 真实姓名 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string RealName { get; set; } | |||
/// <summary> | |||
/// 身份证号码 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string CardNum { get; set; } | |||
/// <summary> | |||
/// 等级 | |||
/// </summary> | |||
[SugarColumn(IsNullable = true)] | |||
public string Level_Id { get; set; } | |||
/// <summary> | |||
/// 向外展示那个平台的信息 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
public int ShowPlatformType { get; set; } | |||
/// <summary> | |||
/// 积分 | |||
/// </summary> | |||
public decimal Integral { get; set; } | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity | |||
{ | |||
/// <summary> | |||
/// 会员标签 | |||
/// </summary> | |||
[SugarTable("BPA_MemberTag")] | |||
public class BPA_MemberTag : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 会员标签名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 排序 | |||
/// </summary> | |||
public int Sort { get; set; } | |||
/// <summary> | |||
/// 平台标签 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
public int PlatformType { get; set; } | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
| |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using BPA.KitChen.StoreManagement.Core.Enum; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity | |||
{ | |||
/// <summary> | |||
/// 平台会员标签 | |||
/// </summary> | |||
[SugarTable("BPA_MemberTagInfo")] | |||
public class BPA_MemberTagInfo : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 会员标签Id | |||
/// </summary> | |||
public string MemberTag_Id { get; set; } | |||
/// <summary> | |||
/// 会员编号 | |||
/// </summary> | |||
public string MemberInfo_Id { get; set; } | |||
/// <summary> | |||
/// 平台标签 0:默认 1.微信 2.支付宝 | |||
/// </summary> | |||
public PlatformType PlatformType { get; set; } | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 优惠卷 | |||
/// </summary> | |||
[SugarTable("BPA_Coupon")] | |||
public class BPA_Coupon: IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 优惠券标题 | |||
/// </summary> | |||
public string CouponTitle { get; set; } | |||
/// <summary> | |||
/// 优惠券类型(1.满减优惠卷 2.代金优惠卷 3.无门槛优惠卷) | |||
/// </summary> | |||
public int CouponType { get; set; } | |||
/// <summary> | |||
/// 优惠券值(优惠金额) | |||
/// </summary> | |||
public decimal CouponValue { get; set; } | |||
/// <summary> | |||
/// 使用条件 | |||
/// </summary> | |||
public decimal Condition { get; set; } | |||
/// <summary> | |||
/// 使用时间的类型 1.时间范围内 2.固定期限 | |||
/// </summary> | |||
public int TimeType { get; set; } | |||
/// <summary> | |||
/// 固定期限值(如领取后10内有效) | |||
/// </summary> | |||
public int ValidFixedTerm { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public DateTime ValidStartTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime ValidEndTime { get; set; } | |||
/// <summary> | |||
/// 状态(1:生效、2:失效 3:作废 4.停用) | |||
/// </summary> | |||
public int ValidStatus { get; set; } | |||
/// <summary> | |||
/// 每人可领取数量 | |||
/// </summary> | |||
public int GetLimit { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
public string Remarks { get; set; } | |||
/// <summary> | |||
/// 创建人类型(0.供应商 1.平台) | |||
/// </summary> | |||
public int CreateType { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 客户领取表与店铺关系表 | |||
/// </summary> | |||
[SugarTable("BPA_CouponCustomerStore")] | |||
public class BPA_CouponCustomerStore:IBaseEntity | |||
{ | |||
public string StoreId { get; set; } | |||
public string Coupon_Customer_Id { get; set; } | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using Furion; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 优惠卷记录与区域店铺供应商关联关系表 | |||
/// </summary> | |||
[SugarTable("BPA_CouponGoodsRelations")] | |||
public class BPA_CouponGoodsRelations : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 范围Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Coupon_Range_Id { get; set; } | |||
/// <summary> | |||
/// 商品Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string GoodsId { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(255)", IsNullable = true)] | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 新增 | |||
/// </summary> | |||
public void Create() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.Id = Guid.NewGuid().ToString(); | |||
this.CreateAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.CreateBy = userId; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
[SugarTable("BPA_CouponLog")] | |||
public class BPA_CouponLog : IBaseEntity | |||
{ | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 客户Id -- 微信的OpenId | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string CustomerId { get; set; } | |||
/// <summary> | |||
/// 0表示退单反券 1表示订单完成 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "INT", IsNullable = true)] | |||
public int OrderType { get; set; } | |||
/// <summary> | |||
/// 券Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string CouponId { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(255)", IsNullable = true)] | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 订单时间 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "DATETIME", IsNullable = true)] | |||
public DateTime OrderTime { get; set; } | |||
/// <summary> | |||
/// 客户领券表Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string Coupon_Customer_Id { get; set; } | |||
} | |||
} |
@@ -0,0 +1,89 @@ | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using Furion; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 优惠券发放记录表 | |||
/// </summary> | |||
[SugarTable("BPA_CouponRange")] | |||
public class BPA_CouponRange : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 发放数量 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "INT", IsNullable = false)] | |||
public int SendNum { get; set; } | |||
/// <summary> | |||
/// 批次号 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string BatchNo { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Coupon_Id { get; set; } | |||
/// <summary> | |||
/// 适用范围类型 1.店铺 2.供应商 3.区域 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "INT", IsNullable = false)] | |||
public int RangeType { get; set; } | |||
/// <summary> | |||
/// 创建人类型(0.供应商 1.平台) | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "INT", IsNullable = false)] | |||
public int CreateType { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(255)", IsNullable = true)] | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 新增 | |||
/// </summary> | |||
public void Create() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.Id = Guid.NewGuid().ToString(); | |||
this.CreateAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.CreateBy = userId; | |||
} | |||
} | |||
/// <summary> | |||
/// 修改 | |||
/// </summary> | |||
public void Modify() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.UpdateAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.UpdateBy = userId; | |||
} | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
public void Delete() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.DeleteAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.DeleteBy = userId; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using Furion; | |||
using SqlSugar; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 优惠卷记录与区域店铺供应商关联关系表 | |||
/// </summary> | |||
[SugarTable("BPA_CouponRangeRelations")] | |||
public class BPA_CouponRangeRelations : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 范围Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Coupon_Range_Id { get; set; } | |||
/// <summary> | |||
/// 店铺Id,区域id或供应商id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string RangeTypeId { get; set; } | |||
/// <summary> | |||
/// 备注 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(255)", IsNullable = true)] | |||
public string Remark { get; set; } | |||
/// <summary> | |||
/// 新增 | |||
/// </summary> | |||
public void Create() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.Id = Guid.NewGuid().ToString(); | |||
this.CreateAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.CreateBy = userId; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,110 @@ | |||
using Furion; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.KitChen.StoreManagement.Core.Common.Const; | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 顾客优惠券 | |||
/// </summary> | |||
[SugarTable("BPA_CustomerCoupon")] | |||
public class BPA_CustomerCoupon: IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 客户Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)",IsNullable =false)] | |||
public string Customer_Id { get; set; } | |||
/// <summary> | |||
/// 订单Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string Order_Id { get; set; } | |||
/// <summary> | |||
/// 领取方式(1.小程序领取 2.线下门店扫码 3.活动自动下发 4.好友分享领取 5.指定发放) | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "INT", IsNullable = false,ColumnName = "ReceiveType")] | |||
public int Receive_Type { get; set; } | |||
/// <summary> | |||
/// 优惠券Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Coupon_Id { get; set; } | |||
/// <summary> | |||
/// 状态(1:未使用 2.已核销 3.占用中 4.失效) | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "INT", IsNullable = true)] | |||
public int State { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "DATETIME", IsNullable = false,ColumnName = "ValidStartTime")] | |||
public DateTime Valid_StartTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "DATETIME", IsNullable = false, ColumnName = "ValidEndTime")] | |||
public DateTime Valid_EndTime { get; set; } | |||
/// <summary> | |||
/// 核销时间 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "DATETIME", IsNullable = true)] | |||
public DateTime? WriteOffTime { get; set; } | |||
/// <summary> | |||
/// 范围Id | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Coupon_Range_Id { get; set; } | |||
/// <summary> | |||
/// 用户手机号 | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string CustomerPhone { get; set; } | |||
/// <summary> | |||
/// 新增 | |||
/// </summary> | |||
public void Create() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.Id = Guid.NewGuid().ToString(); | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.CreateBy = userId; | |||
} | |||
} | |||
/// <summary> | |||
/// 修改 | |||
/// </summary> | |||
public void Modify() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.UpdateAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.UpdateBy = userId; | |||
} | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
public void Delete() | |||
{ | |||
var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||
this.DeleteAt = DateTime.Now; | |||
if (!string.IsNullOrEmpty(userId)) | |||
{ | |||
this.DeleteBy = userId; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
[SugarTable("BPA_GoodsCoupon")] | |||
public class BPA_GoodsCoupon: IBaseEntity | |||
{ | |||
/// <summary> | |||
/// 商品id | |||
/// </summary> | |||
public string GoodsId { get; set; } | |||
public string StoreId { get; set; } | |||
/// <summary> | |||
/// 标题 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 商品名称 | |||
/// </summary> | |||
public string GoodsName { get; set; } | |||
/// <summary> | |||
/// 类型(平台)id | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
/// <summary> | |||
/// 原始金额 | |||
/// </summary> | |||
public decimal Money { get; set; } | |||
/// <summary> | |||
/// 平台金额 | |||
/// </summary> | |||
public decimal SoureMoney { get; set; } | |||
/// <summary> | |||
/// 加盟商id | |||
/// </summary> | |||
public string GroupId { get; set; } | |||
public DateTime CrateTimeAt { get; set; } | |||
/// <summary> | |||
/// 是否启用 | |||
/// </summary> | |||
public bool Enable { get; set; } | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
[SugarTable("bpa_goodscouponwriteofflog")] | |||
public class BPA_GoodsCouponWriteoffLog : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 订单ID | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 优惠券ID | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string GoodsCouponId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 纸质优惠卷 | |||
/// </summary> | |||
[SugarTable("bpa_papercoupon")] | |||
public class BPA_PaperCoupon: IBaseEntity | |||
{ | |||
/// <summary> | |||
/// 标题 | |||
/// </summary> | |||
public string Title { get; set; } | |||
/// <summary> | |||
/// 类型 | |||
/// </summary> | |||
public string CTypeId { get; set; } | |||
/// <summary> | |||
/// 金额 | |||
/// </summary> | |||
public decimal Money { get; set; } | |||
/// <summary> | |||
/// 平台金额 | |||
/// </summary> | |||
public decimal SoureMoney { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public DateTime CrateTimeAt { get; set; } | |||
public string GroupId { get; set; } | |||
public bool Enable { get; set; } | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
/// <summary> | |||
/// 纸质优惠卷类型 | |||
/// </summary> | |||
[SugarTable("bpa_papercoupontype")] | |||
public class BPA_PaperCouponType: IBaseEntity | |||
{ | |||
/// <summary> | |||
/// 类型名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
using BPA.KitChen.StoreManagement.Core.Entity.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Entity.Coupon | |||
{ | |||
[SugarTable("BPA_PaperCouponWriteoffLog")] | |||
public class BPA_PaperCouponWriteoffLog : IBaseGroupIdEntity | |||
{ | |||
/// <summary> | |||
/// 订单ID | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string OrderId { get; set; } | |||
/// <summary> | |||
/// 优惠券ID | |||
/// </summary> | |||
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = true)] | |||
public string PaperCouponId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Enum | |||
{ | |||
public enum E_CouponGitType | |||
{ | |||
小程序领取 = 1, | |||
线下门店扫码 = 2, | |||
活动下发 = 3, | |||
好友分享领取 = 4, | |||
指定领取 = 5, | |||
参与活动 = 6, | |||
商城兑换=7, | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Enum | |||
{ | |||
public enum E_CouponStatus | |||
{ | |||
/// <summary> | |||
/// 生效 | |||
/// </summary> | |||
[Description("生效")] | |||
生效=1, | |||
/// <summary> | |||
/// 生效 | |||
/// </summary> | |||
[Description("失效")] | |||
失效 = 2, | |||
/// <summary> | |||
/// 作废 | |||
/// </summary> | |||
[Description("作废")] | |||
作废 =3 | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.KitChen.StoreManagement.Core.Enum | |||
{ | |||
public enum E_CouponType | |||
{ | |||
/// <summary> | |||
/// 生效 | |||
/// </summary> | |||
[Description("满减优惠卷")] | |||
满减优惠卷=1, | |||
/// <summary> | |||
/// 生效 | |||
/// </summary> | |||
[Description("代金卷")] | |||
代金卷 = 2, | |||
/// <summary> | |||
/// 作废 | |||
/// </summary> | |||
[Description("无门槛优惠卷")] | |||
无门槛优惠卷 = 3 | |||
} | |||
} |