| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\Http\Validator\AdvertValidator;
- use App\Services\Common\AdvertOrderService;
- use App\Services\Common\AdvertService;
- use App\Services\Common\CoinLogService;
- /**
- * 挂单广告
- * Class AdvertController
- * @package App\Http\Controllers\Admin
- */
- class AdvertController extends Backend
- {
- public function __construct()
- {
- parent::__construct();
- $this->service = new AdvertService();
- }
- /**
- * 获取挂单广告列表
- * @return array|mixed
- */
- public function index()
- {
- $pageSize = request()->post('limit', 15);
- $params = request()->all();
- if($this->userInfo['user_type'] == 2){
- $params['business_id'] = $this->userInfo['user_id'];
- }
- $list = AdvertService::make()->getDataList($params, $pageSize);
- $message = array(
- "msg" => '操作成功',
- "code" => 0,
- "data" => isset($list['list'])? $list['list']:[],
- "count" => isset($list['total'])? $list['total']:0,
- );
- return $message;
- }
- /**
- * 获取挂单广告列表
- * @return array|mixed
- */
- public function hall()
- {
- $pageSize = request()->post('limit', 15);
- $params = request()->all();
- $list = AdvertService::make()->getDataList($params, $pageSize);
- $message = array(
- "msg" => '操作成功',
- "code" => 0,
- "data" => isset($list['list'])? $list['list']:[],
- "count" => isset($list['total'])? $list['total']:0,
- );
- return $message;
- }
- /**
- * 发布广告
- * @return array|mixed
- */
- public function edit()
- {
- return AdvertService::make()->saveData($this->userInfo['user_id'], request()->all());
- }
- /**
- * 购买广告
- * @param AdvertValidator $validate
- * @return array
- */
- public function buy(AdvertValidator $validate)
- {
- $params = request()->post();
- $params = $validate->check($params,'buy');
- if(!is_array($params)){
- return returnJson($params, false,[]);
- }
- if(!AdvertOrderService::make()->buy($this->userInfo['user_id'], $params)){
- return returnJson(AdvertOrderService::make()->getError(), false);
- }else{
- return returnJson(AdvertOrderService::make()->getError(), true);
- }
- }
- }
|