瀏覽代碼

Merge remote-tracking branch 'origin/feature/1219_opt' into feature/1219_opt

zouxuan 4 月之前
父節點
當前提交
b18a0686c3

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/DiscountCardRecordServiceImpl.java

@@ -166,7 +166,7 @@ public class DiscountCardRecordServiceImpl extends ServiceImpl<DiscountCardRecor
         deductionRecord.setEndTime(addTime(record.getEndTime(), PeriodEnum.DAY, -days,1));
         deductionRecord.setDeductionBy(result.getCreateBy());
         deductionRecord.setDeductionStatus(EDeductionStatus.DEDUCT);
-        if (record.getStartTime().after(record.getEndTime())) {
+        if (record.getStartTime().after(deductionRecord.getEndTime())) {
             deductionRecord.setEfficientFlag(false);
         }
         this.updateById(deductionRecord);

+ 4 - 55
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java

@@ -71,6 +71,9 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
     @Autowired
     private StudentService studentService;
 
+    @Autowired
+    private UserTenantAlbumRecordService userTenantAlbumRecordService;
+
 
     private static final String PHONE_REG = "^1\\d{10}$";
 
@@ -656,65 +659,11 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             userTenantAlbumRecord.setType(purchase.getPurchaseType());
         }
 
-        List<UserTenantAlbumRecord> userTenantAlbumRecords = userTenantAlbumRecordMapper
-                .selectList(Wrappers.<UserTenantAlbumRecord>lambdaQuery()
-                        .eq(UserTenantAlbumRecord::getTenantId, userTenantAlbumRecord.getTenantId())
-                        .eq(UserTenantAlbumRecord::getUserId, studentId)
-                        .eq(UserTenantAlbumRecord::getTenantAlbumId, userTenantAlbumRecord.getTenantAlbumId())
-                        .eq(UserTenantAlbumRecord::getClientType, ClientEnum.STUDENT)
-                        .orderByDesc(UserTenantAlbumRecord::getEndTime));
 
         userTenantAlbumRecord.setUserId(studentId);
         userTenantAlbumRecord.setCreateBy(studentId);
 
+        userTenantAlbumRecordService.add(userTenantAlbumRecord,false);
 
-//        userTenantAlbumRecord.setType("MONTH");
-
-        Calendar instance = Calendar.getInstance();
-        if (userTenantAlbumRecords.isEmpty()) {
-            instance.setTime(DateTime.now().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).toDate());
-        } else {
-            // 如果最后一次的时间的小于当前时间,则以当前时间为会员的开始时间
-            // 如果最后一次的时间的大于当前时间,则以最后一次的结束时间为记录的开始时间,相当会员续期
-            UserTenantAlbumRecord lastRecord = userTenantAlbumRecords.get(0);
-            Date lastEndTime = lastRecord.getEndTime();
-            if (lastEndTime.before(new Date())) {
-                instance.setTime(DateTime.now().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).toDate());
-            } else {
-                instance.setTime(lastEndTime);
-            }
-        }
-        userTenantAlbumRecord.setStartTime(instance.getTime());
-        //DAY 日 MONTH 月 QUARTERLY 季度 YEAR_HALF 半年 YEAR 年
-        switch (userTenantAlbumRecord.getType()) {
-            case "DAY":
-                instance.add(Calendar.DAY_OF_MONTH, userTenantAlbumRecord.getTimes());
-                break;
-            case "MONTH":
-                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
-                break;
-            case "QUARTERLY":
-                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes() * 3);
-                break;
-            case "YEAR_HALF":
-                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes() * 6);
-                break;
-            case "YEAR":
-                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes() * 12);
-                break;
-            default:
-                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
-                break;
-        }
-
-        instance.set(Calendar.HOUR_OF_DAY, 23);
-        instance.set(Calendar.MINUTE, 59);
-        instance.set(Calendar.SECOND, 59);
-        instance.set(Calendar.MILLISECOND, 0);
-        userTenantAlbumRecord.setEndTime(instance.getTime());
-        userTenantAlbumRecordMapper.insert(userTenantAlbumRecord);
-
-
-        studentService.updateVipStatus(userOrderDetailVo.getUserId());
     }
 }

+ 8 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java

@@ -199,11 +199,13 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     public Boolean add(UserTenantAlbumRecord userTenantAlbumRecord,boolean sendMsg) {
         Long tenantAlbumId = userTenantAlbumRecord.getTenantAlbumId();
         TenantAlbum tenantAlbum = tenantAlbumMapper.selectById(tenantAlbumId);
-        if (tenantAlbum == null || Boolean.TRUE.equals(tenantAlbum.getDelFlag())) {
-            throw new BizException("专辑不存在");
-        }
-        if (Boolean.FALSE.equals(tenantAlbum.getStatus())) {
-            throw new BizException("专辑已经停用");
+        if (userTenantAlbumRecord.getSourceType() == SourceTypeEnum.BACKEND_GIVE) {
+            if (tenantAlbum == null || Boolean.TRUE.equals(tenantAlbum.getDelFlag())) {
+                throw new BizException("专辑不存在");
+            }
+            if (Boolean.FALSE.equals(tenantAlbum.getStatus())) {
+                throw new BizException("专辑已经停用");
+            }
         }
 
         List<UserTenantAlbumRecord> userTenantAlbumRecords = this.getBaseMapper()
@@ -712,7 +714,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         userTenantAlbumRecord.setEndTime(addTime(record.getEndTime(), PeriodEnum.DAY, -days,1));
         userTenantAlbumRecord.setDeductionBy(result.getCreateBy());
         userTenantAlbumRecord.setDeductionStatus(EDeductionStatus.DEDUCT);
-        if (record.getStartTime().after(record.getEndTime())) {
+        if (record.getStartTime().after(userTenantAlbumRecord.getEndTime())) {
             userTenantAlbumRecord.setEfficientFlag(false);
         }
         this.updateById(userTenantAlbumRecord);