Przeglądaj źródła

Merge branch 'feature/0712_vip' into develop-new

刘俊驰 1 rok temu
rodzic
commit
1ca8b8df3b

+ 5 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/MessageTypeEnum.java

@@ -118,8 +118,13 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     PRACTICE_ADJUST("陪练课调整"),
     ACTIVITY_WIN("获奖消息"),
     PLATFORM_ADD_VIP("会员赠送"),
+    PLATFORM_ADD_SVIP("会员赠送"),
+
+    PLATFORM_ADD_PER_SVIP("会员永久赠送"),
 
     PLATFORM_ADD_DUDECT_VIP("会员扣减"),
+    PLATFORM_ADD_DUDECT_SVIP("会员扣减"),
+    PLATFORM_ADD_DUDECT_PER_SVIP("会员永久扣减"),
 
     SMS_STUDENT_LIVE_COMPLETION_FAIL("直播课成课失败"),
     STUDENT_LIVE_COMPLETION_FAIL("直播课成课失败"),

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

@@ -461,12 +461,12 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
 
     }
 
-    private void checkOrder(ClientEnum orderGoodsInfo, String orderType, Long orderGoodsInfo1) {
+    private void checkOrder(ClientEnum orderGoodsInfo, String orderType, Long userId) {
         // 判断是否有待支付订单 如果有返回不可下单
         OrderSearch search = new OrderSearch();
         search.setOrderClient(orderGoodsInfo.name());
         search.setGoodType(orderType);
-        search.setUserId(orderGoodsInfo1);
+        search.setUserId(userId);
 
         UserOrderVo userOrderVo = userOrderDao.getPendingOrder(search);
         if (null != userOrderVo) {

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

@@ -331,7 +331,24 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
                     userVip.setVipType(EVipType.VIP);
                 }
                 Optional<VipCardRecord> max = vipList.stream().max(Comparator.comparing(VipCardRecord::getEndTime));
+                Optional<VipCardRecord> min = vipList.stream().min(Comparator.comparing(VipCardRecord::getStartTime));
                 max.ifPresent(vipCardRecord -> userVip.setVipEndDate(vipCardRecord.getEndTime()));
+                Date minDate = null;
+                if (min.isPresent()) {
+                    minDate = min.get().getStartTime();
+                }
+                // 设置VIP剩余天数
+                if (userVip.getVipEndDate() != null) {
+                    int num;
+                    if (userVip.getSvipEndDate() != null && userVip.getSvipEndDate().after(new Date())) {
+                        num = DateUtil.daysBetween(userVip.getSvipEndDate(), userVip.getVipEndDate());
+                    } else if (minDate != null && minDate.after(new Date())){
+                        num = DateUtil.daysBetween(minDate, userVip.getVipEndDate());
+                    } else {
+                        num = DateUtil.daysBetween(new Date(), userVip.getVipEndDate()) +1;
+                    }
+                    userVip.setVipEndDays(Math.max(num, 0));
+                }
             } else {
                 Integer vipCount = this.lambdaQuery()
                     .eq(VipCardRecord::getUserId, userId)
@@ -345,16 +362,6 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
             }
         }
 
-        // 设置剩余天数
-        if (userVip.getVipEndDate() != null) {
-            int num;
-            if (userVip.getSvipEndDate() != null && userVip.getSvipEndDate().after(new Date())) {
-                num = DateUtil.daysBetween(userVip.getSvipEndDate(), userVip.getVipEndDate());
-            } else {
-                num = DateUtil.daysBetween(new Date(), userVip.getVipEndDate()) + 1;
-            }
-            userVip.setVipEndDays(Math.max(num, 0));
-        }
         if (userVip.getSvipEndDate() != null) {
             int num = DateUtil.daysBetween(new Date(), userVip.getSvipEndDate()) +1;
             userVip.setSvipEndDays(Math.max(num, 0));
@@ -815,7 +822,35 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
         if (sysUser == null) {
             return;
         }
-        MessageTypeEnum messageTypeEnum = EVipRecordStatus.ADD.equals(addVipCardRecord.getStatus()) ? MessageTypeEnum.PLATFORM_ADD_VIP : MessageTypeEnum.PLATFORM_ADD_DUDECT_VIP;
+        MessageTypeEnum messageTypeEnum;
+        EVipRecordStatus status = addVipCardRecord.getStatus();
+        EVipType vipType = addVipCardRecord.getVipType();
+        if (EVipRecordStatus.ADD.equals(status)) {
+            if (EVipType.VIP.equals(vipType)) {
+                messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_VIP;
+            }else {
+                PeriodEnum period = addVipCardRecord.getType();
+                if (PeriodEnum.PERPETUAL.equals(period)) {
+                    messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_PER_SVIP;
+                } else {
+                    messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_SVIP;
+                }
+            }
+        } else if (EVipRecordStatus.DEDUCTION.equals(status)) {
+            if (EVipType.VIP.equals(vipType)) {
+                messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_DUDECT_VIP;
+            }else {
+                PeriodEnum period = addVipCardRecord.getType();
+                if (PeriodEnum.PERPETUAL.equals(period)) {
+                    messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_DUDECT_PER_SVIP;
+                } else {
+                    messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_DUDECT_SVIP;
+                }
+            }
+        } else {
+            throw new BizException("不支持类型");
+        }
+
         Map<Long, String> receivers = new HashMap<>();
         receivers.put(addVipCardRecord.getUserId(), sysUser.getPhone());
 

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

@@ -103,7 +103,7 @@
             u.phone_ as phone,
             !isnull(birthdate_) as isReal,
             u.real_name_ as realName,
-            ifnull(vcr2.vip_type_,'NORMAL') as vipType,
+            ifnull(vcr2.vip_type_ ,'NORMAL') as vipType,
 <!--            if(vcr.type_ = 'PERMANENT',null,vcr.end_time_) as membershipEndTime,-->
             max(if(vcr.vip_type_ = 'VIP', vcr.end_time_, null)) vipEndTime,
             max(if(vcr.vip_type_ = 'SVIP' and vcr.type_ = 'PERPETUAL', vcr.end_time_ , null)) perSvipEndTime,

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

@@ -109,7 +109,7 @@
 <!--        (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,-->
         <!--            t.tag_ tag,-->
         u.del_flag_ as delFlag,
-        ifnull(vcr2.vip_type_,'NORMAL') as vipType,
+        ifnull(vcr2.vip_type_ ,'NORMAL') as vipType,
         max(if(vcr.vip_type_ = 'VIP', vcr.end_time_, null)) vipEndTime,
         max(if(vcr.vip_type_ = 'SVIP' and vcr.type_ = 'PERPETUAL', vcr.end_time_ , null)) perSvipEndTime,
         max(if(vcr.vip_type_ = 'SVIP', vcr.end_time_, null)) svipEndTime,

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

@@ -146,19 +146,20 @@
     </select>
 
     <select id="queryUserVipInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.VipCardRecordWrapper$UserVipInfo">
-        select t.user_id_ userId
-        ,ifnull(vcr.vip_type_,'NORMAL') currentVipType
-        ,max(if(t.vip_type_ = 'VIP', t.end_time_, null)) vipEndTime
-        ,max(if(t.vip_type_ = 'SVIP' and t.type_ = 'PERPETUAL', t.end_time_ , null)) perSvipEndTime
-        ,max(if(t.vip_type_ = 'SVIP' , t.end_time_, null)) svipEndTime
+        select m.*
+        , ifnull(vcr.vip_type_, 'NORMAL') currentVipType
+        from (select t.user_id_ userId
+        , max(if(t.vip_type_ = 'VIP', t.end_time_, null)) vipEndTime
+        , max(if(t.vip_type_ = 'SVIP' and t.type_ = 'PERPETUAL', t.end_time_, null)) perSvipEndTime
+        , max(if(t.vip_type_ = 'SVIP', t.end_time_, null)) svipEndTime
         from vip_card_record t
-        left join vip_card_record vcr on t.id_ = vcr.id_ and vcr.end_time_>now() and now()>= vcr.start_time_
         where t.user_id_ in
         <foreach collection="userIdList" separator="," item="item" open="(" close=")">
             #{item}
         </foreach>
-        and t.client_type_ = #{clientType}
+        and t.client_type_ = 'STUDENT'
         and t.efficient_flag_ = 1
-        group by t.user_id_
+        group by t.user_id_) m
+        left join vip_card_record vcr on m.userId = vcr.user_id_ and vcr.end_time_ > now() and now() >= vcr.start_time_ and efficient_flag_ = 1
     </select>
 </mapper>