姜永辉 1 жил өмнө
parent
commit
bf2274cd57

+ 18 - 2
src/main/java/com/dk/oauth/scheduled/UserInfoPublicOpenIdScheduled.java

@@ -2,6 +2,7 @@ package com.dk.oauth.scheduled;
 
 import com.dk.oauth.service.IPublicOpenUnionService;
 import com.dk.oauth.service.impl.PublicOpenUnionService;
+import com.dk.oauth.service.integral.CouponUseService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -18,15 +19,30 @@ public class UserInfoPublicOpenIdScheduled {
     @Autowired
     IPublicOpenUnionService service;
 
+    @Autowired
+    private CouponUseService couponUseService;
+
     // 添加定时任务 每天凌晨 1 点执行一次
-    @Scheduled(cron = "0 0 1 * * ?")
+//    @Scheduled(cron = "0 0 1 * * ?")
     public void updateUserPublicOpenIds(){
         log.info("准备获取微信公账号的openid");
         try {
-            service.updateUserPublicOpenIds();
+//             service.updateUserPublicOpenIds();
         }catch (Exception e){
             log.info("获取微信公账号的openid异常" + e.getMessage());
         }
         log.info("准备获取微信公账号的openid完成");
     }
+
+    // 添加定时任务 每天凌晨 1 点执行一次 检索优惠券状态
+    @Scheduled(cron = "0 0 1 * * ?")
+    public void retrievalCouponStatus(){
+        log.info("检索优惠券状态");
+        try {
+             couponUseService.retrievalCouponStatus();
+        }catch (Exception e){
+            log.info("检索优惠券状态异常" + e.getMessage());
+        }
+        log.info("检索优惠券状态完成");
+    }
 }

+ 5 - 1
src/main/java/com/dk/oauth/service/integral/CouponUseService.java

@@ -20,6 +20,7 @@ import com.dk.oauth.model.query.integral.CouponReceiveQuery;
 import com.dk.oauth.model.query.integral.CouponUseQuery;
 import com.dk.oauth.model.response.integral.CouponReceiveResponse;
 import com.dk.oauth.model.response.integral.CouponUseResponse;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -29,6 +30,7 @@ import java.time.ZoneOffset;
 import java.util.List;
 import java.util.UUID;
 
+@Slf4j
 @Service
 @Transactional
 public class CouponUseService extends BaseService<CouponUse> {
@@ -118,6 +120,7 @@ public class CouponUseService extends BaseService<CouponUse> {
         //查询全部优惠券使用
         List<CouponUseResponse> couponUseResponseList = couponUseMapper.selectByCond(new CouponUseQuery()
                 .setCouponStatus(Constant.couponStatus.WEI_SHI_YONG.getName()));
+        log.info("retrievalCouponStatus查询全部优惠券使用:{}",couponUseResponseList);
         //数据存在
         if (couponUseResponseList != null && couponUseResponseList.size() > 0) {
             for (CouponUseResponse couponUseResponse : couponUseResponseList) {
@@ -125,6 +128,7 @@ public class CouponUseService extends BaseService<CouponUse> {
                 long beOverdueTime = couponUseResponse.getReceiveDate().plusDays(couponUseResponse.getUseValidDays()).toInstant(ZoneOffset.of("+8")).toEpochMilli();
                 //当前时间
                 long nowTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                log.info("过期时间:{},当前时间:{}",beOverdueTime,nowTime);
                 //当前时间大于过期时间   优惠券已过期
                 if ((nowTime / 1000) > (beOverdueTime / 1000)) {
                     //类型转换
@@ -140,9 +144,9 @@ public class CouponUseService extends BaseService<CouponUse> {
                             new UpdateWrapper<CouponUse>().lambda()
                                     .eq(CouponUse::getUseId, UUID.fromString(couponUse.getUseId()))
                     );
+                    log.info("couponUse数据:{}",couponUse);
                 }
             }
-
         }
         return ResponseResultUtil.success();
     }