diff --git a/ARW.Model/Dto/Api/Marketing/CouponManage/Coupons/CouponApiDto.cs b/ARW.Model/Dto/Api/Marketing/CouponManage/Coupons/CouponApiDto.cs index 5530f41..2a83a76 100644 --- a/ARW.Model/Dto/Api/Marketing/CouponManage/Coupons/CouponApiDto.cs +++ b/ARW.Model/Dto/Api/Marketing/CouponManage/Coupons/CouponApiDto.cs @@ -14,6 +14,7 @@ namespace ARW.Model.Dto.Api.Marketing.CouponManage.Coupons /// public class CouponQueryDtoApi : PagerInfo { + public long CustomerGuid { get; set; } public long ShopGuid { get; set; } public string CouponName { get; set; } public int? CouponType { get; set; } diff --git a/ARW.Model/Dto/Business/Marketing/CouponManage/CustomerCoupons/CustomerCouponDto.cs b/ARW.Model/Dto/Business/Marketing/CouponManage/CustomerCoupons/CustomerCouponDto.cs index 03abc49..f6e818f 100644 --- a/ARW.Model/Dto/Business/Marketing/CouponManage/CustomerCoupons/CustomerCouponDto.cs +++ b/ARW.Model/Dto/Business/Marketing/CouponManage/CustomerCoupons/CustomerCouponDto.cs @@ -21,13 +21,10 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons [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; } diff --git a/ARW.Model/Vo/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiVo.cs b/ARW.Model/Vo/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiVo.cs index 1c90d0d..77f561f 100644 --- a/ARW.Model/Vo/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiVo.cs +++ b/ARW.Model/Vo/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiVo.cs @@ -18,7 +18,6 @@ namespace ARW.Model.Vo.Api.Marketing.CouponManage.CustomerCoupons /// 描述 : CouponGuid /// [JsonConverter(typeof(ValueToStringConverter))] - [JsonIgnore] public long CouponGuid { get; set; } diff --git a/ARW.Service/Api/BusinessService/Marketing/CouponManage/Coupons/CouponServiceApi.cs b/ARW.Service/Api/BusinessService/Marketing/CouponManage/Coupons/CouponServiceApi.cs index bf946d0..b15b6dd 100644 --- a/ARW.Service/Api/BusinessService/Marketing/CouponManage/Coupons/CouponServiceApi.cs +++ b/ARW.Service/Api/BusinessService/Marketing/CouponManage/Coupons/CouponServiceApi.cs @@ -29,10 +29,12 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.Coupons public class CouponServiceImplApi : BaseService, ICouponServiceApi { private readonly CouponRepository _CouponRepository; + private readonly CustomerCouponRepository _CustomerCouponRepository; - public CouponServiceImplApi(CouponRepository CouponRepository) + public CouponServiceImplApi(CouponRepository CouponRepository, CustomerCouponRepository customerCouponRepository) { this._CouponRepository = CouponRepository; + _CustomerCouponRepository = customerCouponRepository; } #region Api接口代码 @@ -85,6 +87,12 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.Coupons item.TimeLimit = firstTime + "-" + lastTime; } + // 处理领取状态 + var customerCoupon = await _CustomerCouponRepository.GetFirstAsync(s => s.CouponGuid == item.CouponGuid && s.CustomerGuid == parm.CustomerGuid); + if (customerCoupon != null) + item.Status = 5; + else item.Status = 4; + } diff --git a/ARW.Service/Api/BusinessService/Marketing/CouponManage/CustomerCoupons/CustomerCouponServiceApi.cs b/ARW.Service/Api/BusinessService/Marketing/CouponManage/CustomerCoupons/CustomerCouponServiceApi.cs index 502bd21..af069e8 100644 --- a/ARW.Service/Api/BusinessService/Marketing/CouponManage/CustomerCoupons/CustomerCouponServiceApi.cs +++ b/ARW.Service/Api/BusinessService/Marketing/CouponManage/CustomerCoupons/CustomerCouponServiceApi.cs @@ -115,6 +115,28 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.CustomerCoupons return list; } + + + /// + /// 领取优惠券 + /// + public async Task AddCustomerCoupon(CustomerCoupon model) + { + model.CustomerCouponIsExpired = 1; + model.CustomerCouponIsUsed = 1; + + 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 "领取成功"; + } + + /// /// 查询领券记录详情(Api) /// diff --git a/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs b/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs index a9f5d9a..a5acbdb 100644 --- a/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs +++ b/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs @@ -120,8 +120,8 @@ namespace ARW.Service.Api.BusinessService.PaymentManage // 获取金额 - var price = 1;//单位:分 - //int price = (int)(afterPriceRes.DiscountPrice * 100);//单位:分 + //var price = 1;//单位:分 + int price = (int)(afterPriceRes.DiscountPrice * 100);//单位:分 // 生成订单号 diff --git a/ARW.Service/Api/IBusinessService/Marketing/CouponManage/CustomerCoupons/ICustomerCouponServiceApi.cs b/ARW.Service/Api/IBusinessService/Marketing/CouponManage/CustomerCoupons/ICustomerCouponServiceApi.cs index 1bc9e09..b7ff98b 100644 --- a/ARW.Service/Api/IBusinessService/Marketing/CouponManage/CustomerCoupons/ICustomerCouponServiceApi.cs +++ b/ARW.Service/Api/IBusinessService/Marketing/CouponManage/CustomerCoupons/ICustomerCouponServiceApi.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using ARW.Model; using ARW.Model.Dto.Api.Marketing.CouponManage.CustomerCoupons; +using ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons; using ARW.Model.Models.Business.Marketing.CouponManage.CustomerCoupons; using ARW.Model.Vo.Api.Marketing.CouponManage.CustomerCoupons; @@ -25,7 +26,16 @@ namespace ARW.Service.Api.IBusinessService.Marketing.CouponManage.CustomerCoupon /// Task> GetCustomerCouponListApi(CustomerCouponQueryDtoApi parm); - /// + + /// + /// 领取优惠券 + /// + /// + /// + Task AddCustomerCoupon(CustomerCoupon parm); + + + /// /// 获取领券记录详情(Api) /// /// diff --git a/ARW.WebApi/Controllers/Api/Marketing/CouponManage/Coupons/CouponApiController.cs b/ARW.WebApi/Controllers/Api/Marketing/CouponManage/Coupons/CouponApiController.cs index 3e87ffe..2824c4c 100644 --- a/ARW.WebApi/Controllers/Api/Marketing/CouponManage/Coupons/CouponApiController.cs +++ b/ARW.WebApi/Controllers/Api/Marketing/CouponManage/Coupons/CouponApiController.cs @@ -15,6 +15,7 @@ using ARW.Model.Models.Business.Marketing.CouponManage.Coupons; using ARW.Model.Vo.Api.Marketing.CouponManage.Coupons; using Microsoft.AspNetCore.Authorization; using Geocoding; +using ARW.Admin.WebApi.Framework; namespace ARW.WebApi.Controllers.Api.Marketing.CouponManage.Coupons { @@ -48,6 +49,8 @@ namespace ARW.WebApi.Controllers.Api.Marketing.CouponManage.Coupons [HttpGet("getCouponList")] public async Task GetCouponListApi([FromQuery] CouponQueryDtoApi parm) { + var user = JwtUtil.GetLoginUser(App.HttpContext); + parm.CustomerGuid = user.UserId; var res = await _CouponServiceApi.GetCouponListApi(parm); return SUCCESS(res); } diff --git a/ARW.WebApi/Controllers/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiController.cs b/ARW.WebApi/Controllers/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiController.cs index 7a2c24f..a498374 100644 --- a/ARW.WebApi/Controllers/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiController.cs +++ b/ARW.WebApi/Controllers/Api/Marketing/CouponManage/CustomerCoupons/CustomerCouponApiController.cs @@ -16,6 +16,8 @@ using ARW.Model.Vo.Api.Marketing.CouponManage.CustomerCoupons; using Microsoft.AspNetCore.Authorization; using Geocoding; using ARW.Admin.WebApi.Framework; +using ARW.Model.Dto.Business.Marketing.CouponManage.CustomerCoupons; +using ARW.Service.Business.IBusinessService.Marketing.CouponManage.CustomerCoupons; namespace ARW.WebApi.Controllers.Api.Marketing.CouponManage.CustomerCoupons { @@ -55,7 +57,28 @@ namespace ARW.WebApi.Controllers.Api.Marketing.CouponManage.CustomerCoupons return SUCCESS(res); } - /// + + /// + /// 领取优惠券 + /// + /// + /// + [HttpPost("addCustomerCoupon")] + [Log(Title = "领取优惠券", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddCustomerCoupon([FromBody] CustomerCouponDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + var user = JwtUtil.GetLoginUser(App.HttpContext); + parm.CustomerGuid = user.UserId; + + var modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _CustomerCouponServiceApi.AddCustomerCoupon(modal); + return SUCCESS(res); + } + + + /// /// 获取CustomerCoupon详情(Api) /// /// 查询参数 diff --git a/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs b/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs index ef375ae..d7aec21 100644 --- a/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs +++ b/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs @@ -80,8 +80,8 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay var payment = await _PayServiceApi.GetFirstAsync(s => s.PaymentGuid == order.PaymentGuid); // 获取金额 - var price = 1;//单位:分 - //var price = payment.PaymentBeforeMoney;//单位:分 + //var price = 1;//单位:分 + var price = (int)(payment.PaymentBeforeMoney * 100);//单位:分 var orderNo = Common.Common.CreateNoQuery();