Commit 8c9fbe03 by huluobin

update

parent 7594d361
......@@ -3,8 +3,6 @@ package com.gogirl.application.market.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gogirl.application.market.CouponService;
import com.gogirl.application.market.MarketService;
import com.gogirl.domain.market.coupon.Coupon;
......@@ -224,7 +222,20 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
return ListUtil.isNotEmpty(canUserServeIds);
})
.peek(coupon -> {
List<Integer> canUserServeIds = couponCustomerRelevanceMapper.queryCouponCustomerServeRelevance(coupon.getId());
canUserServeIds.retainAll(orderServeList.stream()
.filter(orderServe -> orderServe.getBindCoupon() == 2)
.filter(orderServe -> {
if (orderServe.getProduceId() != null) {
return orderServe.getProduceCurrentPrice().compareTo(orderServe.getProduceBargainPrice()) > -1;
}
return true;
})
.filter(orderServe -> orderServe.getProducePromotionTimeId() == null)
.filter(orderServe -> orderServe.getLeisureDiscountConfigId() == null || orderServe.getLeisureDiscountConfigId() == 0)
.map(OrderServe::getServeId)
.collect(Collectors.toList()));
coupon.setCanBeUse(ListUtil.isNotEmpty(canUserServeIds));
})
//过滤达到可用金额
.filter(coupon -> coupon.getReachingAmount().compareTo(orderManage.getTotalPrice()) < 0)
......
......@@ -540,18 +540,20 @@ public class MarketServiceImpl implements MarketService {
//每个服务的内部券抵扣金额
BigDecimal discountAmount = orderServe.getPayPrice().multiply(totalCouponDiscount).divide(total, 2, BigDecimal.ROUND_HALF_UP);
//每个服务的内部券支付金额
//每个服务的卡券实际支付金额
BigDecimal payAmount = orderServe.getPayPrice().multiply(totalCouponPay).divide(total, 2, BigDecimal.ROUND_HALF_UP);
//最后一个服务使用总额减法而不是除法
if (canUserOrderServeList.lastIndexOf(orderServe) == canUserOrderServeList.size() - 1) {
discountAmount = totalCouponDiscount.subtract(discountCalc);
payAmount = totalCouponPay.subtract(payCalc);
}
BigDecimal actualDiscountAmount = discountAmount.min(orderServe.getPayPrice());
//卡券在订单服务上的抵扣情况
CouponOrderRelevance couponOrderRelevance = CouponOrderRelevance.builder()
.discountAmount(discountAmount.min(orderServe.getPayPrice()))
.discountAmount(actualDiscountAmount)
//卡券在这个服务上的实际支付金额
.payForOrderServe(payAmount)
.createTime(new Date())
......@@ -574,8 +576,8 @@ public class MarketServiceImpl implements MarketService {
//保存卡券在订单服务上的使用请款
couponOrderRelevanceService.save(couponOrderRelevance);
orderServe.addDiscountPrice(discountAmount);
orderManage.addDiscountPrice(discountAmount);
orderServe.addDiscountPrice(actualDiscountAmount);
orderManage.addDiscountPrice(actualDiscountAmount);
orderServe.setBindCoupon(1);
discountCalc = discountCalc.add(discountAmount);
......
......@@ -71,6 +71,6 @@ public class Coupon {
private Integer isCalcAchievement;
@TableField(exist = false)
private Integer canBeUse;
private Boolean canBeUse;
}
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