|
|
@@ -76,6 +76,17 @@ public class CouponShareService {
|
|
|
|
|
|
private static final long DAY_MILLIS = 24L * 3600 * 1000;
|
|
|
|
|
|
+ /** 配置 coupon.share.expire-days 解析:空/非法/<=0 回退默认 7 天。 */
|
|
|
+ public static int resolveExpireDays(String configuredValue) {
|
|
|
+ if (configuredValue == null || configuredValue.trim().isEmpty()) return DEFAULT_EXPIRE_DAYS;
|
|
|
+ try {
|
|
|
+ int days = Integer.parseInt(configuredValue.trim());
|
|
|
+ return days > 0 ? days : DEFAULT_EXPIRE_DAYS;
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return DEFAULT_EXPIRE_DAYS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static final String STATUS_PENDING = "PENDING";
|
|
|
private static final String STATUS_CLAIMED = "CLAIMED";
|
|
|
private static final String STATUS_REVOKED = "REVOKED";
|
|
|
@@ -99,6 +110,8 @@ public class CouponShareService {
|
|
|
private NotificationDispatchService notificationDispatchService;
|
|
|
@Resource
|
|
|
private FamilyCouponGrantLogMapper familyCouponGrantLogMapper;
|
|
|
+ @Resource
|
|
|
+ private com.etotem.cfc.service.SysConfigService sysConfigService;
|
|
|
|
|
|
// ----------------------------------------------------------------
|
|
|
// create(幂等 + 防并发双 PENDING)
|
|
|
@@ -162,7 +175,10 @@ public class CouponShareService {
|
|
|
share.setFamilyCouponId(familyCouponId);
|
|
|
share.setCouponId(coupon.getId());
|
|
|
share.setStatus(STATUS_PENDING);
|
|
|
- share.setExpireAt(new Date(now.getTime() + DEFAULT_EXPIRE_DAYS * DAY_MILLIS));
|
|
|
+ // P1-4/POI-1:有效期可配 coupon.share.expire-days(默认7天);单测直构时 sysConfigService 为 null → 回退默认
|
|
|
+ String expireDaysCfg = sysConfigService != null ? sysConfigService.getValue("coupon.share.expire-days") : null;
|
|
|
+ int expireDays = resolveExpireDays(expireDaysCfg);
|
|
|
+ share.setExpireAt(new Date(now.getTime() + expireDays * DAY_MILLIS));
|
|
|
share.setCreatedAt(now);
|
|
|
couponShareMapper.insert(share);
|
|
|
|