| | |
| | | @Autowired |
| | | private CodeDecorator codeDecorator; |
| | | |
| | | @Autowired |
| | | private OrderItemCheckMapper orderItemCheckMapper; |
| | | |
| | | @Autowired |
| | | private DeliveryOrderService deliveryOrderService; |
| | | |
| | | 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("申请数量不能超过总数"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public List<OrderStatusCountDTO> getSalesStatusCount(OrderItemSalesQueryDTO dto) { |
| | | dto.setOrderStartDate(parseLocalDateTime(dto.getOrderStartDateStr())); |
| | | dto.setOrderEndDate(parseLocalDateTime(dto.getOrderEndDateStr())); |
| | | dto.setSalesStartDate(parseLocalDateTime(dto.getSalesStartDateStr())); |
| | | dto.setSalesEndDate(parseLocalDateTime(dto.getSalesEndDateStr())); |
| | | dto.setOrderStartDate(parseLocalDateTime(dto.getOrderStartDateStr(), true)); |
| | | dto.setOrderEndDate(parseLocalDateTime(dto.getOrderEndDateStr(), false)); |
| | | dto.setSalesStartDate(parseLocalDateTime(dto.getSalesStartDateStr(), true)); |
| | | dto.setSalesEndDate(parseLocalDateTime(dto.getSalesEndDateStr(), false)); |
| | | |
| | | List<CodeValueDTO> ls = codeService.searchValue("ORDER_SALES_STATUS"); |
| | | List<OrderStatusCountDTO> ll = orderItemSalesMapper.getSalesStatusCount(dto); |
| | |
| | | List<OrderItemSalesNewListDTO> ls = orderItemSalesMapper.selectItemSalesList(null, dto); |
| | | codeDecorator.decorate(ls); |
| | | |
| | | String[] rowsName = new String[]{"集货站", "商品名称", "商品单位", "商品颜色", "商品等级" |
| | | String[] rowsName = new String[]{"序号", "集货站", "商品名称", "商品单位", "商品颜色", "商品等级" |
| | | , "商品分类", "收货人", "收货人手机号码", "收货地址", "商品数量", "供应商名称", "商品售价" |
| | | , "总金额", "订单号", "售后单号", "标题", "申请数量", "理由", "实际退款", "审核结果" |
| | | , "申请时间", "平台回复"}; |
| | | List<Object[]> dataList = new ArrayList<>(); |
| | | |
| | | int sn = 1; |
| | | for (OrderItemSalesNewListDTO d : ls) { |
| | | Object[] objs = new Object[rowsName.length]; |
| | | int a = 0; |
| | | objs[a++] = sn; |
| | | objs[a++] = d.getStationName(); |
| | | objs[a++] = d.getFlowerName(); |
| | | objs[a++] = d.getFlowerUnit(); |
| | |
| | | objs[a++] = d.getFlowerCategory(); |
| | | objs[a++] = d.getCustomer(); |
| | | objs[a++] = d.getCustomerTel(); |
| | | objs[a++] = d.getCustomerAddress(); |
| | | objs[a++] = d.getCustomerProvince() + d.getCustomerCity() + d.getCustomerRegion() + d.getCustomerAddress(); |
| | | objs[a++] = d.getFlowerNum(); |
| | | objs[a++] = d.getSupplierName(); |
| | | objs[a++] = d.getPrice(); |
| | |
| | | objs[a++] = d.getRemarks(); |
| | | |
| | | dataList.add(objs); |
| | | |
| | | sn++; |
| | | } |
| | | |
| | | ExcelExportUtil excelExportUtil = new ExcelExportUtil("售后申请列表", rowsName, dataList, response); |
| | |
| | | rr.setTotal(oi.getTotal()); |
| | | rr.setSupplierPrice(oi.getSupplierPrice()); |
| | | rr.setMarkupPartner(oi.getMarkupPartner()); |
| | | rr.setRealPrice(oi.getRealPrice()); |
| | | rr.setRealTotal(oi.getRealTotal()); |
| | | |
| | | Long stationId = oi.getStationId(); |
| | | if(stationId != null) { |
| | | Station s = stationMapper.selectById(oi.getStationId()); |
| | | rr.setStationName(s.getName()); |
| | | } |
| | | |
| | | List<OrderItemCheck> cLs = orderItemCheckMapper.selectList(new QueryWrapper<OrderItemCheck>() |
| | | .eq("order_item_id", oi.getId()) |
| | | .eq("audit_status", Constants.CHECK_AUDIT_STATUS.AGREED.name()) |
| | | ); |
| | | int reduceNum = 0; |
| | | BigDecimal reduceAmount = new BigDecimal(0); |
| | | int replaceNum = 0; |
| | | if(cLs != null && cLs.size() > 0){ |
| | | for(OrderItemCheck c : cLs){ |
| | | if(Constants.CHECK_TYPE.reduce.name().equals(c.getType())){ |
| | | reduceNum += c.getNum(); |
| | | reduceAmount = reduceAmount.add(c.getDeductAmount()); |
| | | } else if(Constants.CHECK_TYPE.replace.name().equals(c.getType())){ |
| | | replaceNum += c.getNum(); |
| | | } |
| | | } |
| | | } |
| | | rr.setReduceNum(reduceNum); |
| | | rr.setReduceAmount(reduceAmount); |
| | | rr.setReplaceNum(replaceNum); |
| | | |
| | | return rr; |
| | | } |
| | |
| | | } |
| | | |
| | | BigDecimal feeSupplier = getAmount(dto.getFeeSupplier()); |
| | | BigDecimal supplierTotal = oi.getSupplierPrice().multiply(new BigDecimal(sl.getNum())); |
| | | if(feeSupplier.doubleValue() > supplierTotal.doubleValue()){ |
| | | throw new ValidationException("供应商扣款金额不能大于商品申请数量的供应商售价"); |
| | | } |
| | | |
| | | BigDecimal feePartner = getAmount(dto.getFeePartner()); |
| | | BigDecimal feePlatform = getAmount(dto.getFeePlatform()); |
| | | BigDecimal feePlatformPack = getAmount(dto.getFeePlatformPack()); |
| | |
| | | BigDecimal totalFee = feeSupplier.add(feePartner).add(feePlatform).add(feePlatformPack) |
| | | .add(feePlatformCheck).add(feePlatformTransport); |
| | | |
| | | BigDecimal st = oi.getPrice().multiply(new BigDecimal(sl.getNum()));//申请售后的花的金额 |
| | | BigDecimal st = oi.getRealPrice().multiply(new BigDecimal(sl.getNum()));//申请售后的花的金额,使用券后的单价 |
| | | if(totalFee.doubleValue() > st.doubleValue()){ |
| | | throw new ValidationException("退款金额不能大于商品申请数量的售价"); |
| | | } |
| | |
| | | } |
| | | } |
| | | preFee = preFee.add(totalFee); |
| | | if(preFee.doubleValue() > oi.getTotal().doubleValue()){ |
| | | if(preFee.doubleValue() > oi.getRealTotal().doubleValue()){//使用券后的总价 |
| | | throw new ValidationException("退款总金额不能大于商品总价"); |
| | | } |
| | | |
| | | BigDecimal deduct = deliveryOrderService.calculateOrderItemDeduct(sl.getOrderItemId());//质检已扣款金额 |
| | | preFee = preFee.add(deduct); |
| | | if(preFee.doubleValue() > oi.getRealTotal().doubleValue()){ |
| | | throw new ValidationException("退款总金额(包含质检退款)不能大于商品总价"); |
| | | } |
| | | |
| | | sl.setRemarks(dto.getRemarks()); |
| | | sl.setFeeSupplier(feeSupplier); |
| | | sl.setFeePartner(feePartner); |