123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <?php
- namespace crmeb\services;
- class CrmebPlatService
- {
-
- const PLAT_CODE = 'user/code';
-
- const PLAT_OPEN = 'user/register';
-
- const PLAT_USER_INFO = 'user/info';
-
- const PLAT_USER_MODIFY = 'user/modify';
-
- const PLAT_USER_FORGET = 'user/forget';
-
- const PLAT_BILL = 'user/bill';
-
- const PlAT_RRCORD = 'user/record';
-
- const MEAL_LIST = 'meal/list';
-
- const MEAL_CODE = 'meal/code';
-
- protected $account = NULL;
-
- protected $sercet = NULL;
-
- protected $accessToken = NULL;
- public function __construct($account = '', $sercet = '')
- {
- $this->accessToken = $this->getAccessToken($account, $sercet);
- }
- protected function getAccessToken($account, $sercet)
- {
- $this->account = $account ? $account : sys_config('sms_account');
- $this->sercet = $sercet ? $sercet : sys_config('sms_token');
- return new AccessTokenServeService($this->account, $this->sercet);
- }
-
- public function code($phone)
- {
- $param = [
- 'phone' => $phone
- ];
- return $this->accessToken->httpRequest(self::PLAT_CODE, $param, 'POST', false);
- }
-
- public function register($account, $phone, $password, $verify_code)
- {
- $param = [
- 'account' => $account,
- 'phone' => $phone,
- 'password' => md5($password),
- 'verify_code' => $verify_code
- ];
- $result = $this->accessToken->httpRequest(self::PLAT_OPEN, $param, 'POST', false);
- return $result;
- }
-
- public function login($account, $secret)
- {
- $token = $this->getAccessToken($account, $secret)->getToken();
- return $token;
- }
-
- public function loginOut()
- {
- return $this->accessToken->destroyToken();
- }
-
- public function info()
- {
- $result = $this->accessToken->httpRequest(self::PLAT_USER_INFO);
- return $result;
- }
-
- public function modify($account, $phone, $password, $verify_code)
- {
- $param = [
- 'account' => $account,
- 'phone' => $phone,
- 'password' => md5($password),
- 'verify_code' => $verify_code
- ];
- return $this->accessToken->httpRequest(self::PLAT_USER_MODIFY, $param, 'POST', false);
- }
-
- public function forget($phone, $verify_code)
- {
- $param = [
- 'phone' => $phone,
- 'verify_code' => $verify_code
- ];
- $result = $this->accessToken->httpRequest(self::PLAT_USER_FORGET, $param, 'POST', false);
- return $result;
- }
-
- public function bill($page = 0, $limit = 10)
- {
- $param = [
- 'page' => $page,
- 'limit' => $limit
- ];
- $result = $this->accessToken->httpRequest(self::PLAT_BILL, $param);
- return $result;
- }
-
- public function record($type = 'sms', $page = 0, $limit = 10)
- {
- $param = [
- 'type' => $type,
- 'page' => $page,
- 'limit' => $limit
- ];
- $result = $this->accessToken->httpRequest(self::PlAT_RRCORD, $param);
- return $result;
- }
-
- public function meal($type = 'sms')
- {
- $param = [
- 'type' => $type
- ];
- return $this->accessToken->httpRequest(self::MEAL_LIST, $param);
- }
-
- public function pay($type, $meal_id, $price, $num, $pay_type = 'weixin')
- {
- $param = [
- 'type' => $type,
- 'meal_id' => $meal_id,
- 'price' => $price,
- 'num' => $num,
- 'pay_type' => $pay_type
- ];
- return $this->accessToken->httpRequest(self::MEAL_CODE, $param);
- }
- }
|