Bläddra i källkod

借用库存 部分开发

shish 2 år sedan
förälder
incheckning
85e24320ee
2 ändrade filer med 61 tillägg och 19 borttagningar
  1. 37 19
      app-ghs/controllers/ItemController.php
  2. 24 0
      biz-ghs/item/classes/ItemClass.php

+ 37 - 19
app-ghs/controllers/ItemController.php

@@ -44,9 +44,9 @@ class ItemController extends BaseController
         $item->save();
 
         $shop = $this->shop;
-        $bookSn = $shop->bookSn??0;
-        if(!empty($bookSn)){
-            BookItemClass::updateByCondition(['bookSn'=>$bookSn,'itemId'=>$id],['cgStaffId'=>$staffId,'cgStaffName'=>$staffName]);
+        $bookSn = $shop->bookSn ?? 0;
+        if (!empty($bookSn)) {
+            BookItemClass::updateByCondition(['bookSn' => $bookSn, 'itemId' => $id], ['cgStaffId' => $staffId, 'cgStaffName' => $staffName]);
         }
 
         util::complete('修改成功');
@@ -161,25 +161,25 @@ class ItemController extends BaseController
         $field = '*';
 
         //只查我负责的花材
-        $globalCgMyCharge = $get['globalCgMyCharge']??0;
+        $globalCgMyCharge = $get['globalCgMyCharge'] ?? 0;
         $needCgList = [];
         $shop = $this->shop;
-        $bookSn = $shop->bookSn??0;
+        $bookSn = $shop->bookSn ?? 0;
         $staff = $this->shopAdmin;
-        $staffId = $staff->id??0;
-        if(!empty($bookSn)){
-            $biList = BookItemClass::getAllByCondition(['bookSn'=>$bookSn,'cgStaffId'=>$staffId],null,'*',null,true);
-            if(!empty($biList)){
+        $staffId = $staff->id ?? 0;
+        if (!empty($bookSn)) {
+            $biList = BookItemClass::getAllByCondition(['bookSn' => $bookSn, 'cgStaffId' => $staffId], null, '*', null, true);
+            if (!empty($biList)) {
                 $myIds = [];
-                foreach($biList as $biInfo){
-                    $biProductId = $biInfo->itemId??0;
-                    if($biInfo->needCgNum > 0){
+                foreach ($biList as $biInfo) {
+                    $biProductId = $biInfo->itemId ?? 0;
+                    if ($biInfo->needCgNum > 0) {
                         $myIds[] = $biProductId;
                         $needCgList[$biProductId] = $biInfo->needCgNum;
                     }
                 }
-                if(!empty($myIds)){
-                    $where['id']=['in',$myIds];
+                if (!empty($myIds)) {
+                    $where['id'] = ['in', $myIds];
                 }
             }
         }
@@ -226,12 +226,12 @@ class ItemController extends BaseController
             util::fail('没有数据');
         }
 
-        if(!empty($needCgList)) {
+        if (!empty($needCgList)) {
             //采购人采自己花材需要知道要采多少
-            if(!empty($list)){
-                foreach($list as $key => $val){
-                    $productId = $val['id']??0;
-                    if(isset($needCgList[$productId])){
+            if (!empty($list)) {
+                foreach ($list as $key => $val) {
+                    $productId = $val['id'] ?? 0;
+                    if (isset($needCgList[$productId])) {
                         $needCgNum = $needCgList[$productId];
                         $list[$key]['needCgNum'] = $needCgNum;
                     }
@@ -287,6 +287,24 @@ class ItemController extends BaseController
         util::success($respond);
     }
 
+    //借库存的花材列表 ssh 20240720
+    public function actionGetLoanList()
+    {
+        $get = Yii::$app->request->get();
+        $name = $get['name'] ?? '';
+        $num = $get['num'] ?? 0;
+        $where = ['mainId' => $this->mainId, 'delStatus' => 0];
+        if (!empty($name)) {
+            if (stringUtil::isLetter($name)) {
+                $where['py'] = ['like', $name];
+            } else {
+                $where['name'] = ['like', $name];
+            }
+        }
+        $respond = ItemClass::getLoanList($where, $num);
+        util::success($respond);
+    }
+
     public function actionChangeFrontHide()
     {
         $get = Yii::$app->request->get();

+ 24 - 0
biz-ghs/item/classes/ItemClass.php

@@ -15,6 +15,30 @@ class ItemClass extends BaseClass
 
     public static $baseFile = '\bizGhs\item\models\Item';
 
+    public static function getLoanList($where, $num)
+    {
+        $data = self::getList('id,name,price,stock,frontHide,cover', $where);
+        if (isset($data['list']) && !empty($data['list'])) {
+            foreach ($data['list'] as $key => $val) {
+                $data['list'][$key]['bigCount'] = '';
+                if ($num > 0) {
+                    $data['list'][$key]['bigCount'] = $num;
+                }
+                $data['list'][$key]['smallCount'] = '';
+                $shortCover = $val['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";
+                $data['list'][$key]['shortCover'] = $shortCover;
+                $data['list'][$key]['cover'] = $smallCover;
+                $data['list'][$key]['smallCover'] = $smallCover;
+                $data['list'][$key]['bigCover'] = $bigCover;
+                //前端使用字段
+                $data['list'][$key]['showUsePrice'] = '';
+            }
+        }
+        return $data;
+    }
+
     public static function getSimpleList($where, $num)
     {
         $data = self::getList('id,name,price,stock,frontHide,cover', $where);