You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
66 lines
1.8 KiB
9 months ago
|
<?php
|
||
|
|
||
|
namespace app\api\controller;
|
||
|
|
||
|
use app\api\model\Goods as GoodsModel;
|
||
|
use app\common\model\ActiveMain;
|
||
|
use app\common\model\Goods;
|
||
|
use think\response\Json;
|
||
|
|
||
|
/**
|
||
|
* 活动相关接口
|
||
|
*/
|
||
|
class Active extends Controller
|
||
|
{
|
||
|
/**
|
||
|
* 新年换新机活动详情
|
||
|
* @return void
|
||
|
*/
|
||
|
public function detail(): Json {
|
||
|
$param = $this->request->param();
|
||
|
if (empty($param['active_id'])) {
|
||
|
return $this->renderSuccess('活动ID必填');
|
||
|
}
|
||
|
$model = new ActiveMain();
|
||
|
$list = $model->with('col')
|
||
|
->where('status', '=', 1)
|
||
|
->where('id', $param['active_id'])->find();
|
||
|
if ($list) {
|
||
|
foreach ($list['col'] as $k => $row) {
|
||
|
$goodsModel = new GoodsModel();
|
||
|
$goods_list = $goodsModel->getListByIdsFromApi(explode(',', $row['col_goods_ids']));
|
||
|
$list['col'][$k]['goods_list'] = $goods_list;
|
||
|
}
|
||
|
return $this->renderSuccess($list->toArray());
|
||
|
}
|
||
|
return $this->renderSuccess('暂无数据');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 新年换新机活动
|
||
|
* @return Json
|
||
|
*/
|
||
|
public function info(): Json{
|
||
|
$model = new ActiveMain();
|
||
|
$data = $model->where('id',1)
|
||
|
->where('')
|
||
|
->field('id,name,title,index_icon')->find();
|
||
|
if (!$data) {
|
||
|
return $this->renderSuccess('暂无数据');
|
||
|
}
|
||
|
return $this->renderSuccess($data->toArray());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 活动商品分页加载
|
||
|
* @return Json
|
||
|
* @throws ]
|
||
|
*/
|
||
|
public function getGoodsByPage(): Json {
|
||
|
$page = $this->request->get('page');
|
||
|
$limit = $this->request->get('limit');
|
||
|
$goodsModel = new GoodsModel();
|
||
|
$goods_list = $goodsModel->getList([], $limit);
|
||
|
return $this->renderSuccess($goods_list->toArray());
|
||
|
}
|
||
|
}
|