Commit b101c4a4 by 吕明尚

Merge branch 'dev' into test

parents c115fa9e 3d16661c
package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.ConsumerMember;
import share.system.domain.ConsumerWallet;
import share.system.domain.EquityMembersOrder;
import share.system.domain.vo.EquityMembersOrderVo;
import share.system.request.CreateEquityMembersRequest;
import share.system.response.EquityMembersResultResponse;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -74,4 +77,6 @@ public interface EquityMembersOrderService extends IService<EquityMembersOrder>
EquityMembersOrder getByEquityOrderNo(String equityOrderNo);
EquityMembersOrderVo queryEquityMembersOrderInfoByNo(String equityOrderNo);
void addConsumerMember(Long consumerId, BigDecimal giftPoints, ConsumerMember consumerMember, ConsumerWallet consumerWallet);
}
......@@ -216,11 +216,12 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, consumerMember.getExpirationDate())),
Integer.parseInt(expirationDateEquityMembership)));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
// extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
addConsumerMember(equityMembersOrder.getConsumerId(), equityMembersOrderConfig.getGiftPoints(), consumerMember, consumerWallet);
consumerMemberService.updateById(consumerMember);
logger.debug("权益会员原来的基础上增加有效期");
} else {
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
addConsumerMember(equityMembersOrder.getConsumerId(), equityMembersOrderConfig.getGiftPoints(), consumerMember, consumerWallet);
ConsumerMember newConsumerMember = new ConsumerMember();
newConsumerMember.setConsumerId(equityMembersOrder.getConsumerId());
newConsumerMember.setIsRights(YesNoEnum.yes.getIndex());
......@@ -266,28 +267,30 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
updateEquityMembersOrder(equityMembersOrder);
}
private void extracted(EquityMembersOrder equityMembersOrder, EquityMembersOrderConfig equityMembersOrderConfig,
ConsumerMember consumerMember, ConsumerWallet consumerWallet, MemberConfig memberConfigServiceOne) {
@Override
public void addConsumerMember(Long consumerId, BigDecimal giftPoints,
ConsumerMember consumerMember, ConsumerWallet consumerWallet) {
String expirationDateEquityMembership = sysConfigService.selectConfigByKey("expirationDateEquityMembership");
if (equityMembersOrderConfig.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) {
if (giftPoints.compareTo(BigDecimal.ZERO) > 0) {
MemberProgressLog memberProgressLog = new MemberProgressLog();
memberProgressLog.setConsumerId(equityMembersOrder.getConsumerId());
memberProgressLog.setConsumerId(consumerId);
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
memberProgressLog.setVariableProgress(equityMembersOrderConfig.getGiftPoints());
memberProgressLog.setVariableProgress(giftPoints);
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), Integer.parseInt(expirationDateEquityMembership)));
consumerMember.setMembershipProgress(giftPoints.add(consumerMember.getMembershipProgress()));
IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(equityMembersOrder.getConsumerId());
integralLog.setCurrentIntegral(consumerMember.getMembershipProgress());
consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(equityMembersOrderConfig.getGiftPoints()));
integralLog.setVariableIntegral(equityMembersOrderConfig.getGiftPoints());
integralLog.setConsumerId(consumerId);
integralLog.setCurrentIntegral(consumerWallet.getRemainingIntegral());
integralLog.setVariableIntegral(giftPoints);
integralLog.setOperationType(YesNoEnum.yes.getIndex());
integralLog.setOperationTime(new Date());
integralLog.setCreateTime(new Date());
consumerMember.setMembershipProgress(equityMembersOrderConfig.getGiftPoints().add(consumerMember.getMembershipProgress()));
consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(giftPoints));
integralLogService.save(integralLog);
memberProgressLogService.save(memberProgressLog);
consumerWalletService.updateById(consumerWallet);
......
......@@ -15,10 +15,7 @@ import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtils;
import share.common.utils.bean.BeanUtils;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.MonthlyCardConf;
import share.system.domain.MonthlyCardOrder;
import share.system.domain.SConsumer;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MonthlyCardOrderVo;
import share.system.mapper.MonthlyCardOrderMapper;
......@@ -51,6 +48,12 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap
private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired
private RedisUtil redisUtil;
@Autowired
private ConsumerWalletService consumerWalletService;
@Autowired
private ConsumerMemberService consumerMemberService;
@Autowired
private EquityMembersOrderService equityMembersOrderService;
/**
* 查询月卡订单
......@@ -168,6 +171,8 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap
public void paymentSuccessful(MonthlyCardOrder monthlyCardOrder) {
updateById(monthlyCardOrder);
ConsumerMonthlyCard consumerMonthlyCard = new ConsumerMonthlyCard();
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, monthlyCardOrder.getConsumerId()));
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, monthlyCardOrder.getConsumerId()));
MonthlyCardConf byId = monthlyCardConfService.getById(monthlyCardOrder.getMonthlyCardConfId());
consumerMonthlyCard.setMonthlyCardConfId(byId.getId());
consumerMonthlyCard.setConsumerId(monthlyCardOrder.getConsumerId());
......@@ -177,6 +182,7 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap
consumerMonthlyCard.setMonthlyCardDays(byId.getMonthlyCardDays());
consumerMonthlyCard.setCreateTime(new Date());
consumerMonthlyCardService.save(consumerMonthlyCard);
equityMembersOrderService.addConsumerMember(monthlyCardOrder.getConsumerId(), monthlyCardOrder.getMonthlyCardAmount(), consumerMember, consumerWallet);
Map<String, String> map = new HashMap<>();
map.put("consumerMonthlyCardId", String.valueOf(consumerMonthlyCard.getId()));
map.put("expirationTime", consumerMonthlyCard.getExpirationDate().toString());
......
......@@ -1579,23 +1579,20 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
monthlyCardLogService.save(monthlyCardLog);
}
// if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId()) && !ObjectUtils.isEmpty(sOrder.getPackId())) {
// if (sOrder.getPackId().equals(consumerSecondaryCard.getPackId())) {
// consumerSecondaryCard.setNumber(consumerSecondaryCard.getNumber() + 1);
// SecondaryCardLog secondaryCardLog = new SecondaryCardLog();
// secondaryCardLog.setConsumerSecondaryCardId(sOrder.getSecondaryCardId());
// secondaryCardLog.setConsumerId(consumerSecondaryCard.getConsumerId());
// secondaryCardLog.setPhone(sOrder.getConsumerPhone());
// secondaryCardLog.setPackId(sOrder.getPackId());
// secondaryCardLog.setUsageCount(1L);
// secondaryCardLog.setResidueCount(Long.valueOf(consumerSecondaryCard.getNumber()));
// secondaryCardLog.setOperationType(YesNoEnum.yes.getIndex());
// secondaryCardLog.setOperationTime(new Date());
// secondaryCardLog.setCreateTime(new Date());
// consumerSecondaryCardService.updateById(consumerSecondaryCard);
// secondaryCardLogService.save(secondaryCardLog);
// }
// }
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
consumerSecondaryCard.setNumber(consumerSecondaryCard.getNumber() + 1);
SecondaryCardLog secondaryCardLog = new SecondaryCardLog();
secondaryCardLog.setConsumerSecondaryCardId(sOrder.getSecondaryCardId());
secondaryCardLog.setConsumerId(consumerSecondaryCard.getConsumerId());
secondaryCardLog.setPhone(sOrder.getConsumerPhone());
secondaryCardLog.setUsageCount(1L);
secondaryCardLog.setResidueCount(Long.valueOf(consumerSecondaryCard.getNumber()));
secondaryCardLog.setOperationType(YesNoEnum.yes.getIndex());
secondaryCardLog.setOperationTime(new Date());
secondaryCardLog.setCreateTime(new Date());
consumerSecondaryCardService.updateById(consumerSecondaryCard);
secondaryCardLogService.save(secondaryCardLog);
}
}
private String lockOrder(CreateOrderRequest request) throws BaseException {
try {
......@@ -2669,8 +2666,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (ObjectUtil.isNotEmpty(user)) {
consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getId, request.getMonthlyCardId()));
consumerSecondaryCard = consumerSecondaryCardService.getOne(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getId, request.getSecondaryCardId()));
if (ObjectUtil.isNotEmpty(request.getMonthlyCardId())) {
consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getId, request.getMonthlyCardId()));
}
if (ObjectUtil.isNotEmpty(request.getSecondaryCardId())) {
consumerSecondaryCard = consumerSecondaryCardService.getOne(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getId, request.getSecondaryCardId()));
}
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
// if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
......@@ -2711,6 +2712,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (ObjectUtil.isNotEmpty(consumerMember)) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room, consumerMember);
} else if (ObjectUtil.isNotEmpty(consumerSecondaryCard)) {
totalFee = getBigDecimal(consumerSecondaryCard, priceResponse, payPrice, timeLong, room);
} else {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
......@@ -2759,6 +2762,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (ObjectUtil.isNotEmpty(consumerMember)) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room, consumerMember);
} else if (ObjectUtil.isNotEmpty(consumerSecondaryCard)) {
totalFee = getBigDecimal(consumerSecondaryCard, priceResponse, payPrice, timeLong, room);
} else {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
......@@ -3156,14 +3161,28 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private BigDecimal getBigDecimal(ConsumerSecondaryCard consumerSecondaryCard,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
// if (consumerSecondaryCard.getPackId().equals(byId.getId())) {
// priceResponse.setDiscount(BigDecimal.ZERO);
// priceResponse.setMemberDiscount(BigDecimal.ZERO);
// priceResponse.setTotalFeeNow(BigDecimal.ZERO);
// priceResponse.setPayFee(BigDecimal.ZERO);
// priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
// payPrice = BigDecimal.ZERO;
// }
if (Integer.getInteger(byId.getDuration()) > (consumerSecondaryCard.getSingleDuration()) && consumerSecondaryCard.getSingleAmount().compareTo(byId.getPrice()) > 0) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(BigDecimal.ZERO);
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO;
}
return payPrice;
}
private BigDecimal getBigDecimal(ConsumerSecondaryCard consumerSecondaryCard,
ComputedOrderPriceResponse priceResponse, BigDecimal payPrice, BigDecimal timeLong, SRoom room) {
BigDecimal bigDecimal = new BigDecimal(consumerSecondaryCard.getSingleDuration());
if (bigDecimal.compareTo(timeLong) == 0 && consumerSecondaryCard.getSingleAmount().compareTo(timeLong.multiply(room.getPrice())) >= 0) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(BigDecimal.ZERO);
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO;
}
return payPrice;
}
......
......@@ -14,10 +14,7 @@ import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtils;
import share.common.utils.bean.BeanUtils;
import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.SConsumer;
import share.system.domain.SecondaryCardConf;
import share.system.domain.SecondaryCardOrder;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SecondaryCardOrderVo;
import share.system.mapper.SecondaryCardOrderMapper;
......@@ -50,6 +47,12 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired
private RedisUtil redisUtil;
@Autowired
private ConsumerWalletService consumerWalletService;
@Autowired
private ConsumerMemberService consumerMemberService;
@Autowired
private EquityMembersOrderService equityMembersOrderService;
/**
* 查询次卡购买记录
......@@ -157,6 +160,8 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
@Override
public void paymentSuccessful(SecondaryCardOrder secondaryCardOrder) {
updateById(secondaryCardOrder);
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, secondaryCardOrder.getConsumerId()));
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, secondaryCardOrder.getConsumerId()));
ConsumerSecondaryCard consumerSecondaryCard = new ConsumerSecondaryCard();
SecondaryCardConf secondaryCardConf = secondaryCardConfService.getById(secondaryCardOrder.getSecondaryCardConfId());
consumerSecondaryCard.setSecondaryCardConfId(secondaryCardOrder.getSecondaryCardConfId());
......@@ -168,6 +173,7 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
consumerSecondaryCard.setNumber(secondaryCardConf.getNumber());
consumerSecondaryCard.setCreateTime(new Date());
consumerSecondaryCardService.save(consumerSecondaryCard);
equityMembersOrderService.addConsumerMember(secondaryCardOrder.getConsumerId(), secondaryCardOrder.getSecondaryCardAmount(), consumerMember, consumerWallet);
Map<String, String> map = new HashMap<>();
map.put("consumerSecondaryCardId", String.valueOf(consumerSecondaryCard.getId()));
map.put("expirationTime", consumerSecondaryCard.getExpirationDate().toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment