| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace ghs\controllers;
- use bizGhs\item\classes\ItemClass;
- use bizGhs\item\classes\ItemMsClass;
- use common\components\imgUtil;
- use common\components\util;
- use Yii;
- class ItemMsController extends BaseController
- {
- //分配库存和改价 ssh 20230719
- public function actionSendStock()
- {
- util::complete();
- }
- //批量添加子花材 ssh 20230719
- public function actionBatchAddItem()
- {
- $post = Yii::$app->request->post();
- $idsList = $post['ids'] ?? '';
- $ids = json_decode($idsList, true);
- if (empty($ids)) {
- util::fail('请选择花材15');
- }
- $motherId = $post['motherId'] ?? 0;
- $mother = ItemClass::getById($motherId, true);
- if (empty($mother) || $mother->mainId != $this->mainId) {
- util::fail('没有权限');
- }
- $relate = ItemMsClass::getByCondition(['motherId' => $motherId], true);
- if (empty($relate)) {
- $relate = ItemMsClass::add(['motherId' => $motherId], true);
- }
- $hasIdString = $relate->idList ?? '';
- $hasIds = [];
- if (!empty($hasIdString)) {
- $hasIds = explode(',', $hasIdString);
- }
- foreach ($ids as $current) {
- if (in_array($current, $hasIds) == false && $current != $motherId) {
- $hasIds[] = $current;
- }
- }
- $newString = implode(',', $hasIds);
- $relate->idList = $newString;
- $relate->save();
- util::complete();
- }
- //删除花材 ssh 20230718
- public function actionDelItem()
- {
- $get = Yii::$app->request->get();
- $motherId = $get['motherId'] ?? 0;
- $delId = $get['id'] ?? 0;
- $mother = ItemClass::getById($motherId, true);
- if (empty($mother) || $mother->mainId != $this->mainId) {
- util::fail('没有权限');
- }
- $relate = ItemMsClass::getByCondition(['motherId' => $motherId], true);
- if (empty($relate)) {
- util::fail('没有找到花材');
- }
- $idList = $relate->idList ?? '';
- if (!empty($idList)) {
- $ids = explode(',', $idList);
- $new = [];
- foreach ($ids as $current) {
- if ($current != $delId) {
- $new[] = $current;
- }
- }
- $idString = implode(',', $new);
- $relate->idList = $idString;
- $relate->save();
- }
- util::complete();
- }
- //获取子花材 ssh 20230718
- public function actionGetSonList()
- {
- $get = Yii::$app->request->get();
- $motherId = $get['motherId'] ?? 0;
- $item = ItemClass::getById($motherId, true);
- if (empty($item) || $item->mainId != $this->mainId) {
- util::fail('没有找到花材');
- }
- $ms = ItemMsClass::getByCondition(['motherId' => $motherId], true);
- $list = [];
- $idList = $ms->idList ?? '';
- if (!empty($idList)) {
- $ids = explode(',', $idList);
- $list = ItemClass::getAllByCondition(['id' => ['in', $ids], 'delStatus' => 0,], null, '*');
- if (!empty($list)) {
- foreach ($list as $key => $val) {
- $shortCover = $val['cover'] ?? '';
- $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
- $smallCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
- $list[$key]['bigCover'] = $bigCover;
- $list[$key]['smallCover'] = $smallCover;
- $list[$key]['shortCover'] = $shortCover;
- $list[$key]['cover'] = $bigCover;
- $list[$key]['sendHyPrice'] = '';
- $list[$key]['sendSonStock'] = '';
- $list[$key]['sendLsPrice'] = '';
- $list[$key]['sendPfPrice'] = '';
- }
- }
- }
- util::success(['list' => $list]);
- }
- }
|