12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace app\admin\controller\sms;
- use think\facade\Route;
- use app\admin\controller\AuthController;
- use crmeb\services\{
- sms\Sms, FormBuilder, JsonService, UtilService
- };
- class SmsPay extends AuthController
- {
-
- protected $smsHandle;
- protected function initialize()
- {
- parent::initialize();
- $this->smsHandle = new Sms('yunxin', [
- 'sms_account' => sys_config('sms_account'),
- 'sms_token' => sys_config('sms_token'),
- 'site_url' => sys_config('site_url')
- ]);
- }
-
- public function index()
- {
- if (!$this->smsHandle->isLogin()) return redirect(url('sms.smsConfig/index').'?type=4&tab_id=18');
- return $this->fetch();
- }
-
- public function number()
- {
- $countInfo = $this->smsHandle->count();
- if ($countInfo['status'] == 400) return JsonService::fail($countInfo['msg']);
- return JsonService::success($countInfo['data']);
- }
-
- public function price()
- {
- list($page, $limit) = UtilService::getMore([
- ['page', 1],
- ['limit', 20],
- ], null, true);
- $mealInfo = $this->smsHandle->meal($page, $limit);
- if ($mealInfo['status'] == 400) return JsonService::fail($mealInfo['msg']);
- return JsonService::success($mealInfo['data']['data']);
- }
-
- public function pay()
- {
- list($payType, $mealId, $price) = UtilService::postMore([
- ['payType', 'weixin'],
- ['mealId', 0],
- ['price', 0],
- ], null, true);
- $payInfo = $this->smsHandle->pay($payType, $mealId, $price, $this->adminId);
- if ($payInfo['status'] == 400) return JsonService::fail($payInfo['msg']);
- return JsonService::success($payInfo['data']);
- }
- }
|