| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace addons\BlindBox\backend\controllers;
- use addons\BlindBox\common\models\BlindBoxGoods;
- use common\enums\AddonsEnum;
- use common\enums\StatusEnum;
- use common\models\common\AddonsMarketingSetting;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\BlindBox\backend\controllers
- */
- class DiyController extends BaseController
- {
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isPost) {
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params, [
- [['content'], 'required'],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['addons_name'] = AddonsEnum::ADDONS_NAME_BLIND_BOX;
- $res = AddonsMarketingSetting::setData($params);
- if ($res == false) return $this->error(AddonsMarketingSetting::getStaticError());
- return $this->success('操作成功', []);
- }
- if (\Yii::$app->request->isGet) {
- $params['mall_id'] = $this->mall_id;
- $params['addons_name'] = AddonsEnum::ADDONS_NAME_BLIND_BOX;
- $params['status'] = StatusEnum::ENABLED;
- $res = AddonsMarketingSetting::findOne($params);
- if ($res == false) return $this->success('操作成功', $data ?? []);
- $data = $res->toArray();
- $content = json_decode($data['content'], true);
- if (!empty($content)) {
- // $active_data = array_pop($content);
- // $active_ids = [];
- if (!empty($active_data['data']['goods'])) {
- // foreach ($active_data['data']['goods'] as $item) {
- // $active_ids[] = $item['params']['id'];
- // }
- // $list = BargainActive::lists(['where' => [
- // ['id' => $active_ids],
- // ['status' => StatusEnum::ENABLED],
- // ['active_status' => [BargainEnum::ACTIVE_HANDING]],
- // ['mall_id' => $this->mall_id]], 'select' => 'id']
- // );
- // $active_id_arr = array_column($list, 'id');//没有被删除的活动id
- // $goods_data = [];
- // foreach ($active_data['data']['goods'] as $item) {
- // if (in_array($item['params']['id'], $active_id_arr)) $goods_data[] = $item;
- // }
- // $active_data['data']['goods'] = $goods_data;
- // $content[] = $active_data;
- // $data['content'] = json_encode($content);
- }
- }
- return $this->success('操作成功', $data ?? []);
- }
- }
- return $this->render('index', [
- ]);
- }
- public function actionCheckGoodsList()
- {
- $params = \Yii::$app->request->get();
- $goods_id = json_decode($params['goods_id'], true);
- $list = BlindBoxGoods::getGoodsList($this->mall_id,$goods_id);
- return $this->success('操作成功', $list);
- }
- }
|