xiaoyong931011
2022-10-08 7a7800c647fdf315879a6e989089a951f2b1291f
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -14,6 +14,7 @@
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.*;
import cc.mrbird.febs.mall.vo.ApiShopApplyVo;
import cc.mrbird.febs.mall.vo.OrderDetailVo;
import cc.mrbird.febs.mall.vo.OrderListVo;
import cc.mrbird.febs.mall.vo.OrderRefundVo;
@@ -75,6 +76,7 @@
    private final MallMemberBankSignMapper mallMemberBankSignMapper;
    private final MallMemberBankMapper mallMemberBankMapper;
    private final MallShopApplyMapper mallShopApplyMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -102,6 +104,22 @@
        if (CollUtil.isEmpty(addOrderDto.getItems())) {
            throw new FebsException("参数错误");
        }
        int deliverType = ObjectUtil.isEmpty(addOrderDto.getDeliverType()) ? 1 : addOrderDto.getDeliverType();
        if(2 == deliverType){
            if(ObjectUtil.isEmpty(addOrderDto.getShopId())){
                throw new FebsException("请选择门店");
            }
            Long shopId = addOrderDto.getShopId();
            MallShopApply mallShopApply = mallShopApplyMapper.selectById(shopId);
            if(ObjectUtil.isEmpty(mallShopApply)){
                throw new FebsException("请选择门店");
            }
            if(MallShopApply.APPLY_AGREE != mallShopApply.getStatus()){
                throw new FebsException("请选择门店");
            }
            orderInfo.setShopId(shopId);
        }
        this.baseMapper.insert(orderInfo);
@@ -186,7 +204,6 @@
        }
        orderInfo.setAmount(total);
        int deliverType = ObjectUtil.isEmpty(addOrderDto.getDeliverType()) ? 1 : addOrderDto.getDeliverType();
        if(2 == deliverType){
            orderInfo.setDeliverType(2);
            orderInfo.setCarriage(BigDecimal.ZERO);
@@ -514,6 +531,21 @@
            long remainTime = DateUtil.between(new Date(), endTime, DateUnit.SECOND, false);
            orderDetailVo.setRemainTime(remainTime);
        }
        Integer deliverType = orderInfo.getDeliverType();
        if(2 == deliverType){
            MallShopApply mallShopApply = mallShopApplyMapper.selectById(orderInfo.getShopId());
            if(ObjectUtil.isNotEmpty(mallShopApply)){
                ApiShopApplyVo apiShopApplyVo = new ApiShopApplyVo();
                apiShopApplyVo.setName(mallShopApply.getName());
                apiShopApplyVo.setPhone(mallShopApply.getPhone());
                apiShopApplyVo.setSaleArea(mallShopApply.getSaleArea());
                apiShopApplyVo.setLatitude(mallShopApply.getLatitude());
                apiShopApplyVo.setLongitude(mallShopApply.getLongitude());
                apiShopApplyVo.setShopName(mallShopApply.getShopName());
                apiShopApplyVo.setAddress(mallShopApply.getAddress());
                orderDetailVo.setApiShopApplyVo(apiShopApplyVo);
            }
        }
        return orderDetailVo;
    }