167 lines
3.5 KiB
PHP
167 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace app\channel\service;
|
|
|
|
use app\core\Service;
|
|
|
|
/**
|
|
* 系统基本服务
|
|
* Class ChannelService
|
|
* @package app\channel\service
|
|
*/
|
|
class SystemService extends Service
|
|
{
|
|
/**
|
|
* 设置默认操作表
|
|
* @var string
|
|
*/
|
|
public $table = 'service_system';
|
|
|
|
# 加密方法
|
|
public array $sign = array
|
|
(
|
|
1 => '公共md5加密',
|
|
2 => '公共sha1加密',
|
|
3 => '公共aes加密',
|
|
4 => '本平台sha1加密',
|
|
5 => '本平台md5加密',
|
|
);
|
|
|
|
# 大小写转换
|
|
public array $sign_convert = array
|
|
(
|
|
1 => '小写',
|
|
2 => '大写',
|
|
);
|
|
|
|
# 拼接形式
|
|
public array $sign_type = array
|
|
(
|
|
1 => '&key=value形式',
|
|
2 => 'keyvalue形式',
|
|
3 => 'value形式',
|
|
);
|
|
|
|
# 是否排序
|
|
public array $sign_sort = array
|
|
(
|
|
1 => '排序',
|
|
2 => '不排序',
|
|
);
|
|
|
|
# 接口方法
|
|
public array $api_type = array
|
|
(
|
|
1 => '提交',
|
|
2 => '查询',
|
|
3 => '取消',
|
|
);
|
|
|
|
# 请求方法
|
|
public array $request_method = array
|
|
(
|
|
1 => 'POST',
|
|
2 => 'POST_JSON',
|
|
3 => 'GET',
|
|
4 => 'GET_JSON',
|
|
5 => 'XML',
|
|
);
|
|
|
|
# 字段类型
|
|
public array $col_type = array
|
|
(
|
|
1 => '自定义',
|
|
2 => '加油卡号',
|
|
3 => '手机号',
|
|
4 => '订单号',
|
|
5 => '商户MID',
|
|
6 => '商户TOKEN',
|
|
7 => '回调地址',
|
|
8 => '签名',
|
|
9 => '时间戳',
|
|
10 => 'YmdHis形式时间',
|
|
11 => 'Y-m-d H:i:s形式时间',
|
|
12 => '金额',
|
|
13 => '卡密的卡号',
|
|
14 => '卡密的密码',
|
|
15 => '身份证号',
|
|
16 => '真实姓名',
|
|
17 => '产品ID',
|
|
18 => '产品KEY',
|
|
);
|
|
|
|
# 是否必填
|
|
public array $col_option = array
|
|
(
|
|
1 => '必填',
|
|
2 => '选填',
|
|
);
|
|
|
|
# 是否参与签名
|
|
public array $col_sign = array
|
|
(
|
|
1 => '参与签名',
|
|
2 => '不参与签名',
|
|
);
|
|
|
|
public function getConfig(): array
|
|
{
|
|
return array
|
|
(
|
|
'sign' => $this->sign,
|
|
'sign_convert' => $this->sign_convert,
|
|
'sign_type' => $this->sign_type,
|
|
'sign_sort' => $this->sign_sort,
|
|
'api_type' => $this->api_type,
|
|
'request_method' => $this->request_method,
|
|
'col_type' => $this->col_type,
|
|
'col_option' => $this->col_option,
|
|
'col_sign' => $this->col_sign,
|
|
);
|
|
}
|
|
|
|
public function getOne($id)
|
|
{
|
|
$where['id'] = $id;
|
|
$where['status'] = 1;
|
|
$data = $this->db()->where($where)->find();
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getApi($key, $system_id, $type = 1)
|
|
{
|
|
$where['system_id'] = $system_id;
|
|
$where['type'] = $type;
|
|
$where['status'] = 1;
|
|
$data = $this->app->db->name('service_system_api')->where($where)->select();
|
|
|
|
if ($data) {
|
|
foreach ($data as $k => $v) {
|
|
$service_key = explode(',', $v['service_key']);
|
|
if (in_array($key, $service_key)) {
|
|
$v['col'] = $this->getCol($v['id']);
|
|
return $v;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function getApiInfo($id)
|
|
{
|
|
$where['id'] = $id;
|
|
$data = $this->app->db->name('service_system_api')->where($where)->find();
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getCol($api_id)
|
|
{
|
|
$where['api_id'] = $api_id;
|
|
$data = $this->app->db->name('service_system_col')->where($where)->select()->toArray();
|
|
|
|
return $data;
|
|
}
|
|
} |