fix(after-sale): 售后工单已完结仍可再次申请,改由订单是否已退款决定
上一个提交把「工单 completed」当成了不能再申请售后的判据,方向搞反了: 能否再售后应该看订单有没有被标「已退款」,而不是看工单状态。订单已退款时 status_group 变成 refunded、enabled 直接为 false,那道闸门本来就够用;用工单 状态再判一次,反而把「工单已完结但订单没退款」的用户堵死,售后详细弹窗底部 也只剩下一个「我知道了」死胡同。 - reapplyable_statuses 补上 STATUS_COMPLETED:rejected / cancelled / completed 一律放行再次申请,售后详细弹窗底部按钮对已完成订单渲染「再次申请售后」 - can_apply 还原为只看有没有进行中的工单(!open),不再二次校验工单状态 - create() 的重复申请闸门还原为 find_active():只挡仍在流转的工单, completed 不挡;订单已退款由上面的 STATUS_PAID 校验先挡掉 - 点「再次申请售后」后清 has_application 落回申请表单,提交走 create() 新建工单,链路本来就通,无需改动 harness 场景名改为 settled_ticket_still_allows_reapply,断言 completed / rejected / cancelled 三种已终结状态都能新建工单;待审核工单同因幂等、换因 挡住的场景保留。 验证:tests/widget-system/ 462 项、tests/admin/ 76 项通过;after-sale-log-harness 7/7。未做浏览器视觉验收。
This commit is contained in:
@@ -63,15 +63,12 @@ test('after-sale submissions are order-locked and admins set status directly', (
|
||||
assert.ok(!column.includes(dead), `${dead} column must be removed from aksrt_order_aftersale`)
|
||||
}
|
||||
// create() 的重复申请闸门看「最新一条工单」而不是只看进行中的:已完结同样要挡
|
||||
assert.match(afterSale, /GET_LOCK\(%s, 5\)[\s\S]*?get_user_order\(\$user_id, \$order_number\)[\s\S]*?latest_for_order\(\$order_number\)/)
|
||||
assert.ok(afterSale.includes("return new \\WP_Error('aksrt_after_sale_exists', __('该订单的售后申请已完结,不能再次申请', 'aksrt'), ['status' => 409]);"),
|
||||
'completed ticket must block a new application')
|
||||
// 待审核 / 处理中仍走同人同因幂等,rejected / cancelled 放行再次发起
|
||||
assert.match(afterSale, /in_array\(\$latest_status, \[self::STATUS_PENDING, self::STATUS_PROCESSING\], true\)/)
|
||||
assert.match(afterSale, /hash_equals\(\(string\) \(\$latest\['reason'\] \?\? ''\), \$reason\)/)
|
||||
// 只看 create() 方法体,避免跨方法匹配到 cancel_for_user() 里的 find_active
|
||||
const createBody = afterSale.slice(afterSale.indexOf('public function create('), afterSale.indexOf('private function sanitize_images('))
|
||||
assert.ok(!createBody.includes('find_active'), 'create must not gate on find_active alone')
|
||||
// 只挡仍在流转的工单:已完结(completed)不挡,能否再售后由订单是否已退款决定
|
||||
assert.match(afterSale, /GET_LOCK\(%s, 5\)[\s\S]*?get_user_order\(\$user_id, \$order_number\)[\s\S]*?find_active\(\$order_number\)/)
|
||||
// 待审核 / 处理中:同人同因幂等返回原工单
|
||||
assert.match(afterSale, /hash_equals\(\(string\) \(\$active\['reason'\] \?\? ''\), \$reason\)/)
|
||||
// 订单已退款走 STATUS_PAID 校验挡掉,工单 completed 不参与这道闸门
|
||||
assert.ok(!afterSale.includes('该订单的售后申请已完结,不能再次申请'), 'completed-block copy must be removed')
|
||||
assert.match(afterSale, /Order::STATUS_PAID/)
|
||||
assert.match(afterSale, /public function set_status\(int \$id, string \$status, string \$note = ''\)/)
|
||||
assert.match(afterSale, /in_array\(\$status, \[self::STATUS_PENDING, self::STATUS_PROCESSING, self::STATUS_COMPLETED, self::STATUS_REJECTED, self::STATUS_CANCELLED\], true\)/)
|
||||
|
||||
Reference in New Issue
Block a user