소스 검색

获取对象资源

shish 1 년 전
부모
커밋
ce1d76815a
1개의 변경된 파일34개의 추가작업 그리고 10개의 파일을 삭제
  1. 34 10
      app-ghs/controllers/BookItemCustomController.php

+ 34 - 10
app-ghs/controllers/BookItemCustomController.php

@@ -4,6 +4,7 @@ namespace ghs\controllers;
 
 use bizGhs\book\classes\BookItemClass;
 use bizGhs\book\classes\BookItemCustomClass;
+use bizGhs\order\classes\OrderClass;
 use bizGhs\product\classes\ProductClass;
 use common\components\util;
 use Yii;
@@ -11,18 +12,41 @@ use Yii;
 class BookItemCustomController extends BaseController
 {
 
+    //获取对象资源 ssh 20240829
+    public function actionGetInfo()
+    {
+        $get = Yii::$app->request->get();
+        $orderId = $get['orderId'] ?? 0;
+        $productId = $get['productId'] ?? 0;
+        $shop = $this->shop;
+        $order = OrderClass::getById($orderId, true);
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        $bookSn = $shop->bookSn ?? 0;
+        if (empty($bookSn)) {
+            util::fail('当前不是在预订活动中');
+        }
+        $customId = $order->customId ?? 0;
+        $res = BookItemCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId, 'itemId' => $productId], true);
+        if (empty($res)) {
+            util::fail('数据有问题');
+        }
+        util::success(['res' => $res]);
+    }
+
     //下架 ssh 20240721
     public function actionGoOff()
     {
         $staff = $this->shopAdmin;
-        if(isset($staff->identity) && $staff->identity == 2){
+        if (isset($staff->identity) && $staff->identity == 2) {
             util::fail('不能操作');
         }
 
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $num = $get['num'] ?? 0;
-        if(empty($num)){
+        if (empty($num)) {
             util::fail('请填写下架数量');
         }
         $shop = $this->shop;
@@ -82,7 +106,7 @@ class BookItemCustomController extends BaseController
     public function actionGoOn()
     {
         $staff = $this->shopAdmin;
-        if(isset($staff->identity) && $staff->identity == 2){
+        if (isset($staff->identity) && $staff->identity == 2) {
             util::fail('不能操作');
         }
 
@@ -110,10 +134,10 @@ class BookItemCustomController extends BaseController
     public function actionBatchGoOn()
     {
         $post = Yii::$app->request->post();
-        $ids = $post['ids']??'';
+        $ids = $post['ids'] ?? '';
 
         $staff = $this->shopAdmin;
-        if(isset($staff->identity) && $staff->identity == 2){
+        if (isset($staff->identity) && $staff->identity == 2) {
             util::fail('不能操作');
         }
 
@@ -123,11 +147,11 @@ class BookItemCustomController extends BaseController
             util::fail('预订没有开启');
         }
 
-        if(empty($ids)){
+        if (empty($ids)) {
             util::fail('请选择要上齐的项');
         }
-        $arr = json_decode($ids,true);
-        if(empty($arr)){
+        $arr = json_decode($ids, true);
+        if (empty($arr)) {
             util::fail('请选择项');
         }
 
@@ -139,13 +163,13 @@ class BookItemCustomController extends BaseController
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            foreach($arr as $id){
+            foreach ($arr as $id) {
                 $num = 0;
                 $book = BookItemCustomClass::getById($id, true);
                 if (empty($book)) {
                     util::fail('有选择项没有找到');
                 }
-                if($book->bookSn != $bookSn){
+                if ($book->bookSn != $bookSn) {
                     util::fail('有选择的项不是当前预订活动');
                 }
                 BookItemCustomClass::goOn($book, $shop, $params, $num);