Browse Source

修复达标优惠券时间精度

Eric 2 years ago
parent
commit
943a51641b

+ 13 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityPlanStandardServiceImpl.java

@@ -32,6 +32,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -159,8 +161,17 @@ public class ActivityPlanStandardServiceImpl extends ServiceImpl<ActivityPlanSta
                                                    .map(activityPlanRewardDto -> activityPlanRewardDto.getActivityReward()
                                                                                                       .getId())
                                                    .collect(Collectors.toList());
+
+        Date date = DateTime.now().toDate(); // 发奖时间
+        try {
+            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            date = formatter.parse(formatter.format(date));
+        } catch (ParseException e) {
+            log.warn("sendUserReward TIME_CONVERT, userId={}, activityId={}, winningTime={}", userId, activityId, winningTime);
+        }
+
         //给用户发奖
-        List<Long> successRewardIds = activityRewardService.sendReward(userId, activityId, rewardIdList, new Date());
+        List<Long> successRewardIds = activityRewardService.sendReward(userId, activityId, rewardIdList, date);
 
         for (ActivityPlanRewardDto dto : activityPlanRewardDtos) {
             ActivityUserReward userReward = new ActivityUserReward();
@@ -171,7 +182,7 @@ public class ActivityPlanStandardServiceImpl extends ServiceImpl<ActivityPlanSta
             Optional<Long> first = successRewardIds.stream().filter(o -> o.equals(dto.getRewardId())).findFirst();
             userReward.setGrantFlag(first.isPresent() ? 1 : 0);
             userReward.setWinningTime(winningTime); // 获将时间
-            userReward.setCreateTime(DateTime.now().toDate()); // 发奖时间
+            userReward.setCreateTime(date); // 发奖时间
 
             ActivityUserReward one = activityUserRewardService.getOne(Wrappers.<ActivityUserReward>lambdaQuery()
                     .eq(ActivityUserReward::getUserId, userId)