1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace tinymeng\Chinaums\Service\Contract; |
4
|
|
|
|
5
|
|
|
use tinymeng\Chinaums\Service\Contract\Base; |
6
|
|
|
use tinymeng\Chinaums\Tools\DES; |
7
|
|
|
use Exception; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* 分店变更签约接口 |
11
|
|
|
*/ |
12
|
|
|
class StoreChangeSign extends Base |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var string 接口地址 |
16
|
|
|
*/ |
17
|
|
|
protected $api = '/self-contract-nmrs/interface/autoReg'; |
18
|
|
|
/** |
19
|
|
|
* @var array $body 请求参数 |
20
|
|
|
*/ |
21
|
|
|
protected $body = [ |
22
|
|
|
'service' => 'store_change_sign', |
23
|
|
|
'sign_type' => 'SHA-256', |
24
|
|
|
]; |
25
|
|
|
/** |
26
|
|
|
* 必传的值 |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
protected $require = ['service', 'accesser_id', 'sign_type', 'request_date', 'request_seq', 'ums_reg_id']; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* 获取get前端签约方式 |
33
|
|
|
* @param array $data |
34
|
|
|
* @return void |
35
|
|
|
*/ |
36
|
|
|
public function getUrl($data = []) |
37
|
|
|
{ |
38
|
|
|
$data['accesser_id'] = $this->config['accesser_id']; |
39
|
|
|
$key = $this->config['private_key']; |
40
|
|
|
if ($data) { |
|
|
|
|
41
|
|
|
$this->body = array_merge($this->body, $data); |
42
|
|
|
} |
43
|
|
|
try { |
44
|
|
|
$this->validate(); |
45
|
|
|
$data = $this->body; |
46
|
|
|
$gateway = $this->config['gateway'] . $this->api; |
47
|
|
|
$data = json_encode($data); |
48
|
|
|
$sign = hash('sha256', $data); |
49
|
|
|
$method = $this->method; |
50
|
|
|
$des = new DES($key, $method, DES::OUTPUT_HEX); |
51
|
|
|
// 加密 |
52
|
|
|
$str = $des->encrypt($data); |
53
|
|
|
$url = $gateway . '?sign_data=' . $sign . '&json_data=' . $str . '&accesser_id=' . $this->config['accesser_id']; |
54
|
|
|
return json_encode(['res_code' => '0000', 'res_msg' => 'success', 'url' => $url], JSON_UNESCAPED_SLASHES); |
|
|
|
|
55
|
|
|
} catch (Exception $e) { |
56
|
|
|
return json_encode(['res_code' => -1, 'res_msg' => $e->getMessage(), 'request_seq' => null]); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.