|  | @@ -3,24 +3,21 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
 |  |  import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.entity.PlatformCashAccountRecord;
 |  | 
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.entity.VipCardRecord;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.entity.*;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 |  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
 |  |  import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.enums.PeriodEnum;
 |  |  import com.yonge.cooleshow.biz.dal.enums.PeriodEnum;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.service.*;
 |  |  import com.yonge.cooleshow.biz.dal.service.*;
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.vo.StudentVo;
 |  | 
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import com.yonge.cooleshow.biz.dal.vo.*;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes;
 |  |  import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.common.entity.HttpResponseResult;
 |  |  import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
											
												
													
														|  |  import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 |  |  import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 | 
											
												
													
														|  |  import com.yonge.toolset.utils.date.DateUtil;
 |  |  import com.yonge.toolset.utils.date.DateUtil;
 | 
											
												
													
														|  | 
 |  | +import org.springframework.beans.BeanUtils;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Service;
 |  |  import org.springframework.stereotype.Service;
 | 
											
												
													
														|  |  import org.slf4j.Logger;
 |  |  import org.slf4j.Logger;
 | 
											
												
													
														|  |  import org.slf4j.LoggerFactory;
 |  |  import org.slf4j.LoggerFactory;
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.entity.MemberPriceSettings;
 |  | 
 | 
											
												
													
														|  | -import com.yonge.cooleshow.biz.dal.vo.MemberPriceSettingsVo;
 |  | 
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.dto.search.MemberPriceSettingsSearch;
 |  |  import com.yonge.cooleshow.biz.dal.dto.search.MemberPriceSettingsSearch;
 | 
											
												
													
														|  |  import com.yonge.cooleshow.biz.dal.dao.MemberPriceSettingsDao;
 |  |  import com.yonge.cooleshow.biz.dal.dao.MemberPriceSettingsDao;
 | 
											
												
													
														|  |  import org.springframework.transaction.annotation.Transactional;
 |  |  import org.springframework.transaction.annotation.Transactional;
 | 
											
										
											
												
													
														|  | @@ -33,6 +30,10 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
 | 
											
												
													
														|  |      private final static Logger log = LoggerFactory.getLogger(MemberPriceSettingsServiceImpl.class);
 |  |      private final static Logger log = LoggerFactory.getLogger(MemberPriceSettingsServiceImpl.class);
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private StudentService studentService;
 |  |      private StudentService studentService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private TeacherService teacherService;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private VipCardRecordService vipCardRecordService;
 |  |      private VipCardRecordService vipCardRecordService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
										
											
												
													
														|  | @@ -76,22 +77,27 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public void orderSuccess(UserOrderDetailVo orderDetailVo) {
 |  |      public void orderSuccess(UserOrderDetailVo orderDetailVo) {
 | 
											
												
													
														|  | -        StudentVo studentVo = studentService.detail(orderDetailVo.getUserId());
 |  | 
 | 
											
												
													
														|  | -        if (null == studentVo) {
 |  | 
 | 
											
												
													
														|  | -            return;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          VipCardRecord vipCardRecord = vipCardRecordService.buildVipCardRecordByOrderDetail(orderDetailVo);
 |  |          VipCardRecord vipCardRecord = vipCardRecordService.buildVipCardRecordByOrderDetail(orderDetailVo);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if (null == studentVo.getMembershipEndTime() || studentVo.getMembershipEndTime().before(new Date())) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +        UserVipInfoVo userVipInfoVo = getVipInfo(orderDetailVo.getOrderClient(),orderDetailVo.getUserId());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        if (userVipInfoVo == null) {
 | 
											
												
													
														|  | 
 |  | +            log.error("未找到用户信息");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        if (null == userVipInfoVo.getMembershipEndTime() || userVipInfoVo.getMembershipEndTime().before(new Date())) {
 | 
											
												
													
														|  |              //没有会员、会员已过期 会员卡生效时间为当前时间
 |  |              //没有会员、会员已过期 会员卡生效时间为当前时间
 | 
											
												
													
														|  | -            studentVo.setMembershipStartTime(vipCardRecord.getStartTime());
 |  | 
 | 
											
												
													
														|  | -            studentVo.setMembershipEndTime(vipCardRecord.getEndTime());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            userVipInfoVo.setMembershipStartTime(vipCardRecord.getStartTime());
 | 
											
												
													
														|  | 
 |  | +            userVipInfoVo.setMembershipEndTime(vipCardRecord.getEndTime());
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  | -            studentVo.setMembershipEndTime(vipCardRecord.getEndTime());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            userVipInfoVo.setMembershipEndTime(vipCardRecord.getEndTime());
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        studentVo.setMemberRankSettingId(1l);
 |  | 
 | 
											
												
													
														|  | -        studentVo.setUpdateTime(new Date());
 |  | 
 | 
											
												
													
														|  | -        studentService.updateById(studentVo);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        userVipInfoVo.setMemberRankSettingId(1l);
 | 
											
												
													
														|  | 
 |  | +        userVipInfoVo.setUpdateTime(new Date());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        updateUser(userVipInfoVo);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          //会员购买记录入库
 |  |          //会员购买记录入库
 | 
											
												
													
														|  |          vipCardRecordService.save(vipCardRecord);
 |  |          vipCardRecordService.save(vipCardRecord);
 | 
											
												
													
														|  |          //记录平台收入
 |  |          //记录平台收入
 | 
											
										
											
												
													
														|  | @@ -100,26 +106,68 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
 | 
											
												
													
														|  |  //        platformCashAccountRecord.setTransAmount(ClientEnum.STUDENT.getCode());
 |  |  //        platformCashAccountRecord.setTransAmount(ClientEnum.STUDENT.getCode());
 | 
											
												
													
														|  |  //        platformCashAccountRecordService.save();
 |  |  //        platformCashAccountRecordService.save();
 | 
											
												
													
														|  |          //会员购买消息推送
 |  |          //会员购买消息推送
 | 
											
												
													
														|  | -        authSend(studentVo.getUserId(), studentVo.getPhone(), DateUtil.format(vipCardRecord.getEndTime(), DateUtil.DEFAULT_PATTERN));
 |  | 
 | 
											
												
													
														|  | 
 |  | +        authSend(userVipInfoVo.getUserId(), userVipInfoVo.getPhone(), DateUtil.format(vipCardRecord.getEndTime(), DateUtil.DEFAULT_PATTERN),orderDetailVo.getOrderClient());
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private void updateUser(UserVipInfoVo userVipInfoVo) {
 | 
											
												
													
														|  | 
 |  | +        if (userVipInfoVo.getUserType().equals(ClientEnum.STUDENT)) {
 | 
											
												
													
														|  | 
 |  | +            studentService.lambdaUpdate()
 | 
											
												
													
														|  | 
 |  | +                    .eq(Student::getUserId,userVipInfoVo.getUserId())
 | 
											
												
													
														|  | 
 |  | +                    .set(Student::getMemberRankSettingId,userVipInfoVo.getMemberRankSettingId())
 | 
											
												
													
														|  | 
 |  | +                    .set(Student::getMembershipStartTime,userVipInfoVo.getMembershipStartTime())
 | 
											
												
													
														|  | 
 |  | +                    .set(Student::getMembershipEndTime,userVipInfoVo.getMembershipEndTime())
 | 
											
												
													
														|  | 
 |  | +                    .set(Student::getUpdateTime,userVipInfoVo.getUpdateTime())
 | 
											
												
													
														|  | 
 |  | +                    .update();
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            teacherService.lambdaUpdate()
 | 
											
												
													
														|  | 
 |  | +                          .eq(Teacher::getUserId, userVipInfoVo.getUserId())
 | 
											
												
													
														|  | 
 |  | +                          .set(Teacher::getMemberRankSettingId,userVipInfoVo.getMemberRankSettingId())
 | 
											
												
													
														|  | 
 |  | +                          .set(Teacher::getMembershipStartTime,userVipInfoVo.getMembershipStartTime())
 | 
											
												
													
														|  | 
 |  | +                          .set(Teacher::getMembershipEndTime,userVipInfoVo.getMembershipEndTime())
 | 
											
												
													
														|  | 
 |  | +                          .set(Teacher::getUpdateTime,userVipInfoVo.getUpdateTime())
 | 
											
												
													
														|  | 
 |  | +                          .update();
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    private UserVipInfoVo getVipInfo(ClientEnum userType, Long userId) {
 | 
											
												
													
														|  | 
 |  | +        if (userType.equals(ClientEnum.STUDENT)) {
 | 
											
												
													
														|  | 
 |  | +            StudentVo studentVo = studentService.detail(userId);
 | 
											
												
													
														|  | 
 |  | +            if (studentVo == null) {
 | 
											
												
													
														|  | 
 |  | +                return null;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            UserVipInfoVo userVipInfoVo = new UserVipInfoVo();
 | 
											
												
													
														|  | 
 |  | +            BeanUtils.copyProperties(studentVo,userVipInfoVo);
 | 
											
												
													
														|  | 
 |  | +            return userVipInfoVo;
 | 
											
												
													
														|  | 
 |  | +        } else if (userType.equals(ClientEnum.TEACHER)) {
 | 
											
												
													
														|  | 
 |  | +            TeacherVo teacherVo = teacherService.detail(userId);
 | 
											
												
													
														|  | 
 |  | +            if (teacherVo == null) {
 | 
											
												
													
														|  | 
 |  | +                return null;
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            UserVipInfoVo userVipInfoVo = new UserVipInfoVo();
 | 
											
												
													
														|  | 
 |  | +            BeanUtils.copyProperties(teacherVo,userVipInfoVo);
 | 
											
												
													
														|  | 
 |  | +            return userVipInfoVo;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return null;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      // 发送会员购买消息推送
 |  |      // 发送会员购买消息推送
 | 
											
												
													
														|  | -    private void authSend(Long userId, String phone, String param1) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private void authSend(Long userId, String phone, String param1,ClientEnum clientEnum) {
 | 
											
												
													
														|  |          Map<Long, String> receivers = new HashMap<>();
 |  |          Map<Long, String> receivers = new HashMap<>();
 | 
											
												
													
														|  |          receivers.put(userId, phone);
 |  |          receivers.put(userId, phone);
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.VIP_BUY_SUCCESS,
 |  |              sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.VIP_BUY_SUCCESS,
 | 
											
												
													
														|  | -                    receivers, null, 0, null, ClientEnum.STUDENT.getCode(), param1);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    receivers, null, 0, null, clientEnum.getCode(), param1);
 | 
											
												
													
														|  |          } catch (Exception e) {
 |  |          } catch (Exception e) {
 | 
											
												
													
														|  |              log.error("会员购买极光消息推送异常,userId={}", userId);
 |  |              log.error("会员购买极光消息推送异常,userId={}", userId);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SMS_VIP_BUY_SUCCESS,
 |  |              sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SMS_VIP_BUY_SUCCESS,
 | 
											
												
													
														|  | -                    receivers, null, 0, null, ClientEnum.STUDENT.getCode(), param1);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    receivers, null, 0, null, clientEnum.getCode(), param1);
 | 
											
												
													
														|  |          } catch (Exception e) {
 |  |          } catch (Exception e) {
 | 
											
												
													
														|  |              log.error("会员购买短信消息推送异常,userId={}", userId);
 |  |              log.error("会员购买短信消息推送异常,userId={}", userId);
 | 
											
												
													
														|  |          }
 |  |          }
 |