fix(vr_ticket): 修复非票务商品错误生成票据的 Bug

问题根因:
1. isTicketGoods() 依赖不存在的 venue_data 字段,导致非票务商品被误判
2. onOrderPaid() 的第二个循环缺少校验,即使非票务商品被 continue 跳过,仍会进入 issueTicket()

修复内容:
1. BaseService::isTicketGoods() - 严格检查 item_type === 'ticket'
2. TicketService::onOrderPaid() - 在发票循环中检查 _parsed_spec_name 是否存在
main
Council 2026-06-26 12:43:23 +08:00
parent 70354300eb
commit 8c0fd983a3
2 changed files with 6 additions and 1 deletions

View File

@ -116,7 +116,8 @@ class BaseService
if (empty($goods)) {
return false;
}
return !empty($goods['venue_data']) || ($goods['item_type'] ?? '') === 'ticket';
// 严格:只检查 item_type 字段,避免因 goods 表无 venue_data 列导致所有商品都通过检查的问题
return ($goods['item_type'] ?? '') === 'ticket';
}
/**

View File

@ -112,6 +112,10 @@ class TicketService extends BaseService
// 逐个生成票(每个订单明细行 = 一张票)
$count = 0;
foreach ($order_goods as $og) {
// 过滤非票务商品(如果被上面的循环 continue 跳过了,就不会有 _parsed_spec_name
if (!isset($og['_parsed_spec_name'])) {
continue;
}
$ticket_id = self::issueTicket($order, $og);
if ($ticket_id > 0) {
$count++;