Forráskód Böngészése

小程序配合修改

cqpCow 11 hónapja
szülő
commit
4927704609
3 módosított fájl, 58 hozzáadás és 0 törlés
  1. 53 0
      app/Service/OaService.php
  2. 3 0
      app/Service/ScheduleService.php
  3. 2 0
      config/morequery.php

+ 53 - 0
app/Service/OaService.php

@@ -959,4 +959,57 @@ class OaService extends Service
         list($status, $msg) = $service->wx_sendMsg($user_id,$type,$state,$menu_id,$order_data);
         file_put_contents('msg_result.txt',date('Y-m-d H:i:s') . "结果:" .  $msg . PHP_EOL,8);
     }
+
+    public function getConstructionOaOrderState($order_no, $user, $menu_id)
+    {
+        $user_id = $user['id'];
+        $return = [];
+        foreach ($order_no as $value){
+            $return[$value] = ['oa_state' => 0];
+        }
+        $detail = OaOrder::whereIn('order_no', $order_no)
+            ->where('channel',$user['depart_top'][0]['depart_id'])
+            ->where('menu_id', $menu_id)
+            ->where('del_time', 0)
+            ->orderBy('id', 'desc')
+            ->get()->toArray();
+        if (empty($detail)) $return;
+        $final_detail = $oa_order = $oa_order2 = $map = [];
+        foreach ($detail as $value){
+            if(! isset($final_detail[$value['order_no']])){
+                $map[$value['id']] = $value['order_no'];
+                if($value['state'] == 2) {
+                    $oa_order[] = $value['id'];
+                }else{
+                    $oa_order2[] = $value['id'];
+                }
+                $final_detail[$value['order_no']] = $value['id'];
+            }
+        }
+        if (count($oa_order) == count($final_detail)) return $return;
+
+        $oa_detail = OaOrderSubEmployee::where('employee_id', $user_id)
+            ->whereIn('oa_order_id', $oa_order2)
+            ->pluck('oa_order_sub_id','oa_order_id')
+            ->toArray();
+        if(empty($oa_detail)) return $return;
+
+        $oa_detail_map = array_flip($oa_detail);
+        $oa_detail_value = array_values($oa_detail);
+        $state = OaOrderSub::whereIn('id', $oa_detail_value)
+            ->where('state', '<>', 2)
+            ->orderBy('sort', 'desc')
+            ->get()->toArray();
+        foreach ($state as $value){
+            $oa_order_id_tmp = $oa_detail_map[$value['id']];
+            $order_no_tmp = $map[$oa_order_id_tmp];
+            if (in_array($value['state'], [0, 2])) {
+                $return[$order_no_tmp] = ['oa_state' => 1, 'oa_id' => $value['id']];
+            }else{
+                $return[$order_no_tmp] = ['oa_state' => 0];
+            }
+        }
+
+        return $return;
+    }
 }

+ 3 - 0
app/Service/ScheduleService.php

@@ -631,6 +631,8 @@ class ScheduleService extends Service
 
         $return = [];
 
+        $construction_oa = (new OaService())->getConstructionOaOrderState(array_column($construction,'order_number'),$user,$data['menu_id']);
+
         //可见范围
         $employee = (new RangeService())->RangeConstructionEmpDetail($order_id);
         foreach ($construction as $value){
@@ -646,6 +648,7 @@ class ScheduleService extends Service
                 'product' => $product_title[$value['id']],
                 'crt_time' => $str,
             ];
+            $tmp = $tmp + ($construction_oa[$value['order_number']] ?? []);
             $return[] = $tmp;
         }
 

+ 2 - 0
config/morequery.php

@@ -16,6 +16,7 @@ return [
         "api/invoiceOrderList" => 36,
         "api/ReturnExchangeOrderList" => 35,
         "api/constructionList" => 34,
+        "api/getSettingGetDetail2" => 34,
         "api/purchaseOrderList" => [
             'key' => 'order_type',
             'array' => [
@@ -38,6 +39,7 @@ return [
         "wx/invoiceOrderList" => 36,
         "wx/ReturnExchangeOrderList" => 35,
         "wx/constructionList" => 34,
+        "wx/getSettingGetDetail2" => 34,
         "wx/purchaseOrderList" => [
             'key' => 'order_type',
             'array' => [