|
@@ -4,26 +4,35 @@ use Dever\Http\Curl;
|
|
# 银联商务商户资金自主管理系统
|
|
# 银联商务商户资金自主管理系统
|
|
class Multi
|
|
class Multi
|
|
{
|
|
{
|
|
- static $test_host = 'https://mobl-test.chinaums.com/channel/Business/UnifyMulti/';
|
|
|
|
- static $host = 'https://cloudpay.chinaums.com/channel/Business/UnifyMulti/';
|
|
|
|
|
|
+ static $host = 'https://im.chinaums.com/channel/Business/UnifyMulti/';
|
|
|
|
+
|
|
|
|
+ public function act($config, $merchant, $info, $auto = 1)
|
|
|
|
+ {
|
|
|
|
+ $result = $this->huafu($config, $merchant, $info);
|
|
|
|
+ if ($result == 'ok') {
|
|
|
|
+ //$this->fenzhang($config, $merchant, $info);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
|
|
# 划付
|
|
# 划付
|
|
- public function huafu($config, $merchant, $info, $auto = 1)
|
|
|
|
|
|
+ protected function huafu($config, $merchant, $info, $auto = 1)
|
|
{
|
|
{
|
|
$this->config = $config;
|
|
$this->config = $config;
|
|
|
|
|
|
$mid = $merchant['mid'];
|
|
$mid = $merchant['mid'];
|
|
- $cash = $info['tx_cash'];
|
|
|
|
- $order_num = $info['order_num'];
|
|
|
|
|
|
+ $cash = $info['hf_cash'];
|
|
|
|
+ $order_num = $this->getOrderNum($info['order_num']);
|
|
|
|
|
|
//整理内容信息
|
|
//整理内容信息
|
|
$content = [
|
|
$content = [
|
|
- 'merNo' => $mid,
|
|
|
|
- 'merOrderNo' => $order_num,
|
|
|
|
|
|
+ 'merNo' => $merchant['merno'],
|
|
|
|
+ //'merOrderNo' => $order_num,
|
|
'payAmt' => $cash,
|
|
'payAmt' => $cash,
|
|
];
|
|
];
|
|
Dever::log($content, 'yspay_huafu');
|
|
Dever::log($content, 'yspay_huafu');
|
|
- $result = $this->curl('202001', $content);
|
|
|
|
|
|
+ $result = $this->curl('202002', $content);
|
|
if ($result == 'ok') {
|
|
if ($result == 'ok') {
|
|
$data['status'] = 1;
|
|
$data['status'] = 1;
|
|
} else {
|
|
} else {
|
|
@@ -41,26 +50,24 @@ class Multi
|
|
$data['auto'] = $auto;
|
|
$data['auto'] = $auto;
|
|
Dever::db('pay/yspay_cash_log')->insert($data);
|
|
Dever::db('pay/yspay_cash_log')->insert($data);
|
|
|
|
|
|
- $this->fenzhang($config, $merchant, $info, $auto);
|
|
|
|
-
|
|
|
|
return 'ok';
|
|
return 'ok';
|
|
}
|
|
}
|
|
|
|
|
|
# 分账
|
|
# 分账
|
|
- public function fenzhang($config, $merchant, $info, $auto = 1)
|
|
|
|
|
|
+ protected function fenzhang($config, $merchant, $info, $auto = 1)
|
|
{
|
|
{
|
|
$this->config = $config;
|
|
$this->config = $config;
|
|
|
|
|
|
- $mid = $this->config['mid'];
|
|
|
|
|
|
+ $mid = $merchant['mid'];
|
|
$cash = $info['fz_cash'];
|
|
$cash = $info['fz_cash'];
|
|
if (!$cash || $cash <= 0) {
|
|
if (!$cash || $cash <= 0) {
|
|
- return;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- $order_num = $info['order_num'];
|
|
|
|
|
|
+ $order_num = $this->getOrderNum($info['order_num']);
|
|
|
|
|
|
//整理内容信息
|
|
//整理内容信息
|
|
$content = [
|
|
$content = [
|
|
- 'merNo' => $mid,
|
|
|
|
|
|
+ 'merNo' => $merchant['merno'],
|
|
'merOrderNo' => $order_num,
|
|
'merOrderNo' => $order_num,
|
|
'payAmt' => $cash,
|
|
'payAmt' => $cash,
|
|
'cardNo' => hash("sha256",$this->config['card']),
|
|
'cardNo' => hash("sha256",$this->config['card']),
|
|
@@ -86,6 +93,17 @@ class Multi
|
|
Dever::db('pay/yspay_cash_log')->insert($data);
|
|
Dever::db('pay/yspay_cash_log')->insert($data);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected function getOrderNum($order_num)
|
|
|
|
+ {
|
|
|
|
+ $where['order_num'] = $order_num . '_' . Dever::rand(8, 0);
|
|
|
|
+ $state = Dever::db('pay/yspay_cash_log')->one($where);
|
|
|
|
+ if (!$state) {
|
|
|
|
+ return $where['order_num'];
|
|
|
|
+ } else {
|
|
|
|
+ return $this->getOrderNum($order_num);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
protected function header($code)
|
|
protected function header($code)
|
|
{
|
|
{
|
|
$header = array(
|
|
$header = array(
|
|
@@ -95,7 +113,7 @@ class Multi
|
|
'srcReqTime' => date("His"),
|
|
'srcReqTime' => date("His"),
|
|
'srcReqId' => Dever::uuid(),
|
|
'srcReqId' => Dever::uuid(),
|
|
'channelId' => '043',
|
|
'channelId' => '043',
|
|
- 'groupId' => config('param.groupId'),
|
|
|
|
|
|
+ 'groupId' => $this->config['cash_groupid'],
|
|
);
|
|
);
|
|
|
|
|
|
return $header;
|
|
return $header;
|
|
@@ -103,15 +121,21 @@ class Multi
|
|
|
|
|
|
protected function curl($code, $param, $state = true)
|
|
protected function curl($code, $param, $state = true)
|
|
{
|
|
{
|
|
- $url = $this->config['box'] == 1 ? self::$host : self::$test_host;
|
|
|
|
|
|
+ $url = self::$host;
|
|
$url .= $code;
|
|
$url .= $code;
|
|
|
|
|
|
$header = $this->header($code);
|
|
$header = $this->header($code);
|
|
$header['signature'] = $this->sign($param);
|
|
$header['signature'] = $this->sign($param);
|
|
|
|
+ echo $url;
|
|
|
|
+ print_r($header);
|
|
|
|
+ print_r($param);
|
|
$curl = Curl::getInstance($url, $param, 'post', true, $header)->setResultHeader(true);
|
|
$curl = Curl::getInstance($url, $param, 'post', true, $header)->setResultHeader(true);
|
|
$header = $curl->header();
|
|
$header = $curl->header();
|
|
$body = $curl->result();
|
|
$body = $curl->result();
|
|
|
|
|
|
|
|
+ print_r($header);
|
|
|
|
+ print_r($body);die;
|
|
|
|
+
|
|
if (strstr($body, '<html><head>')) {
|
|
if (strstr($body, '<html><head>')) {
|
|
return 'error';
|
|
return 'error';
|
|
}
|
|
}
|
|
@@ -119,7 +143,9 @@ class Multi
|
|
if (isset($header['respCode'])) {
|
|
if (isset($header['respCode'])) {
|
|
if ($header['respCode'] == '99999999') {
|
|
if ($header['respCode'] == '99999999') {
|
|
return $state ? 'ok' : $body;
|
|
return $state ? 'ok' : $body;
|
|
- } else {
|
|
|
|
|
|
+ } elseif ($header['respCode'] == 'FAN00012') {
|
|
|
|
+ return $this->curl($code, $param, $state);
|
|
|
|
+ } else {
|
|
return $header['respMsg'];
|
|
return $header['respMsg'];
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -130,12 +156,13 @@ class Multi
|
|
protected function sign($data)
|
|
protected function sign($data)
|
|
{
|
|
{
|
|
$data = $this->getParams($data);
|
|
$data = $this->getParams($data);
|
|
- $file = $this->config['file_cert'];
|
|
|
|
- if(!file_exists($file)) {
|
|
|
|
- Dever::alert('private_key not exit');
|
|
|
|
|
|
+ $file = $this->config['cash_private_file'];
|
|
|
|
+ if (!strstr($file, 'http')) {
|
|
|
|
+ $file = Dever::local($file);
|
|
}
|
|
}
|
|
|
|
+
|
|
$pkcs12 = file_get_contents($file);
|
|
$pkcs12 = file_get_contents($file);
|
|
- openssl_pkcs12_read($pkcs12, $certs, $this->config['key']);
|
|
|
|
|
|
+ openssl_pkcs12_read($pkcs12, $certs, $this->config['cash_private_file_password']);
|
|
if (!$certs) {
|
|
if (!$certs) {
|
|
Dever::alert('private_key error');
|
|
Dever::alert('private_key error');
|
|
}
|
|
}
|
|
@@ -149,9 +176,9 @@ class Multi
|
|
|
|
|
|
protected function checkSign($data, $signature)
|
|
protected function checkSign($data, $signature)
|
|
{
|
|
{
|
|
- $file = $this->config['file_key'];
|
|
|
|
- if(!file_exists($file)) {
|
|
|
|
- Dever::alert('public_key not exit');
|
|
|
|
|
|
+ $file = $this->config['cash_public_file'];
|
|
|
|
+ if (!strstr($file, 'http')) {
|
|
|
|
+ $file = Dever::local($file);
|
|
}
|
|
}
|
|
$cert = file_get_contents($file);
|
|
$cert = file_get_contents($file);
|
|
$cert = '-----BEGIN CERTIFICATE-----' . PHP_EOL
|
|
$cert = '-----BEGIN CERTIFICATE-----' . PHP_EOL
|