REAPI/app/channel/service/SystemService.php

167 lines
3.5 KiB
PHP
Raw Permalink Normal View History

2024-09-29 15:43:18 +08:00
<?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';
# 加密方法
2024-11-02 15:27:08 +08:00
public array $sign = array
2024-09-29 15:43:18 +08:00
(
1 => '公共md5加密',
2 => '公共sha1加密',
3 => '公共aes加密',
4 => '本平台sha1加密',
5 => '本平台md5加密',
);
# 大小写转换
2024-11-02 15:27:08 +08:00
public array $sign_convert = array
2024-09-29 15:43:18 +08:00
(
1 => '小写',
2 => '大写',
);
# 拼接形式
2024-11-02 15:27:08 +08:00
public array $sign_type = array
2024-09-29 15:43:18 +08:00
(
1 => '&key=value形式',
2 => 'keyvalue形式',
3 => 'value形式',
);
# 是否排序
2024-11-02 15:27:08 +08:00
public array $sign_sort = array
2024-09-29 15:43:18 +08:00
(
1 => '排序',
2 => '不排序',
);
# 接口方法
2024-11-02 15:27:08 +08:00
public array $api_type = array
2024-09-29 15:43:18 +08:00
(
1 => '提交',
2 => '查询',
2024-11-02 15:27:08 +08:00
3 => '取消',
2024-09-29 15:43:18 +08:00
);
# 请求方法
2024-11-02 15:27:08 +08:00
public array $request_method = array
2024-09-29 15:43:18 +08:00
(
1 => 'POST',
2 => 'POST_JSON',
3 => 'GET',
4 => 'GET_JSON',
5 => 'XML',
);
# 字段类型
2024-11-02 15:27:08 +08:00
public array $col_type = array
2024-09-29 15:43:18 +08:00
(
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',
);
# 是否必填
2024-11-02 15:27:08 +08:00
public array $col_option = array
2024-09-29 15:43:18 +08:00
(
1 => '必填',
2 => '选填',
);
# 是否参与签名
2024-11-02 15:27:08 +08:00
public array $col_sign = array
2024-09-29 15:43:18 +08:00
(
1 => '参与签名',
2 => '不参与签名',
);
2024-11-02 15:27:08 +08:00
public function getConfig(): array
2024-09-29 15:43:18 +08:00
{
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;
}
}