| | |
| | | if(Objects.isNull(orderGoodsCalculateResponse.getCouponDeductCash())){ |
| | | orderGoodsCalculateResponse.setCouponDeductCash(BigDecimal.ZERO); |
| | | } |
| | | // orderGoodsCalculateResponse.setIntegralDeductCash(BigDecimal.ZERO); |
| | | } |
| | | //订单总金额 |
| | | BigDecimal amount = BigDecimal.ZERO; |
| | |
| | | List<MemberCoupon> memberCouponList = memberCouponService.getApplyCoupon(request.getPayDetailRequestList(),request.getMemberId()); |
| | | if(CollectionUtils.isNotEmpty(memberCouponList)){ |
| | | orderPayConfirmResponse.setMemberCouponList(memberCouponList); |
| | | if(Objects.nonNull(request.getCouponId())&&Constants.equalsInteger(request.getCouponId(),-Constants.ONE)&&Objects.nonNull(memberCouponList)){ |
| | | request.setCouponId(memberCouponList.get(Constants.ZERO).getId()); |
| | | } |
| | | //如果选择了优惠券,则判断选择的优惠券是否有效 |
| | | if(Objects.nonNull(request.getCouponId())){ |
| | | List<MemberCoupon> memberCoupons = memberCouponList.stream().filter(i->Constants.equalsInteger(i.getId(),request.getCouponId())).collect(Collectors.toList()); |
| | |
| | | //查询用户总积分 |
| | | Member member = memberMapper.selectById(request.getMemberId()); |
| | | //最低可用启用积分 |
| | | BigDecimal minimumIntegral = new BigDecimal(systemDictDataBiz.queryByCode(Constants.SHOP_CONFIG,Constants.MINIMUM_AVAILABLE_INTEGRAL).getCode()); |
| | | BigDecimal minimumIntegral = new BigDecimal(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET,Constants.INTERALSET_MININTEGRALPRICELIMIT).getCode()); |
| | | //积分可使用状态 大于0 大于最小可用配置积分值 |
| | | orderPayConfirmResponse.setIntegralStatus( |
| | | (member.getIntegral().compareTo(BigDecimal.ZERO)<=Constants.ZERO|| |
| | |
| | | orderPayConfirmResponse.setIntegralAmount(integralAmount); |
| | | if(Constants.equalsInteger(orderPayConfirmResponse.getIntegralStatus(),Constants.ZERO)){ |
| | | integralAmount = this.calculateIntegralRata(orderPayConfirmResponse,goodsCalculateList,member.getIntegral()); |
| | | }else{ |
| | | orderPayConfirmResponse.setSurplusIntegral(member.getIntegral()); |
| | | } |
| | | |
| | | //邮费金额 |
| | |
| | | } |
| | | Areas areas = areasMapper.selectOne(new QueryWrapper<Areas>().lambda() |
| | | .eq(Areas::getIsdeleted,Constants.ZERO) |
| | | .eq(Areas::getId,StringUtils.leftPad(addr.getAreaId().toString().substring(0,2),6,"0")) |
| | | .eq(Areas::getId,StringUtils.rightPad(addr.getAreaId().toString().substring(0,2),6,"0")) |
| | | .isNotNull(Areas::getYunFeeId) |
| | | .last(" limit 1 ") |
| | | ); |
| | |
| | | BigDecimal totalWeight = goodsCalculateList.stream().map(i-> |
| | | i.getWeight().multiply(new BigDecimal(i.getGoodsNum().toString())) |
| | | ).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if(totalWeight.compareTo(mailConfigResponse.getWeight0())>=Constants.ZERO){ |
| | | if(totalWeight.compareTo(mailConfigResponse.getWeight0())<=Constants.ZERO){ |
| | | mailAmount = mailConfigResponse.getFee0(); |
| | | }else{ |
| | | //超重重量 |
| | |
| | | public BigDecimal calculateIntegralRata(OrderPayConfirmResponse orderPayConfirmResponse,List<OrderGoodsCalculateResponse> goodsCalculateList,BigDecimal totalIntegral){ |
| | | //当前选择商品最大可用积分抵扣的金额 |
| | | BigDecimal maxDeductionCash = goodsCalculateList.stream().map(i->i.getSkuAmount().subtract(Objects.isNull(i.getCouponDeductCash())?BigDecimal.ZERO:i.getCouponDeductCash()) |
| | | .multiply(i.getDeductRata()).multiply(new BigDecimal("0.01"))).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | .multiply(i.getDeductRata()).divide(new BigDecimal("100"),2,RoundingMode.DOWN)).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | //积分-现金兑换比例(XXX积分抵扣1元) |
| | | BigDecimal cashToIntegralRata = new BigDecimal(systemDictDataBiz.queryByCode(Constants.SHOP_CONFIG,Constants.INTEGRAL_EXCHANGE_CASH_RATA).getCode()); |
| | | BigDecimal cashToIntegralRata = new BigDecimal(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET,Constants.INTERALSET_DEDUCTINTEGRALLIMIT).getCode()); |
| | | //当前选择商品抵扣需要使用的积分 |
| | | BigDecimal maxDeductionIntegral = maxDeductionCash.multiply(cashToIntegralRata); |
| | | //获取当前需要支付的现金总额 |
| | |
| | | //循环下单商品列表 计算应该使用的积分值 |
| | | BigDecimal realDeductionCash = BigDecimal.ZERO; |
| | | for (int j = 0; j < goodsCalculateList.size(); j++) { |
| | | BigDecimal deductionCash = goodsCalculateList.get(j).getSkuAmount().subtract(goodsCalculateList.get(j).getCouponDeductCash()); |
| | | //获取最大可抵扣金额 |
| | | BigDecimal deductionCash = goodsCalculateList.get(j).getSkuAmount().subtract(goodsCalculateList.get(j).getCouponDeductCash()) |
| | | .multiply(goodsCalculateList.get(j).getDeductRata()).divide(new BigDecimal("100"),2,RoundingMode.DOWN); |
| | | goodsCalculateList.get(j).setIntegralMaxDeductCash(deductionCash); |
| | | //如果剩余积分大于可以使用积分 则直接满额计算 反之 剩余积分不能满足全部抵扣 单独计算每个商品占比 |
| | | if(totalIntegral.compareTo(maxDeductionIntegral)<Constants.ZERO){ |