zgg 3 miesięcy temu
rodzic
commit
bfc03131d5

+ 21 - 25
application/admin/controller/Orders.php

@@ -1348,58 +1348,54 @@ class Orders extends Auth {
 //
 //            }
             $userIds = array_column($newUser, 'id');
-            $todoCounts = Db::name('todo')
+            $taskCounts = Db::name('todo')
                 ->where('to_user_id', 'in', $userIds)
                 ->where('work_type_mode', 3)
                 ->where('create_yyyymmdd', date('Ymd'))
                 ->where('todo_mode', 'in', [1, 2, 3])
+                ->field([
+                    'to_user_id',
+                    'COUNT(*) as nums',
+                    'SUM(CASE WHEN todo_mode IN (1, 2) THEN 1 ELSE 0 END) as nums2' // 进行中任务数(todo_mode in [1,2])
+                ])
                 ->group('to_user_id')
-                ->column('to_user_id, COUNT(*) as nums');
-            $todoStatusCounts = Db::name('todo')
-                ->where('to_user_id', 'in', $userIds)
-                ->where('work_type_mode', 3)
-                ->where('todo_mode', 'in', [1, 2])
-                ->group('to_user_id')
-                ->column('to_user_id, COUNT(*) as nums2');
+                ->select();
+            $taskCountMap = array_column($taskCounts, null, 'to_user_id');
             $addrInfo = Db::name('order_convey')
                 ->alias('cpr')
                 ->join('todo os', 'cpr.order_id = os.order_id')
-                ->join('orders ods', 'cpr.order_id = ods.id')
-                ->join('address ca', 'ca.id = cpr.start')
-                ->join('address cad', 'cad.id = cpr.end')
-                ->field('os.to_user_id, os.todo_mode, ca.title as start_name, cad.title as end_name, os.create_time')
+                ->field('os.to_user_id, os.todo_mode, cpr.end,cpr.start,os.create_time')
                 ->where('os.to_user_id', 'in', $userIds)
                 ->where('os.del', 0)
-                ->where('ods.del', 0)
                 ->select();
             $addrMap = [];
             foreach ($addrInfo as $addr) {
                 $addrMap[$addr['to_user_id']] = $addr;
             }
-            $userSex = Db::name('user')
-                ->where('id', 'in', $userIds)
-                ->column('id, sex');
+            $start = array_column($addrInfo,'start');
+            $end = array_column($addrInfo,'end');
+            $addressIds = array_unique(array_merge($start,$end));
+            $address = Db::name('address')
+                ->where('id','in',$addressIds)
+                ->column('title','id');
             foreach ($newUser as $key => $value) {
                 $userId = $value['id'];
-                $newUser[$key]['nums'] = isset($todoCounts[$userId]) ? $todoCounts[$userId] : 0;
-                $newUser[$key]['cur_status'] = 0; // 默认空闲
-                if (isset($todoStatusCounts[$userId]) && $todoStatusCounts[$userId] > 0) {
-                    $newUser[$key]['cur_status'] = 1; // 任务中
-                }
+                $counts = $taskCountMap[$userId] ?? ['nums' => 0, 'nums2' => 0];
+
+                $newUser[$key]['nums'] = $counts['nums'];
+                $newUser[$key]['cur_status'] = $counts['nums2'] > 0 ? 1 : 0;
 
                 $newUser[$key]['title'] = '';
                 $newUser[$key]['addr_time'] = '';
                 if (isset($addrMap[$userId])) {
                     $addr = $addrMap[$userId];
                     if (in_array($addr['todo_mode'], [1, 2])) {
-                        $newUser[$key]['title'] = $addr['start_name'];
+                        $newUser[$key]['title'] = $address[$addr['start']];
                     } else {
-                        $newUser[$key]['title'] = $addr['end_name'];
+                        $newUser[$key]['title'] = $address[$addr['end']];
                     }
                     $newUser[$key]['addr_time'] = $addr['create_time'];
                 }
-
-                $newUser[$key]['sex_name'] = isset($mm->sex[$userSex[$userId]]) ? $mm->sex[$userSex[$userId]] : "";
             }
             $newUser = list_sort_by($newUser,"addr_time", 'asc');
             if($this->orgId==3){

+ 0 - 2
application/admin/view/orders/batchsend.html

@@ -28,7 +28,6 @@
                                 <tr>
                                     <th><input type="checkbox" class="check-all"></th>
                                     <th>运送员名称</th>
-                                    <th>性别</th>
                                     <th>今日送达次数</th>
                                     <th>上次位置</th>
                                     <th>上次修改时间</th>
@@ -40,7 +39,6 @@
                                 <tr>
                                     <td><input name="to_user_id[]" type="checkbox" class="ids" value="{$value['id']}"></td>
                                     <td style="cursor: pointer;color: #023894;text-decoration:underline" onclick="oneU('{$value.id}')">{$value['real_name']}</td>
-                                    <td>{$value['sex_name']}</td>
                                     <td>{$value['nums']}</td>
                                     <td>{$value['title']}</td>
                                     <td>{$value['addr_time']}</td>