| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace ghs\controllers;
- use bizHd\ad\services\AdService;
- use Yii;
- use common\components\util;
- class AdController extends BaseController
- {
-
- //广告列表
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $type = isset($get['type']) ? $get['type'] : 0;
- $where = [];
- $where['sjId'] = $this->sjId;
- $where['type'] = $type;
- $where['delStatus'] = 0;
- $list = AdService::getAdList($where);
- util::success($list);
- }
-
- //添加广告
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $post['sjId'] = $this->sjId;
- $ad = AdService::addAd($post);
- $id = $ad['id'];
- $info = AdService::getDetail($id);
- util::success($info);
- }
-
- public function actionOrder()
- {
- $data = Yii::$app->request->post();
-
- $id = $data['firstAd'];
- $updateData = ['inTurn' => $data['secondOrder']];
- AdService::updateById($id, $updateData);
-
- $id = $data['secondAd'];
- $updateData = ['inTurn' => $data['firstOrder']];
- AdService::updateById($id, $updateData);
-
- $tempOrder = $data['firstOrder'];
- $data['firstOrder'] = $data['secondOrder'];
- $data['secondOrder'] = $tempOrder;
- util::success($data);
- }
-
- //广告点击
- public function actionClick()
- {
- $id = Yii::$app->request->get('id', 0);
- $info = AdService::getById($id);
- AdService::valid($info, $this->sjId);
- AdService::clickAd($id);
- util::complete();
- }
-
- //更新广告
- public function actionUpdate()
- {
- $post = Yii::$app->request->post();
- $id = isset($post['id']) ? $post['id'] : 0;
- $info = AdService::getById($id);
- AdService::valid($info, $this->sjId);
- AdService::updateAd($id, $post);
- util::complete('修改成功');
- }
-
- //删除广告
- public function actionDelete()
- {
- $id = Yii::$app->request->get('id', 0);
- $info = AdService::getById($id);
- AdService::valid($info, $this->sjId);
- AdService::deleteAd($id);
- util::complete('删除成功');
- }
-
- //上下架广告
- public function actionUpdateStatus()
- {
- $id = Yii::$app->request->get('id', 0);
- $status = Yii::$app->request->get('status', 1);
- $info = AdService::getById($id);
- AdService::valid($info, $this->sjId);
- AdService::updateById($id, ['status' => $status]);
- util::complete('操作成功');
- }
-
- //广告详情
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id', 0);
- $info = AdService::getDetail($id);
- util::success($info);
- }
-
- //广告排序
- public function actionSort()
- {
- $id = Yii::$app->request->get('id', 0);
- $inTurn = Yii::$app->request->get('inTurn', 0);
- $info = AdService::getById($id);
- AdService::valid($info, $this->sjId);
- AdService::updateById($id, ['inTurn' => $inTurn]);
- util::complete('操作成功');
- }
-
- }
|