feat 初始化优惠券api接口
This commit is contained in:
parent
e9ee2fa7df
commit
be2e90d3aa
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Marketing.CouponManage.Coupons
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 优惠券查询对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-08-01
|
||||
/// </summary>
|
||||
public class CouponQueryDtoApi : PagerInfo
|
||||
{
|
||||
public string CouponName { get; set; }
|
||||
public int? CouponType { get; set; }
|
||||
public int? CouponExpireType { get; set; }
|
||||
public int? CouponApplicableScope { get; set; }
|
||||
public int? CouponDisplayStatus { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 优惠券详情输入对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-08-01
|
||||
/// </summary>
|
||||
public class CouponDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "CouponGuid不能为空")]
|
||||
public long CouponGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
182
ARW.Model/Vo/Api/Marketing/CouponManage/Coupons/CouponApiVo.cs
Normal file
182
ARW.Model/Vo/Api/Marketing/CouponManage/Coupons/CouponApiVo.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Api.Marketing.CouponManage.Coupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 优惠券展示对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-08-01
|
||||
/// </summary>
|
||||
public class CouponVoApi
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int CouponId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long CouponGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "优惠劵名称")]
|
||||
public string CouponName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵类型
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "优惠劵类型")]
|
||||
public int CouponType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :减免金额
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public decimal CouponDeductionMoney { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :折扣率
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public float CouponDiscountRate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :最低消费金额
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "最低消费金额")]
|
||||
public decimal CouponMinConsumeMoney { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :到期类型
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "到期类型")]
|
||||
public int CouponExpireType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :有效天数
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int? CouponEffectiveDays { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :固定时间-开始时间
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public DateTime? CouponFixedStartTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :固定时间-结束时间
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public DateTime? CouponFixedEndTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :适用范围
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int? CouponApplicableScope { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :发送数量(-1不限制)
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "发送数量(-1不限制)")]
|
||||
public int CouponSendNumber { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :显示状态
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "显示状态")]
|
||||
public int CouponDisplayStatus { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int CouponSort { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 优惠券详情展示对象Api
|
||||
/// </summary>
|
||||
public class CouponApiDetailsVo
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 : Key
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long Key { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵类型
|
||||
/// </summary>
|
||||
public int Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵状态
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :折扣或者满减值
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :描述
|
||||
/// </summary>
|
||||
public string Desc { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :订单底价,满n元
|
||||
/// </summary>
|
||||
public decimal Base { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :有效时间限制
|
||||
/// </summary>
|
||||
public string TimeLimit { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
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 ARW.Model;
|
||||
using ARW.Repository;
|
||||
using ARW.Repository.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Service.Api.IBusinessService.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Dto.Api.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.Coupons;
|
||||
using Senparc.Weixin.WxOpen.AdvancedAPIs.Tcb;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.Coupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 优惠券接口实现类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-08-01
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ICouponServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||
public class CouponServiceImplApi : BaseService<Coupon>, ICouponServiceApi
|
||||
{
|
||||
private readonly CouponRepository _CouponRepository;
|
||||
|
||||
public CouponServiceImplApi(CouponRepository CouponRepository)
|
||||
{
|
||||
this._CouponRepository = CouponRepository;
|
||||
}
|
||||
|
||||
#region Api接口代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询优惠券列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedInfo<CouponVoApi>> GetCouponListApi(CouponQueryDtoApi parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Coupon>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CouponName), s => s.CouponName == parm.CouponName);
|
||||
predicate = predicate.AndIF(parm.CouponType != null, s => s.CouponType == parm.CouponType);
|
||||
predicate = predicate.AndIF(parm.CouponExpireType != null, s => s.CouponExpireType == parm.CouponExpireType);
|
||||
predicate = predicate.AndIF(parm.CouponApplicableScope != null, s => s.CouponApplicableScope == parm.CouponApplicableScope);
|
||||
predicate = predicate.AndIF(parm.CouponDisplayStatus != null, s => s.CouponDisplayStatus == parm.CouponDisplayStatus);
|
||||
var query = _CouponRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.CouponSort, OrderByType.Desc)
|
||||
.Select(s => new CouponVoApi
|
||||
{
|
||||
CouponId = s.CouponId,
|
||||
CouponGuid = s.CouponGuid,
|
||||
CouponName = s.CouponName,
|
||||
CouponType = s.CouponType,
|
||||
CouponDeductionMoney = s.CouponDeductionMoney,
|
||||
CouponDiscountRate = s.CouponDiscountRate,
|
||||
CouponMinConsumeMoney = s.CouponMinConsumeMoney,
|
||||
CouponExpireType = s.CouponExpireType,
|
||||
CouponEffectiveDays = s.CouponEffectiveDays,
|
||||
CouponFixedStartTime = s.CouponFixedStartTime,
|
||||
CouponFixedEndTime = s.CouponFixedEndTime,
|
||||
CouponApplicableScope = s.CouponApplicableScope,
|
||||
CouponSendNumber = s.CouponSendNumber,
|
||||
CouponDisplayStatus = s.CouponDisplayStatus,
|
||||
CouponSort = s.CouponSort,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询优惠券详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetCouponDetails(CouponDtoApi parm)
|
||||
{
|
||||
|
||||
var query = _CouponRepository
|
||||
.Queryable()
|
||||
.Where(s => s.CouponGuid == parm.CouponGuid)
|
||||
.Select(s => new CouponApiDetailsVo
|
||||
{
|
||||
Key = s.CouponGuid,
|
||||
Type = s.CouponType,
|
||||
Value = s.CouponDeductionMoney != 0 ? s.CouponDeductionMoney.ToString() : s.CouponDiscountRate.ToString(),
|
||||
Desc = s.CouponDesc,
|
||||
Title = s.CouponName,
|
||||
Base = s.CouponMinConsumeMoney,
|
||||
CreateTime = s.Create_time
|
||||
}).Take(1);
|
||||
|
||||
|
||||
return await query.ToJsonAsync();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.Coupons;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.Marketing.CouponManage.Coupons
|
||||
{
|
||||
/// <summary>
|
||||
/// 优惠券接口类Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-08-01
|
||||
/// </summary>
|
||||
public interface ICouponServiceApi : IBaseService<Coupon>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取优惠券分页列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<CouponVoApi>> GetCouponListApi(CouponQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取优惠券详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetCouponDetails(CouponDtoApi parm);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
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.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Dto.Api.Marketing.CouponManage.Coupons;
|
||||
using ARW.Service.Api.IBusinessService.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.Coupons;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.Marketing.CouponManage.Coupons
|
||||
{
|
||||
/// <summary>f
|
||||
/// 优惠券控制器Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-08-01
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class CouponApiController : BaseController
|
||||
{
|
||||
private readonly ICouponServiceApi _CouponServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="CouponServiceApi">优惠券优惠券Api服务</param>
|
||||
public CouponApiController(ICouponServiceApi CouponServiceApi)
|
||||
{
|
||||
_CouponServiceApi = CouponServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取优惠券列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCouponList")]
|
||||
public async Task<IActionResult> GetCouponListApi([FromQuery] CouponQueryDtoApi parm)
|
||||
{
|
||||
var res = await _CouponServiceApi.GetCouponListApi(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Coupon详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCouponDetails")]
|
||||
public async Task<IActionResult> GetCouponDetails([FromQuery] CouponDtoApi parm)
|
||||
{
|
||||
//if (parm == null) throw new CustomException("参数错误!");
|
||||
|
||||
var res = await _CouponServiceApi.GetCouponDetails(parm);
|
||||
|
||||
if (res != "[]")
|
||||
{
|
||||
res = res.Remove(0, 1);
|
||||
res = res.Substring(0, res.Length - 1);
|
||||
var data = res.FromJSON<CouponApiDetailsVo>();
|
||||
return SUCCESS(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUCCESS(res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user