|
@@ -2,10 +2,15 @@ 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.dao.MemberPriceSettingsDao;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.MemberPriceSettings;
|
|
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.service.MemberPriceSettingsService;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysMessageService;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.PeriodEnum;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.MemberPriceSettingsVo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -16,12 +21,8 @@ import com.yonge.cooleshow.biz.dal.entity.VipCardRecord;
|
|
import com.yonge.cooleshow.biz.dal.vo.VipCardRecordVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.VipCardRecordVo;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.VipCardRecordSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.VipCardRecordSearch;
|
|
import com.yonge.cooleshow.biz.dal.dao.VipCardRecordDao;
|
|
import com.yonge.cooleshow.biz.dal.dao.VipCardRecordDao;
|
|
-import com.yonge.cooleshow.biz.dal.service.VipCardRecordService;
|
|
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -30,6 +31,14 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysMessageService sysMessageService;
|
|
private SysMessageService sysMessageService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MemberPriceSettingsDao memberPriceSettingsDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentService studentService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MemberPriceSettingsService memberPriceSettingsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserOrderDetailService orderDetailService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public VipCardRecordVo detail(Long orderDetilId) {
|
|
public VipCardRecordVo detail(Long orderDetilId) {
|
|
@@ -39,13 +48,71 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
|
|
@Override
|
|
@Override
|
|
public VipCardRecordVo detail(Long orderDetilId, Long userId) {
|
|
public VipCardRecordVo detail(Long orderDetilId, Long userId) {
|
|
VipCardRecordVo detail = baseMapper.detail(orderDetilId, userId);
|
|
VipCardRecordVo detail = baseMapper.detail(orderDetilId, userId);
|
|
- if(null == detail){
|
|
|
|
|
|
+ if (null == detail && null != userId) {
|
|
|
|
+ detail = new VipCardRecordVo();
|
|
|
|
|
|
|
|
+ UserOrderDetailVo orderDetailVo = orderDetailService.detail(orderDetilId);
|
|
|
|
+ VipCardRecord vipCardRecord = buildVipCardRecordByOrderDetail(orderDetailVo);
|
|
|
|
+ if (null == vipCardRecord) {
|
|
|
|
+ return detail;
|
|
|
|
+ }
|
|
|
|
+ BeanUtils.copyProperties(vipCardRecord, detail);
|
|
|
|
+ MemberPriceSettings memberPrice = memberPriceSettingsDao.getMemberPriceByOrderDetilId(orderDetilId);
|
|
|
|
+ detail.setOriginalPrice(memberPrice.getOriginalPrice());
|
|
|
|
+ detail.setSalePrice(memberPrice.getSalePrice());
|
|
|
|
+ detail.setPeriod(memberPrice.getPeriod());
|
|
}
|
|
}
|
|
return detail;
|
|
return detail;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public VipCardRecord buildVipCardRecordByOrderDetail(UserOrderDetailVo orderDetailVo) {
|
|
|
|
+ if (null == orderDetailVo) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ MemberPriceSettingsVo detail = memberPriceSettingsService.detail(orderDetailVo.getBizId());
|
|
|
|
+ if (null == detail) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ StudentVo studentVo = studentService.detail(orderDetailVo.getUserId());
|
|
|
|
+ if (null == studentVo) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ //修改用户会员时长
|
|
|
|
+ Date membershipEndTime = studentVo.getMembershipEndTime();
|
|
|
|
+
|
|
|
|
+ VipCardRecord vipCardRecord = new VipCardRecord();
|
|
|
|
+ vipCardRecord.setUserId(orderDetailVo.getUserId());
|
|
|
|
+ vipCardRecord.setOrderNo(orderDetailVo.getOrderNo());
|
|
|
|
+ vipCardRecord.setSubOrderNo(orderDetailVo.getSubOrderNo());
|
|
|
|
+ vipCardRecord.setVipCardId(detail.getId());
|
|
|
|
+ vipCardRecord.setMsgStatus(0);
|
|
|
|
+
|
|
|
|
+ if (null == membershipEndTime || membershipEndTime.before(new Date())) {
|
|
|
|
+ //没有会员、会员已过期 会员卡生效时间为当前时间
|
|
|
|
+ vipCardRecord.setStartTime(new Date());
|
|
|
|
+ } else {
|
|
|
|
+ vipCardRecord.setStartTime(membershipEndTime);
|
|
|
|
+ }
|
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
|
+ cal.setTime(vipCardRecord.getStartTime());
|
|
|
|
+
|
|
|
|
+ if (PeriodEnum.DAY.equals(detail.getPeriod())) {
|
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
+ } else if (PeriodEnum.MONTH.equals(detail.getPeriod())) {
|
|
|
|
+ cal.add(Calendar.MONTH, 1);
|
|
|
|
+ } else if (PeriodEnum.QUARTERLY.equals(detail.getPeriod())) {
|
|
|
|
+ cal.add(Calendar.MONTH, 3);
|
|
|
|
+ } else if (PeriodEnum.YEAR_HALF.equals(detail.getPeriod())) {
|
|
|
|
+ cal.add(Calendar.MONTH, 6);
|
|
|
|
+ } else if (PeriodEnum.YEAR.equals(detail.getPeriod())) {
|
|
|
|
+ cal.add(Calendar.YEAR, 1);
|
|
|
|
+ }
|
|
|
|
+ vipCardRecord.setEndTime(cal.getTime());
|
|
|
|
+ return vipCardRecord;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public IPage<VipCardRecordVo> selectPage(IPage<VipCardRecordVo> page, VipCardRecordSearch query) {
|
|
public IPage<VipCardRecordVo> selectPage(IPage<VipCardRecordVo> page, VipCardRecordSearch query) {
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
}
|
|
}
|
|
@@ -92,7 +159,6 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// 发送会员到期3天消息推送
|
|
// 发送会员到期3天消息推送
|
|
private void temporary3DaysSend(Long userId, String phone) {
|
|
private void temporary3DaysSend(Long userId, String phone) {
|
|
Map<Long, String> receivers = new HashMap<>();
|
|
Map<Long, String> receivers = new HashMap<>();
|