Commit 10adbc0b by 吕明尚

增加次卡,月卡的订单计算

parent 4942f11f
...@@ -13,7 +13,9 @@ public enum ReceiptRdeisEnum { ...@@ -13,7 +13,9 @@ public enum ReceiptRdeisEnum {
//房间15分钟过期 //房间15分钟过期
ROOM_EXPIRE_TIME(9, "ROOM_EXPIRE_TIME."), ROOM_EXPIRE_TIME(9, "ROOM_EXPIRE_TIME."),
ORDER_CANCEL_PAY(10, "ORDER_CANCEL_PAY."), ORDER_CANCEL_PAY(10, "ORDER_CANCEL_PAY."),
EQUITY_MEMBERS_TIME(11, "EQUITY_MEMBERS_TIME.") EQUITY_MEMBERS_TIME(11, "EQUITY_MEMBERS_TIME."),
MONTHLY_CARD(12, "MONTHLY_CARD."),
SECONDARY_CARD(13, "SECONDARY_CARD.")
; ;
......
package share.system.domain; package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
...@@ -10,6 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; ...@@ -10,6 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel; import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity; import share.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
...@@ -51,7 +50,7 @@ public class ConsumerMonthlyCard extends BaseEntity { ...@@ -51,7 +50,7 @@ public class ConsumerMonthlyCard extends BaseEntity {
* 免费时长 * 免费时长
*/ */
@Excel(name = "免费时长") @Excel(name = "免费时长")
private Long freeDuration; private BigDecimal freeDuration;
/** /**
* 月卡天数 * 月卡天数
...@@ -69,7 +68,10 @@ public class ConsumerMonthlyCard extends BaseEntity { ...@@ -69,7 +68,10 @@ public class ConsumerMonthlyCard extends BaseEntity {
/** /**
* 删除标记:1-删除,0-正常 * 删除标记:1-删除,0-正常
*/ */
private Long isDelete; //逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Integer isDelete;
@Override @Override
......
...@@ -43,7 +43,7 @@ public class MonthlyCardConf extends BaseEntity { ...@@ -43,7 +43,7 @@ public class MonthlyCardConf extends BaseEntity {
* 免费时长 * 免费时长
*/ */
@Excel(name = "免费时长") @Excel(name = "免费时长")
private Long freeDuration; private BigDecimal freeDuration;
/** /**
* 月卡天数 * 月卡天数
......
...@@ -9,6 +9,8 @@ import org.apache.commons.lang3.builder.ToStringStyle; ...@@ -9,6 +9,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel; import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity; import share.common.core.domain.BaseEntity;
import java.math.BigDecimal;
/** /**
* 月卡使用记录对象 s_monthly_card_log * 月卡使用记录对象 s_monthly_card_log
* *
...@@ -47,13 +49,13 @@ public class MonthlyCardLog extends BaseEntity { ...@@ -47,13 +49,13 @@ public class MonthlyCardLog extends BaseEntity {
* 使用时长 * 使用时长
*/ */
@Excel(name = "使用时长") @Excel(name = "使用时长")
private Long useDuration; private BigDecimal useDuration;
/** /**
* 剩余时长 * 剩余时长
*/ */
@Excel(name = "剩余时长") @Excel(name = "剩余时长")
private Long residueDuration; private BigDecimal residueDuration;
/** /**
* 删除标记:1-删除,0-正常 * 删除标记:1-删除,0-正常
......
...@@ -81,6 +81,12 @@ public class SOrder extends BaseEntity ...@@ -81,6 +81,12 @@ public class SOrder extends BaseEntity
@Excel(name = "优惠券金额") @Excel(name = "优惠券金额")
private BigDecimal couponPrice; private BigDecimal couponPrice;
@Excel(name = "次卡ID")
private Long secondaryCardId;
@Excel(name = "月卡ID")
private Long monthlyCardId;
@Excel(name = "订单总价") @Excel(name = "订单总价")
private BigDecimal totalPrice; private BigDecimal totalPrice;
......
...@@ -2,9 +2,10 @@ package share.system.domain.vo; ...@@ -2,9 +2,10 @@ package share.system.domain.vo;
import lombok.Data; import lombok.Data;
import share.system.domain.ConsumerMember; import share.system.domain.ConsumerMember;
import share.system.domain.ConsumerWallet;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import java.util.List;
/** /**
* @className: share.system.domain.vo.SConsumerVo * @className: share.system.domain.vo.SConsumerVo
* @description: 会员 * @description: 会员
...@@ -46,7 +47,8 @@ public class SConsumerVo extends SConsumer { ...@@ -46,7 +47,8 @@ public class SConsumerVo extends SConsumer {
private Long newId; private Long newId;
private List<ConsumerMonthlyCardVo> monthlyCardList;
private List<ConsumerSecondaryCardVo> secondaryCardList;
} }
...@@ -61,5 +61,5 @@ public interface ConsumerMonthlyCardMapper extends BaseMapper<ConsumerMonthlyCar ...@@ -61,5 +61,5 @@ public interface ConsumerMonthlyCardMapper extends BaseMapper<ConsumerMonthlyCar
*/ */
public int deleteConsumerMonthlyCardByIds(Long[] ids); public int deleteConsumerMonthlyCardByIds(Long[] ids);
ConsumerMonthlyCardVo selectByConsumerId(ConsumerMonthlyCardVo consumerMemberVo); List<ConsumerMonthlyCardVo> selectByConsumerId(ConsumerMonthlyCardVo consumerMemberVo);
} }
...@@ -89,4 +89,12 @@ public class CreateOrderRequest { ...@@ -89,4 +89,12 @@ public class CreateOrderRequest {
@ApiModelProperty(value = "使用时长") @ApiModelProperty(value = "使用时长")
private BigDecimal duration; private BigDecimal duration;
//次卡ID
@ApiModelProperty(value = "次卡ID")
private Long secondaryCardId;
//月卡ID
@ApiModelProperty(value = "月卡ID")
private Long monthlyCardId;
} }
...@@ -68,5 +68,12 @@ public class ComputedOrderPriceResponse implements Serializable { ...@@ -68,5 +68,12 @@ public class ComputedOrderPriceResponse implements Serializable {
@ApiModelProperty(value = "剩余余额") @ApiModelProperty(value = "剩余余额")
private BigDecimal remainingBalance; private BigDecimal remainingBalance;
//次卡ID
@ApiModelProperty(value = "次卡ID")
private Long secondaryCardId;
//月卡ID
@ApiModelProperty(value = "月卡ID")
private Long monthlyCardId;
} }
...@@ -61,5 +61,5 @@ public interface ConsumerMonthlyCardService extends IService<ConsumerMonthlyCard ...@@ -61,5 +61,5 @@ public interface ConsumerMonthlyCardService extends IService<ConsumerMonthlyCard
*/ */
public int deleteConsumerMonthlyCardById(Long id); public int deleteConsumerMonthlyCardById(Long id);
ConsumerMonthlyCardVo selectByConsumerId(); List<ConsumerMonthlyCardVo> selectByConsumerId();
} }
...@@ -95,7 +95,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC ...@@ -95,7 +95,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
} }
@Override @Override
public ConsumerMonthlyCardVo selectByConsumerId() { public List<ConsumerMonthlyCardVo> selectByConsumerId() {
SConsumer info = sConsumerService.getInfo(); SConsumer info = sConsumerService.getInfo();
ConsumerMonthlyCardVo vo = new ConsumerMonthlyCardVo(); ConsumerMonthlyCardVo vo = new ConsumerMonthlyCardVo();
vo.setConsumerId(info.getId()); vo.setConsumerId(info.getId());
......
package share.system.service.impl; package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
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 share.common.core.redis.RedisUtil;
import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.YesNoEnum; import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil; import share.common.utils.BaseUtil;
...@@ -24,7 +27,9 @@ import share.system.response.MonthlyyCardPayResultResponse; ...@@ -24,7 +27,9 @@ import share.system.response.MonthlyyCardPayResultResponse;
import share.system.service.*; import share.system.service.*;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 月卡订单Service业务层处理 * 月卡订单Service业务层处理
...@@ -44,6 +49,8 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap ...@@ -44,6 +49,8 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap
private MonthlyCardConfService monthlyCardConfService; private MonthlyCardConfService monthlyCardConfService;
@Autowired @Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService; private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired
private RedisUtil redisUtil;
/** /**
* 查询月卡订单 * 查询月卡订单
...@@ -170,6 +177,18 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap ...@@ -170,6 +177,18 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap
consumerMonthlyCard.setMonthlyCardDays(byId.getMonthlyCardDays()); consumerMonthlyCard.setMonthlyCardDays(byId.getMonthlyCardDays());
consumerMonthlyCard.setCreateTime(new Date()); consumerMonthlyCard.setCreateTime(new Date());
consumerMonthlyCardService.save(consumerMonthlyCard); consumerMonthlyCardService.save(consumerMonthlyCard);
Map<String, String> map = new HashMap<>();
map.put("consumerMonthlyCardId", String.valueOf(consumerMonthlyCard.getId()));
map.put("expirationTime", consumerMonthlyCard.getExpirationDate().toString());
JSONObject jsonObject = new JSONObject(map);
new Thread(() -> {
try {
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.MONTHLY_CARD.getValue() + consumerMonthlyCard.getId(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
} }
@Override @Override
......
...@@ -25,7 +25,6 @@ import share.common.utils.DateUtils; ...@@ -25,7 +25,6 @@ import share.common.utils.DateUtils;
import share.common.utils.StringUtils; import share.common.utils.StringUtils;
import share.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.*; import share.system.domain.vo.*;
import share.system.mapper.ConsumerMemberMapper;
import share.system.mapper.SConsumerMapper; import share.system.mapper.SConsumerMapper;
import share.system.mapper.SStoreConsumerMapper; import share.system.mapper.SStoreConsumerMapper;
import share.system.request.RegisterThirdSConsumerRequest; import share.system.request.RegisterThirdSConsumerRequest;
...@@ -63,6 +62,10 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer ...@@ -63,6 +62,10 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
private MemberConfigService memberConfigService; private MemberConfigService memberConfigService;
@Autowired @Autowired
private MemberProgressLogService memberProgressLogService; private MemberProgressLogService memberProgressLogService;
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired @Autowired
...@@ -214,6 +217,8 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer ...@@ -214,6 +217,8 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
BeanUtils.copyProperties(currentUser, vo); BeanUtils.copyProperties(currentUser, vo);
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, currentUser.getId())); ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, currentUser.getId()));
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, currentUser.getId())); ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, currentUser.getId()));
List<ConsumerSecondaryCardVo> consumerSecondaryCardVos = consumerSecondaryCardService.selectByConsumerId();
List<ConsumerMonthlyCardVo> consumerMonthlyCardVo = consumerMonthlyCardService.selectByConsumerId();
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
vo.setConsumerMember(consumerMember); vo.setConsumerMember(consumerMember);
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
...@@ -277,9 +282,12 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer ...@@ -277,9 +282,12 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
} else { } else {
vo.setIsManage(true); vo.setIsManage(true);
} }
if (!CollectionUtils.isEmpty(consumerSecondaryCardVos)) {
vo.setSecondaryCardList(consumerSecondaryCardVos);
}
if (!CollectionUtils.isEmpty(consumerMonthlyCardVo)) {
vo.setMonthlyCardList(consumerMonthlyCardVo);
}
return vo; return vo;
} }
...@@ -352,8 +360,8 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer ...@@ -352,8 +360,8 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
public TableDataInfo selectConsumernotById(SConsumerVo sConsumer) { public TableDataInfo selectConsumernotById(SConsumerVo sConsumer) {
List<ConsumerMember> consumerMembers = consumerMemberService List<ConsumerMember> consumerMembers = consumerMemberService
.list(new LambdaQueryWrapper<ConsumerMember>() .list(new LambdaQueryWrapper<ConsumerMember>()
.eq(ConsumerMember::getIsRights,YesNoEnum.yes.getIndex()) .eq(ConsumerMember::getIsRights, YesNoEnum.yes.getIndex())
.ne(ConsumerMember::getConsumerId,sConsumer.getNewId())); .ne(ConsumerMember::getConsumerId, sConsumer.getNewId()));
List<Long> collect = consumerMembers.stream().map(ConsumerMember::getConsumerId).collect(Collectors.toList()); List<Long> collect = consumerMembers.stream().map(ConsumerMember::getConsumerId).collect(Collectors.toList());
LambdaQueryWrapper<SConsumer> uSConsumer = new LambdaQueryWrapper<SConsumer>(); LambdaQueryWrapper<SConsumer> uSConsumer = new LambdaQueryWrapper<SConsumer>();
if (StringUtils.isNotEmpty(sConsumer.getPhone())){ if (StringUtils.isNotEmpty(sConsumer.getPhone())){
......
...@@ -172,6 +172,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -172,6 +172,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired @Autowired
private RechargeService rechargeService; private RechargeService rechargeService;
@Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired
private MonthlyCardLogService monthlyCardLogService;
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired
private SecondaryCardLogService secondaryCardLogService;
@Autowired @Autowired
private SharingActivitiesService sharingActivitiesService; private SharingActivitiesService sharingActivitiesService;
...@@ -2480,10 +2488,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2480,10 +2488,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
Activity activity = null; Activity activity = null;
ConsumerMember consumerMember = null; ConsumerMember consumerMember = null;
ConsumerWallet consumerWallet = null; ConsumerWallet consumerWallet = null;
ConsumerMonthlyCard consumerMonthlyCard = null;
List<ConsumerSecondaryCard> consumerSecondaryCardList = null;
LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(user)) { if (ObjectUtil.isNotEmpty(user)) {
consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId())); consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId())); consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getConsumerId, user.getId()));
consumerSecondaryCardList = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId())
.ne(ConsumerSecondaryCard::getNumber, YesNoEnum.no.getIndex())
);
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex()); queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
// if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) { // if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
...@@ -2532,6 +2546,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2532,6 +2546,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
} }
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
}
} else { } else {
SPack byId = packService.getById(roomLabel.getPackId()); SPack byId = packService.getById(roomLabel.getPackId());
if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) { if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
...@@ -2549,6 +2566,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2549,6 +2566,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
} }
if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
}
// if(ObjectUtil.isNotEmpty(consumerMonthlyCard)){
// totalFee = getBigDecimal(consumerMonthlyCard,timeLong,priceResponse,totalFee,room);
// }
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId); // totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId);
} else { } else {
...@@ -2566,6 +2589,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2566,6 +2589,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
} }
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
}
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room); // totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room);
} }
...@@ -2586,6 +2612,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2586,6 +2612,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
} }
if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
}
} }
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
...@@ -2914,6 +2943,46 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2914,6 +2943,46 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return payPrice; return payPrice;
} }
private BigDecimal getBigDecimal(ConsumerMonthlyCard consumerMonthlyCard, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) {
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
priceResponse.setDiscount(BigDecimal.ZERO);
totalFee = new BigDecimal(0);
priceResponse.setMemberDiscount(new BigDecimal(0.00));
priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
} else if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerMonthlyCard.getFreeDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = consumerMonthlyCard.getFreeDuration().multiply(room.getPrice());
remainingBalance = totalFee.subtract(remainingBalance);
priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance;
priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
}
return totalFee;
}
private BigDecimal getBigDecimal(List<ConsumerSecondaryCard> consumerSecondaryCardList,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
//获取集合中次数最少的次卡,次数不低于0
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardList.stream().min(Comparator.comparing(ConsumerSecondaryCard::getNumber)).get();
if (consumerSecondaryCard.getPackId().equals(byId.getId())) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(payPrice);
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO;
}
return payPrice;
}
private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) { private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) {
SPack pack = packService.getById(packId); SPack pack = packService.getById(packId);
if (Objects.isNull(pack)) { if (Objects.isNull(pack)) {
......
package share.system.service.impl; package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
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 share.common.core.redis.RedisUtil;
import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.YesNoEnum; import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil; import share.common.utils.BaseUtil;
...@@ -23,7 +26,9 @@ import share.system.response.SecondaryCardOrderPayResultResponse; ...@@ -23,7 +26,9 @@ import share.system.response.SecondaryCardOrderPayResultResponse;
import share.system.service.*; import share.system.service.*;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 次卡购买记录Service业务层处理 * 次卡购买记录Service业务层处理
...@@ -43,6 +48,8 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde ...@@ -43,6 +48,8 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
private SecondaryCardConfService secondaryCardConfService; private SecondaryCardConfService secondaryCardConfService;
@Autowired @Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService; private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired
private RedisUtil redisUtil;
/** /**
* 查询次卡购买记录 * 查询次卡购买记录
...@@ -160,6 +167,18 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde ...@@ -160,6 +167,18 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
consumerSecondaryCard.setNumber(secondaryCardConf.getNumber()); consumerSecondaryCard.setNumber(secondaryCardConf.getNumber());
consumerSecondaryCard.setCreateTime(new Date()); consumerSecondaryCard.setCreateTime(new Date());
consumerSecondaryCardService.save(consumerSecondaryCard); consumerSecondaryCardService.save(consumerSecondaryCard);
Map<String, String> map = new HashMap<>();
map.put("consumerSecondaryCardId", String.valueOf(consumerSecondaryCard.getId()));
map.put("expirationTime", consumerSecondaryCard.getExpirationDate().toString());
JSONObject jsonObject = new JSONObject(map);
new Thread(() -> {
try {
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.SECONDARY_CARD.getValue() + consumerSecondaryCard.getId(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
} }
@Override @Override
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
<result property="packPrice" column="pack_price"/> <result property="packPrice" column="pack_price"/>
<result property="couponId" column="coupon_id"/> <result property="couponId" column="coupon_id"/>
<result property="couponPrice" column="coupon_price"/> <result property="couponPrice" column="coupon_price"/>
<result property="secondaryCardId" column="secondary_card_id"/>
<result property="monthlyCardId" column="monthly_card_id"/>
<result property="totalPrice" column="total_price"/> <result property="totalPrice" column="total_price"/>
<result property="duration" column="duration"/> <result property="duration" column="duration"/>
<result property="balance" column="balance"/> <result property="balance" column="balance"/>
...@@ -63,6 +65,8 @@ ...@@ -63,6 +65,8 @@
pack_price, pack_price,
coupon_id, coupon_id,
coupon_price, coupon_price,
secondary_card_id,
monthly_card_id,
total_price, total_price,
pay_price, pay_price,
duration, duration,
...@@ -106,6 +110,8 @@ ...@@ -106,6 +110,8 @@
pack_price, pack_price,
coupon_id, coupon_id,
coupon_price, coupon_price,
secondary_card_id,
monthly_card_id,
total_price, total_price,
pay_price, pay_price,
duration, duration,
...@@ -149,6 +155,8 @@ ...@@ -149,6 +155,8 @@
<if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if> <if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if>
<if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if> <if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if>
<if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if> <if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if>
<if test="secondaryCardId != null and secondaryCardId != ''">and secondary_card_id = #{secondaryCardId}</if>
<if test="monthlyCardId != null and monthlyCardId != ''">and monthly_card_id = #{monthlyCardId}</if>
<if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if> <if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if>
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if> <if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="duration != null and duration != ''">and duration = #{duration}</if> <if test="duration != null and duration != ''">and duration = #{duration}</if>
...@@ -230,6 +238,8 @@ ...@@ -230,6 +238,8 @@
s.pack_price, s.pack_price,
s.coupon_id, s.coupon_id,
s.coupon_price, s.coupon_price,
s.secondary_card_id,
s.monthly_card_id,
s.total_price, s.total_price,
s.pay_price, s.pay_price,
s.discount_ratio, s.discount_ratio,
...@@ -278,6 +288,8 @@ ...@@ -278,6 +288,8 @@
s.pack_price, s.pack_price,
s.coupon_id, s.coupon_id,
s.coupon_price, s.coupon_price,
s.secondary_card_id,
s.monthly_card_id,
s.total_price, s.total_price,
s.pay_price, s.pay_price,
s.discount_ratio, s.discount_ratio,
...@@ -339,6 +351,8 @@ ...@@ -339,6 +351,8 @@
<if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if> <if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if>
<if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if> <if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if>
<if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if> <if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if>
<if test="secondaryCardId != null and secondaryCardId != ''">and secondary_card_id = #{secondaryCardId}</if>
<if test="monthlyCardId != null and monthlyCardId != ''">and monthly_card_id = #{monthlyCardId}</if>
<if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if> <if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if>
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if> <if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="duration != null and duration != ''">and duration = #{duration}</if> <if test="duration != null and duration != ''">and duration = #{duration}</if>
...@@ -401,6 +415,8 @@ ...@@ -401,6 +415,8 @@
<if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if> <if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if>
<if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if> <if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if>
<if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if> <if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if>
<if test="secondaryCardId != null and secondaryCardId != ''">and secondary_card_id = #{secondaryCardId}</if>
<if test="monthlyCardId != null and monthlyCardId != ''">and monthly_card_id = #{monthlyCardId}</if>
<if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if> <if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if>
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if> <if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="duration != null and duration != ''">and duration = #{duration}</if> <if test="duration != null and duration != ''">and duration = #{duration}</if>
...@@ -480,6 +496,8 @@ ...@@ -480,6 +496,8 @@
<if test="discountRatio != null and discountRatio != ''">discount_ratio,</if> <if test="discountRatio != null and discountRatio != ''">discount_ratio,</if>
<if test="duration != null and duration != ''">duration,</if> <if test="duration != null and duration != ''">duration,</if>
<if test="balance != null and balance != '' ">balance,</if> <if test="balance != null and balance != '' ">balance,</if>
<if test="secondaryCardId != null and secondaryCardId != ''">secondary_card_id,</if>
<if test="monthlyCardId != null and monthlyCardId != ''">monthly_card_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null">#{orderNo},</if> <if test="orderNo != null">#{orderNo},</if>
...@@ -517,6 +535,8 @@ ...@@ -517,6 +535,8 @@
<if test="discountRatio != null">#{discountRatio},</if> <if test="discountRatio != null">#{discountRatio},</if>
<if test="duration != null">#{duration},</if> <if test="duration != null">#{duration},</if>
<if test="balance != null">#{balance},</if> <if test="balance != null">#{balance},</if>
<if test="secondaryCardId != null">#{secondary_card_id},</if>
<if test="monthlyCardId != null">#{monthly_card_id},</if>
</trim> </trim>
</insert> </insert>
...@@ -559,6 +579,8 @@ ...@@ -559,6 +579,8 @@
<if test="discountRatio != null">discount_ratio = #{discountRatio},</if> <if test="discountRatio != null">discount_ratio = #{discountRatio},</if>
<if test="duration != null">duration = #{duration},</if> <if test="duration != null">duration = #{duration},</if>
<if test="balance != null">balance = #{balance},</if> <if test="balance != null">balance = #{balance},</if>
<if test="monthlyCardId != null">monthly_card_id = #{monthlyCardId},</if>
<if test="secondaryCardId != null">secondary_card_id = #{secondaryCardId},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
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