feat(after-sale): 支持撤销售后工单并接入人机验证
This commit is contained in:
@@ -93,6 +93,10 @@ final class AfterSaleService {
|
||||
}
|
||||
|
||||
public function rest_submit(\WP_REST_Request $request) {
|
||||
$captcha = $this->require_captcha($request, 'after_sale_apply');
|
||||
if (is_wp_error($captcha)) {
|
||||
return $captcha;
|
||||
}
|
||||
$images = $request->get_param('images');
|
||||
$materials = $request->get_param('materials');
|
||||
$result = $this->create(
|
||||
@@ -116,10 +120,23 @@ final class AfterSaleService {
|
||||
}
|
||||
|
||||
public function rest_cancel(\WP_REST_Request $request) {
|
||||
$captcha = $this->require_captcha($request, 'after_sale_cancel');
|
||||
if (is_wp_error($captcha)) {
|
||||
return $captcha;
|
||||
}
|
||||
$result = $this->cancel_for_user(get_current_user_id(), (string) $request->get_param('order_number'));
|
||||
return is_wp_error($result) ? $result : rest_ensure_response(['success' => true, 'data' => $result]);
|
||||
}
|
||||
|
||||
/** 人机验证(申请售后 / 撤销售后):场景未启用时 aksrt_require_captcha 直接放行。 */
|
||||
private function require_captcha(\WP_REST_Request $request, string $scene) {
|
||||
if (!function_exists('aksrt_require_captcha')) {
|
||||
return true;
|
||||
}
|
||||
$params = $request->get_json_params();
|
||||
return aksrt_require_captcha($scene, is_array($params) ? $params : []);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $apply_form */
|
||||
public function create(int $user_id, string $order_number, string $reason, array $images = [], array $apply_form = []) {
|
||||
$reason = sanitize_textarea_field($reason);
|
||||
|
||||
Reference in New Issue
Block a user