Sfoglia il codice sorgente

Merge branch 'feature/0712_vip' of http://git.dayaedu.com/yonge/cooleshow into feature/0712_vip

刘俊驰 8 mesi fa
parent
commit
f3351df6a3

+ 3 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/teacher/TeacherVO.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.admin.io.request.teacher;
 
 import com.alibaba.fastjson.JSON;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.biz.dal.enums.GenderEnum;
 import com.yonge.cooleshow.biz.dal.enums.MK;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
@@ -138,5 +139,7 @@ public class TeacherVO {
 
         @ApiModelProperty("出生日期")
         private Integer age;
+
+        private EUserVipType vipType;
     }
 }

+ 17 - 12
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -934,18 +934,7 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     public IPage<MyFens> queryMyFans(IPage<MyFens> page, Long teacherId) {
         List<MyFens> teacherVos = baseMapper.queryMyFans(page,
                 TeacherQueryInfo.FansQuery.builder().teacherId(teacherId).build());
-        if (!teacherVos.isEmpty()) {
-            List<Long> studentIds = teacherVos.stream().map(n -> Long.valueOf(n.getUserId())).collect(Collectors.toList());
-            Map<Long, EUserVipType> vipMap = vipCardRecordService.queryUserVipInfo(studentIds,ClientEnum.STUDENT.getCode()).stream()
-                    .collect(Collectors.toMap(VipCardRecordWrapper.UserVipInfo::getUserId, VipCardRecordWrapper.UserVipInfo::getCurrentVipType));
-
-            for (MyFens teacherVo : teacherVos) {
-                EUserVipType vipType = vipMap.getOrDefault(Long.valueOf(teacherVo.getUserId()), EUserVipType.NORMAL);
-                teacherVo.setIsVip(EUserVipType.NORMAL.equals(vipType) ? YesOrNoEnum.NO : YesOrNoEnum.YES);
-                teacherVo.setVipType(vipType);
-            }
-
-        }
+        setVip(teacherVos);
         return page.setRecords(teacherVos);
     }
 
@@ -960,6 +949,7 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     public IPage<MyFens> queryMyFans(IPage<MyFens> page, TeacherQueryInfo.FansQuery query) {
 
         List<MyFens> teacherVos = baseMapper.queryMyFans(page, query);
+        setVip(teacherVos);
         return page.setRecords(teacherVos);
     }
 
@@ -1283,4 +1273,19 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
         sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, messageType,
                 receivers, null, 0, null, ClientEnum.SYSTEM.getCode(), tenantInfo.getName());
     }
+
+    private void setVip(List<MyFens> teacherVos) {
+        if (CollectionUtils.isEmpty(teacherVos)) {
+            return;
+        }
+        List<Long> studentIds = teacherVos.stream().map(n -> Long.valueOf(n.getUserId())).collect(Collectors.toList());
+        Map<Long, EUserVipType> vipMap = vipCardRecordService.queryUserVipInfo(studentIds, ClientEnum.STUDENT.getCode()).stream()
+                .collect(Collectors.toMap(VipCardRecordWrapper.UserVipInfo::getUserId, VipCardRecordWrapper.UserVipInfo::getCurrentVipType));
+
+        for (MyFens teacherVo : teacherVos) {
+            EUserVipType vipType = vipMap.getOrDefault(Long.valueOf(teacherVo.getUserId()), EUserVipType.NORMAL);
+            teacherVo.setIsVip(EUserVipType.NORMAL.equals(vipType) ? YesOrNoEnum.NO : YesOrNoEnum.YES);
+            teacherVo.setVipType(vipType);
+        }
+    }
 }

+ 18 - 11
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/VipCardRecordServiceImpl.java

@@ -490,23 +490,30 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
                         .map(VipCardRecord::getEndTime).max(Date::compareTo).get().getTime() + 1000;
             }
         }
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(new Date(startTimeMills));
-        calendar.set(Calendar.HOUR_OF_DAY, 23);
-        calendar.set(Calendar.MINUTE, 59);
-        calendar.set(Calendar.SECOND, 59);
-        calendar.set(Calendar.MILLISECOND, 0);
-        Date endDate = plusDate(calendar.getTime(), addVipCardRecord.getType(), Long.valueOf(addVipCardRecord.getTimes()));
+
         VipCardRecord newRecord = JSON.parseObject(JSON.toJSONString(addVipCardRecord), VipCardRecord.class);
         newRecord.setSourceType(addVipCardRecord.getSourceType() !=null?addVipCardRecord.getSourceType():SourceTypeEnum.BACKEND_GIVE);
         newRecord.setStatus(EVipRecordStatus.ADD);
         newRecord.setStartTime(new Date(startTimeMills));
-        newRecord.setEndTime(new Date(endDate.getTime()));
+        if (index == 0) { // 当天剩余时间属于赠送
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(new Date(startTimeMills));
+            calendar.set(Calendar.HOUR_OF_DAY, 23);
+            calendar.set(Calendar.MINUTE, 59);
+            calendar.set(Calendar.SECOND, 59);
+            calendar.set(Calendar.MILLISECOND, 0);
+            Date endDate = plusDate(calendar.getTime(), addVipCardRecord.getType(), Long.valueOf(addVipCardRecord.getTimes()));
+            newRecord.setEndTime(new Date(endDate.getTime()));
+        } else {
+            Date endDate = plusDate(new Date(startTimeMills - 1000), addVipCardRecord.getType(), Long.valueOf(addVipCardRecord.getTimes()));
+            newRecord.setEndTime(endDate);
+        }
+
         newRecord.setDisplayFlag(true);
         newRecord.setEfficientFlag(true);
 
         // 平移时间
-        long plusMills = endDate.getTime() - startTimeMills;
+//        long plusMills = newRecord.getEndTime().getTime() - startTimeMills;
         long beforeEndTime = newRecord.getEndTime().getTime();
         for (int i = 0; i < vipCardRecordList.size(); i++) {
             VipCardRecord vipCardRecord = vipCardRecordList.get(i);
@@ -516,8 +523,8 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
 
                 addRecord.setStartTime(new Date(beforeEndTime + 1000));
 
-                int days = (int) Math.ceil(plusMills * 1.0D / (24 * 60 * 60 * 1000));
-                Date endTime = plusDate(vipCardRecord.getEndTime(), PeriodEnum.DAY, days);
+//                int days = (int) Math.ceil(plusMills * 1.0D / (24 * 60 * 60 * 1000));
+                Date endTime = plusDate(vipCardRecord.getEndTime(), addVipCardRecord.getType(), addVipCardRecord.getTimes());
                 addRecord.setEndTime(endTime);
                 addRecord.setDisplayFlag(false);
                 addRecord.setEfficientFlag(true);

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/VipCardRecordMapper.xml

@@ -139,7 +139,7 @@
               and t.display_flag_ = #{param.displayFlag}
           </if>
           <if test="param.vipType != null">
-              and t.vip_card_record = #{param.vipType}
+              and t.vip_type_ = #{param.vipType}
           </if>
       </where>
         order by  t.id_ desc