JSON_SUCCESS_STATUS
JSON_SUCCESS_STATUS = 1
拼团拼单控制器 Class Active
$view : \think\View
$request : \think\Request
__construct(\think\Request $request = null)
构造方法
\think\Request | $request | Request 对象 |
getUser(boolean $is_force = true) : \app\api\model\User|boolean|null
获取当前用户信息
boolean | $is_force |
validate(array $data, string|array $validate, array $message = array(), boolean $batch = false, mixed $callback = null) : array|string|true
验证数据
array | $data | 数据 |
string|array | $validate | 验证器名或者验证规则数组 |
array | $message | 提示信息 |
boolean | $batch | 是否批量验证 |
mixed | $callback | 回调方法(闭包) |
<?php
namespace app\api\controller\sharing;
use app\api\controller\Controller;
use app\api\model\sharing\Active as ActiveModel;
use app\api\model\sharing\Goods as GoodsModel;
/**
* 拼团拼单控制器
* Class Active
* @package app\api\controller\sharing
*/
class Active extends Controller
{
/**
* 拼单详情
* @param $active_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function detail($active_id)
{
// 拼单详情
$detail = ActiveModel::detail($active_id);
if (!$detail) {
return $this->renderError('很抱歉,拼单不存在');
}
// 拼团商品详情
$model = new GoodsModel;
$goods = $model->getDetails($detail['goods_id'], $this->getUser(false));
// 更多拼团商品
$goodsList = $model->getList([], $this->getUser(false));
return $this->renderSuccess(compact('detail', 'goods', 'goodsList'));
}
}