Procházet zdrojové kódy

wesmiler 报恩寺项目提交

wesmiler před 4 roky
rodič
revize
bd0bf4b81e

+ 1 - 1
app/Http/Controllers/Api/v1/WorkController.php

@@ -46,7 +46,7 @@ class WorkController extends BaseController
      */
     public function bookList(){
         $params = request()->all();
-        return $this->booksService->getDataList($params);
+        return $this->bookService->getDataList($params);
     }
 
     /**

+ 37 - 18
app/Services/WorkBooksService.php

@@ -106,7 +106,7 @@ class WorkBooksService extends BaseService
             ->leftJoin('works as a', 'a.id', '=', 'b.aid')
             ->leftJoin('member as m', 'm.id', '=', 'b.user_id')
             ->where(['a.mark'=> 1,'a.user_id'=> $userId])
-            ->whereIn('a.status',[1,2])
+            ->whereIn('a.status',[1,2,3])
             ->select(['b.id', 'b.aid', 'a.title', 'm.nickname', 'b.realname', 'b.phone', 'b.thumb', 'b.status','b.reason', 'b.create_time', 'b.update_time', 'b.description'])
             ->orderBy('b.update_time', 'desc')
             ->paginate($pageSize);
@@ -163,26 +163,45 @@ class WorkBooksService extends BaseService
 
         // 是否报名过
         $aid = isset($params['id'])? intval($params['id']) : 0;
-        $info = $this->model::where(['aid'=> $aid,'user_id'=> $userId, 'mark'=> 1,'status'=> 1])
-            ->where('create_time','>=', strtotime(date('Y-m-d')))
+        $info = $this->model::where(['aid'=> $aid,'user_id'=> $userId, 'mark'=> 1])
             ->first();
-        if($info){
-            return message('该信息下您今日已经提交过信息', false);
+        if($info && $info->status==1){
+            return message('该岗位您已经成功报名', false);
+        }else if($info && $info->status==2){
+            return message('该岗位您已经提交报名,请耐心等候审核', false);
         }
 
-        $data = [
-            'aid'=> $aid,
-            'user_id'=> $userId,
-            'realname'=> isset($params['realname'])? trim($params['realname']) : '',
-            'phone'=> isset($params['phone'])? trim($params['phone']) : '',
-            'thumb'=> isset($params['thumb'])? trim($params['thumb']) : '',
-            'description'=> isset($params['description'])? trim($params['description']) : '',
-            'create_time'=> time(),
-            'mark'=> 1,
-            'status'=> 1
-        ];
+        if($info){
+            $info->realname = isset($params['realname'])? trim($params['realname']) : '';
+            $info->phone = isset($params['phone'])? trim($params['phone']) : '';
+            $info->thumb = isset($params['thumb'])? trim($params['thumb']) : '';
+            $info->description = isset($params['description'])? trim($params['description']) : '';
+            $info->create_time = time();
+            $info->update_time = time();
+            $info->mark = 1;
+            $info->status = 1;
+            $info->reason = '';
+            if($info->save()){
+                return message('提交成功', true);
+            }else{
+                return message('提交失败', false);
+            }
+        }else{
+            $data = [
+                'aid'=> $aid,
+                'user_id'=> $userId,
+                'realname'=> isset($params['realname'])? trim($params['realname']) : '',
+                'phone'=> isset($params['phone'])? trim($params['phone']) : '',
+                'thumb'=> isset($params['thumb'])? trim($params['thumb']) : '',
+                'description'=> isset($params['description'])? trim($params['description']) : '',
+                'create_time'=> time(),
+                'mark'=> 1,
+                'status'=> 1
+            ];
+
+            $data['update_time'] = time();
+            return parent::edit($data); // TODO: Change the autogenerated stub
+        }
 
-        $data['update_time'] = time();
-        return parent::edit($data); // TODO: Change the autogenerated stub
     }
 }