wupengfei 1 рік тому
батько
коміт
76877ee1ff

+ 2 - 1
.idea/workspace.xml

@@ -3,6 +3,7 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/common.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/common.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/api/controller/Recruit.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Recruit.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -387,7 +388,7 @@
       <workItem from="1690764472148" duration="16055000" />
       <workItem from="1690851419503" duration="20529000" />
       <workItem from="1690938001930" duration="13294000" />
-      <workItem from="1691040879419" duration="6022000" />
+      <workItem from="1691040879419" duration="6613000" />
     </task>
     <servers />
   </component>

+ 11 - 0
application/api/common.php

@@ -125,3 +125,14 @@ function numTransform($num)
     return $cal_num.'w+';
 }
 
+
+function timeTransform($time)
+{
+    $time_tmp = strtotime($time);
+    $cal = time() - $time_tmp;
+    $hour_second = 3600;
+    if($cal < $hour_second) return bcdiv($cal,60).'分钟前';
+    return date('m-d',$time_tmp);
+}
+
+

+ 13 - 5
application/api/controller/Recruit.php

@@ -507,13 +507,21 @@ class Recruit extends Base
         $recruits = \app\common\model\Recruit::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
         $recruit_ids  = RecruitResume::where('recruit_id','in',$recruits)->where('is_deleted',0)->where('to_deleted',0)->group('recruit_id')->column('recruit_id');
         $ids_str = implode(',',$recruit_ids);
-        $list =   \app\common\model\Recruit::where(['r.user_id'=>$this->user_id,'r.is_deleted'=>0,])
+        $list =   \app\common\model\Recruit::where(['r.user_id'=>$this->user_id,'r.is_deleted'=>0,]) ->alias('r')
             //->where('r.id','in',$ids_str)
-            ->alias('r')
-            ->field('r.id,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num,IFNULL( (SELECT max(y.id) FROM dd_recruit_resume as y WHERE r.id=y.recruit_id ),0) as max_id')
-            ->order('max_id desc')
+            //->field('r.id,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num,IFNULL( (SELECT max(y.id) FROM dd_recruit_resume as y WHERE r.id=y.recruit_id ),0) as max_id')
+            ->field('r.id,r.title,r.salary,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num')
+            ->order('r.id desc')
+            ->limit($this->off_set,$this->page_num)
             ->select()->toArray();
-        var_dump( $list);
+        array_walk($list,function (&$v){
+            $v['unread_num'] = RecruitResume::where(['recruit_id'=>$v['id'],'is_deleted'=>0,'is_read'=>0])->count();
+            $v['time_str'] = timeTransform($v['crate_at']);
+        });
+        $total_num = \app\common\model\Recruit::where(['r.user_id'=>$this->user_id,'r.is_deleted'=>0,]) ->alias('r')
+            ->field('r.id,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num')
+            ->order('r.id desc')->count();
+        $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
 
     }