Administrator
6 days ago 4a7433917b1e711200f11c841f6f725882658366
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -71,6 +71,7 @@
    private final IApiMallMemberService memberService;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final RedisUtils redisUtils;
    private final MallCountryDeliveryMapper mallCountryDeliveryMapper;
    private final AgentProducer agentProducer;
    private final ApiChatPayService apiChatPayService;
@@ -116,8 +117,6 @@
        this.baseMapper.insert(orderInfo);
        BigDecimal total = BigDecimal.ZERO;
        //运费
        BigDecimal delivaryAmount = addOrderDto.getDeliveryAmount() == null ? BigDecimal.ZERO : addOrderDto.getDeliveryAmount();
        for (AddOrderItemDto item : addOrderDto.getItems()) {
            MallOrderItem orderItem = new MallOrderItem();
@@ -140,8 +139,6 @@
            if(1 != goodsResult){
                throw new FebsException("Discontinued");
            }
            delivaryAmount = delivaryAmount.add(mallGoods.getCarriageAmount());
            BigDecimal amount = sku.getPresentPrice().multiply(BigDecimal.valueOf(item.getCnt()));
            orderItem.setAmount(amount);
@@ -167,6 +164,24 @@
            }
            mallOrderItemMapper.insert(orderItem);
        }
        //运费
        MallCountryDelivery delivery = mallCountryDeliveryMapper.selectOne(
                Wrappers.lambdaQuery(MallCountryDelivery.class)
                        .eq(MallCountryDelivery::getCountryCode, addOrderDto.getCountryCode().toUpperCase())
                        .eq(MallCountryDelivery::getStatus, 1)
        );
        MallCountryDelivery defaultDelivery = mallCountryDeliveryMapper.selectOne(
                Wrappers.lambdaQuery(MallCountryDelivery.class)
                        .eq(MallCountryDelivery::getCountryCode, "DEFAULT")
                        .eq(MallCountryDelivery::getStatus, 1)
        );
        BigDecimal delivaryAmount = defaultDelivery.getShippingFee();
        if (delivery != null) {
            delivaryAmount = delivery.getShippingFee();
        }
        orderInfo.setCarriage(delivaryAmount);
        total = total.add(delivaryAmount);