| | |
| | | @Autowired |
| | | private CodeDecorator codeDecorator; |
| | | |
| | | @Autowired |
| | | private OrderItemCheckMapper orderItemCheckMapper; |
| | | |
| | | public String createSales(OrderItemSalesCreateDTO dto){ |
| | | Integer num = dto.getNum(); |
| | | if(num == null || num == 0){ |
| | |
| | | throw new ValidationException("订单商品不存在"); |
| | | } |
| | | |
| | | if(num > oi.getNum()){ |
| | | OrderItemCheck c = orderItemCheckMapper.selectOne(new QueryWrapper<OrderItemCheck>() |
| | | .eq("order_item_id", oi.getId()) |
| | | .eq("type", Constants.CHECK_TYPE.lack.name()) |
| | | .eq("audit_status", Constants.CHECK_AUDIT_STATUS.AGREED.name()) |
| | | ); |
| | | int totalNum = oi.getNum(); |
| | | if(c != null){//需要减去缺货的数量 |
| | | totalNum -= c.getNum(); |
| | | } |
| | | if(num > totalNum){ |
| | | throw new ValidationException("申请数量不能超过总数"); |
| | | } |
| | | |
| | |
| | | |
| | | String userId = SecurityUtils.getUserId(); |
| | | int count = orderItemSalesMapper.selectCount(new QueryWrapper<OrderItemSales>() |
| | | .eq("order_item_id", oi.getId())); |
| | | .eq("order_item_id", oi.getId()) |
| | | .eq("status", Constants.ORDER_SALES_STATUS.AGREED.name()) |
| | | ); |
| | | if(count >= 2){ |
| | | throw new ValidationException("售后申请超过限额"); |
| | | } |
| | |
| | | s.setReason(dto.getReason()); |
| | | s.setStatus(Constants.ORDER_SALES_STATUS.PENDING.name()); |
| | | s.create(userId); |
| | | s.setSalesType(dto.getSalesType()); |
| | | orderItemSalesMapper.insert(s); |
| | | |
| | | return s.getId(); |
| | |
| | | BigDecimal totalFee = feeSupplier.add(feePartner).add(feePlatform).add(feePlatformPack) |
| | | .add(feePlatformCheck).add(feePlatformTransport); |
| | | |
| | | BigDecimal st = oi.getPrice().multiply(new BigDecimal(sl.getNum()));//申请售后的花的金额 |
| | | if(totalFee.doubleValue() > st.doubleValue()){ |
| | | throw new ValidationException("退款金额不能大于商品申请数量的售价"); |
| | | } |
| | | |
| | | List<OrderItemSales> ls = orderItemSalesMapper.selectList(new QueryWrapper<OrderItemSales>() |
| | | .eq("order_item_id", oi.getId()) |
| | | .eq("status", Constants.ORDER_SALES_STATUS.AGREED.name()) |
| | |
| | | } |
| | | preFee = preFee.add(totalFee); |
| | | if(preFee.doubleValue() > oi.getTotal().doubleValue()){ |
| | | throw new ValidationException("退款金额不能大于商品总价"); |
| | | throw new ValidationException("退款总金额不能大于商品总价"); |
| | | } |
| | | |
| | | sl.setRemarks(dto.getRemarks()); |
| | |
| | | orderItemSalesMapper.updateById(sl); |
| | | |
| | | return oi; |
| | | } |
| | | |
| | | private BigDecimal getAmount(BigDecimal amount){ |
| | | return amount == null ? new BigDecimal(0) : amount; |
| | | } |
| | | } |