shish 2 жил өмнө
parent
commit
d16827423e

+ 6 - 1
app-ghs/controllers/BookController.php

@@ -76,10 +76,15 @@ class BookController extends BaseController
         $shop = $this->shop;
 
         $staff = $this->shopAdmin;
-        if($staff->founder!=2 && $staff->mobile!=15280215347){
+        if ($staff->founder != 2 && $staff->mobile != 15280215347) {
             util::fail('这个需要超管才能操作');
         }
 
+        $pfLevel = $shop->pfLevel ?? 0;
+        if ($pfLevel == 0) {
+            util::fail('昆明批发才能使用');
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {

+ 15 - 2
app-ghs/controllers/BookItemCustomController.php

@@ -2,7 +2,9 @@
 
 namespace ghs\controllers;
 
+use bizGhs\book\classes\BookItemClass;
 use bizGhs\book\classes\BookItemCustomClass;
+use bizGhs\product\classes\ProductClass;
 use common\components\util;
 use Yii;
 
@@ -29,11 +31,22 @@ class BookItemCustomController extends BaseController
             $where['customId'] = $customId;
         }
         $itemId = $get['itemId'] ?? 0;
+        $remainNum = 0;
+        $remainName = '';
         if (!empty($itemId)) {
             $where['itemId'] = $itemId;
+            //显示剩余数量
+            $product = ProductClass::getById($itemId, true);
+            $booItem = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true);
+            if (!empty($booItem)) {
+                $stock = $product->stock ?? 0;
+                $onNum = $booItem->onNum ?? 0;
+                $remainNum = bcsub($stock, $onNum);
+                $remainName = $product->name ?? '';
+            }
         }
-        $list = BookItemCustomClass::getAllByCondition($where, 'addTime DESC', '*');
-        util::success(['list' => $list]);
+        $list = BookItemCustomClass::getAllByCondition($where, '(bookNum-onNum) DESC', '*');
+        util::success(['list' => $list, 'remainNum' => $remainNum, 'remainName' => $remainName]);
     }
 
 }

+ 29 - 30
app-ghs/controllers/PurchaseOrderController.php

@@ -315,10 +315,10 @@ class PurchaseOrderController extends BaseController
         try {
             $shop = $this->shop;
             $staff = $this->shopAdmin;
-            $staffId = $staff->id??0;
-            $staffName = $staff->name??'';
-            $params = ['staffId'=>$staffId,'staffName'=>$staffName,'staff'=>$staff];
-            PurchaseOrderClass::cancel($cg,$shop,$params);
+            $staffId = $staff->id ?? 0;
+            $staffName = $staff->name ?? '';
+            $params = ['staffId' => $staffId, 'staffName' => $staffName, 'staff' => $staff];
+            PurchaseOrderClass::cancel($cg, $shop, $params);
             $transaction->commit();
             util::complete();
         } catch (\Exception $e) {
@@ -464,17 +464,17 @@ class PurchaseOrderController extends BaseController
             $bookSn = $shop->bookSn ?? 0;
 
             //只查我负责的花材
-            $globalCgMyCharge = $post['globalCgMyCharge']??0;
+            $globalCgMyCharge = $post['globalCgMyCharge'] ?? 0;
             $needCgList = [];
-            if($globalCgMyCharge == 1){
-                $staffId = $staff->id??0;
-                if(!empty($bookSn)){
-                    $bList = BookItemClass::getAllByCondition(['bookSn'=>$bookSn,'cgStaffId'=>$staffId],null,'*',null,true);
-                    if(!empty($bList)){
+            if ($globalCgMyCharge == 1) {
+                $staffId = $staff->id ?? 0;
+                if (!empty($bookSn)) {
+                    $bList = BookItemClass::getAllByCondition(['bookSn' => $bookSn, 'cgStaffId' => $staffId], null, '*', null, true);
+                    if (!empty($bList)) {
                         $myIds = [];
-                        foreach($bList as $bInfo){
-                            $biProductId = $bInfo->itemId??0;
-                            if($bInfo->needCgNum > 0){
+                        foreach ($bList as $bInfo) {
+                            $biProductId = $bInfo->itemId ?? 0;
+                            if ($bInfo->needCgNum > 0) {
                                 $myIds[] = $biProductId;
                                 $needCgList[$biProductId] = $bInfo->needCgNum;
                             }
@@ -488,7 +488,7 @@ class PurchaseOrderController extends BaseController
                 $bigNum = $v['bigNum'] ?? 0;
                 $productId = $v['productId'] ?? 0;
                 $smallNum = $v['smallNum'] ?? 0;
-                $name = $v['name']??'';
+                $name = $v['name'] ?? '';
                 if (!isset($v['itemPrice'])) {
                     util::fail('采购价格不能为空');
                 }
@@ -499,13 +499,13 @@ class PurchaseOrderController extends BaseController
                     util::fail('花材数量不能为0');
                 }
 
-                if($globalCgMyCharge == 1){
-                    if(isset($needCgList[$productId]) == false){
-                        util::fail($name.' 不需要采购');
+                if ($globalCgMyCharge == 1) {
+                    if (isset($needCgList[$productId]) == false) {
+                        util::fail($name . ' 不需要采购');
                     }
                     $needNum = $needCgList[$productId];
-                    if($bigNum>$needNum){
-                        util::fail($name.' 只要采'.$needNum.'份');
+                    if ($bigNum > $needNum) {
+                        util::fail($name . ' 只要采' . $needNum . '份');
                     }
                 }
 
@@ -533,15 +533,14 @@ class PurchaseOrderController extends BaseController
             if (isset($order->needPrint) && $order->needPrint == 1) {
                 PurchaseOrderClass::printTicket($order);
             }
-            $pfLevel = $shop->pfLevel ?? 0;
-            if ($pfLevel == 1 && !empty($bookSn) && $inType == 0) {
+            if (!empty($bookSn) && $inType == 0) {
                 //如果是昆明批发,有开启预订则直接分配货位
                 $key = 'ghs_cg_order_scan_seat_' . $order->id;
                 $noLock = util::lock($key);
                 if ($noLock) {
                     //没有锁定,即没有在分配货位,可以进行货位分配
-                    $params = ['staffId'=>$shopAdmin->id,'staffName'=>$shopAdmin->name];
-                    PurchaseOrderClass::assign($order,$shop,$params);
+                    $params = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name];
+                    PurchaseOrderClass::assign($order, $shop, $params);
                     util::unlock($key);
                 }
             }
@@ -583,9 +582,9 @@ class PurchaseOrderController extends BaseController
                 util::success(['assign' => 0, 'hint' => 'shop bookSn != cg bookSn']);
             }
             $staff = $this->shopAdmin;
-            $staffId = $staff->id??0;
-            $staffName = $staff->name??'';
-            $params = ['staffId'=>$staffId,'staffName'=>$staffName];
+            $staffId = $staff->id ?? 0;
+            $staffName = $staff->name ?? '';
+            $params = ['staffId' => $staffId, 'staffName' => $staffName];
         } else {
             if ($cg->salt != $salt) {
                 util::success(['assign' => 0, 'hint' => 'cg salt != post salt']);
@@ -598,14 +597,14 @@ class PurchaseOrderController extends BaseController
             if ($shop->bookSn != $cgBookSn) {
                 util::success(['assign' => 0, 'hint' => 'shop bookSn != cg bookSn o']);
             }
-            $staffId = $cg->shopAdminId??0;
-            $staffName = $cg->shopAdminName??'';
-            $params = ['staffId'=>$staffId,'staffName'=>$staffName];
+            $staffId = $cg->shopAdminId ?? 0;
+            $staffName = $cg->shopAdminName ?? '';
+            $params = ['staffId' => $staffId, 'staffName' => $staffName];
         }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            PurchaseOrderClass::assign($cg,$shop,$params);
+            PurchaseOrderClass::assign($cg, $shop, $params);
             $transaction->commit();
             util::success(['assign' => 1]);
         } catch (\Exception $e) {

+ 1 - 1
app-ghs/controllers/StatBookController.php

@@ -85,7 +85,7 @@ class StatBookController extends BaseController
             $where['cgStaffId'] = $staffId;
         }
 
-        $list = BookItemClass::getAllByCondition($where, 'addTime DESC', '*');
+        $list = BookItemClass::getAllByCondition($where, '(bookNum-onNum) DESC', '*');
         if (!empty($list)) {
             $ids = array_column($list, 'itemId');
             $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);

+ 0 - 1
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -273,7 +273,6 @@ class PurchaseOrderClass extends BaseClass
             }
         }
         $bookSn = $cg->bookSn ?? 0;
-        $shop = ShopClass::getById($shopId, true);
         if ($shop->pfLevel == 1 && !empty($shop->bookSn)) {
             if ($shop->bookSn == $bookSn) {
                 //取消分配的货位