|
@@ -1,12 +1,18 @@
|
|
|
package com.fs.his.service.impl;
|
|
package com.fs.his.service.impl;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.SecurityUtils;
|
|
import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
|
|
+import com.fs.his.config.CouponConfig;
|
|
|
import com.fs.his.domain.FsCoupon;
|
|
import com.fs.his.domain.FsCoupon;
|
|
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.mapper.FsCouponMapper;
|
|
import com.fs.his.mapper.FsCouponMapper;
|
|
|
import com.fs.his.param.FsUserCouponParam;
|
|
import com.fs.his.param.FsUserCouponParam;
|
|
|
import com.fs.his.param.FsUserCouponSendParam;
|
|
import com.fs.his.param.FsUserCouponSendParam;
|
|
@@ -15,6 +21,7 @@ import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.FsUserCouponCountUVO;
|
|
import com.fs.his.vo.FsUserCouponCountUVO;
|
|
|
import com.fs.his.vo.FsUserCouponListUVO;
|
|
import com.fs.his.vo.FsUserCouponListUVO;
|
|
|
import com.fs.his.vo.FsUserCouponListVO;
|
|
import com.fs.his.vo.FsUserCouponListVO;
|
|
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,6 +44,10 @@ public class FsUserCouponServiceImpl implements IFsUserCouponService
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsCouponMapper fsCouponMapper;
|
|
private FsCouponMapper fsCouponMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询会员优惠券
|
|
* 查询会员优惠券
|
|
|
*
|
|
*
|
|
@@ -192,4 +203,37 @@ public class FsUserCouponServiceImpl implements IFsUserCouponService
|
|
|
}
|
|
}
|
|
|
return countUVO;
|
|
return countUVO;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void sendRegisterCoupon(FsUser user) {
|
|
|
|
|
+ Date createTime = user.getCreateTime();
|
|
|
|
|
+ if (!isCreateTimeMoreThanOneDay(createTime)) {
|
|
|
|
|
+ Long userId = user.getUserId();
|
|
|
|
|
+ String json = configService.selectConfigByKey("his.coupon");
|
|
|
|
|
+ CouponConfig config = JSONUtil.toBean(json, CouponConfig.class);
|
|
|
|
|
+ Long[] registerCoupons = config.getRegisterCoupon();
|
|
|
|
|
+ if (registerCoupons != null){
|
|
|
|
|
+ for (Long registerCoupon : registerCoupons) {
|
|
|
|
|
+ FsUserCouponSendParam param = new FsUserCouponSendParam();
|
|
|
|
|
+ param.setCouponId(registerCoupon);
|
|
|
|
|
+ param.setUserId(userId);
|
|
|
|
|
+ sendFsUserCoupon(param);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断是否超过一天
|
|
|
|
|
+ * @param createTime
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static boolean isCreateTimeMoreThanOneDay(Date createTime) {
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ LocalDateTime createTimeLocal = createTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
|
|
+
|
|
|
|
|
+ // 判断是否超过一天
|
|
|
|
|
+ return createTimeLocal.isBefore(now.minusDays(1));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|