Commit db34dcf7 by 章家宝

feat:优惠券需求,优惠券模板手动发放

1 parent 7f0e1646
......@@ -134,7 +134,7 @@ public class CouponDistributionRecord extends AuditingEntity implements Serializ
private BigDecimal faceAmount;
/**
* 发放备注(后台可见)
* 发放备注(后台可见,最多200个字符)
*/
@JsonView(value = Summary.class)
@Column(name = "distribution_remark", nullable = true, length = 200)
......
......@@ -3,6 +3,8 @@ package com.glsx.usedcar.module.coupon.service;
import cn.hutool.core.util.StrUtil;
import com.glsx.usedcar.converts.CouponConverter;
import com.glsx.usedcar.enums.common.DeleteFlag;
import com.glsx.usedcar.module.account.dao.AccountDao;
import com.glsx.usedcar.module.account.entity.Account;
import com.glsx.usedcar.module.coupon.dao.*;
import com.glsx.usedcar.module.coupon.entity.*;
import com.glsx.usedcar.module.coupon.enums.*;
......@@ -38,6 +40,7 @@ public class CouponTemplateService {
private final CouponActivityRepository couponActivityRepository;
private final CouponActivityPriceRangeRepository priceRangeRepository;
private final CouponConverter couponConverter;
private final AccountDao accountDao;
/**
* 生成优惠券模板 ID
......@@ -360,6 +363,13 @@ public class CouponTemplateService {
int successCount = 0;
for (Integer accountId : vo.getAccountIds()) {
try {
// 查询用户信息
Account account = accountDao.findTopByAccountId(accountId);
if (account == null) {
log.warn("用户不存在,跳过发放:accountId={}", accountId);
continue;
}
// 生成优惠券实例 ID
String couponId = "CPN" + System.currentTimeMillis() + UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase();
......@@ -395,6 +405,8 @@ public class CouponTemplateService {
.templateName(template.getTemplateName())
.couponId(couponId)
.accountId(accountId)
.accountName(account.getAccountName())
.mobile(account.getMobile())
.distributionType(CouponDistributionTypeEnum.MANUAL.getCode())
.faceAmount(template.getFaceAmount())
.distributionRemark(vo.getRemark())
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!