Browse Source

fix:订单状态

super-yimizi 1 month ago
parent
commit
c0cfa2dc51

+ 2 - 2
application/api/controller/Order.php

@@ -156,7 +156,7 @@ class Order extends Base
         // $order->append(['status_text']);
         // $order->hidden(explode(',', 'method,transactionid,updatetime,deletetime'));
         // $order->expiretime = $order->expiretime - time();
-        $order->order_status_text = OrderEnum::SHOW_TYPE_STATUS_MAP[$order->order_status];
+        $order->order_status_text = OrderEnum::STATUS_TEXT_MAP[$order->order_status];
         $this->success('', $order);
     }
 
@@ -183,7 +183,7 @@ class Order extends Base
            // $item->append(['order_status_text']);
             $field = 'id,order_sn,amount,goods_price,order_amount,express_name,express_no,order_goods,order_status_text,order_status';
             $item->visible(explode(',', $field));
-            $item->order_status_text = OrderEnum::SHOW_TYPE_STATUS_MAP[$item->order_status];
+            $item->order_status_text = OrderEnum::STATUS_TEXT_MAP[$item->order_status];
         }
         $this->success('获取成功', $list);
     }

+ 26 - 26
application/common/Enum/OrderEnum.php

@@ -100,26 +100,6 @@ class OrderEnum
     {
         return self::getInvoiceStatusList()[$invoiceStatus] ?? '未知';
     }
-
-    public static function getActivityTypeList()
-    {
-        return [
-            self::ACTIVITY_TYPE_NORMAL => '普通活动',
-            self::ACTIVITY_TYPE_SECKILL => '秒杀活动',
-            self::ACTIVITY_TYPE_GROUP => '拼团活动',
-            self::ACTIVITY_TYPE_PRESALE => '预售活动',
-            self::ACTIVITY_TYPE_DISCOUNT => '折扣活动',
-        ];
-    }
-
-    public static function getActivityTypeText($activityType)
-    {
-        return self::getActivityTypeList()[$activityType] ?? $activityType;
-    }
-
-
-
-
     const STATUS_TEXT_MAP = [
         self::STATUS_CREATE => '未付款',
         self::STATUS_CANCEL => "已取消",
@@ -149,6 +129,9 @@ class OrderEnum
         self::STATUS_REFUND_CONFIRM => 'refund_time',
         self::STATUS_AUTO_CANCEL => 'expire_time',
         self::STATUS_CANCEL => 'cancel_time',
+        self::STATUS_INSPECTION => 'inspection_time',
+        self::STATUS_INSPECTION_PASS => 'inspection_time',
+        self::STATUS_INSPECTION_FAIL => 'inspection_time',
     ];
 
     public static function isValidOrderStatus($status)
@@ -167,7 +150,7 @@ class OrderEnum
     }
 
 
-
+    #######  用户前端传的参数
     const SHOW_TYPE_ALL = 0;//全部订单
     const SHOW_TYPE_WAIT_PAY = 1;//待付款订单
     const SHOW_TYPE_WAIT_DELIVERY = 2;//待发货订单
@@ -176,11 +159,28 @@ class OrderEnum
 
 
     const SHOW_TYPE_STATUS_MAP = [
-        self::SHOW_TYPE_ALL => [],
-        self::SHOW_TYPE_WAIT_PAY => [self::STATUS_CREATE],
-        self::SHOW_TYPE_WAIT_DELIVERY => [self::STATUS_PAY],
-        self::SHOW_TYPE_WAIT_RECEIPT => [self::STATUS_SHIP],
-        self::SHOW_TYPE_WAIT_COMMENT => [self::STATUS_CONFIRM],
+        self::SHOW_TYPE_ALL => [
+            self::STATUS_CANCEL,
+            self::STATUS_AUTO_CANCEL,
+            self::STATUS_ADMIN_CANCEL,
+            self::STATUS_CREATE,
+            self::STATUS_PAY,
+            self::STATUS_SHIP,
+            self::STATUS_CONFIRM,
+            self::STATUS_COMMENT,
+        ],
+        self::SHOW_TYPE_WAIT_PAY => [
+            self::STATUS_CREATE
+        ],
+        self::SHOW_TYPE_WAIT_DELIVERY => [
+            self::STATUS_PAY
+        ],
+        self::SHOW_TYPE_WAIT_RECEIPT => [
+            self::STATUS_SHIP
+        ],
+        self::SHOW_TYPE_WAIT_COMMENT => [
+            self::STATUS_CONFIRM
+        ],
     ];
 
     const SHOW_INSPECTION_TYPE_STATUS_MAP = [

+ 23 - 11
application/common/Service/InspectService.php

@@ -4,6 +4,7 @@ namespace app\common\Service;
 
 
 use think\Db;
+use app\common\enum\OrderEnum;
 
 class InspectService
 {
@@ -155,11 +156,8 @@ class InspectService
         return $this->getInspectionItems($params);
     }
 
-
-    //  提交验货 记录
-    
     /**
-     * 提交验货任务
+     * 提交验货任务  接口总方法
      * @param array $taskData 任务数据
      * @param array $resultData 验货结果数据
      * @return array
@@ -188,12 +186,24 @@ class InspectService
                     }
                 }
             }
-            
+            //  验货结果 是 通过 还是 不通过
+            $isPass = 1;
+            foreach ($resultData as $result) {
+                if ($result['is_qualified'] == 0) {
+                    $isPass = 0;
+                }
+            }            
             // 4. 更新任务状态为已完成
-            self::updateTaskStatus($taskId, 2); // 2:已完成
-            
-            Db::commit();
-            
+            self::updateTaskStatus($taskId, 2, $isPass); // 2:已完成
+
+            if ($isPass) {
+               $orderStatus = OrderEnum::STATUS_INSPECTION_PASS;
+            } else {
+               $orderStatus = OrderEnum::STATUS_INSPECTION_FAIL;
+            }
+            // 5. 更新订单状态
+            OrderService::updateOrderStatus($taskData['order_id'], $taskData['inspector_id'], $orderStatus); //修改订单状态            
+            Db::commit();            
             return [
                 'code' => 1,
                 'msg' => '验货任务提交成功',
@@ -293,16 +303,18 @@ class InspectService
      * 更新任务状态
      * @param int $taskId 任务ID
      * @param int $status 状态 1:进行中 2:已完成
+     * @param int $isPass 是否通过
      * @return bool
      */
-    private static function updateTaskStatus($taskId, $status)
+    private static function updateTaskStatus($taskId, $status,$isPass)
     {
         return Db::table('inspection_task')
             ->where('id', $taskId)
             ->update([
                 'task_status' => $status,
                 'end_time' => time(),
-                'updatetime' => time()
+                'updatetime' => time(),
+                'is_qualified' => $isPass
             ]);
     }
     

+ 2 - 0
application/common/Service/OrderService.php

@@ -637,6 +637,8 @@ class OrderService
         return $order;
     }
 
+    
+
 
 
 } 

+ 2 - 0
application/common/service/OrderService.php

@@ -637,6 +637,8 @@ class OrderService
         return $order;
     }
 
+    
+
 
 
 }