| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers;
- use app\models\Goods;
- use app\models\Option;
- use app\constants\OptionSetting;
- use app\modules\admin\models\ActivityNewUserForm;
- class ActivityNewUserController extends BaseController
- {
- /**
- * @return \yii\web\Response
- * 获取列表
- */
- public function actionList()
- {
- $form = new ActivityNewUserForm();
- $form->attributes = get_params();
- $res = $form->search();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 保存信息
- */
- public function actionSave()
- {
- $form = new ActivityNewUserForm();
- $form->attributes = post_params();
- $res = $form->save();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 获取信息
- */
- public function actionGetInfo()
- {
- $form = new ActivityNewUserForm();
- $form->attributes = get_params();
- $res = $form->getInfo();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 获取普通商品
- */
- public function actionGetGoods()
- {
- $form = new ActivityNewUserForm();
- $form->attributes = get_params();
- $res = $form->getGoods();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 获取优惠券
- */
- public function actionGetCoupons()
- {
- $form = new ActivityNewUserForm();
- $form->attributes = get_params();
- $res = $form->getCoupons();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 修改状态
- */
- public function actionSetStatus()
- {
- $form = new ActivityNewUserForm();
- $form->attributes = post_params();
- $res = $form->setStatus();
- return $this->asJson($res);
- }
-
- public function actionPushGoods(){
- //{'conf':[{'tab':'推荐',goods_ids:[1,2,3],cat_ids:[5,6,7]}]}
- $conf = Option::get(OptionSetting::ACTIVITY_NEW_USER_GOODS_CONF, get_store_id(), 'store')['value'];
- if($conf){
- $conf = json_decode($conf, true);
- }else{
- $conf = ['conf' => []];
- }
- foreach($conf['conf'] as &$item){
- $item['goods_list'] = [];
- if($item['goods_ids'] && is_array($item['goods_ids'])){
- $goods_list = Goods::find()->where(['in', 'id', $item['goods_ids']])->all();
- $item['goods_list'] = $goods_list;
- }
- }
- return $this->asJson([
- 'code'=>0,
- 'msg'=>'ok',
- 'data' => $conf,
- ]);
- }
- public function actionPushGoodsSave(){
- //{'conf':[{'tab':'推荐',goods_ids:[1,2,3],cat_ids:[5,6,7]}]}
- $conf = input_params('conf');
- if(!is_array($conf)){
- $conf = json_decode($conf, true);
- }
- $data = ['conf' => $conf];
- Option::set(OptionSetting::ACTIVITY_NEW_USER_GOODS_CONF, json_encode($data), get_store_id(), 'store');
- return $this->asJson([
- 'code'=>0,
- 'msg'=>'保存成功'
- ]);
- }
-
- public function actionConf(){
- $conf = Option::get(OptionSetting::ACTIVITY_NEW_USER_CONF, get_store_id(), 'store')['value'];
- if($conf){
- $conf = json_decode($conf, true);
- }else{
- $conf = ['conf' => [
- 'head' => ['bg_color' => '#f00', 'bg_img' => ''],
- 'body' => ['bg_color' => '#f00', 'bg_img' => ''],
- ]];
- }
- return $this->asJson([
- 'code'=>0,
- 'msg'=>'ok',
- 'data' => $conf,
- ]);
- }
- public function actionConfSave(){
- $conf = input_params('conf');
- if(!is_array($conf)){
- $conf = json_decode($conf, true);
- }
- $data = ['conf' => $conf];
- Option::set(OptionSetting::ACTIVITY_NEW_USER_CONF, json_encode($data), get_store_id(), 'store');
- return $this->asJson([
- 'code'=>0,
- 'msg'=>'保存成功'
- ]);
- }
- /**
- * 联盟审核列表
- */
- public function actionGetAuditList() {
- $form = new ActivityNewUserForm();
- $form->attributes = get_params();
- $res = $form->auditList();
- return $this->asJson($res);
- }
- /**
- * 活动审核状态修改
- */
- public function actionAuditHandle() {
- $form = new ActivityNewUserForm();
- $form->attributes = post_params();
- $res = $form->auditHandle();
- return $this->asJson($res);
- }
- }
|