|
@@ -464,42 +464,60 @@ class WeixinService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function getArticleList($data){
|
|
public function getArticleList($data){
|
|
- $model = WxArticleDetail::where('del_time',0)
|
|
|
|
- ->where('is_deleted', 'false')
|
|
|
|
- ->select('title','author','digest','thumb_url','content_name')
|
|
|
|
- ->orderBy('id','desc');
|
|
|
|
-
|
|
|
|
- if(! empty($data['depart'])) {
|
|
|
|
- $depart = Depart::where('del_time',0)
|
|
|
|
- ->select('id','parent_id')
|
|
|
|
- ->get()->toArray();
|
|
|
|
- $result = array_merge($this->getAllDescendants($depart,$data['depart']),[$data['depart']]);
|
|
|
|
- $employee_id = DB::table('employee_depart_permission')
|
|
|
|
- ->whereIn("depart_id", $result)
|
|
|
|
- ->select("employee_id")
|
|
|
|
- ->get()->toArray();
|
|
|
|
- $employee_id = array_column($employee_id,'employee_id');
|
|
|
|
- $model->whereIn("id", $employee_id);
|
|
|
|
|
|
+ list($status, $msg) = $this->rule($data);
|
|
|
|
+ if(! $status) {
|
|
|
|
+ file_put_contents('record_ip.txt',date("Y-m-d H:i:s",time()).json_encode($data) . PHP_EOL."来源IP".$msg.PHP_EOL,8);
|
|
|
|
+ return [false, 'IP未入白名单'];
|
|
}
|
|
}
|
|
|
|
|
|
- if(! empty($data['card_no'])) $model->where('card_no', 'LIKE', '%'.$data['card_no'].'%');
|
|
|
|
- if(! empty($data['number'])) $model->where('number', 'LIKE', '%'.$data['number'].'%');
|
|
|
|
- if(! empty($data['emp_name'])) $model->where('emp_name', 'LIKE', '%'.$data['emp_name'].'%');
|
|
|
|
- if(! empty($data['state'])) $model->where('state',$data['state']);
|
|
|
|
- if(! empty($data['mobile'])) $model->where('mobile', 'LIKE', '%'.$data['mobile'].'%');
|
|
|
|
- if(! isset($data['all_emp'])) $model->where('id','<>',Employee::SPECIAL_ADMIN);
|
|
|
|
- if(! empty($data['role'])) {
|
|
|
|
- $emp = EmployeeRole::where('role_id',$data['role'])
|
|
|
|
- ->where('del_time',0)
|
|
|
|
- ->select('employee_id')->get()->toArray();
|
|
|
|
- $model->whereIn('id',array_column($emp,'employee_id'));
|
|
|
|
- }
|
|
|
|
|
|
+ $model = WxArticleDetail::where('del_time',0)
|
|
|
|
+ ->where('is_deleted', 'false')
|
|
|
|
+ ->select('title','author','digest','thumb_url','id')
|
|
|
|
+ ->orderBy('crt_time','desc');
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
$list = $this->limit($model,'',$data);
|
|
|
|
|
|
//组织数据
|
|
//组织数据
|
|
- $list = $this->organizationEmployeeData($list);
|
|
|
|
|
|
+ $list = $this->organizationData($list);
|
|
|
|
|
|
return [true , $list];
|
|
return [true , $list];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function organizationData($data){
|
|
|
|
+ if(empty($data['data'])) return [true, $data];
|
|
|
|
+
|
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
|
+ $my_thumb_url = "";
|
|
|
|
+ if(! empty($value['thumb_url'])) $my_thumb_url = "getWxFileLocal/" . md5($value['thumb_url']) . '.jpg';
|
|
|
|
+ $data['data'][$key]['my_thumb_url'] = $my_thumb_url;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return [true, $data];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getArticleContent($data){
|
|
|
|
+ list($status, $msg) = $this->rule($data);
|
|
|
|
+ if(! $status) {
|
|
|
|
+ file_put_contents('record_ip.txt',date("Y-m-d H:i:s",time()).json_encode($data) . PHP_EOL."来源IP".$msg.PHP_EOL,8);
|
|
|
|
+ return [false, 'IP未入白名单'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
+
|
|
|
|
+ $detail = WxArticleDetail::where('id',$data['id'])->first();
|
|
|
|
+ if(empty($detail)) return [false, '文章不存在或已被删除'];
|
|
|
|
+ $detail = $detail->toArray();
|
|
|
|
+ if($detail['is_deleted']) return [false, '文章不存在或被删除'];
|
|
|
|
+
|
|
|
|
+ if(empty($detail['content_name'])) return [true, 'content' => ''];
|
|
|
|
+
|
|
|
|
+ // 定义本地文件路径
|
|
|
|
+ $name = $detail['content_name'] . '.txt';
|
|
|
|
+ $localFilePath = storage_path(self::wx_img . $name);
|
|
|
|
+
|
|
|
|
+ // 读取文件内容
|
|
|
|
+ $fileContent = file_get_contents($localFilePath);
|
|
|
|
+
|
|
|
|
+ return [true, 'content' => $fileContent];
|
|
|
|
+ }
|
|
}
|
|
}
|