master:档口客户销售返单明细表添加字段;

pull/1121/head
liujiang 2025-09-20 12:35:05 +08:00
parent 57cc0fb1ed
commit 4a7992b38d
4 changed files with 72 additions and 7 deletions

View File

@ -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 '版本号',

View File

@ -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() {

View File

@ -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<StoreSale> saleList = storeSaleMapper.selectList(new LambdaQueryWrapper<StoreSale>()
.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<StoreSaleDetail> saleDetailList = this.saleDetailMapper.selectList(new LambdaQueryWrapper<StoreSaleDetail>()
.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<StoreSaleRefundRecord> refundList = this.saleRefundRecordMapper.selectList(new LambdaQueryWrapper<StoreSaleRefundRecord>()
.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<StoreSaleRefundRecordDetail> refundDetailList = this.saleRefundRecordDetailMapper.selectList(new LambdaQueryWrapper<StoreSaleRefundRecordDetail>()
.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);
}
}
}

View File

@ -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}
<if test="cusName != null and cusName != ''"> AND scpd.store_cus_name = #{cusName}</if>
<if test="cusName != null and cusName != ''"> AND scpd.store_cus_name like concat('%', #{cusName}, '%')</if>
<if test="prodArtNum != null and prodArtNum != ''"> AND sp.prod_art_num like concat('%', #{prodArtNum}, '%')</if>
ORDER BY
scpd.store_cus_id,