|
@@ -4,26 +4,28 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
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.MessageTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
+
|
|
|
import com.yonge.cooleshow.biz.dal.vo.ShareProfitVo;
|
|
|
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.common.constant.SysConfigConstant;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.toolset.base.string.MessageFormatter;
|
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.slf4j.Logger;
|
|
|
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.dao.MemberPriceSettingsDao;
|
|
|
|
|
@@ -35,6 +37,10 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
|
|
|
private final static Logger log = LoggerFactory.getLogger(MemberPriceSettingsServiceImpl.class);
|
|
|
@Autowired
|
|
|
private StudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TeacherService teacherService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private VipCardRecordService vipCardRecordService;
|
|
|
@Autowired
|
|
@@ -80,22 +86,27 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
|
|
|
|
|
|
@Override
|
|
|
public void orderSuccess(UserOrderDetailVo orderDetailVo) {
|
|
|
- StudentVo studentVo = studentService.detail(orderDetailVo.getUserId());
|
|
|
- if (null == studentVo) {
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
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 {
|
|
|
- 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);
|
|
|
//记录平台收入
|
|
@@ -104,7 +115,27 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
|
|
|
// platformCashAccountRecord.setTransAmount(ClientEnum.STUDENT.getCode());
|
|
|
// 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 (ClientEnum.STUDENT.equals(userVipInfoVo.getUserType())) {
|
|
|
+ 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();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -116,26 +147,50 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
|
|
|
result.setName(sysUser.getUsername());
|
|
|
result.setTeacherId(sysUser.getId());
|
|
|
|
|
|
- String teacherVipShareProfitUrl= sysConfigService.findConfigValue(SysConfigConstant.TEACHER_VIP_SHARE_PROFIT_URL);
|
|
|
+ String teacherVipShareProfitUrl = sysConfigService.findConfigValue(SysConfigConstant.TEACHER_VIP_SHARE_PROFIT_URL);
|
|
|
result.setUrl(MessageFormatter.arrayFormat(teacherVipShareProfitUrl, detail.getId(), sysUser.getId()));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private UserVipInfoVo getVipInfo(ClientEnum userType, Long userId) {
|
|
|
+
|
|
|
+ UserVipInfoVo userVipInfoVo = new UserVipInfoVo();
|
|
|
+ userVipInfoVo.setUserType(userType);
|
|
|
+ if (userType.equals(ClientEnum.STUDENT)) {
|
|
|
+ StudentVo studentVo = studentService.detail(userId);
|
|
|
+ if (studentVo == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(studentVo,userVipInfoVo);
|
|
|
+ return userVipInfoVo;
|
|
|
+ } else if (userType.equals(ClientEnum.TEACHER)) {
|
|
|
+ TeacherVo teacherVo = teacherService.detail(userId);
|
|
|
+ if (teacherVo == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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<>();
|
|
|
receivers.put(userId, phone);
|
|
|
try {
|
|
|
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) {
|
|
|
log.error("会员购买极光消息推送异常,userId={}", userId);
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
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) {
|
|
|
log.error("会员购买短信消息推送异常,userId={}", userId);
|
|
|
}
|