| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace ghs\controllers;
- use bizGhs\cp\classes\CpClass;
- use bizGhs\cp\classes\CpClassClass;
- use common\components\imgUtil;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- class CpController extends BaseController
- {
- //根据分类id取集合,带分页 ssh 20231228
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $classId = $get['classId'] ?? 0;
- $search = $get['search'] ?? '';
- $mainId = $this->mainId ?? 0;
- $where = [];
- $where['mainId'] = $mainId;
- $where['delStatus'] = 0;
- if (!empty($search)) {
- if (stringUtil::isLetter($search)) {
- $where['py'] = ['like', $search];
- } else {
- $where['name'] = ['like', $search];
- }
- } else {
- if (!empty($classId)) {
- $where['classId'] = $classId;
- }
- }
- $respond = CpClass::getCpList($where);
- util::success($respond);
- }
- //添加产品 ssh 20240106
- public function actionAddCp()
- {
- $post = Yii::$app->request->post();
- $post['mainId'] = $this->mainId;
- $post['adminId'] = $this->adminId;
- if (isset($post['name']) == false || empty($post['name'])) {
- util::fail('请填写名称');
- }
- $post['py'] = stringUtil::py($post['name']);
- $staff = $this->shopAdmin;
- $staffName = $staff->name ?? '';
- $post['staffName'] = $staffName;
- $shop = $this->shop;
- unset($post['id']);
- CpClass::addCp($post, $shop);
- util::complete('添加成功');
- }
- public function actionUpdateCp()
- {
- util::complete();
- }
- //查看详情 ssh 20240219
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $cp = CpClass::getById($id);
- if ($cp['mainId'] != $this->mainId) {
- util::fail('无法查看');
- }
- $classId = $cp['classId'] ?? 0;
- $class = CpClassClass::getById($classId, true);
- $className = $class->name ?? '';
- $shortCover = $class->cover ?? '';
- $smallCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
- $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
- $cp['shortCover'] = $shortCover;
- $cp['cover'] = $smallCover;
- $cp['smallCover'] = $smallCover;
- $cp['bigCover'] = $bigCover;
- $cp['className'] = $className;
- util::success($cp);
- }
- }
|