|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Plugin\Wechat\Shortcut; |
|
6
|
|
|
|
|
7
|
|
|
use Yansongda\Pay\Contract\ShortcutInterface; |
|
8
|
|
|
use Yansongda\Pay\Exception\Exception; |
|
9
|
|
|
use Yansongda\Pay\Exception\InvalidParamsException; |
|
10
|
|
|
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryBatchDetailIdPlugin; |
|
11
|
|
|
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryBatchIdPlugin; |
|
12
|
|
|
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryBillReceiptPlugin; |
|
13
|
|
|
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryDetailReceiptPlugin; |
|
14
|
|
|
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryOutBatchDetailNoPlugin; |
|
15
|
|
|
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryOutBatchNoPlugin; |
|
16
|
|
|
use Yansongda\Pay\Plugin\Wechat\Pay\Common\FindRefundPlugin; |
|
17
|
|
|
use Yansongda\Pay\Plugin\Wechat\Pay\Common\QueryPlugin; |
|
18
|
|
|
|
|
19
|
|
|
class QueryShortcut implements ShortcutInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @throws \Yansongda\Pay\Exception\InvalidParamsException |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getPlugins(array $params): array |
|
25
|
|
|
{ |
|
26
|
|
|
$typeMethod = ($params['_type'] ?? 'default').'Plugins'; |
|
27
|
|
|
|
|
28
|
|
|
if (isset($params['combine_out_trade_no'])) { |
|
29
|
|
|
return $this->combinePlugins(); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
if (method_exists($this, $typeMethod)) { |
|
33
|
|
|
return $this->{$typeMethod}(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
throw new InvalidParamsException(Exception::SHORTCUT_QUERY_TYPE_ERROR, "Query type [$typeMethod] not supported"); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function transferBatchId(): array |
|
40
|
|
|
{ |
|
41
|
|
|
return [ |
|
42
|
|
|
QueryBatchIdPlugin::class, |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function transferBillReceipt(): array |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
QueryBillReceiptPlugin::class, |
|
50
|
|
|
]; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function transferDetailReceipt(): array |
|
54
|
|
|
{ |
|
55
|
|
|
return [ |
|
56
|
|
|
QueryDetailReceiptPlugin::class, |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function transferOutBatchDetailNo(): array |
|
61
|
|
|
{ |
|
62
|
|
|
return [ |
|
63
|
|
|
QueryOutBatchDetailNoPlugin::class, |
|
64
|
|
|
]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function transferOutBatchNo(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return [ |
|
70
|
|
|
QueryOutBatchNoPlugin::class, |
|
71
|
|
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
protected function defaultPlugins(): array |
|
75
|
|
|
{ |
|
76
|
|
|
return [ |
|
77
|
|
|
QueryPlugin::class, |
|
78
|
|
|
]; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
protected function refundPlugins(): array |
|
82
|
|
|
{ |
|
83
|
|
|
return [ |
|
84
|
|
|
FindRefundPlugin::class, |
|
85
|
|
|
]; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
protected function combinePlugins(): array |
|
89
|
|
|
{ |
|
90
|
|
|
return [ |
|
91
|
|
|
\Yansongda\Pay\Plugin\Wechat\Pay\Combine\QueryPlugin::class, |
|
92
|
|
|
]; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
protected function transferBatchDetailId(): array |
|
96
|
|
|
{ |
|
97
|
|
|
return [ |
|
98
|
|
|
QueryBatchDetailIdPlugin::class, |
|
99
|
|
|
]; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: