refactor(print): 优化门票打印逻辑

- 移除了 AppClaimController 中的重复代码
- 在 VoucherPrintServiceImpl 中增加了打印配置的判断和警告日志
- 保留了 FeiETicketPrinter 的调用逻辑,增加了配置判断
This commit is contained in:
2025-08-30 13:17:47 +08:00
parent fc8818a595
commit 607c5bc057
2 changed files with 7 additions and 5 deletions

View File

@@ -49,7 +49,6 @@ public class AppClaimController {
if (voucherPrintResp != null) {
claimResp.setHasCoupon(false);
claimResp.setHasPrint(true);
claimResp.setHasPrint(voucherPrintResp.getPrintStatus() == 1);
claimResp.setPrintCode(voucherPrintResp.getCode());
claimResp.setPrintType(voucherPrintResp.getType());
return ApiResponse.success(claimResp);
@@ -66,7 +65,6 @@ public class AppClaimController {
if (voucherPrintResp != null) {
claimResp.setHasCoupon(false);
claimResp.setHasPrint(true);
claimResp.setHasPrint(voucherPrintResp.getPrintStatus() == 1);
claimResp.setPrintCode(voucherPrintResp.getCode());
claimResp.setPrintType(voucherPrintResp.getType());
return ApiResponse.success(claimResp);

View File

@@ -327,7 +327,7 @@ public class VoucherPrintServiceImpl implements VoucherPrintService {
}
/**
* 调用打印机接口(待实现)
* 调用打印机接口
*/
private void printTicket(VoucherPrintRecord record, VoucherPrintResp voucherPrintResp) throws Exception {
FaceEntity face = faceRepository.getFace(record.getFaceId());
@@ -362,7 +362,11 @@ public class VoucherPrintServiceImpl implements VoucherPrintService {
content += "<CB>"+voucherPrintResp.getCode()+"</CB>";
content += "<C>"+voucherPrintResp.getType()+"</C>";
content += "<C>有效期:"+sdf2.format(new Date())+"</C>";
// FeiETicketPrinter.doPrint("550519002", content, 1);
log.info("打印完成->内容:\n{}", content);
ScenicConfigManager config = scenicRepository.getScenicConfigManager(face.getScenicId());
if (Strings.isNotBlank(config.getString("ticket_print_sn"))) {
FeiETicketPrinter.doPrint(config.getString("ticket_print_sn"), content, 1);
} else {
log.warn("打印没有配置->内容:\n{}", content);
}
}
}