| | |
| | | DEFECTIVE_PASS("11", "不合格-让步放行"), |
| | | RETURN_HE_IN("14", "销售退货-合格入库"), |
| | | RETURN_UNSTOCK_IN("15", "销售退货-不合格入库"), |
| | | RETURN_WASTE_IN("16", "销售退货-废品入库"), |
| | | PICK_RETURN_IN("20", "领料退料-合格入库"), |
| | | FEED_RETURN_IN("22", "生产退料-合格入库"); |
| | | |
| | |
| | | |
| | | @Schema(description = "发货出库数量") |
| | | private BigDecimal stockOutNum; |
| | | |
| | | @Schema(description = "原发货库存类型:qualified/waste") |
| | | private String stockType; |
| | | } |
| | |
| | | |
| | | @Schema(description = "含税单价") |
| | | private BigDecimal taxInclusiveUnitPrice; |
| | | |
| | | @Schema(description = "原发货库存类型:qualified/waste") |
| | | private String stockType; |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | for (ReturnSaleProductDto returnSaleProduct : list) { |
| | | bigDecimal = bigDecimal.add(returnSaleProduct.getPrice()); |
| | | salesRefundAmountOrder.setRefundedAmount(new BigDecimal(0)); |
| | | // 是否有质量问题 |
| | | if (returnSaleProduct.getIsQuality() == 1) { |
| | | // 有质量问题,入不合格库(带批次) |
| | | stockUtils.addUnStockWithBatchNo(returnSaleProduct.getProductModelId(),returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_UNSTOCK_IN.getCode(),returnSaleProduct.getId(),returnSaleProduct.getBatchNo()); |
| | | }else{ |
| | | // 无质量问题,入合格库(带批次) |
| | | stockUtils.addStockWithBatchNo(returnSaleProduct.getProductModelId(),returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_HE_IN.getCode(),returnSaleProduct.getId(),returnSaleProduct.getBatchNo()); |
| | | String stockType = normalizeStockType(returnSaleProduct.getStockType()); |
| | | boolean hasQualityIssue = Integer.valueOf(1).equals(returnSaleProduct.getIsQuality()); |
| | | if ("waste".equals(stockType)) { |
| | | // 废品发货退回后仍回废品库,不再回合格/不合格库。 |
| | | stockUtils.addWasteStockWithBatchNo( |
| | | returnSaleProduct.getProductModelId(), |
| | | returnSaleProduct.getNum(), |
| | | StockInQualifiedRecordTypeEnum.RETURN_WASTE_IN.getCode(), |
| | | returnSaleProduct.getId(), |
| | | returnSaleProduct.getBatchNo() |
| | | ); |
| | | } else if (hasQualityIssue) { |
| | | // 合格发货且有质量问题,回不合格库。 |
| | | stockUtils.addUnStockWithBatchNo( |
| | | returnSaleProduct.getProductModelId(), |
| | | returnSaleProduct.getNum(), |
| | | StockInQualifiedRecordTypeEnum.RETURN_UNSTOCK_IN.getCode(), |
| | | returnSaleProduct.getId(), |
| | | returnSaleProduct.getBatchNo() |
| | | ); |
| | | } else { |
| | | // 合格发货且无质量问题,回合格库。 |
| | | stockUtils.addStockWithBatchNo( |
| | | returnSaleProduct.getProductModelId(), |
| | | returnSaleProduct.getNum(), |
| | | StockInQualifiedRecordTypeEnum.RETURN_HE_IN.getCode(), |
| | | returnSaleProduct.getId(), |
| | | returnSaleProduct.getBatchNo() |
| | | ); |
| | | } |
| | | } |
| | | salesRefundAmountOrder.setRefundAmount(bigDecimal); |
| | |
| | | return returnManagementDtoById; |
| | | } |
| | | |
| | | private String normalizeStockType(String stockType) { |
| | | if (ObjectUtils.isEmpty(stockType)) { |
| | | return "qualified"; |
| | | } |
| | | String normalized = stockType.trim().toLowerCase(Locale.ROOT); |
| | | return normalized.isEmpty() ? "qualified" : normalized; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 废品入库带批次号 |
| | | * |
| | | * @param productModelId 产品规格ID |
| | | * @param quantity 数量 |
| | | * @param recordType 记录类型 |
| | | * @param recordId 业务ID |
| | | * @param batchNo 批次号 |
| | | */ |
| | | public void addWasteStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setRecordId(recordId); |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryDto.setBatchNo(batchNo); |
| | | stockUninventoryDto.setType("waste"); |
| | | stockUninventoryService.addStockInRecordOnly(stockUninventoryDto); |
| | | } |
| | | |
| | | /** |
| | | * 不合格出库 |
| | | * |
| | | * @param productModelId |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer addStockInRecordOnly(StockUninventoryDto stockUninventoryDto) { |
| | | stockUninventoryDto.setType(resolveInventoryType(stockUninventoryDto)); |
| | | String inventoryType = resolveInventoryType(stockUninventoryDto); |
| | | stockUninventoryDto.setType(inventoryType); |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | stockInRecordDto.setRecordId(stockUninventoryDto.getRecordId()); |
| | | stockInRecordDto.setRecordType(stockUninventoryDto.getRecordType()); |
| | |
| | | } |
| | | stockInRecordDto.setBatchNo(batchNo); |
| | | stockInRecordDto.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("1"); |
| | | if (UNQUALIFIED_TYPE.equals(inventoryType)) { |
| | | stockInRecordDto.setType("1"); |
| | | } else { |
| | | stockInRecordDto.setType("2"); |
| | | } |
| | | stockInRecordDto.setRemark(stockUninventoryDto.getRemark()); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | return 1; |
| | |
| | | p.product_name as product_name, |
| | | pm.model as model, |
| | | pm.unit as unit, |
| | | COALESCE(spd.stock_type, slp.stock_type, 'qualified') as stock_type, |
| | | rsp.*, |
| | | sor.outbound_batches, |
| | | sor.stock_out_num, |
| | |
| | | FROM return_sale_product rsp |
| | | LEFT JOIN return_management rm ON rm.id = rsp.return_management_id |
| | | LEFT JOIN shipping_info si ON si.id = rm.shipping_id |
| | | LEFT JOIN shipping_product_detail spd ON spd.shipping_info_id = si.id |
| | | LEFT JOIN stock_out_record sor ON rsp.stock_out_record_id = sor.id and sor.record_type = '13' |
| | | LEFT JOIN shipping_product_detail spd ON spd.shipping_info_id = si.id |
| | | AND spd.product_model_id = sor.product_model_id |
| | | AND ( |
| | | (spd.batch_no = sor.batch_no) |
| | | OR (spd.batch_no IS NULL AND sor.batch_no IS NULL) |
| | | ) |
| | | LEFT JOIN sales_ledger_product slp ON si.sales_ledger_product_id = slp.id and slp.type = 1 |
| | | left join product_model pm on slp.product_model_id = pm.id |
| | | LEFT JOIN product p on pm.product_id = p.id |
| | |
| | | <select id="listReturnSaleProduct" resultType="com.ruoyi.procurementrecord.bean.dto.ReturnSaleProductDto"> |
| | | select rsp.*, |
| | | sor.batch_no, |
| | | COALESCE(spd.stock_type, slp.stock_type, 'qualified') as stock_type, |
| | | slp.tax_inclusive_unit_price , |
| | | slp.tax_inclusive_total_price*rsp.num as price |
| | | from return_sale_product rsp |
| | | LEFT JOIN return_management rm ON rm.id = rsp.return_management_id |
| | | LEFT JOIN shipping_info si ON si.id = rm.shipping_id |
| | | LEFT JOIN sales_ledger_product slp ON si.sales_ledger_product_id = slp.id and slp.type = 1 |
| | | LEFT JOIN stock_out_record sor ON rsp.stock_out_record_id = sor.id |
| | | LEFT JOIN shipping_product_detail spd ON spd.shipping_info_id = si.id |
| | | AND spd.product_model_id = sor.product_model_id |
| | | AND ( |
| | | (spd.batch_no = sor.batch_no) |
| | | OR (spd.batch_no IS NULL AND sor.batch_no IS NULL) |
| | | ) |
| | | LEFT JOIN sales_ledger_product slp ON si.sales_ledger_product_id = slp.id and slp.type = 1 |
| | | where rsp.return_management_id = #{returnManagementId} |
| | | </select> |
| | | |
| | |
| | | slp.specification_model, |
| | | slp.unit, |
| | | slp.product_model_id, |
| | | COALESCE(spd.stock_type, slp.stock_type, 'qualified') AS stock_type, |
| | | sor.outbound_batches, |
| | | sor.stock_out_num, |
| | | sor.batch_no, |