feat(pricing): 实现优惠券打印功能

- 新增 AppVoucherController 控制器处理打印请求
- 实现 VoucherPrintService 接口和 VoucherPrintServiceImpl 实现类
- 添加 VoucherPrintReq 请求对象和 VoucherPrintResp 响应对象
- 创建 VoucherPrintRecord 实体和对应的 Mapper
- 更新 PriceVoucherCodeMapper 接口,添加随机获取未打印券码的方法
- 实现分布式锁机制防止重复打印- 生成流水号并记录打印状态
This commit is contained in:
2025-08-24 01:16:16 +08:00
parent 4c794cdda2
commit 0204b3bc23
12 changed files with 616 additions and 11 deletions

View File

@@ -91,4 +91,11 @@ public interface PriceVoucherCodeMapper extends BaseMapper<PriceVoucherCode> {
* @return 可用券码
*/
PriceVoucherCode findFirstAvailableByBatchId(@Param("batchId") Long batchId);
/**
* 随机获取一个未被打印过的可用券码
* @param scenicId 景区ID
* @return 可用券码
*/
PriceVoucherCode findRandomUnprintedVoucher(@Param("scenicId") Long scenicId);
}

View File

@@ -0,0 +1,42 @@
package com.ycwl.basic.pricing.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ycwl.basic.pricing.entity.VoucherPrintRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 优惠券打印记录Mapper
*/
@Mapper
public interface VoucherPrintRecordMapper extends BaseMapper<VoucherPrintRecord> {
/**
* 根据faceId、brokerId、scenicId查询已存在的打印记录
* @param faceId 用户faceId
* @param brokerId 经纪人ID
* @param scenicId 景区ID
* @return 打印记录
*/
VoucherPrintRecord selectByFaceBrokerScenic(@Param("faceId") Long faceId,
@Param("brokerId") Long brokerId,
@Param("scenicId") Long scenicId);
/**
* 根据券码ID查询是否已被打印
* @param voucherCodeId 券码ID
* @return 打印记录
*/
VoucherPrintRecord selectByVoucherCodeId(@Param("voucherCodeId") Long voucherCodeId);
/**
* 更新打印状态
* @param id 记录ID
* @param printStatus 打印状态
* @param errorMessage 错误信息(可为null)
* @return 影响行数
*/
int updatePrintStatus(@Param("id") Long id,
@Param("printStatus") Integer printStatus,
@Param("errorMessage") String errorMessage);
}