初始化项目
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\Card as CardModel;
|
||||
use app\api\model\Setting as SettingModel;
|
||||
use app\api\service\User as UserService;
|
||||
use cores\exception\BaseException;
|
||||
use app\common\service\QueueService;
|
||||
|
||||
/**
|
||||
* 实体卡兑换管理
|
||||
* Class Card
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Card extends Controller
|
||||
{
|
||||
/**
|
||||
* 确认兑换
|
||||
* @param string|null $card_number 兑换卡号
|
||||
* @param string|null $secret_key 卡密
|
||||
* @return array|\think\response\Json
|
||||
* @throws BaseException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function submit($card_number = null, $secret_key = null)
|
||||
{
|
||||
/*if (!$card_number) {
|
||||
return $this->renderError('请输入兑换卡号');
|
||||
}*/
|
||||
if (!$secret_key) {
|
||||
return $this->renderError('请输入卡密');
|
||||
}
|
||||
// 充值设置
|
||||
$setting = SettingModel::getItem('exchange');
|
||||
// 验证最低充值金额
|
||||
if (!$setting['is_entrance']) {
|
||||
return $this->renderError("很抱歉,兑换功能已关闭");
|
||||
}
|
||||
|
||||
// 分销对象
|
||||
$obj = CardModel::detail([['secret_key','=',$secret_key], ['is_used','=',10]]);
|
||||
if(!$obj){
|
||||
return $this->renderError('无效卡密');
|
||||
}
|
||||
// 当前用户信息
|
||||
$userInfo = UserService::getCurrentLoginUser(true);
|
||||
|
||||
// 存入队列处理
|
||||
$queueService = new QueueService();
|
||||
$queueService->push('card_queue', json_encode(['card_id'=>$obj['card_id'],'user_id'=>$userInfo['user_id']],320));
|
||||
|
||||
return $this->renderSuccess('操作成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user