|
|
@@ -44,6 +44,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.cyksj.enums.GatewayApiCode.GROUP_INDEX_ALREADY_BE_USER;
|
|
|
import static com.cyksj.enums.GatewayApiCode.GROUP_INDEX_NOT_FIND;
|
|
|
@@ -608,6 +610,52 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<RenewalView> getExpiryRenewalNotify(Long userId) {
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ DateTime thisZero = DateUtil.beginOfDay(now);
|
|
|
+ String thisDate = thisZero.toDateStr();
|
|
|
+ Object exists = redisService.get(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId));
|
|
|
+ if (exists != null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ User u = userMapper.selectById(userId);
|
|
|
+ if (u == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
+ if (u.getIsBlack()) {
|
|
|
+ redisService.setNx(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId), userId, RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getTimeout());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, u);
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ SearchResult<RenewalView> list = beanSearcher.search(RenewalView.class, builder
|
|
|
+ .field(RenewalView::getUserId, 0).op(Operator.GreaterThan)
|
|
|
+ .field(RenewalView::getUserId, userIds).op(Operator.InList)
|
|
|
+ .field("condition", String.format("(gr.expiry_time is null or gr.expiry_time > '%s')", now))
|
|
|
+ .field(RenewalView::getStatus, List.of("validity", "overdue", "outside")).op(Operator.InList)
|
|
|
+ .orderBy(RenewalView::getExpiryTime).asc()
|
|
|
+ .build());
|
|
|
+ if (list.getDataList().size() > 5) {
|
|
|
+ redisService.setNx(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId), userId, RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getTimeout());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //提前7天
|
|
|
+ AtomicInteger day = new AtomicInteger(7);
|
|
|
+ List<RenewalView> expiryTickets = list.getDataList().stream().filter(ticket -> {
|
|
|
+ Long skuNum = ticket.getSkuNum();
|
|
|
+ Date expiryTime = ticket.getExpiryTime();
|
|
|
+ //年付 提前一个月
|
|
|
+ if (skuNum >= 12) {
|
|
|
+ day.set(30);
|
|
|
+ }
|
|
|
+ if (DateUtil.beginOfDay(expiryTime).compareTo(DateUtil.offsetDay(thisZero, day.get())) <= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ redisService.setNx(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId), userId, RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getTimeout());
|
|
|
+ return expiryTickets;
|
|
|
+ }
|
|
|
+
|
|
|
public String getDifferentGoodsCode(Long goodsId, String body, Integer type) {
|
|
|
String code = null;
|
|
|
//奈飞
|