123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?php
- namespace crmeb\services\serve\storage;
- use crmeb\basic\BaseStorage;
- use crmeb\services\AccessTokenServeService;
- use think\exception\ValidateException;
- class Crmeb extends BaseStorage
- {
- protected $accessToken;
-
- public function __construct(string $name, AccessTokenServeService $service, string $configFile = null)
- {
- $this->accessToken = $service;
- }
-
- public function getUser()
- {
- return $this->accessToken->httpRequest('user/info');
- }
-
- public function login(string $account, string $secret)
- {
- return $this->accessToken->httpRequest('user/login', ['account' => $account, 'secret' => $secret], 'POST', false);
- }
-
- public function register(array $data)
- {
- return $this->accessToken->httpRequest('user/register', $data, 'POST', false);
- }
-
- public function userBill(int $page, int $limit)
- {
- return $this->accessToken->httpRequest('user/bill', ['page' => $page, 'limit' => $limit]);
- }
-
- public function forget(array $data)
- {
- return $this->accessToken->httpRequest('user/forget', $data, 'POST', false);
- }
-
- public function modify(array $data)
- {
- return $this->accessToken->httpRequest('user/modify', $data, 'POST', false);
- }
-
- public function code(string $phone, $type = 0)
- {
- return $this->accessToken->httpRequest('user/code', ['phone' => $phone, 'types' => $type], 'POST', false);
- }
-
- public function checkCode(string $phone, string $verify_code)
- {
- return $this->accessToken->httpRequest('user/code/verify', ['phone' => $phone, 'verify_code' => $verify_code], 'POST', false);
- }
-
- public function mealList(string $type)
- {
- return $this->accessToken->httpRequest('meal/list', ['type' => $type]);
- }
-
- public function payMeal(array $data)
- {
- return $this->accessToken->httpRequest('meal/code', $data);
- }
-
- 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);
- }
-
- public function modifyPhone(array $data)
- {
- return $this->accessToken->httpRequest('user/modify/phone', $data);
- }
- protected function initialize(array $config)
- {
- }
- }
|