new files

This commit is contained in:
panchengyong
2026-03-07 22:29:07 +08:00
parent cd7e80b502
commit 7acbf45ff7
12516 changed files with 1808447 additions and 194 deletions

View File

@@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace crmeb\services\serve;
use crmeb\basic\BaseManager;
use crmeb\services\AccessTokenServeService;
use crmeb\services\serve\storage\Crmeb;
use think\facade\Config;
use think\Container;
/**
* Class Serve
* @package crmeb\services\serve
* @mixin Crmeb
*/
class Serve extends BaseManager
{
/**
* 空间名
* @var string
*/
protected string $namespace = '\\crmeb\\services\\serve\\storage\\';
/**
* 默认驱动
* @return mixed
*/
protected function getDefaultDriver()
{
return Config::get('serve.default', 'crmeb');
}
/**
* 获取类的实例
* @param $class
* @return mixed|void
*/
protected function invokeClass($class)
{
if (!class_exists($class)) {
throw new \RuntimeException('class not exists: ' . $class);
}
$this->getConfigFile();
if (!$this->config) {
$this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
}
$handleAccessToken = new AccessTokenServeService($this->config['access_key'] ?? '', $this->config['secret_key'] ?? '');
$handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
$this->config = [];
return $handle;
}
}

View File

@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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)
{
}
}