| | |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.SaleEnum; |
| | |
| | | private final FileUtil fileUtil; |
| | | private final AccountInvoiceApplicationMapper accountInvoiceApplicationMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final IProductService productService; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | |
| | | .in("customer_name", salesLedgerImportDtoList.stream() |
| | | .map(SalesLedgerImportDto::getCustomerName).collect(Collectors.toList())) |
| | | .and(wrapper -> wrapper.eq("type", 0) |
| | | .or(wrapper2 -> wrapper2.eq("type", 1).eq("is_assigned", 1))) |
| | | .or(wrapper2 -> wrapper2.eq("type", 1).eq("usage_status", 1))) |
| | | .and(wrapper -> wrapper.eq("usage_user", loginUserId) |
| | | .or(wrapper2 -> wrapper2.eq("create_user", loginUserId) |
| | | .or(wrapper3 -> wrapper3.exists("select 1 from customer_user cu where cu.customer_id = customer.id and cu.user_id = " + loginUserId))))); |
| | |
| | | salesLedger.setContractAmount(salesLedgerProductImportDtos.stream() |
| | | .map(SalesLedgerProductImportDto::getTaxInclusiveTotalPrice) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | salesLedger.setNetContractAmount(salesLedger.getContractAmount()); |
| | | salesLedgerMapper.insert(salesLedger); |
| | | |
| | | |
| | |
| | | |
| | | @Override |
| | | public void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, SaleEnum type) { |
| | | // 销售台账手工录入「产品大类+规格型号」时,自动注册到产品维护(统一挂「成品」大类下) |
| | | if (SaleEnum.SALE.equals(type)) { |
| | | for (SalesLedgerProduct product : products) { |
| | | registerProductFromLedgerProduct(product); |
| | | } |
| | | } |
| | | |
| | | // 按ID分组,区分新增和更新的记录 |
| | | Map<Boolean, List<SalesLedgerProduct>> partitionedProducts = products.stream() |
| | | .peek(p -> p.setSalesLedgerId(salesLedgerId)) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 手工录入「产品大类+规格型号」时,在产品维护自动注册: |
| | | * 统一挂在「成品」大类下 —— 成品=一级大类,产品大类=子类,规格型号=子类下的规格 |
| | | */ |
| | | private void registerProductFromLedgerProduct(SalesLedgerProduct product) { |
| | | String productName = StringUtils.trim(product.getProductCategory()); |
| | | String modelName = StringUtils.trim(product.getSpecificationModel()); |
| | | if (StringUtils.isEmpty(productName) || StringUtils.isEmpty(modelName)) { |
| | | return; |
| | | } |
| | | product.setProductCategory(productName); |
| | | product.setSpecificationModel(modelName); |
| | | |
| | | ProductModel productModel = productService.ensureProductHierarchy(productName, modelName, product.getUnit()); |
| | | if (productModel != null) { |
| | | product.setProductId(productModel.getProductId()); |
| | | product.setProductModelId(productModel.getId()); |
| | | } |
| | | } |
| | | |
| | | private SalesLedger convertToEntity(SalesLedgerDto dto) { |
| | | SalesLedger entity = new SalesLedger(); |
| | | BeanUtils.copyProperties(dto, entity); |