gongzuming
2024-09-19 a768dc3daa04d35fedfbe75c0a59b9b2545b85c4
src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
@@ -238,8 +238,8 @@
        return deliveryOrderItemMapper.selectDoItemList(id);
    }
    public List<DeliveryOrderItemDTO> getSupplierDeliveryOrderItems(String ids){
        List<String> idList = splitParam(ids);
    public List<DeliveryOrderItemDTO> getSupplierDeliveryOrderItems(PostQueryDTO dto){
        List<String> idList = dto.getIds();
        List<DeliveryOrderItemDTO> ls = new ArrayList<>();
        if(idList != null && idList.size() > 0){
            for(String id : idList){
@@ -274,7 +274,21 @@
        dto.setParams(parseArray(oi.getFlowerParams(), ParamItemDTO.class));
        dto.setNum(oi.getNum());
        return dto;
    }
    public List<DeliveryOrderItemDTO> getDeliveryOrderItems(PostQueryDTO dto){
        List<String> idList = dto.getIds();
        List<DeliveryOrderItemDTO> ls = new ArrayList<>();
        if(idList != null && idList.size() > 0){
            for(String id : idList){
                ls.add(getDeliveryOrderItem(id));
            }
        }
        return ls;
    }
    public DeliveryOrderItemDTO getDeliveryOrderItem(String id) {
@@ -296,6 +310,8 @@
        dto.setFlowerCategory(oi.getFlowerCategory());
        dto.setParams(parseArray(oi.getFlowerParams(), ParamItemDTO.class));
        dto.setNum(oi.getNum());
        return dto;
    }
@@ -394,7 +410,7 @@
        );
        if (count == 0) {
            Order o = orderMapper.selectById(orderId);
            if(!Constants.ORDER_STATUS_BACKEND.COLLECTION.name().equals(o.getStatus())){
            if(!Constants.ORDER_STATUS_BACKEND.COLLECTION.name().equals(o.getStatusBackend())){
                log.warn("非待集货状态,不可设置待发货");
                return;
            }
@@ -479,17 +495,19 @@
        return dto;
    }
    public List<StationStatisticDTO> statisticStationList(String name, LocalDateTime startDate, LocalDateTime endDate) {
    public List<StationStatisticDTO> statisticStationList(String name, LocalDateTime startDate
            , LocalDateTime endDate, String status) {
        String userId = SecurityUtils.getUserId();
        LambdaQueryWrapper<Station> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(Station::getUserIds, userId);
        lambdaQueryWrapper.like(Station::getUserIds, "%" + userId + "%");
        lambdaQueryWrapper.eq(Station::getType, "0");
        boolean hasZc = stationMapper.selectCount(lambdaQueryWrapper)>0;//当前用户是否有总仓权限,总仓能查看到所有集货站的数据
        boolean hasZc = stationMapper.selectCount(lambdaQueryWrapper) > 0;//当前用户是否有总仓权限,总仓能查看到所有集货站的数据
        List<String> statusList = splitParam(status);
        if(hasZc){
            List<StationStatisticDTO> stationStatisticDTOS = deliveryOrderMapper.statisticStationList(startDate, endDate,name,null);
            List<StationStatisticDTO> stationStatisticDTOS = deliveryOrderMapper.statisticStationList(startDate, endDate,name,null, statusList);
            return stationStatisticDTOS;
        }else{
            List<StationStatisticDTO> stationStatisticDTOS = deliveryOrderMapper.statisticStationList(startDate, endDate,name,userId);
            List<StationStatisticDTO> stationStatisticDTOS = deliveryOrderMapper.statisticStationList(startDate, endDate, name, userId, statusList);
            return stationStatisticDTOS;
        }
    }
@@ -593,7 +611,7 @@
        return dto;
    }
    public OrderItemCheckNumDTO getOtherCheck(String itemId, String type){
    public OrderItemCheckNumDTO getOtherCheck(String itemId, String type, boolean isSupplier){
        OrderItemCheck c = orderItemCheckMapper.selectOne(new QueryWrapper<OrderItemCheck>()
                .eq("type", type)
                .eq("order_item_id", itemId)
@@ -605,6 +623,12 @@
            BeanUtils.copyProperties(c, dto);
            User user = userMapper.selectById(c.getCreateBy());
            dto.setCreateName(user.getNickName());
            if(Constants.CHECK_TYPE.lack.name().equals(c.getType()) && isSupplier){
                OrderItem oi = orderItemMapper.selectById(itemId);
                BigDecimal lackFeeSupplier = oi.getSupplierPrice().multiply(new BigDecimal(c.getNum()));
                dto.setDeductAmount(lackFeeSupplier);
            }
        }
        return dto;
@@ -649,13 +673,19 @@
            deduct = oi.getSupplierPrice().multiply(new BigDecimal(dto.getNum()));
        } else if(Constants.CHECK_TYPE.lack.name().equals(dto.getType())){
            deduct = realPrice.multiply(new BigDecimal(dto.getNum()));
            //质检退款,按照这个单价扣,如果3扎都缺货,按照总的金额退
            //缺货数量等于商品总数时按真实总价退款
            if(dto.getNum().intValue() == oi.getNum() && oi.getRealTotal() != null){
                deduct = oi.getRealTotal();
            }
        } else if (Constants.CHECK_TYPE.reduce.name().equals(dto.getType())) {
            if(deductAmount == null){
                throw new ValidationException("降级金额不能为空");
            }
            deduct = deductAmount.multiply(new BigDecimal(dto.getNum()));
            BigDecimal dt = realPrice.multiply(new BigDecimal(dto.getNum()));
            if(deduct.doubleValue() > dt.doubleValue()){
            if(deduct.doubleValue() > dt.doubleValue()
                    || (oi.getRealTotal() != null && deduct.doubleValue() > oi.getRealTotal().doubleValue())){
                throw new ValidationException("降级金额不能大于商品处理数量金额");
            }
        }