cqp 2 月之前
父節點
當前提交
f5e9fe7d42
共有 2 個文件被更改,包括 20 次插入1 次删除
  1. 16 1
      app/Service/CustomerSupplyService.php
  2. 4 0
      config/header/66.php

+ 16 - 1
app/Service/CustomerSupplyService.php

@@ -6,6 +6,7 @@ use App\Model\Employee;
 use App\Model\CustomerSupply;
 use App\Model\CustomerSupplyDetails;
 use App\Model\Organization;
+use App\Model\WxEmployeeOfficial;
 use App\Service\Weixin\WxEmployeeService;
 use Illuminate\Support\Facades\DB;
 
@@ -300,8 +301,10 @@ class CustomerSupplyService extends Service
     public function fillData($data, $user, $search){
         if(empty($data['data'])) return $data;
 
+        $id = array_column($data['data'],'id');
         $emp = (new EmployeeService())->getEmployeeMap(array_unique(array_column($data['data'],'crt_id')));
-        $emp_2 = $this->getEmployeeMap(array_column($data['data'],'id'),'detail');
+        $emp_2 = $this->getEmployeeMap($id,'detail');
+        $wx_map = $this->getWxBind($id);
         foreach ($data['data'] as $key => $value){
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
@@ -309,11 +312,23 @@ class CustomerSupplyService extends Service
             $data['data'][$key]['status_title'] = CustomerSupply::$status_name[$value['status']] ?? '';
             $e = $emp_2[$value['id']] ?? [];
             $data['data'][$key]['organization_title'] = $e['organization_title'] ?? "";
+            $tmp = $wx_map[$value['id']] ?? 0;
+            $data['data'][$key]['is_wx_title'] = $tmp ? '是' : '否';
         }
 
         return $data;
     }
 
+    private function getWxBind($employee_id = []){
+        $appid = config("wx_msg.f_appid");
+
+        return WxEmployeeOfficial::whereIn('employee_id', $employee_id)
+            ->where('type', WxEmployeeOfficial::login_type_one)
+            ->where('appid', $appid)
+            ->pluck('id', 'employee_id')
+            ->toArray();
+    }
+
     public function getEmployeeMap($employee_ids, $type = ""){
         if(empty($employee_ids)) return [];
         if(! is_array($employee_ids)) $employee_ids = [$employee_ids];

+ 4 - 0
config/header/66.php

@@ -22,6 +22,10 @@ return [
         'key' =>'password',
         'value' => '微信公众号分配密码',
     ],
+    [
+        'key' =>'is_wx_title',
+        'value' => '微信公众号是否绑定',
+    ],
     [
         'key' =>'type_title',
         'value' => '类型',