新增ca认证对接、新增银行卡、身份证验证、修正消息通知
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\Ca;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 四川ca云证书+电子签章
|
||||
*/
|
||||
class Ca
|
||||
{
|
||||
#[Inject]
|
||||
protected ContainerInterface $container;
|
||||
|
||||
#[Inject]
|
||||
protected Client $client;
|
||||
|
||||
public function __construct(){
|
||||
$this->container = ApplicationContext::getContainer();
|
||||
$this->client = $this->container->get(Client::class);
|
||||
}
|
||||
|
||||
// 获取云证书
|
||||
public function getCloudCert(array $data){
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'entityId' => $data['user_id'], // 用户唯一标识,由业务系统定义
|
||||
'entityType' => "Personal",// 用户类型,可选值[Personal/Organizational]
|
||||
'pin' => $data['user_id'], // 证书PIN码
|
||||
'cardNumber' => $data['card_num'], // 证件号码(个人身份证;企业统一社会信用代码)
|
||||
]
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest(config("ca.api_url") . '/cloud-certificate-service' . '/api/cloudCert/open/V2/cert/offlineAuthCertEnroll', $option);
|
||||
if (empty($response)){
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取签名
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
protected function getSign(array $data): string
|
||||
{
|
||||
$data = implode('&',$data['form_params']);
|
||||
return hash_hmac("sha1",$data,config("ca.secret"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装公共请求
|
||||
* @param string $path
|
||||
* @param array $arg
|
||||
* @return mixed
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function httpRequest(string $path,array $arg = []): mixed
|
||||
{
|
||||
|
||||
$option = [
|
||||
"headers" => [
|
||||
"app_id" => config("ca.app_id"),
|
||||
"signature" => $this->getSign($arg)
|
||||
],
|
||||
];
|
||||
|
||||
$arg = array_merge($arg,$option);
|
||||
|
||||
dump($path);die;
|
||||
dump($arg);die;
|
||||
$response = $this->client->post($path, $arg);
|
||||
dump(1);
|
||||
if ($response->getStatusCode() != '200'){
|
||||
// 请求失败
|
||||
throw new BusinessException($response->getBody()->getContents());
|
||||
}
|
||||
dump(2);
|
||||
$body = json_decode($response->getBody(),true);
|
||||
dump($body);die;
|
||||
if (empty($body)){
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
|
||||
if ($body['result_code'] != 0){
|
||||
// 请求失败
|
||||
if (!empty($body['result_msg'])){
|
||||
throw new BusinessException($body['result_msg']);
|
||||
}
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
|
||||
return $body['body'];
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,12 @@ class Prescription
|
||||
return $response['result']['token'];
|
||||
}
|
||||
|
||||
// 获取药品
|
||||
/**
|
||||
* 获取药品
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
* @return mixed
|
||||
*/
|
||||
public function getProd(int $page = 1,int $pageSize = 10){
|
||||
$option = [
|
||||
"json" => array(
|
||||
@@ -125,8 +130,30 @@ class Prescription
|
||||
}
|
||||
}
|
||||
|
||||
// 获取运费
|
||||
/**
|
||||
* 获取运费
|
||||
* @return array
|
||||
*/
|
||||
public function getLogisticsFee(): array
|
||||
{
|
||||
$option = [
|
||||
"json" => array(
|
||||
"pharmacyCode" => "JG-10009",
|
||||
),
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/transportationExpenses', $option);
|
||||
if (empty($response)){
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求封装
|
||||
|
||||
@@ -3,18 +3,25 @@
|
||||
namespace Extend\VerifyDun;
|
||||
|
||||
use App\Exception\BusinessException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
/**
|
||||
* 银行卡三/四要素认证
|
||||
*/
|
||||
class BankCard extends Base
|
||||
{
|
||||
public function checkBankCard(array $params){
|
||||
/**
|
||||
* @param array $params
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function checkBankCard(array $params): string
|
||||
{
|
||||
try {
|
||||
// 组合请求地址
|
||||
$api_url = $this->api_url . $this->version . '/bankcard/check';
|
||||
|
||||
$this->params['businessId'] = "98c43b77719e4752b15519fbce011a58";
|
||||
$this->params['businessId'] = "3cb726bd85104161b25613153c4fba7c";
|
||||
|
||||
$this->params = array_merge($this->params,$params);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class IdCard extends Base
|
||||
// 组合请求地址
|
||||
$api_url = $this->api_url . $this->version . '/idcard/check';
|
||||
|
||||
$this->params['businessId'] = "f7262b91aac1448a848d29c0800b109a";
|
||||
$this->params['businessId'] = "45a8fd254b4649e9bd25d773ac7ab666";
|
||||
|
||||
$this->params = array_merge($this->params,$params);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user