Пример #1
0
 public function actionIndex()
 {
     $model = new StatisticsSearchForm();
     $model->load(Yii::$app->request->post());
     $query = (new Query())->from(Statistics::tableName())->where('1=1');
     if (!empty($model->shop)) {
         $query->andWhere('shop=:shop', [':shop' => $model->shop]);
     }
     if (!empty($model->commodity)) {
         $query->andWhere('commodity like :commodity', [':commodity' => '%' . $model->commodity . '%']);
     }
     if (!empty($model->platform)) {
         $query->andWhere('platform=:platform', [':platform' => $model->platform]);
     }
     if (!empty($model->btime)) {
         $query->andWhere('handle_time >= :handle_time', [':handle_time' => $model->btime]);
     }
     if (!empty($model->etime)) {
         $query->andWhere('handle_time <= :handle_time', [':handle_time' => $model->etime]);
     }
     if ($this->user->rid == 3) {
         $query->andWhere('uid = :uid', [':uid' => $this->user->id]);
     }
     $query->orderBy('handle_time desc');
     $pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => '20']);
     $query->limit($pages->limit)->offset($pages->offset);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     $platforms = Platform::find()->all();
     $ops = array();
     $enarray = ['value' => '', 'text' => '全部'];
     array_push($ops, $enarray);
     foreach ($platforms as $platform) {
         $enarray = ['value' => $platform->name, 'text' => $platform->name];
         array_push($ops, $enarray);
     }
     $page = 'index';
     if ($this->user->rid == 4) {
         $page = 'index-4';
     }
     return $this->render($page, ['model' => $model, 'dataProvider' => $dataProvider, 'pages' => $pages, 'ops' => $ops]);
 }
 public function updatePlatform($parameters)
 {
     try {
         $userLogs = new UserLogsService();
         switch ($parameters['oper']) {
             case 'changePassword':
                 $id = $parameters['id'];
                 $platform = Platform::find(reset($id));
                 $platform->api_password = $this->hashPassword($parameters['password']);
                 $platform->save();
                 $parameters['oper'] = 'apiChangePassword';
                 $userLogs->createUserLog($parameters);
                 return true;
                 break;
             case 'del':
                 $parameters['oper'] = 'apiDel';
                 $userLogs->createUserLog($parameters);
                 return Platform::destroy($parameters['ids']);
                 break;
             case 'add':
                 $platform = $this->newPlatform($parameters);
                 $parameters['oper'] = 'apiAdd';
                 $userLogs->createUserLog($parameters);
                 break;
             case 'edit':
                 $id = $parameters['id'];
                 $platform = Platform::find($id);
                 $parameters['oper'] = 'apiEdit';
                 $userLogs->createUserLog($parameters);
                 break;
         }
         $columns = array_intersect_key($parameters, array_flip($platform->getFillableColumns()));
         if (!empty($columns)) {
             $platform->update($columns);
         }
         return $platform;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Пример #3
0
 public function actionSylist()
 {
     $model = new Buyer();
     $query = (new Query())->select('*')->from(Buyer::tableName())->where('platform=:platform', [':platform' => '淘宝'])->andWhere('isSync=:isSync', [':isSync' => 0]);
     $pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => '20']);
     $query->limit($pages->limit)->offset($pages->offset);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     $platforms = Platform::find()->all();
     return $this->render('sylist', ['model' => $model, 'dataProvider' => $dataProvider, 'platforms' => $platforms, 'pages' => $pages]);
 }
Пример #4
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Platform::find()]);
     return $this->render('index', array('dataProvider' => $dataProvider));
 }
Пример #5
0
 public function actionUpdate($id)
 {
     $model = Commodity::findOne($id);
     if (empty($model)) {
         throw new HttpException(404, '操作失败,商品不存在!');
     }
     if ($this->user->rid != 1 && $model->uid != $this->user->id) {
         throw new HttpException(404, 'error');
     }
     $oimg = $model->img;
     if ($model->load(Yii::$app->request->post())) {
         $img = UploadedFile::getInstance($model, 'img');
         if (!is_null($img)) {
             $model->img = $img;
             $name = time() . '.' . $model->img->extension;
             $model->img->saveAs('uploads/images/' . $name);
             $model->img = '/uploads/images/' . $name;
         } else {
             $model->img = $oimg;
         }
         $platform = Platform::findOne($model->platform_id);
         $model->platform = $platform->name;
         $shop = Shop::findOne($model->shop_id);
         if (!empty($shop)) {
             $model->shop = $shop->shop_name;
         }
         $model->statu = Commodity::$_AUDIT_PEND;
         if ($model->save()) {
             $this->redirect('/commodity/index');
         } else {
             var_dump($model->errors);
         }
     }
     $shops = array();
     if ($this->user->rid == 3) {
         $shops = Shop::find()->where('uid = :uid', [':uid' => $this->user->id])->all();
     } else {
         $shops = Shop::find()->all();
     }
     $platforms = Platform::find()->all();
     return $this->render('update', array('model' => $model, 'shops' => $shops, 'platforms' => $platforms));
 }