2026-03-21 02:55:24 +08:00
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
2026-03-29 11:22:52 +08:00
|
|
|
// | Author: ScottPan Team
|
2026-03-21 02:55:24 +08:00
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace crmeb\services\serve\storage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use crmeb\basic\BaseStorage;
|
|
|
|
|
use crmeb\services\AccessTokenServeService;
|
|
|
|
|
use think\exception\ValidateException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Crmeb
|
|
|
|
|
* @package crmeb\services\serve\storage
|
|
|
|
|
*/
|
|
|
|
|
class Crmeb extends BaseStorage
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
protected $accessToken;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Crmeb constructor.
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @param AccessTokenServeService $service
|
|
|
|
|
* @param string|null $configFile
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(string $name, AccessTokenServeService $service, string $configFile = null)
|
|
|
|
|
{
|
|
|
|
|
$this->accessToken = $service;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户信息
|
|
|
|
|
* @param string $account
|
|
|
|
|
* @param string $secret
|
|
|
|
|
* @return array|mixed
|
|
|
|
|
*/
|
|
|
|
|
public function getUser()
|
|
|
|
|
{
|
|
|
|
|
return $this->accessToken->httpRequest('v2/user/info');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用量记录
|
|
|
|
|
* @param int $page
|
|
|
|
|
* @param int $limit
|
|
|
|
|
* @param int $type
|
|
|
|
|
* @return array|mixed
|
|
|
|
|
*/
|
|
|
|
|
public function record(int $page, int $limit, int $type, $status = '')
|
|
|
|
|
{
|
|
|
|
|
$typeContent = [1 => 'sms', 2 => 'expr_dump', 3 => 'expr_query', 4 => 'copy'];
|
|
|
|
|
if (!isset($typeContent[$type])) {
|
|
|
|
|
throw new ValidateException('参数类型不正确');
|
|
|
|
|
}
|
|
|
|
|
$data = ['page' => $page, 'limit' => $limit, 'type' => $typeContent[$type]];
|
|
|
|
|
if ($type == 1 && $status != '') {
|
|
|
|
|
$data['status'] = $status;
|
|
|
|
|
}
|
|
|
|
|
return $this->accessToken->httpRequest('user/record', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function initialize(array $config)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|