| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?php
- namespace ghs\controllers;
- use biz\product\classes\XjClass;
- use bizGhs\item\classes\ItemClass;
- use common\components\imgUtil;
- use common\components\util;
- use Yii;
- class XjController extends BaseController
- {
- //删除选项 ssh 20230728
- public function actionDelItem()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $xj = XjClass::getById($id, true);
- if (empty($xj) || $xj->mainId != $this->mainId) {
- util::fail('删除失败');
- }
- $xj->delStatus = 1;
- $xj->status = 2;
- $xj->save();
- util::complete();
- }
- //修改多颜色名称 ssh 20220107
- public function actionChangeXjName()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $name = $get['name'] ?? '';
- $xj = XjClass::getById($id, true);
- if (empty($xj) || $xj->mainId != $this->mainId) {
- util::fail('修改失败');
- }
- $xj->name = $name;
- $xj->save();
- util::complete('修改成功');
- }
- //取出所有小菊 ssh 20210904
- public function actionGetAllXj()
- {
- $where = [];
- $where['shopId'] = $this->shopId;
- $where['status'] = 1;
- $list = XjClass::getShopXj($this->shopId);
- util::success(['list' => $list]);
- }
- //取出商家上架的小菊 ssh 20210904
- public function actionGetSjXj()
- {
- $get = Yii::$app->request->get();
- $itemId = $get['itemId'] ?? 0;
- $product = ItemClass::getById($itemId, true);
- if (empty($product)) {
- util::fail('没有花材信息');
- }
- if ($product->mainId != $this->mainId) {
- util::fail('不是您的花材');
- }
- $list = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 0, 'status' => 1], null, '*');
- if (!empty($list)) {
- foreach ($list as $key => $val) {
- $shortCover = $val['cover'] ?? '';
- $cover = 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";
- $list[$key]['cover'] = $cover;
- $list[$key]['bigCover'] = $bigCover;
- $list[$key]['shortCover'] = $shortCover;
- }
- }
- util::success(['list' => $list]);
- }
- //取出商家所有小菊 ssh 20210904
- public function actionGetFilterXj()
- {
- $get = Yii::$app->request->get();
- $itemId = $get['itemId'] ?? 0;
- $product = ItemClass::getById($itemId, true);
- if ($product->mainId != $this->mainId) {
- util::fail('不是您的花材');
- }
- $list = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 0], null, '*');
- if (!empty($list)) {
- foreach ($list as $key => $val) {
- $shortCover = $val['cover'] ?? '';
- $cover = 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";
- $list[$key]['cover'] = $cover;
- $list[$key]['bigCover'] = $bigCover;
- $list[$key]['shortCover'] = $shortCover;
- }
- }
- util::success(['list' => $list]);
- }
- //保存所有数量 ssh 20221030
- public function actionSaveAllNum()
- {
- $post = Yii::$app->request->post();
- $itemId = $post['itemId'] ?? 0;
- $product = ItemClass::getById($itemId, true);
- if ($product->mainId != $this->mainId) {
- util::fail('不是您的花材');
- }
- $data = $post['data'] ?? '';
- $arr = json_decode($data, true);
- if (empty($arr)) {
- util::fail('没有找到花材列表');
- }
- foreach ($arr as $item) {
- $id = $item['id'] ?? 0;
- $stock = $item['stock'] ?? -1;
- $xj = XjClass::getById($id, true);
- if (empty($xj)) {
- continue;
- }
- if ($xj->itemId != $itemId) {
- continue;
- }
- $xj->stock = $stock;
- //有库存则上架,没库存则下架
- $status = $stock == 0 ? 2 : 1;
- $xj->status = $status;
- $xj->save();
- }
- util::complete('保存成功');
- }
- //清除全部小菊 lqh 2021.12.8
- public function actionClearAll()
- {
- $get = Yii::$app->request->get();
- $itemId = $get['itemId'] ?? 0;
- $product = ItemClass::getById($itemId, true);
- if ($product->mainId != $this->mainId) {
- util::fail('不是您的花材');
- }
- XjClass::clearAll($itemId);
- util::complete('已删除');
- }
- //新增小菊 lqh 2021.12.8
- public function actionBatchAdd()
- {
- $post = Yii::$app->request->post();
- $itemId = $post['itemId'] ?? 0;
- $product = ItemClass::getById($itemId, true);
- if ($product->mainId != $this->mainId) {
- util::fail('不是您的花材');
- }
- $xjData = $post['xjData'] ?? '';
- if (empty($xjData)) {
- util::fail('请上传图片');
- }
- $arr = json_decode($xjData, true);
- if (is_array($arr) == false) {
- util::fail('请上传图片...');
- }
- XjClass::batchAddXj($arr, $this->shop, $product);
- util::complete('添加成功');
- }
- }
|