|
|
@@ -2,6 +2,7 @@ package com.cyksj.web.controller.coupon;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
@@ -413,7 +414,7 @@ public class CouponFrontController {
|
|
|
SysConfig one = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
.eq(SysConfig::getSysKey, Constant.YL_NEW_WELFARE_COUPON_ID)
|
|
|
.last("limit 1"));
|
|
|
- if (one == null) {
|
|
|
+ if (one == null || StrUtil.isNotBlank(one.getSysValue())) {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
String couponId = one.getSysValue();
|
|
|
@@ -428,4 +429,21 @@ public class CouponFrontController {
|
|
|
}
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(couponDetailView);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 领取新人优惠券
|
|
|
+ */
|
|
|
+ @PostMapping("/receive/newWelfare")
|
|
|
+ public Result<CouponUserView> receiveNewWelfareCoupon() {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ SysConfig one = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
+ .eq(SysConfig::getSysKey, Constant.YL_NEW_WELFARE_COUPON_ID)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (one == null || StrUtil.isNotBlank(one.getSysValue())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("暂无新人优惠券活动");
|
|
|
+ }
|
|
|
+ String couponId = one.getSysValue();
|
|
|
+ CouponUserView couponUserView = couponFontService.receiveCoupon(userId, Long.valueOf(couponId));
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(couponUserView);
|
|
|
+ }
|
|
|
}
|