Commit 487fde0a by 吕明尚

修改查询订单金额

parent 7b02730d
...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -10,6 +10,7 @@ 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 com.cronutils.model.Cron; import com.cronutils.model.Cron;
import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinitionBuilder; import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.model.time.ExecutionTime; import com.cronutils.model.time.ExecutionTime;
import com.cronutils.parser.CronParser; import com.cronutils.parser.CronParser;
...@@ -1852,51 +1853,67 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1852,51 +1853,67 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private ComputedOrderPriceResponse computedPrice(OrderComputedPriceRequest request, SConsumer user) { private ComputedOrderPriceResponse computedPrice(OrderComputedPriceRequest request, SConsumer user) {
// 计算各种价格 // 计算各种价格
ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse(); ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse();
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId())); Activity activity;
ConsumerMember consumerMember = new ConsumerMember();
LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(user)) {
consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
queryWrapper.eq(Activity::getMemberType, consumerMember.getMemberType());
}
}
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate()); BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate());
BigDecimal payPrice = new BigDecimal(0); BigDecimal payPrice = new BigDecimal(0);
BigDecimal totalFee = new BigDecimal(0); BigDecimal totalFee = new BigDecimal(0);
Activity activity;
LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
queryWrapper.eq(Activity::getMemberType, consumerMember.getMemberType());
if (!ObjectUtils.isEmpty(request.getRoomLabelId())) { if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId()); RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
payPrice = totalPrice;
request.setBuyType(BuyTypeEnum.TIME.getCode());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) { if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId()); if (ObjectUtil.isNotEmpty(consumerMember)) {
activity = activityService.getOne(queryWrapper); queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
payPrice = totalPrice; activity = activityService.getOne(queryWrapper);
request.setBuyType(BuyTypeEnum.TIME.getCode()); totalFee = getBigDecimal(request, activity, payPrice, user);
totalFee = getBigDecimal(request, activity, payPrice, user); }
} 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())) {
queryWrapper.eq(Activity::getPackId, roomLabel.getPackId());
activity = activityService.getOne(queryWrapper);
payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice); payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode()); request.setBuyType(BuyTypeEnum.PACK.getCode());
totalFee = getBigDecimal(request, activity, payPrice, user); if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getPackId, roomLabel.getPackId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user);
}
} else { } else {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
payPrice = totalPrice; payPrice = totalPrice;
request.setBuyType(BuyTypeEnum.TIME.getCode()); request.setBuyType(BuyTypeEnum.TIME.getCode());
totalFee = getBigDecimal(request, activity, payPrice, user); if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user);
}
} }
} }
} else if (!ObjectUtils.isEmpty(request.getPackId())) { } else if (!ObjectUtils.isEmpty(request.getPackId())) {
queryWrapper.eq(Activity::getPackId, request.getPackId());
activity = activityService.getOne(queryWrapper);
payPrice = computeTotalPrice(request.getPackId(), totalPrice); payPrice = computeTotalPrice(request.getPackId(), totalPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode()); request.setBuyType(BuyTypeEnum.PACK.getCode());
totalFee = getBigDecimal(request, activity, payPrice, user); if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getPackId, request.getPackId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user);
}
} }
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
priceResponse.setPayFee(totalFee); priceResponse.setPayFee(totalFee);
// 计算优惠券金额 // 计算优惠券金额
if (ObjectUtil.isNull(request.getCouponId()) || request.getCouponId() <= 0) { if (ObjectUtil.isNull(request.getCouponId()) || request.getCouponId() <= 0) {
priceResponse.setCouponFee(BigDecimal.ZERO); priceResponse.setCouponFee(BigDecimal.ZERO);
priceResponse.setPayFee(payPrice);
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee()).multiply(new BigDecimal(100)));
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getId, consumerMember.getMemberConfigId())); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getId, consumerMember.getMemberConfigId()));
//总金额乘以折扣比例除以100 //总金额乘以折扣比例除以100
...@@ -1922,14 +1939,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1922,14 +1939,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private BigDecimal getBigDecimal(OrderComputedPriceRequest request, Activity activity, BigDecimal payPrice, SConsumer user) { private BigDecimal getBigDecimal(OrderComputedPriceRequest request, Activity activity, BigDecimal payPrice, SConsumer user) {
if (ObjectUtil.isNotEmpty(activity)) { if (ObjectUtil.isNotEmpty(activity)) {
CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(com.cronutils.model.CronType.QUARTZ)); CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
Cron cron = cronParser.parse(activity.getCronExpression()); Cron cron = cronParser.parse(activity.getCronExpression());
ExecutionTime executionTime = ExecutionTime.forCron(cron); ExecutionTime executionTime = ExecutionTime.forCron(cron);
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getConsumerId, user.getId()); queryWrapper.eq(SOrder::getConsumerId, user.getId());
queryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus()); queryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus());
queryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex()); queryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
queryWrapper.ne(SOrder::getPayPrice, new BigDecimal(0.00)); queryWrapper.ne(SOrder::getPayPrice, new BigDecimal(0));
queryWrapper.isNull(SOrder::getCouponId); queryWrapper.isNull(SOrder::getCouponId);
List<SOrder> orderList = list(queryWrapper); List<SOrder> orderList = list(queryWrapper);
if (CollectionUtils.isEmpty(orderList)) { if (CollectionUtils.isEmpty(orderList)) {
......
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