Cui Zhi Feng
2024-08-28 18a87d19f80e3b87244546ad080f125587eb9d70
src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
@@ -585,14 +585,16 @@
        if(dto.getNum() == null || dto.getNum() == 0){
            throw new ValidationException("处理数量不能为0");
        }
        OrderItemCheck c = orderItemCheckMapper.selectOne(new QueryWrapper<OrderItemCheck>()
                .eq("type", dto.getType())
                .eq("order_item_id", dto.getOrderItemId())
        );
        OrderItem oi = orderItemMapper.selectById(dto.getOrderItemId());
        if(dto.getNum() > oi.getNum()){
            throw new ValidationException("处理数量不能大于商品数量");
        }
        if(deductAmount != null && deductAmount.doubleValue() > oi.getTotal().doubleValue()){
            throw new ValidationException("降级金额不能大于商品总金额");
        }
        BigDecimal deduct = deductAmount;
        if(deduct == null){
            deduct = new BigDecimal(0);
@@ -602,7 +604,15 @@
                deduct = oi.getPrice().multiply(new BigDecimal(dto.getNum()));
            }
        }
        OrderItemCheck c = orderItemCheckMapper.selectOne(new QueryWrapper<OrderItemCheck>()
                .eq("type", dto.getType())
                .eq("order_item_id", dto.getOrderItemId())
        );
        if(c != null){
            if(StringUtils.isNotEmpty(c.getAuditStatus())){
                throw new ValidationException("已审核,不可修改");
            }
            c.setCheckTime(LocalDateTime.now());
            c.setNum(dto.getNum());
            c.setRemarks(dto.getRemarks());
@@ -646,6 +656,19 @@
            oi.update(SecurityUtils.getUserId());
            orderItemMapper.updateById(oi);
        }
        DeliveryOrderItem di = deliveryOrderItemMapper.selectOne(new QueryWrapper<DeliveryOrderItem>()
                .eq("order_item_id", id));
        if(di != null) {
            Integer count = deliveryOrderItemMapper.getUnCheckCount(di.getDeliveryId());
            if(count == 0) {
                DeliveryOrder d = deliveryOrderMapper.selectById(di.getDeliveryId());
                d.setCheckTime(LocalDateTime.now());
                d.setStatus(Constants.DELIVERY_ORDER_STATUS.CHECKED.name());
                d.update(SecurityUtils.getUserId());
                deliveryOrderMapper.updateById(d);
            }
        }
    }
    public void deleteCheckInfo(String itemId, String type){