/** * @param array $data * @throws \Exception */ protected function newPlatform(array $data) { try { $platform = new Platform(); $platform->platform_name = $data['platform_name']; $platform->api_url = $data['api_url']; $platform->api_username = $data['api_username']; if (!empty($data['api_password'])) { $platform->api_password = $this->hashPassword($data['api_password']); } $platform->save(); return $platform; } catch (\Exception $e) { throw $e; } }
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 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]); }
public function actionDelete($id) { Platform::findOne($id)->delete(); $this->redirect('/platform/index'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $platform = Platform::findOrFail($id); //Activity::log(Auth::user()->name.' deleted platform:'.$platform->name); try { Activity::log(Auth::user()->name . ' deleted platform:' . $platform->name); } catch (\Exception $e) { echo $e->getCode() . $e->getMessage(); } $platform->delete(); // redirect Session::flash('message', 'Successfully deleted the platform!'); return redirect('admin/platforms'); }
/** * 扩展查询,用于获取课程类型相应课程的课程列表 * @author FuRongxin * @date 2016-06-21 * @version 2.1 * @param \Illuminate\Database\Eloquent\Builder $query 查询对象 * @param string $type 课程类型 * @return \Illuminate\Database\Eloquent\Builder 查询对象 */ public function scopeOfType($query, $type) { switch ($type) { case 'public': // 2016-06-21:应教务处要求修改为只显示社科类课程(TB15开头) return $query->where('pk_kczy.pt', '=', 'T')->where('pk_kczy.xz', '=', 'B')->where('pk_kczy.nj', '=', session('grade'))->where('pk_kczy.zy', '=', session('major'))->where('pk_kczy.kcxh', 'like', 'TB15%'); case 'require': $platforms = array_pluck(Platform::all()->toArray(), 'dm'); unset($platforms[array_search('T', $platforms)]); return $query->whereIn('pk_kczy.pt', $platforms)->where('pk_kczy.xz', '=', 'B')->where('pk_kczy.nj', '=', session('grade'))->where('pk_kczy.zy', '=', session('major')); case 'elect': return $query->where('pk_kczy.xz', '=', 'X')->where('pk_kczy.nj', '=', session('grade'))->where('pk_kczy.zy', '=', session('major')); case 'human': return $query->where('pk_kczy.pt', '=', 'T')->where('pk_kczy.xz', '=', 'W'); case 'nature': return $query->where('pk_kczy.pt', '=', 'T')->where('pk_kczy.xz', '=', 'I'); case 'art': return $query->where('pk_kczy.pt', '=', 'T')->where('pk_kczy.xz', '=', 'Y'); case 'other': return $query->where('pk_kczy.pt', '=', 'T')->where('pk_kczy.xz', '=', 'Q'); case 'pubsport': return $query->where('pk_kczy.pt', '=', 'T')->where('pk_kczy.xz', '=', 'B')->where('pk_kczy.nj', '=', session('grade'))->where('pk_kczy.zy', '=', session('major'))->where('pk_kczy.kcxh', 'like', 'TB14%'); default: break; } }
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)); }
public function About() { $request = (object) $_POST; $about = new Platform(); $about->update($request->title, $request->contenido, $request->option); newFlashMessage('test', ucwords($request->option) . " actualizada."); return redirect('admin'); }
/** * 扩展查询:用于获取课程类型相应课程的课程列表 * @author FuRongxin * @date 2016-03-02 * @version 2.0 * @param \Illuminate\Database\Eloquent\Builder $query 查询对象 * @param string $type 课程类型 * @return \Illuminate\Database\Eloquent\Builder 查询对象 */ public function scopeOfType($query, $type) { switch ($type) { case 'public': return $query->where('xk_xkxx.pt', '=', 'T')->where('xk_xkxx.xz', '=', 'B'); case 'require': $platforms = array_pluck(Platform::all()->toArray(), 'dm'); unset($platforms[array_search('T', $platforms)]); return $query->whereIn('xk_xkxx.pt', $platforms)->where('xk_xkxx.xz', '=', 'B'); case 'elect': return $query->where('xk_xkxx.xz', '=', 'X'); case 'human': case 'nature': case 'art': case 'other': return $query->where('xk_xkxx.pt', '=', 'T')->whereIn('xk_xkxx.xz', ['W', 'I', 'Y', 'Q']); case 'pubsport': return $query->where('xk_xkxx.pt', '=', 'T')->where('xk_xkxx.xz', '=', 'B')->where('xk_xkxx.kcxh', 'like', 'TB14%'); default: break; } }