new files
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\v1\notification\sms;
|
||||
|
||||
use crmeb\exceptions\AdminException;
|
||||
use app\controller\admin\AuthController;
|
||||
use crmeb\services\{sms\Sms, SystemConfigService};
|
||||
|
||||
/**
|
||||
* 短信购买
|
||||
* Class SmsPay
|
||||
* @package app\controller\admin\v1\notification\sms
|
||||
*/
|
||||
class SmsPay extends AuthController
|
||||
{
|
||||
/**
|
||||
* @var Sms
|
||||
*/
|
||||
protected $smsHandle;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$data = SystemConfigService::more(['sms_account', 'sms_token', 'site_url']);
|
||||
$this->smsHandle = new Sms('yunxin', $data);
|
||||
if (!$this->smsHandle->isLogin()) {
|
||||
return $this->fail('请先填写短息配置');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号信息
|
||||
*/
|
||||
public function number()
|
||||
{
|
||||
$countInfo = $this->smsHandle->count();
|
||||
if ($countInfo['status'] == 400) return $this->fail($countInfo['msg']);
|
||||
$info['account'] = sys_config('sms_account');
|
||||
$info['number'] = $countInfo['data']['number'];
|
||||
$info['send_total'] = $countInfo['data']['send_total'];
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付套餐
|
||||
*/
|
||||
public function price()
|
||||
{
|
||||
[$page, $limit] = $this->request->getMore([
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
], true);
|
||||
$mealInfo = $this->smsHandle->meal($page, $limit);
|
||||
if ($mealInfo['status'] == 400) return $this->fail($mealInfo['msg']);
|
||||
return $this->success($mealInfo['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付码
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
[$payType, $mealId, $price] = $this->request->postMore([
|
||||
['payType', 'weixin'],
|
||||
['mealId', 0],
|
||||
['price', 0],
|
||||
], true);
|
||||
$payInfo = $this->smsHandle->pay($payType, $mealId, $price, $this->adminId);
|
||||
if ($payInfo['status'] == 400) return $this->fail($payInfo['msg']);
|
||||
return $this->success($payInfo['data']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user