From 3c8fa3452ed9fb41ce9d3f68c81bcc4b38d19612 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期一, 31 八月 2026 20:14:41 +0800
Subject: [PATCH] fix: 统一销售和采购相关页面金额、单价、数量、总价保留6位小数
---
doc/20260829_alter_sales_purchase_amount_scale_6.sql | 90 ++++++++++++++++++
src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java | 2
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 2
src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java | 2
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml | 4
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 189 ++++++++++++++++++++++++++++++++++---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 1
src/main/java/com/ruoyi/sales/pojo/SalesQuotationProduct.java | 7
8 files changed, 270 insertions(+), 27 deletions(-)
diff --git a/doc/20260829_alter_sales_purchase_amount_scale_6.sql b/doc/20260829_alter_sales_purchase_amount_scale_6.sql
new file mode 100644
index 0000000..0ea6b08
--- /dev/null
+++ b/doc/20260829_alter_sales_purchase_amount_scale_6.sql
@@ -0,0 +1,90 @@
+-- 閿�鍞�/閲囪喘鐩稿叧椤甸潰閲戦銆佸崟浠枫�佹暟閲忋�佹�讳环缁熶竴淇濈暀 6 浣嶅皬鏁�
+-- 娑夊強椤甸潰锛氶攢鍞姤浠枫�侀攢鍞彴璐︺�佸鎴烽��璐с�佸鎴峰線鏉ャ�侀噰璐彴璐︺�佷緵搴斿晢寰�鏉ャ�侀噰璐��璐с�侀噰璐姤琛�
+-- 缁熶竴浣跨敤 decimal(18, 6)锛氭暣鏁颁綅淇濈暀 12 浣嶏紝閬垮厤鐢� decimal(10, 2) 鐩存帴鏀瑰皬鏁颁綅瀵艰嚧鐨勬孩鍑�
+
+-- ----------------------------
+-- 閿�鍞姤浠凤紙sales_quotation / sales_quotation_product锛�
+-- ----------------------------
+ALTER TABLE `sales_quotation`
+ MODIFY COLUMN `total_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鎶ヤ环閲戦';
+
+ALTER TABLE `sales_quotation_product`
+ MODIFY COLUMN `quantity` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏁伴噺',
+ MODIFY COLUMN `unit_price` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍗曚环',
+ MODIFY COLUMN `amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '閲戦';
+
+-- ----------------------------
+-- 閿�鍞彴璐︼紙sales_ledger / sales_ledger_product锛�
+-- ----------------------------
+ALTER TABLE `sales_ledger`
+ MODIFY COLUMN `contract_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍚堝悓閲戦锛堜骇鍝佸惈绋庢�讳环锛�',
+ MODIFY COLUMN `net_contract_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '瀹為檯鍚堝悓閲戦锛堟墸鍑忛��璐у悗锛�';
+
+ALTER TABLE `sales_ledger_product`
+ MODIFY COLUMN `quantity` decimal(18, 6) NOT NULL COMMENT '鏁伴噺',
+ MODIFY COLUMN `min_stock` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏈�浣庡簱瀛�',
+ MODIFY COLUMN `tax_inclusive_unit_price` decimal(18, 6) NOT NULL COMMENT '鍚◣鍗曚环',
+ MODIFY COLUMN `tax_inclusive_total_price` decimal(18, 6) NOT NULL COMMENT '鍚◣鎬讳环',
+ MODIFY COLUMN `tax_exclusive_total_price` decimal(18, 6) NOT NULL COMMENT '涓嶅惈绋庢�讳环',
+ MODIFY COLUMN `warn_num` decimal(18, 6) NULL DEFAULT NULL COMMENT '棰勮鏁伴噺';
+
+-- 鍙拌处妯℃澘锛堜繚瀛�/濂楃敤妯℃澘鏃朵笌浜у搧琛ㄧ粨鏋勪繚鎸佷竴鑷达級
+ALTER TABLE `sales_ledger_product_template`
+ MODIFY COLUMN `quantity` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏁伴噺',
+ MODIFY COLUMN `min_stock` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏈�浣庡簱瀛�',
+ MODIFY COLUMN `tax_inclusive_unit_price` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍚◣鍗曚环',
+ MODIFY COLUMN `tax_inclusive_total_price` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍚◣鎬讳环',
+ MODIFY COLUMN `tax_exclusive_total_price` decimal(18, 6) NULL DEFAULT NULL COMMENT '涓嶅惈绋庢�讳环',
+ MODIFY COLUMN `warn_num` decimal(18, 6) NULL DEFAULT NULL COMMENT '棰勮鏁伴噺';
+
+-- ----------------------------
+-- 瀹㈡埛閫�璐э紙return_management / return_sale_product / sales_refund_amount_order锛�
+-- ----------------------------
+ALTER TABLE `return_management`
+ MODIFY COLUMN `refund_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '閫�娆炬�婚';
+
+ALTER TABLE `return_sale_product`
+ MODIFY COLUMN `num` decimal(18, 6) NOT NULL COMMENT '閫�璐т骇鍝佹暟閲�',
+ MODIFY COLUMN `price` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍗曚环',
+ MODIFY COLUMN `amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '閲戦';
+
+ALTER TABLE `sales_refund_amount_order`
+ MODIFY COLUMN `refund_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '搴旈��娆鹃噾棰�',
+ MODIFY COLUMN `refunded_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '宸查��娆鹃噾棰�',
+ MODIFY COLUMN `not_refunded_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏈��娆鹃噾棰�';
+
+-- ----------------------------
+-- 瀹㈡埛寰�鏉ワ紙鍥炴閲戦鏉ユ簮锛歛ccount_sales_collection銆乺eceipt_payment锛�
+-- ----------------------------
+ALTER TABLE `account_sales_collection`
+ MODIFY COLUMN `collection_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏀舵閲戦';
+
+ALTER TABLE `receipt_payment`
+ MODIFY COLUMN `receipt_payment_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍥炴閲戦';
+
+-- ----------------------------
+-- 閲囪喘鍙拌处锛坧urchase_ledger / purchase_ledger_template锛�
+-- ----------------------------
+ALTER TABLE `purchase_ledger`
+ MODIFY COLUMN `contract_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍚堝悓閲戦',
+ MODIFY COLUMN `net_contract_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '瀹為檯鍚堝悓閲戦锛堟墸鍑忛��璐у悗锛�';
+
+ALTER TABLE `purchase_ledger_template`
+ MODIFY COLUMN `contract_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鍚堝悓閲戦';
+
+-- ----------------------------
+-- 渚涘簲鍟嗗線鏉ワ紙浠樻閲戦鏉ユ簮锛歛ccount_purchase_payment锛�
+-- ----------------------------
+ALTER TABLE `account_purchase_payment`
+ MODIFY COLUMN `payment_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '浠樻閲戦';
+
+-- ----------------------------
+-- 閲囪喘閫�璐э紙purchase_return_orders / purchase_return_order_products锛�
+-- ----------------------------
+ALTER TABLE `purchase_return_orders`
+ MODIFY COLUMN `total_discount_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏁村崟鎶樻墸棰�',
+ MODIFY COLUMN `total_discount_rate` decimal(18, 6) NULL DEFAULT NULL COMMENT '鏁村崟鎶樻墸鐜�',
+ MODIFY COLUMN `total_amount` decimal(18, 6) NULL DEFAULT NULL COMMENT '鎴愪氦閲戦';
+
+ALTER TABLE `purchase_return_order_products`
+ MODIFY COLUMN `return_quantity` decimal(18, 6) NOT NULL DEFAULT 0.000000 COMMENT '閫�璐ф暟閲�';
diff --git a/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java
index 1246d68..a0bbe95 100644
--- a/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java
@@ -97,7 +97,7 @@
if (dto.getPaymentDate() == null) {
throw new ServiceException("璇烽�夋嫨浠樻鏃ユ湡");
}
- if (dto.getPaymentAmount() == null || dto.getPaymentAmount().compareTo(BigDecimal.valueOf(0.01)) < 0) {
+ if (dto.getPaymentAmount() == null || dto.getPaymentAmount().compareTo(new BigDecimal("0.000001")) < 0) {
throw new ServiceException("璇疯緭鍏ヤ粯娆鹃噾棰�");
}
if (StringUtils.isEmpty(dto.getPurchaseContractNumber())) {
diff --git a/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
index 6b905c9..20374ae 100644
--- a/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
@@ -102,7 +102,7 @@
if (dto.getPaymentDate() == null) {
throw new ServiceException("璇烽�夋嫨鍥炴鏃ユ湡");
}
- if (dto.getPaymentAmount() == null || dto.getPaymentAmount().compareTo(BigDecimal.valueOf(0.01)) < 0) {
+ if (dto.getPaymentAmount() == null || dto.getPaymentAmount().compareTo(new BigDecimal("0.000001")) < 0) {
throw new ServiceException("璇疯緭鍏ュ洖娆鹃噾棰�");
}
if (StringUtils.isEmpty(dto.getSalesContractNo())) {
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index 7d8373d..3c76a76 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -911,20 +911,37 @@
List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName,
salesLedgerImportDtoList.stream().map(PurchaseLedgerImportDto::getRecorderName).collect(Collectors.toList())));
for (PurchaseLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) {
- PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>()
+ PurchaseLedger existPurchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>()
.eq(PurchaseLedger::getPurchaseContractNumber, salesLedgerImportDto.getPurchaseContractNumber())
.last("limit 1"));
- if(purchaseLedger != null){
+ // 宸插鏍搁�氳繃鐨勯噰璐崟璺宠繃锛屼笉鍐嶉噸澶嶅鍏�
+ if (existPurchaseLedger != null && ApprovalStatusEnum.APPROVED.getCode().equals(existPurchaseLedger.getApprovalStatus())) {
continue;
}
PurchaseLedger salesLedger = new PurchaseLedger();
BeanUtils.copyProperties(salesLedgerImportDto, salesLedger);
- // 閫氳繃渚涘簲鍟嗗悕绉版煡璇D
- salesLedger.setSupplierId(customers.stream()
- .filter(customer -> customer.getSupplierName().equals(salesLedger.getSupplierName()))
- .findFirst()
- .map(SupplierManage::getId)
- .orElse(null));
+ // 寰呭鏍哥姸鎬佺殑閲囪喘鍗曪細鍒犻櫎璇ュ崟涓嬬殑浜у搧璇︽儏鍜屽鎵瑰疄渚嬶紝閲嶆柊褰曞叆璇︽儏
+ if (existPurchaseLedger != null) {
+ salesLedgerProductMapper.delete(new LambdaQueryWrapper<SalesLedgerProduct>()
+ .eq(SalesLedgerProduct::getSalesLedgerId, existPurchaseLedger.getId())
+ .eq(SalesLedgerProduct::getType, 2));
+ // 娓呯悊璇ュ崟涓嬬殑璐ㄦ璁板綍鍙婅川妫�鍙傛暟
+ deleteQualityInspectByPurchaseLedger(existPurchaseLedger.getId());
+ ApprovalInstance existApprovalInstance = approvalInstanceService.getOne(
+ Wrappers.<ApprovalInstance>lambdaQuery()
+ .eq(ApprovalInstance::getBusinessId, existPurchaseLedger.getId())
+ .eq(ApprovalInstance::getBusinessType, 5L)
+ .eq(ApprovalInstance::getDeleted, 0)
+ .orderByDesc(ApprovalInstance::getId)
+ .last("limit 1"));
+ if (existApprovalInstance != null) {
+ approvalInstanceService.delete(Collections.singletonList(existApprovalInstance.getId()));
+ }
+ salesLedger.setId(existPurchaseLedger.getId());
+ salesLedger.setApprovalStatus(ApprovalStatusEnum.PENDING.getCode());
+ }
+ // 閫氳繃渚涘簲鍟嗗悕绉版煡璇D锛屼笉瀛樺湪鍒欒嚜鍔ㄦ柊澧�
+ salesLedger.setSupplierId(findOrCreateSupplier(salesLedger.getSupplierName(), customers));
Long aLong = sysUsers.stream()
.filter(sysUser -> sysUser.getNickName().equals(salesLedger.getRecorderName()))
.findFirst()
@@ -964,7 +981,12 @@
String collect = ids.stream().map(Object::toString).collect(Collectors.joining(","));
salesLedger.setApproveUserIds(collect);
}
- purchaseLedgerMapper.insert(salesLedger);
+ if (salesLedger.getId() == null) {
+ purchaseLedgerMapper.insert(salesLedger);
+ } else {
+ // 寰呭鏍哥姸鎬侀噸鏂板綍鍏ユ椂锛屾洿鏂颁富琛�
+ purchaseLedgerMapper.updateById(salesLedger);
+ }
for (PurchaseLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct();
@@ -972,14 +994,21 @@
salesLedgerProduct.setSalesLedgerId(salesLedger.getId());
salesLedgerProduct.setType(2);
// 璁$畻涓嶅惈绋庢�讳环
- salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 2, RoundingMode.HALF_UP));
- list.stream()
- .filter(map -> map.get("productName").equals(salesLedgerProduct.getProductCategory()) && map.get("model").equals(salesLedgerProduct.getSpecificationModel()))
- .findFirst()
- .ifPresent(map -> {
- salesLedgerProduct.setProductModelId(Long.parseLong(map.get("modelId").toString()));
- salesLedgerProduct.setProductId(Long.parseLong(map.get("id").toString()));
- });
+ salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 6, RoundingMode.HALF_UP));
+ // 浜у搧澶х被/瑙勬牸鍨嬪彿涓嶅瓨鍦ㄦ椂鑷姩鍒涘缓
+ String productName = salesLedgerProduct.getProductCategory();
+ if (StringUtils.isNotBlank(productName)) {
+ // 瑙勬牸鍨嬪彿涓虹┖鏃剁敤浜у搧澶х被浣滀负瑙勬牸鍨嬪彿
+ String model = StringUtils.isNotBlank(salesLedgerProduct.getSpecificationModel())
+ ? salesLedgerProduct.getSpecificationModel()
+ : productName;
+ salesLedgerProduct.setSpecificationModel(model);
+ Long productId = findOrCreateProduct(productName, list);
+ Long modelId = findOrCreateProductModel(productId, productName, model,
+ salesLedgerProduct.getUnit(), list);
+ salesLedgerProduct.setProductId(productId);
+ salesLedgerProduct.setProductModelId(modelId);
+ }
salesLedgerProduct.setRegister(loginUser.getNickName());
salesLedgerProduct.setRegisterDate(LocalDateTime.now());
salesLedgerProduct.setApproveStatus(0);
@@ -993,8 +1022,132 @@
return AjaxResult.success("瀵煎叆鎴愬姛");
} catch (Exception e) {
e.printStackTrace();
- return AjaxResult.error("瀵煎叆澶辫触锛�" + e.getMessage());
}
+ return AjaxResult.success("瀵煎叆澶辫触");
+ }
+
+ /**
+ * 鏌ユ壘鎴栨柊澧炰緵搴斿晢锛歴upplier_manage 琛ㄦ寜 supplier_name 鍖归厤锛屼笉瀛樺湪鍒欐柊澧烇紝缂哄け淇℃伅榛樿鍐�"/"
+ */
+ private Long findOrCreateSupplier(String supplierName, List<SupplierManage> supplierList) {
+ if (StringUtils.isBlank(supplierName)) {
+ return null;
+ }
+ // 鍐呭瓨鍒楄〃涓煡鎵撅紙鏈瀵煎叆宸叉柊澧炵殑涔熷寘鍚湪鍐咃級
+ for (SupplierManage supplier : supplierList) {
+ if (supplierName.equals(supplier.getSupplierName())) {
+ return supplier.getId();
+ }
+ }
+ // 鏁版嵁搴撴煡鎵�
+ SupplierManage existSupplier = supplierManageMapper.selectOne(new LambdaQueryWrapper<SupplierManage>()
+ .eq(SupplierManage::getSupplierName, supplierName)
+ .last("limit 1"));
+ if (existSupplier != null) {
+ supplierList.add(existSupplier);
+ return existSupplier.getId();
+ }
+ // 鏂板渚涘簲鍟嗭紝缂哄け淇℃伅锛堢◣鍙枫�佸湴鍧�銆佺數璇濈瓑锛夐粯璁ゅ啓"/"
+ SupplierManage newSupplier = new SupplierManage();
+ newSupplier.setSupplierName(supplierName);
+ newSupplier.setTaxpayerIdentificationNum("/");
+ newSupplier.setCompanyAddress("/");
+ newSupplier.setSupplierType("/");
+ newSupplier.setCompanyPhone("/");
+ newSupplier.setBankAccountName("/");
+ newSupplier.setBankAccountNum("/");
+ newSupplier.setContactUserName("/");
+ newSupplier.setContactUserPhone("/");
+ supplierManageMapper.insert(newSupplier);
+ supplierList.add(newSupplier);
+ return newSupplier.getId();
+ }
+
+ /**
+ * 鏌ユ壘鎴栨柊澧炰骇鍝佸ぇ绫伙細product 琛ㄦ寜 product_name 鍖归厤锛屼笉瀛樺湪鍒欐柊澧烇紝榛樿鐖禝D涓�278
+ */
+ private Long findOrCreateProduct(String productName, List<Map<String, Object>> productAndModelList) {
+ // 鍐呭瓨鍒楄〃涓煡鎵撅紙鏈瀵煎叆宸叉柊澧炵殑涔熷寘鍚湪鍐咃級
+ for (Map<String, Object> map : productAndModelList) {
+ if (map.get("productName") != null && productName.equals(map.get("productName"))) {
+ return Long.valueOf(map.get("id").toString());
+ }
+ }
+ // 鏁版嵁搴撴煡鎵撅紙宸插瓨鍦ㄤ絾鏆傛棤瑙勬牸鍨嬪彿鐨勪骇鍝佷笉鍦ㄥ唴瀛樺垪琛ㄤ腑锛�
+ Product existProduct = productMapper.selectOne(new LambdaQueryWrapper<Product>()
+ .eq(Product::getProductName, productName)
+ .last("limit 1"));
+ if (existProduct != null) {
+ return existProduct.getId();
+ }
+ // 鏂板浜у搧澶х被锛岄粯璁ょ埗ID涓�278
+ Product product = new Product();
+ product.setProductName(productName);
+ product.setParentId(278L);
+ productMapper.insert(product);
+ return product.getId();
+ }
+
+ /**
+ * 鏌ユ壘鎴栨柊澧炰骇鍝佽鏍煎瀷鍙凤細product_model 鎸� 浜у搧ID+瑙勬牸鍨嬪彿 鍖归厤锛屼笉瀛樺湪鍒欐柊澧炪��
+ * 浜у搧缂栫爜 = 瑙勬牸鍨嬪彿 + "_" + 涓変綅娴佹按鍙凤紱瑙勬牸鍨嬪彿涓虹┖鏃剁敤浜у搧澶х被浣滀负瑙勬牸鍨嬪彿銆�
+ */
+ private Long findOrCreateProductModel(Long productId, String productName, String model, String unit,
+ List<Map<String, Object>> productAndModelList) {
+ // 鍐呭瓨鍒楄〃涓煡鎵�
+ for (Map<String, Object> map : productAndModelList) {
+ if (map.get("id") != null && Long.valueOf(map.get("id").toString()).equals(productId)
+ && model.equals(map.get("model"))) {
+ return Long.valueOf(map.get("modelId").toString());
+ }
+ }
+ // 鏁版嵁搴撴煡鎵�
+ ProductModel existProductModel = productModelMapper.selectOne(new LambdaQueryWrapper<ProductModel>()
+ .eq(ProductModel::getProductId, productId)
+ .eq(ProductModel::getModel, model)
+ .last("limit 1"));
+ if (existProductModel != null) {
+ return existProductModel.getId();
+ }
+ // 鏂板瑙勬牸鍨嬪彿锛屼骇鍝佺紪鐮� = 瑙勬牸鍨嬪彿 + "_" + 涓変綅娴佹按鍙凤紙鍚屼骇鍝佷笅鑷锛�
+ long count = productModelMapper.selectCount(new LambdaQueryWrapper<ProductModel>()
+ .eq(ProductModel::getProductId, productId));
+ ProductModel productModel = new ProductModel();
+ productModel.setProductId(productId);
+ productModel.setModel(model);
+ productModel.setUnit(unit);
+ productModel.setProductCode(model + "_" + String.format("%03d", count + 1));
+ productModelMapper.insert(productModel);
+ // 璁板綍鍒板唴瀛樺垪琛紝閬垮厤鏈瀵煎叆鍐呴噸澶嶅垱寤�
+ Map<String, Object> newMap = new HashMap<>();
+ newMap.put("id", productId);
+ newMap.put("modelId", productModel.getId());
+ newMap.put("productName", productName);
+ newMap.put("model", model);
+ productAndModelList.add(newMap);
+ return productModel.getId();
+ }
+
+ /**
+ * 鍒犻櫎閲囪喘鍗曚笅鐨勮川妫�璁板綍鍙婅川妫�鍙傛暟锛堝凡鎻愪氦鐨勬楠屽崟涓嶅厑璁稿垹闄わ級
+ */
+ private void deleteQualityInspectByPurchaseLedger(Long purchaseLedgerId) {
+ LambdaQueryWrapper<QualityInspect> inspectWrapper = new LambdaQueryWrapper<>();
+ inspectWrapper.eq(QualityInspect::getPurchaseLedgerId, purchaseLedgerId);
+ List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(inspectWrapper);
+ for (QualityInspect qualityInspect : qualityInspects) {
+ if (ObjectUtils.isNotEmpty(qualityInspect.getInspectState()) && qualityInspect.getInspectState().equals(1)) {
+ throw new BaseException("宸叉彁浜ょ殑妫�楠屽崟涓嶈兘鍒犻櫎");
+ }
+ }
+ List<Long> inspectIds = qualityInspects.stream()
+ .map(QualityInspect::getId)
+ .collect(Collectors.toList());
+ if (!inspectIds.isEmpty()) {
+ qualityInspectParamMapper.delete(new LambdaQueryWrapper<QualityInspectParam>()
+ .in(QualityInspectParam::getInspectId, inspectIds));
+ }
+ qualityInspectMapper.delete(inspectWrapper);
}
@Override
diff --git a/src/main/java/com/ruoyi/sales/pojo/SalesQuotationProduct.java b/src/main/java/com/ruoyi/sales/pojo/SalesQuotationProduct.java
index 2e55e79..53b9651 100644
--- a/src/main/java/com/ruoyi/sales/pojo/SalesQuotationProduct.java
+++ b/src/main/java/com/ruoyi/sales/pojo/SalesQuotationProduct.java
@@ -4,6 +4,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@@ -27,11 +28,11 @@
@Schema(description = "鍗曚綅")
private String unit;
@Schema(description = "鍗曚环")
- private Double unitPrice;
+ private BigDecimal unitPrice;
@Schema(description = "鏁伴噺")
- private Integer quantity;
+ private BigDecimal quantity;
@Schema(description = "閲戦")
- private Double amount;
+ private BigDecimal amount;
@Schema(description = "鍒涘缓鏃堕棿")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index b8042d8..e697a21 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -321,7 +321,7 @@
BigDecimal remain = stockInventory.getQualitity()
.subtract(stockInventory.getLockedQuantity())
.subtract(required)
- .divide(BigDecimal.ONE, 2, RoundingMode.CEILING);
+ .divide(BigDecimal.ONE, 6, RoundingMode.CEILING);
if (remain.compareTo(BigDecimal.ZERO) < 0) {
count++;
stringBuffer.append(structure.getProductName())
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index ff1ef13..7f2caf2 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -344,7 +344,6 @@
if (CollectionUtils.isEmpty(salesLedgerProductImportDtoList)) return AjaxResult.error("閿�鍞骇鍝佹暟鎹负绌猴紒");
// 瀹㈡埛鏁版嵁 - 鍙傝�� listPage 鏌ヨ绉佹捣瀹㈡埛锛坱ype = 0锛�
// type = 0锛堢娴峰鎴凤級鎴栬�� type = 1锛堝叕娴峰鎴凤級涓斿凡琚垎閰嶏紝骞朵笖鏄嚜宸遍鐢ㄣ�佽嚜宸卞垱寤烘垨鑰呭叡浜粰鑷繁鐨勫鎴�
- // 瀹㈡埛涓嶅瓨鍦ㄦ椂鑷姩鏂板骞舵寕鍒拌嚜宸卞悕涓嬶紝鍏捣瀹㈡埛鑷姩棰嗙敤/鍏变韩缁欒嚜宸�
Long loginUserId = loginUser.getUser().getUserId();
Map<String, Customer> customerCache = new HashMap<>();
// 浜у搧澶х被銆佽鏍煎瀷鍙风紦瀛橈紝key = 浜у搧澶х被 + | + 瑙勬牸鍨嬪彿锛屼笉瀛樺湪鏃惰嚜鍔ㄦ柊澧�
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 6059825..594a49c 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -151,8 +151,8 @@
SUM(slp.quantity) AS purchaseNum,
SUM(slp.tax_inclusive_total_price) AS purchaseAmount,
COUNT(DISTINCT slp.sales_ledger_id) AS purchaseTimes,
- <!-- 骞冲潎鍗曚环 = 鎬婚噰璐噾棰�/鎬婚噰璐暟閲忥紝淇濈暀2浣嶅皬鏁帮紝閬垮厤闄�0 -->
- ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 2) AS averagePrice,
+ <!-- 骞冲潎鍗曚环 = 鎬婚噰璐噾棰�/鎬婚噰璐暟閲忥紝淇濈暀6浣嶅皬鏁帮紝閬垮厤闄�0 -->
+ ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 6) AS averagePrice,
<!-- 璇ヤ骇鍝佸ぇ绫讳笅鏈�鍚庝竴涓綍鍏ユ棩鏈燂紙鍙栧彴璐︿富琛ㄧ殑entry_date锛� -->
MAX(sl.entry_date) AS entryDate,
COALESCE(NULLIF(SUM(t1.return_quantity), 0), 0) AS return_quantity,
--
Gitblit v1.9.3