Crmeb.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace ln\services\serve\storage;
  3. use ln\basic\BaseStorage;
  4. use ln\services\AccessTokenServeService;
  5. use think\exception\ValidateException;
  6. /**
  7. * Class Crmeb
  8. * @package ln\services\serve\storage
  9. */
  10. class Crmeb extends BaseStorage
  11. {
  12. protected $accessToken;
  13. /**
  14. * Crmeb constructor.
  15. * @param string $name
  16. * @param AccessTokenServeService $service
  17. * @param string|null $configFile
  18. */
  19. public function __construct(string $name, AccessTokenServeService $service, string $configFile = null)
  20. {
  21. $this->accessToken = $service;
  22. }
  23. protected function initialize(array $config)
  24. {
  25. // TODO: Implement initialize() method.
  26. }
  27. /**
  28. * 获取用户信息
  29. * @param string $account
  30. * @param string $secret
  31. * @return array|mixed
  32. */
  33. public function getUser()
  34. {
  35. return $this->accessToken->httpRequest('user/info');
  36. }
  37. /**
  38. * 用户登录
  39. * @param string $account
  40. * @param string $secret
  41. * @return array|mixed
  42. */
  43. public function login(string $account, string $secret)
  44. {
  45. return $this->accessToken->httpRequest('user/login', ['account' => $account, 'secret' => $secret], 'POST', false);
  46. }
  47. /**
  48. * 注册平台
  49. * @param array $data
  50. * @return array|mixed
  51. */
  52. public function register(array $data)
  53. {
  54. return $this->accessToken->httpRequest('user/register', $data, 'POST', false);
  55. }
  56. /**
  57. * 平台用户消息记录
  58. * @param int $page
  59. * @param int $limit
  60. * @return array|mixed
  61. */
  62. public function userBill(int $page, int $limit)
  63. {
  64. return $this->accessToken->httpRequest('user/bill', ['page' => $page, 'limit' => $limit]);
  65. }
  66. /**
  67. * 找回账号
  68. * @param array $data
  69. * @return array|mixed
  70. */
  71. public function forget(array $data)
  72. {
  73. return $this->accessToken->httpRequest('user/forget', $data, 'POST', false);
  74. }
  75. /**
  76. * 修改密码
  77. * @param array $data
  78. * @return array|mixed
  79. */
  80. public function modify(array $data)
  81. {
  82. return $this->accessToken->httpRequest('user/modify', $data, 'POST', false);
  83. }
  84. /**
  85. * 获取验证码
  86. * @param string $phone
  87. * @return array|mixed
  88. */
  89. public function code(string $phone, $type = 0)
  90. {
  91. return $this->accessToken->httpRequest('user/code', ['phone' => $phone, 'types' => $type], 'POST', false);
  92. }
  93. /**
  94. * 验证验证码
  95. * @param string $phone
  96. * @return array|mixed
  97. */
  98. public function checkCode(string $phone, string $verify_code)
  99. {
  100. return $this->accessToken->httpRequest('user/code/verify', ['phone' => $phone, 'verify_code' => $verify_code], 'POST', false);
  101. }
  102. /**
  103. * 套餐列表
  104. * @param string $type 套餐类型:sms,短信;query,物流查询;dump,电子面单;copy,产品复制
  105. * @return array|mixed
  106. */
  107. public function mealList(string $type)
  108. {
  109. return $this->accessToken->httpRequest('meal/list', ['type' => $type]);
  110. }
  111. /**
  112. * 套餐支付
  113. * @param array $data
  114. * @return array|mixed
  115. */
  116. public function payMeal(array $data)
  117. {
  118. return $this->accessToken->httpRequest('meal/code', $data);
  119. }
  120. /**
  121. * 用量记录
  122. * @param int $page
  123. * @param int $limit
  124. * @param int $type
  125. * @return array|mixed
  126. */
  127. public function record(int $page, int $limit, int $type, $status = '')
  128. {
  129. $typeContent = [1 => 'sms', 2 => 'expr_dump', 3 => 'expr_query', 4 => 'copy'];
  130. if (!isset($typeContent[$type])) {
  131. throw new ValidateException('参数类型不正确');
  132. }
  133. $data = ['page' => $page, 'limit' => $limit, 'type' => $typeContent[$type]];
  134. return $this->accessToken->httpRequest('user/record', $data);
  135. }
  136. /**
  137. * 修改手机号
  138. * @param array $data
  139. * @return array|mixed
  140. */
  141. public function modifyPhone(array $data)
  142. {
  143. return $this->accessToken->httpRequest('user/modify/phone', $data);
  144. }
  145. }