feat 添加优惠券记录管理,优惠券列表展示领取数量
This commit is contained in:
parent
6136cacff5
commit
e56330d530
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
|
||||
namespace ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录输入对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
public class CustomerCouponDto
|
||||
{
|
||||
|
||||
public int CustomerCouponId { get; set; }
|
||||
|
||||
public long CustomerCouponGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "优惠劵guid不能为空")]
|
||||
public long CouponGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "客户guid不能为空")]
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "是否过期不能为空")]
|
||||
public int CustomerCouponIsExpired { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "是否已使用不能为空")]
|
||||
public int CustomerCouponIsUsed { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 领券记录查询对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
public class CustomerCouponQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public int? CustomerCouponIsExpired { get; set; }
|
||||
|
||||
public int? CustomerCouponIsUsed { get; set; }
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -166,7 +166,7 @@ namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "已领取数量")]
|
||||
[SugarColumn(ColumnName = "coupon_get_number")]
|
||||
public int? CouponGetNumber { get; set; }
|
||||
public int CouponGetNumber { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录,数据实体对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
[SugarTable("tb_customer_coupon")]
|
||||
public class CustomerCoupon : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "customer_coupon_id")]
|
||||
public int CustomerCouponId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "customer_coupon_guid")]
|
||||
public long CustomerCouponGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "coupon_guid")]
|
||||
public long CouponGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :客户guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "customer_guid")]
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否过期
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "customer_coupon_is_expired")]
|
||||
public int CustomerCouponIsExpired { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否已使用
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "customer_coupon_is_used")]
|
||||
public int CustomerCouponIsUsed { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -105,6 +105,11 @@ namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons
|
||||
[EpplusIgnore]
|
||||
public int? CouponApplicableScope { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :领取数量
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "领取数量")]
|
||||
public int CouponGetNumber { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -0,0 +1,59 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录展示对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
public class CustomerCouponVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
public int CustomerCouponId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long CustomerCouponGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long CouponGuid { get; set; }
|
||||
|
||||
public string CouponName{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :客户guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
public string CustomerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否过期
|
||||
/// </summary>
|
||||
public int CustomerCouponIsExpired { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否已使用
|
||||
/// </summary>
|
||||
public int CustomerCouponIsUsed { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
|
||||
namespace ARW.Repository.Business.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录仓储
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class CustomerCouponRepository : BaseRepository<CustomerCoupon>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -69,6 +69,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
CouponFixedEndTime = s.CouponFixedEndTime,
|
||||
CouponApplicableScope = s.CouponApplicableScope,
|
||||
CouponSendNumber = s.CouponSendNumber,
|
||||
CouponGetNumber = s.CouponGetNumber,
|
||||
CouponDisplayStatus = s.CouponDisplayStatus,
|
||||
CouponSort = s.CouponSort,
|
||||
CouponApplicableScopeConfig = s.CouponApplicableScopeConfig,
|
||||
|
@ -0,0 +1,110 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using ARW.Model;
|
||||
using ARW.Repository;
|
||||
using ARW.Repository.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Service.Business.IBusinessService.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Model.Vo.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Repository.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Custom.Customers;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录接口实现类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ICustomerCouponService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class CustomerCouponServiceImpl : BaseService<CustomerCoupon>, ICustomerCouponService
|
||||
{
|
||||
private readonly CustomerCouponRepository _CustomerCouponRepository;
|
||||
private readonly CouponRepository _CouponRepository;
|
||||
|
||||
public CustomerCouponServiceImpl(CustomerCouponRepository CustomerCouponRepository, CouponRepository couponRepository)
|
||||
{
|
||||
this._CustomerCouponRepository = CustomerCouponRepository;
|
||||
_CouponRepository = couponRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询领券记录分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<CustomerCouponVo>> GetCustomerCouponList(CustomerCouponQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<CustomerCoupon>();
|
||||
|
||||
predicate = predicate.AndIF(parm.CustomerCouponIsExpired != null, s => s.CustomerCouponIsExpired == parm.CustomerCouponIsExpired);
|
||||
predicate = predicate.AndIF(parm.CustomerCouponIsUsed != null, s => s.CustomerCouponIsUsed == parm.CustomerCouponIsUsed);
|
||||
var query = _CustomerCouponRepository
|
||||
.Queryable()
|
||||
.LeftJoin<Customer>((s, c) => s.CustomerGuid == c.CustomerGuid)
|
||||
.LeftJoin<Coupon>((s, c, d) => s.CouponGuid == d.CouponGuid)
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
||||
.Select((s, c, d) => new CustomerCouponVo
|
||||
{
|
||||
CustomerCouponId = s.CustomerCouponId,
|
||||
CustomerCouponGuid = s.CustomerCouponGuid,
|
||||
CouponName = d.CouponName,
|
||||
CustomerName = c.CustomerNickname,
|
||||
CouponGuid = s.CouponGuid,
|
||||
CustomerGuid = s.CustomerGuid,
|
||||
CustomerCouponIsExpired = s.CustomerCouponIsExpired,
|
||||
CustomerCouponIsUsed = s.CustomerCouponIsUsed,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改领券记录
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateCustomerCoupon(CustomerCoupon model)
|
||||
{
|
||||
if (model.CustomerCouponId != 0)
|
||||
{
|
||||
var response = await _CustomerCouponRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
var response = await _CustomerCouponRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
if (response != 0)
|
||||
{
|
||||
await _CouponRepository.UpdateAsync(f => new Coupon
|
||||
{
|
||||
CouponGetNumber = f.CouponGetNumber + 1
|
||||
}, s => s.CouponGuid == model.CouponGuid);
|
||||
}
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Model.Vo.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录接口类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
public interface ICustomerCouponService : IBaseService<CustomerCoupon>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取领券记录分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<CustomerCouponVo>> GetCustomerCouponList(CustomerCouponQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改领券记录
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateCustomerCoupon(CustomerCoupon parm);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ARW.Admin.WebApi.Extensions;
|
||||
using ARW.Admin.WebApi.Filters;
|
||||
using ARW.Common;
|
||||
using ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Service.Business.IBusinessService.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Model.Vo.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.CustomerCoupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 领券记录控制器
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-31
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/[controller]")]
|
||||
public class CustomerCouponController : BaseController
|
||||
{
|
||||
private readonly ICustomerCouponService _CustomerCouponService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="CustomerCouponService">领券记录服务</param>
|
||||
public CustomerCouponController(ICustomerCouponService CustomerCouponService)
|
||||
{
|
||||
_CustomerCouponService = CustomerCouponService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取领券记录列表
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCustomerCouponList")]
|
||||
[ActionPermissionFilter(Permission = "business:customercoupon:list")]
|
||||
public async Task<IActionResult> GetCustomerCouponList([FromQuery] CustomerCouponQueryDto parm)
|
||||
{
|
||||
var res = await _CustomerCouponService.GetCustomerCouponList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改领券记录
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateCustomerCoupon")]
|
||||
[ActionPermissionFilter(Permission = "business:customercoupon:addOrUpdate")]
|
||||
[Log(Title = "添加或修改领券记录", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateCustomerCoupon([FromBody] CustomerCouponDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new CustomerCoupon();
|
||||
if (parm.CustomerCouponId != 0) modal = parm.Adapt<CustomerCoupon>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<CustomerCoupon>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _CustomerCouponService.AddOrUpdateCustomerCoupon(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除领券记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:customercoupon:delete")]
|
||||
[Log(Title = "领券记录删除", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult Delete(string ids)
|
||||
{
|
||||
long[] idsArr = Tools.SpitLongArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
var response = _CustomerCouponService.Delete(idsArr);
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user