From 4a7992b38d739431dcc9f748889af5de77222abd Mon Sep 17 00:00:00 2001 From: liujiang <569804566@qq.com> Date: Sat, 20 Sep 2025 12:35:05 +0800 Subject: [PATCH] =?UTF-8?q?master=EF=BC=9A=E6=A1=A3=E5=8F=A3=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E9=94=80=E5=94=AE=E8=BF=94=E5=8D=95=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/ry_20240629.sql | 7 ++- .../domain/StoreSaleRefundRecordDetail.java | 16 +++++- .../impl/StoreCustomerServiceImpl.java | 54 ++++++++++++++++++- .../StoreCustomerProductDiscountMapper.xml | 2 +- 4 files changed, 72 insertions(+), 7 deletions(-) diff --git a/sql/ry_20240629.sql b/sql/ry_20240629.sql index e12174538..31a1d2e7b 100644 --- a/sql/ry_20240629.sql +++ b/sql/ry_20240629.sql @@ -3892,9 +3892,9 @@ CREATE TABLE `store_sale_detail` ( `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '档口商品销售出库明细ID', `store_sale_id` bigint UNSIGNED NOT NULL COMMENT '档口商品销售ID', - `store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID', `store_prod_id` bigint UNSIGNED NOT NULL COMMENT '档口商品ID', `store_prod_color_id` bigint UNSIGNED NOT NULL COMMENT '档口商品颜色ID', + `store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID', `store_cus_id` bigint UNSIGNED NOT NULL COMMENT '档口客户ID', `store_cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户名称', `voucher_date` date NOT NULL COMMENT '单据日期', @@ -3957,13 +3957,16 @@ CREATE TABLE `store_sale_refund_record_detail` `store_sale_refund_record_id` bigint UNSIGNED NOT NULL COMMENT '档口销售返单ID', `store_prod_id` bigint UNSIGNED NOT NULL COMMENT '档口商品ID', `store_prod_color_id` bigint UNSIGNED NOT NULL COMMENT '档口商品颜色尺码ID', + `store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID', + `store_cus_id` bigint UNSIGNED NOT NULL COMMENT '档口客户ID', + `store_cus_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户名称', `prod_art_num` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商品货号', `sale_type` int UNSIGNED NOT NULL COMMENT '销售类型(普通销售、销售退货、销售/退货)', `price` decimal(10, 2) UNSIGNED NOT NULL COMMENT '销售单价', `discounted_price` decimal(10, 2) UNSIGNED NULL DEFAULT NULL COMMENT '给客户优惠后单价', `quantity` int NOT NULL COMMENT '数量', `amount` decimal(10, 2) NOT NULL COMMENT '总金额', - `sns` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '条码', + `sn` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '条码', `color_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '颜色', `size` int UNSIGNED NULL DEFAULT NULL COMMENT '尺码', `version` bigint UNSIGNED NOT NULL COMMENT '版本号', diff --git a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleRefundRecordDetail.java b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleRefundRecordDetail.java index da0ce25c7..7ab101b1d 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleRefundRecordDetail.java +++ b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreSaleRefundRecordDetail.java @@ -35,7 +35,19 @@ public class StoreSaleRefundRecordDetail extends XktBaseEntity { */ @Excel(name = "档口商品销售ID") private Long storeSaleRefundRecordId; - + /** + * 档口客户ID + */ + @Excel(name = "档口客户ID") + private Long storeCusId; + /** + * 档口客户名称呢 + */ + private String storeCusName; + /** + * 档口ID + */ + private Long storeId; /** * 档口商品ID */ @@ -92,7 +104,7 @@ public class StoreSaleRefundRecordDetail extends XktBaseEntity { * 条码 */ @Excel(name = "条码") - private String sns; + private String sn; @Override public String toString() { diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java index 842293177..c13234941 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreCustomerServiceImpl.java @@ -9,12 +9,12 @@ import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.page.Page; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.xkt.domain.StoreCustomer; +import com.ruoyi.xkt.domain.*; import com.ruoyi.xkt.dto.storeCustomer.StoreCusDTO; import com.ruoyi.xkt.dto.storeCustomer.StoreCusFuzzyResDTO; import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageDTO; import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageResDTO; -import com.ruoyi.xkt.mapper.StoreCustomerMapper; +import com.ruoyi.xkt.mapper.*; import com.ruoyi.xkt.service.IStoreCustomerService; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.CollectionUtils; @@ -40,6 +40,11 @@ import java.util.stream.Collectors; public class StoreCustomerServiceImpl implements IStoreCustomerService { final StoreCustomerMapper storeCusMapper; + final StoreSaleMapper storeSaleMapper; + final StoreSaleDetailMapper saleDetailMapper; + final StoreCustomerProductDiscountMapper cusProdDiscMapper; + final StoreSaleRefundRecordMapper saleRefundRecordMapper; + final StoreSaleRefundRecordDetailMapper saleRefundRecordDetailMapper; /** * 模糊查询客户名称列表 @@ -133,6 +138,10 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService { } } BeanUtil.copyProperties(storeCusDTO, storeCus); + // 如果名称变更了,则需要调整关联表中的客户名称 + if (!Objects.equals(storeCusDTO.getCusName(), storeCus.getCusName())) { + this.updateRelatedCusName(storeCusDTO.getCusName(), storeCus.getId(), storeCus.getStoreId()); + } return storeCusMapper.updateById(storeCus); } @@ -152,4 +161,45 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService { return BeanUtil.toBean(storeCus, StoreCusDTO.class); } + /** + * 更新关联表的客户名称 + * @param cusName 最新的客户名臣 + * @param storeCusId 档口客户ID + * @param storeId 档口ID + */ + private void updateRelatedCusName(String cusName, Long storeCusId, Long storeId) { + // 档口销售表 + List saleList = storeSaleMapper.selectList(new LambdaQueryWrapper() + .eq(StoreSale::getStoreId, storeId).eq(StoreSale::getDelFlag, Constants.UNDELETED) + .eq(StoreSale::getStoreCusId, storeCusId)); + if (CollectionUtils.isNotEmpty(saleList)) { + saleList.forEach(x -> x.setStoreCusName(cusName)); + storeSaleMapper.updateById(saleList); + } + // 档口销售明细表 + List saleDetailList = this.saleDetailMapper.selectList(new LambdaQueryWrapper() + .eq(StoreSaleDetail::getStoreId, storeId).eq(StoreSaleDetail::getDelFlag, Constants.UNDELETED) + .eq(StoreSaleDetail::getStoreCusId, storeCusId)); + if (CollectionUtils.isNotEmpty(saleDetailList)) { + saleDetailList.forEach(x -> x.setStoreCusName(cusName)); + this.saleDetailMapper.updateById(saleDetailList); + } + // 档口销售返单表 + List refundList = this.saleRefundRecordMapper.selectList(new LambdaQueryWrapper() + .eq(StoreSaleRefundRecord::getStoreId, storeId).eq(StoreSaleRefundRecord::getDelFlag, Constants.UNDELETED) + .eq(StoreSaleRefundRecord::getStoreCusId, storeCusId)); + if (CollectionUtils.isNotEmpty(refundList)) { + refundList.forEach(x -> x.setStoreCusName(cusName)); + this.saleRefundRecordMapper.updateById(refundList); + } + // 档口销售返单明细表 + List refundDetailList = this.saleRefundRecordDetailMapper.selectList(new LambdaQueryWrapper() + .eq(StoreSaleRefundRecordDetail::getStoreId, storeId).eq(StoreSaleRefundRecordDetail::getDelFlag, Constants.UNDELETED) + .eq(StoreSaleRefundRecordDetail::getStoreCusId, storeCusId)); + if (CollectionUtils.isNotEmpty(refundDetailList)) { + refundDetailList.forEach(x -> x.setStoreCusName(cusName)); + this.saleRefundRecordDetailMapper.updateById(refundDetailList); + } + } + } diff --git a/xkt/src/main/resources/mapper/StoreCustomerProductDiscountMapper.xml b/xkt/src/main/resources/mapper/StoreCustomerProductDiscountMapper.xml index 3d15a3478..f0893f98f 100644 --- a/xkt/src/main/resources/mapper/StoreCustomerProductDiscountMapper.xml +++ b/xkt/src/main/resources/mapper/StoreCustomerProductDiscountMapper.xml @@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" JOIN store_product_color_size spcs ON spc.store_prod_id = spcs.store_prod_id AND spcs.del_flag = 0 AND spc.store_color_id = spcs.store_color_id WHERE scpd.del_flag = 0 AND scpd.store_id = #{storeId} - AND scpd.store_cus_name = #{cusName} + AND scpd.store_cus_name like concat('%', #{cusName}, '%') AND sp.prod_art_num like concat('%', #{prodArtNum}, '%') ORDER BY scpd.store_cus_id,