1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Plugin\Wechat\V3\Extend\Complaints; |
6
|
|
|
|
7
|
|
|
use Closure; |
8
|
|
|
use Yansongda\Artful\Contract\PluginInterface; |
9
|
|
|
use Yansongda\Artful\Exception\ContainerException; |
10
|
|
|
use Yansongda\Artful\Exception\InvalidConfigException; |
11
|
|
|
use Yansongda\Artful\Exception\InvalidParamsException; |
12
|
|
|
use Yansongda\Artful\Exception\ServiceNotFoundException; |
13
|
|
|
use Yansongda\Artful\Logger; |
14
|
|
|
use Yansongda\Artful\Rocket; |
15
|
|
|
use Yansongda\Pay\Exception\Exception; |
16
|
|
|
use Yansongda\Supports\Collection; |
17
|
|
|
|
18
|
|
|
use function Yansongda\Pay\decrypt_wechat_contents; |
19
|
|
|
use function Yansongda\Pay\get_provider_config; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @see https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/query-complaint-v2.html |
23
|
|
|
* @see https://pay.weixin.qq.com/docs/partner/apis/consumer-complaint/complaints/query-complaint-v2.html |
24
|
|
|
*/ |
25
|
|
|
class QueryDetailPlugin implements PluginInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @throws InvalidParamsException |
29
|
|
|
* @throws InvalidConfigException |
30
|
|
|
* @throws ContainerException |
31
|
|
|
* @throws ServiceNotFoundException |
32
|
|
|
*/ |
33
|
|
|
public function assembly(Rocket $rocket, Closure $next): Rocket |
34
|
|
|
{ |
35
|
|
|
Logger::debug('[Wechat][Extend][Complaints][QueryDetailPlugin] 插件开始装载', ['rocket' => $rocket]); |
36
|
|
|
|
37
|
|
|
$complaintId = $rocket->getPayload()?->get('complaint_id') ?? null; |
38
|
|
|
|
39
|
|
|
if (empty($complaintId)) { |
40
|
|
|
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 查询投诉单详情,参数缺少 `complaint_id`'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$rocket->setPayload([ |
44
|
|
|
'_method' => 'GET', |
45
|
|
|
'_url' => 'v3/merchant-service/complaints-v2/'.$complaintId, |
46
|
|
|
'_service_url' => 'v3/merchant-service/complaints-v2/'.$complaintId, |
47
|
|
|
]); |
48
|
|
|
|
49
|
|
|
Logger::info('[Wechat][Extend][Complaints][QueryDetailPlugin] 插件装载完毕', ['rocket' => $rocket]); |
50
|
|
|
|
51
|
|
|
/** @var Rocket $rocket */ |
52
|
|
|
$rocket = $next($rocket); |
53
|
|
|
|
54
|
|
|
Logger::debug('[Wechat][Extend][Complaints][QueryDetailPlugin] 插件开始后置装载', ['rocket' => $rocket]); |
55
|
|
|
|
56
|
|
|
$destination = $rocket->getDestination(); |
57
|
|
|
|
58
|
|
|
if ($destination instanceof Collection && !empty($payerPhone = $destination->get('payer_phone'))) { |
59
|
|
|
$decryptPayerPhone = decrypt_wechat_contents($payerPhone, get_provider_config('wechat', $rocket->getParams())); |
|
|
|
|
60
|
|
|
|
61
|
|
|
if (empty($decryptPayerPhone)) { |
62
|
|
|
throw new InvalidConfigException(Exception::DECRYPT_WECHAT_ENCRYPTED_CONTENTS_INVALID, '参数异常: 查询投诉单详情,参数 `payer_phone` 解密失败'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$destination->set('payer_phone', $decryptPayerPhone); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
Logger::debug('[Wechat][Extend][Complaints][QueryDetailPlugin] 插件后置装载完毕', ['rocket' => $rocket]); |
69
|
|
|
|
70
|
|
|
return $rocket; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.