Ver Fonte

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

yuanliang há 1 ano atrás
pai
commit
a9f398d62e

+ 6 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/MemberPriceSettingsController.java

@@ -1,5 +1,7 @@
 package com.yonge.cooleshow.admin.controller;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
@@ -69,6 +71,9 @@ public class MemberPriceSettingsController extends BaseController {
 		}
 		memberPriceSettings.setUpdateBy(user.getId());
 		memberPriceSettings.setUpdateTime(new Date());
-		return status(memberPriceSettingsService.updateById(memberPriceSettings));
+		boolean update = memberPriceSettingsService.update(memberPriceSettings, new UpdateWrapper<MemberPriceSettings>().lambda()
+				.set(MemberPriceSettings::getDesc, memberPriceSettings.getDesc())
+				.eq(MemberPriceSettings::getId, memberPriceSettings.getId()));
+		return status(update);
 	}
 }

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/VipCardRecord.java

@@ -110,4 +110,8 @@ public class VipCardRecord implements Serializable {
     @TableField(value = "ref_id_")
     private Long refId;
 
+    @ApiModelProperty("是否发送消息")
+    @TableField(value = "send_msg_")
+    private Boolean sendMsg;
+
 }

+ 3 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/MessageTypeEnum.java

@@ -112,6 +112,9 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     PRACTICE_ADJUST("陪练课调整"),
     ACTIVITY_WIN("获奖消息"),
     PLATFORM_ADD_VIP("会员赠送"),
+
+    PLATFORM_ADD_DUDECT_VIP("会员扣减"),
+
     SMS_STUDENT_LIVE_COMPLETION_FAIL("直播课成课失败"),
     STUDENT_LIVE_COMPLETION_FAIL("直播课成课失败"),
     COUPON_ISSUE("优惠券发放"),
@@ -126,7 +129,6 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     TENANT_VIP_BUY("开通平台会员"),
     TENANT_VIP_EXPIRE("平台会员到期"),
     TENANT_PLATFORM_ADD_VIP("后台添加平台会员"),
-    TENANT_PLATFORM_DUDECT_VIP("后台添加扣减平台会员"),
     TENANT_ALBUM_BUY("购买训练教程"),
     TENANT_ALBUM_EXPIRE("训练教程到期"),
     TENANT_SEND_CODE("发放激活码"),

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

@@ -141,6 +141,7 @@ public class HomeServiceImpl implements HomeService {
         List<HomeTotalStudent> totalList = baserMapper.totalStudent(query.getTimeType().getCode(), query);
         Integer registerNum = 0;
         Integer vipNum = 0;
+        Integer svipNum = 0;
         Integer practiceNum = 0;
         Integer videoNum = 0;
         Integer liveNum = 0;
@@ -151,6 +152,7 @@ public class HomeServiceImpl implements HomeService {
         for (HomeTotalStudent totalStudent : totalList) {
             totalStudent.setRegisterNum(null == totalStudent.getRegisterNum() ? 0 : totalStudent.getRegisterNum());
             totalStudent.setVipNum(null == totalStudent.getVipNum() ? 0 : totalStudent.getVipNum());
+            totalStudent.setSvipNum(null == totalStudent.getSvipNum() ? 0 : totalStudent.getSvipNum());
             totalStudent.setPracticeNum(null == totalStudent.getPracticeNum() ? 0 : totalStudent.getPracticeNum());
             totalStudent.setVideoNum(null == totalStudent.getVideoNum() ? 0 : totalStudent.getVideoNum());
             totalStudent.setLiveNum(null == totalStudent.getLiveNum() ? 0 : totalStudent.getLiveNum());
@@ -160,6 +162,7 @@ public class HomeServiceImpl implements HomeService {
 
             registerNum += totalStudent.getRegisterNum();
             vipNum += totalStudent.getVipNum();
+            svipNum += totalStudent.getSvipNum();
             practiceNum += totalStudent.getPracticeNum();
             videoNum += totalStudent.getVideoNum();
             liveNum += totalStudent.getLiveNum();
@@ -170,6 +173,7 @@ public class HomeServiceImpl implements HomeService {
         HomeTotalStudent total = new HomeTotalStudent();
         total.setRegisterNum(registerNum);
         total.setVipNum(vipNum);
+        total.setSvipNum(svipNum);
         total.setPracticeNum(practiceNum);
         total.setVideoNum(videoNum);
         total.setLiveNum(liveNum);

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

@@ -165,7 +165,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         for (StudentVo record : records) {
             EUserVipType vipType = record.getVipType();
             if (EUserVipType.NORMAL.equals(vipType)) {
-                record.setMembershipEndTime(Optional.ofNullable(record.getSvipEndTime()).orElse(record.getVipEndTime()));
+                record.setMembershipEndTime(Optional.ofNullable(record.getVipEndTime()).orElse(record.getSvipEndTime()));
             }
             if (EUserVipType.SVIP.equals(vipType)) {
                 Date perSvipEndTime = record.getPerSvipEndTime();

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

@@ -261,7 +261,7 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
         for (TeacherVo record : teacherVos) {
             EUserVipType vipType = record.getVipType();
             if (EUserVipType.NORMAL.equals(vipType)) {
-                record.setMembershipEndTime(Optional.ofNullable(record.getSvipEndTime()).orElse(record.getVipEndTime()));
+                record.setMembershipEndTime(Optional.ofNullable(record.getVipEndTime()).orElse(record.getSvipEndTime()));
             }
             if (EUserVipType.SVIP.equals(vipType)) {
                 Date perSvipEndTime = record.getPerSvipEndTime();

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

@@ -449,18 +449,24 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
 //        }
 
         Date now = new Date();
-        Date startTime = now;
+        long startTimeMills = now.getTime();
         // 没有会员信息
         if (vipCardRecordList.isEmpty()) {
             PeriodEnum period = addVipCardRecord.getType();
-            Date endDate = plusDate(startTime, period, Long.valueOf(addVipCardRecord.getTimes()));
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(now);
+            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(), period, Long.valueOf(addVipCardRecord.getTimes()));
 
             VipCardRecord addRecord = JSON.parseObject(JSON.toJSONString(addVipCardRecord), VipCardRecord.class);
             addRecord.setSourceType(addVipCardRecord.getSourceType() !=null?addVipCardRecord.getSourceType():SourceTypeEnum.BACKEND_GIVE);
             addRecord.setStatus(EVipRecordStatus.ADD);
             addRecord.setDisplayFlag(true);
             addRecord.setEfficientFlag(true);
-            addRecord.setStartTime(startTime);
+            addRecord.setStartTime(now);
             addRecord.setEndTime(endDate);
             return addRecord;
         }
@@ -469,54 +475,44 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
         int index = 0;
         if (addVipType.equals(EVipType.VIP)) { // vip 放到最后
             index = vipCardRecordList.size();
-            startTime = vipCardRecordList.stream().map(VipCardRecord::getEndTime).max(Date::compareTo).get();
+            startTimeMills = vipCardRecordList.stream().map(VipCardRecord::getEndTime).max(Date::compareTo).get().getTime() + 1000L;
         }
         if (addVipType.equals(EVipType.SVIP)) { //放到VIP的前面
-            PeriodEnum period = addVipCardRecord.getType();
-            if (period.equals(PeriodEnum.PERPETUAL)) {
-                index = (int) vipCardRecordList.stream().filter(n -> EVipType.SVIP.equals(n.getVipType())).count();
-                if (index > 0) {
-                    startTime = vipCardRecordList.stream().filter(n -> EVipType.SVIP.equals(n.getVipType())).map(VipCardRecord::getEndTime).max(Date::compareTo).get();
-                }
-            } else {
-                index = (int) vipCardRecordList.stream().filter(n -> EVipType.SVIP.equals(n.getVipType()) && !PeriodEnum.PERPETUAL.equals(n.getType())).count();
-                if (index > 0) {
-                    startTime = vipCardRecordList.stream().filter(n -> EVipType.SVIP.equals(n.getVipType()) && !PeriodEnum.PERPETUAL.equals(n.getType()))
-                            .map(VipCardRecord::getEndTime).max(Date::compareTo).get();
-                }
+            index = (int) vipCardRecordList.stream().filter(n -> EVipType.SVIP.equals(n.getVipType()) && !PeriodEnum.PERPETUAL.equals(n.getType())).count();
+            if (index > 0) {
+                startTimeMills = vipCardRecordList.stream().filter(n -> EVipType.SVIP.equals(n.getVipType()) && !PeriodEnum.PERPETUAL.equals(n.getType()))
+                        .map(VipCardRecord::getEndTime).max(Date::compareTo).get().getTime() + 1000;
             }
         }
-        Date endDate = plusDate(startTime, addVipCardRecord.getType(), Long.valueOf(addVipCardRecord.getTimes()));
+        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);
-        if (index > 0) {
-            newRecord.setStartTime(new Date(startTime.getTime() + 1000));
-        } else {
-            newRecord.setStartTime(startTime);
-        }
-        newRecord.setEndTime(endDate);
+        newRecord.setStartTime(new Date(startTimeMills));
+        newRecord.setEndTime(new Date(endDate.getTime()));
         newRecord.setDisplayFlag(true);
         newRecord.setEfficientFlag(true);
 
         // 平移时间
-        long plusMills = endDate.getTime() - startTime.getTime();
+        long plusMills = endDate.getTime() - startTimeMills;
+        long beforeEndTime = newRecord.getEndTime().getTime();
         for (int i = 0; i < vipCardRecordList.size(); i++) {
             VipCardRecord vipCardRecord = vipCardRecordList.get(i);
             if (i >= index) {
                 VipCardRecord addRecord = JSON.parseObject(JSON.toJSONString(vipCardRecord), VipCardRecord.class);
                 addRecord.setStatus(EVipRecordStatus.UPDATE);
 
-                long startTimeMills = Math.max(vipCardRecord.getStartTime().getTime(), now.getTime());
-                Date startDate = new Date(startTimeMills + plusMills + 1000);
-                Calendar instance = Calendar.getInstance();
-                instance.setTime(startDate);
-                instance.set(Calendar.SECOND, 0);
-                instance.set(Calendar.MILLISECOND, 0);
-                addRecord.setStartTime(instance.getTime());
+                addRecord.setStartTime(new Date(beforeEndTime + 1000));
 
                 int days = (int) Math.ceil(plusMills * 1.0D / (24 * 60 * 60 * 1000));
-                addRecord.setEndTime(plusDate(vipCardRecord.getEndTime(), PeriodEnum.DAY, days));
+                Date endTime = plusDate(vipCardRecord.getEndTime(), PeriodEnum.DAY, days);
+                addRecord.setEndTime(endTime);
                 addRecord.setDisplayFlag(false);
                 addRecord.setEfficientFlag(true);
                 save(addRecord);
@@ -526,6 +522,7 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
                 updateRecord.setEfficientFlag(false);
                 updateRecord.setRefId(refId);
                 updateById(updateRecord);
+                beforeEndTime = endTime.getTime();
             }
         }
         return newRecord;
@@ -695,14 +692,14 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
     }
 
     private Date plusDate(Date start, PeriodEnum period, long times) {
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(start);
-        calendar.set(Calendar.HOUR_OF_DAY, 23);
-        calendar.set(Calendar.MINUTE, 59);
-        calendar.set(Calendar.SECOND, 59);
-        calendar.set(Calendar.MILLISECOND, 0);
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.setTime(start);
+//        calendar.set(Calendar.HOUR_OF_DAY, 23);
+//        calendar.set(Calendar.MINUTE, 59);
+//        calendar.set(Calendar.SECOND, 59);
+//        calendar.set(Calendar.MILLISECOND, 0);
+        LocalDateTime localDateTimeMaxTime =  LocalDateTime.ofInstant(start.toInstant(),ZoneId.systemDefault());
 
-        LocalDateTime localDateTimeMaxTime =  calendar.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
         LocalDateTime end;
         switch (period) {
             case DAY:
@@ -792,15 +789,16 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
         if (sysUser == null) {
             return;
         }
-        MessageTypeEnum messageTypeEnum = EVipRecordStatus.ADD.equals(addVipCardRecord.getStatus()) ? MessageTypeEnum.TENANT_PLATFORM_ADD_VIP : MessageTypeEnum.TENANT_PLATFORM_DUDECT_VIP;
+        MessageTypeEnum messageTypeEnum = EVipRecordStatus.ADD.equals(addVipCardRecord.getStatus()) ? MessageTypeEnum.PLATFORM_ADD_VIP : MessageTypeEnum.PLATFORM_ADD_DUDECT_VIP;
         Map<Long, String> receivers = new HashMap<>();
         receivers.put(addVipCardRecord.getUserId(), sysUser.getPhone());
 
         try {
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, messageTypeEnum,
-                    receivers, null, 0, null, addVipCardRecord.getClientType().getCode());
+                    receivers, null, 0, null, addVipCardRecord.getClientType().getCode(), String.valueOf(addVipCardRecord.getTimes()), addVipCardRecord.getType().getMsg(),
+                    addVipCardRecord.getReason());
         } catch (Exception e) {
-            log.error("会员赠送消息发送失败 : {}", e.getMessage());
+            log.error("会员添加消息发送失败 : {}", e.getMessage());
         }
     }
 }

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

@@ -107,7 +107,7 @@
 <!--            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,
-            max(if(vcr.vip_type_ = 'SVIP' and vcr.type_ != 'PERPETUAL', vcr.end_time_, null)) svipEndTime,
+            max(if(vcr.vip_type_ = 'SVIP' , vcr.end_time_, null)) svipEndTime,
 <!--            (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,-->
             (
             SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
@@ -199,14 +199,8 @@
             </if>
         </where>
         group by t.user_id_
-        <if test="param.vipStartTime != null and param.vipEndTime != null and param.vipType != null">
-            having
-            <if test="param.vipType.code == 'VIP'">
-                 vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime
-            </if>
-            <if test="param.vipType.code == 'SVIP'">
-                 svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime
-            </if>
+        <if test="param.vipStartTime != null and param.vipEndTime != null">
+        having  ((vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime) or (svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime))
         </if>
         <choose>
             <when test="param.orderBy != null and param.orderBy.trim() != ''">

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

@@ -110,7 +110,7 @@
         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' and vcr.type_ != 'PERPETUAL', vcr.end_time_, null)) svipEndTime,
+        max(if(vcr.vip_type_ = 'SVIP', vcr.end_time_, null)) svipEndTime,
         (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
         (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
         (case when t.tenant_id_ = -1 then '平台' else ti.name_ end) as tenantName
@@ -208,14 +208,8 @@
             </if>
         </where>
         group by t.user_id_
-        <if test="param.vipStartTime != null and param.vipEndTime != null and param.vipType != null">
-            having
-            <if test="param.vipType.code == 'VIP'">
-                vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime
-            </if>
-            <if test="param.vipType.code == 'SVIP'">
-                svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime
-            </if>
+        <if test="param.vipStartTime != null and param.vipEndTime != null">
+            having  ((vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime) or (svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime))
         </if>
         <choose>
             <when test="param.orderBy != null and param.orderBy.trim() != ''">
@@ -274,8 +268,8 @@
         left join (
         select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
         ) b on t.user_id_ = b.user_id_
-        left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and cvr.client_type_ = 'TEACHER'
-        and vcr.efficient_flag_ = 1 and vcr.end_time_ >= now() and now() > vcr.start_time_ and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP')
+        left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.client_type_ = 'TEACHER'
+        and vcr.efficient_flag_ = 1 and vcr.end_time_ >= now() and now() > vcr.start_time_ and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP') and vcr.client_type_ = 'TEACHER'
         where u.del_flag_ = 0 and t.user_id_ = #{userId}
     </select>
 
@@ -348,7 +342,7 @@
         u.gender_ AS gender,
         u.phone_ AS phone,
         u.birthdate_ AS birthdate,
-        (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName,
+        (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName
 <!--        if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip-->
         FROM student_star s
         LEFT JOIN sys_user u ON s.student_id_ = u.id_