IndexController.php
8.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\HireModel;
use app\portal\model\OrderModel;
use app\portal\model\ResumeModel;
use app\portal\validate\ResumeValidate;
use cmf\controller\HomeBaseController;
use think\Db;
use think\Loader;
use think\Session;
class IndexController extends CommentController
{
// 我要雇人首页
public function index()
{
$where_member['id'] = Session::get('uid');
$member = Db::name('Member')->where($where_member)->field('name,tel,card_num')->find();
if(empty($member['name']) || empty($member['tel']) || empty($member['card_num'])){
$final['is_check'] = 0;
}else{
$final['is_check'] = 1;
}
// 轮播图
$where_banner['status'] = array('neq',9);
$where_banner['type'] = 1;
$banner = Db::name('Banner')->where($where_banner)->order('score desc,create_time desc')->limit(3)->select()->toArray();
$final['banner'] = $banner;
// 我的位置
$config = $this->getSignPackage();
$this->assign('config',$config);
// 雇佣事项
$where_select['status'] = array('neq',9);
$where_select['type'] = 1;
$select = Db::name('Select')->where($where_select)->order('score desc,create_time desc')->field('id as value, name as label')->select()->toArray();
$final['select'] = json_encode($select);
// 协议
$where_art['status'] = array('neq',9);
$where_art['type'] = 1;
$art = Db::name('Art')->where($where_art)->find();
$art['content'] = htmlspecialchars_decode($art['content']);
$final['art'] = $art;
$where_cof['status'] = array('neq',9);
$tel = Db::name('Config')->where($where_cof)->value('tel');
$final['tel'] = $tel;
$this->assign('final',$final);
return $this->fetch();
}
// 实名认证
public function Authentication(){
$data = $this->request->param();
if(empty($data['name'])){
$this->apiResponse('0','姓名不能为空');
}
if(empty($data['tel'])){
$this->apiResponse('0','手机号不能为空');
}
if(empty($data['card_num'])){
$this->apiResponse('0','身份证号不能为空');
}
$add = $data;
$add['status'] = 2;
$add['update_time'] = time();
$where_member['id'] = Session::get('uid');
$validate = Loader::validate('Member');
if(!$validate->scene('add')->check($data)){
$mes = $validate->getError();
$this->apiResponse('0',$mes);
}
$res = Db::name('Member')->where($where_member)->update($add);
if($res){
$this->apiResponse('1','成功');
}else{
$this->apiResponse('0','认证失败');
}
}
// 兼职页面展示
public function show()
{
$refund = '';
// 判断是否是首次进入
$where_member['id'] = Session::get('uid');
$member = Db::name('Member')->where($where_member)->field('name,tel,card_num')->find();
if(empty($member['name']) || empty($member['tel']) || empty($member['card_num'])){
$final['is_check'] = 0;
}else{
$final['is_check'] = 1;
}
// 判断是否填写过
$where_resume['user_id'] = Session::get('uid');
$where_resume['status'] = array('neq',9);
$is_resume = Db::name('Resume')->where($where_resume)->find();
if($is_resume){
if($is_resume['status'] == 2){
$final['is_resume'] = 2;
}else{
if($is_resume['status'] == 4){
$final['is_resume'] = 0;
$where_refund['elseId'] = $is_resume['id'];
$where_refund['type'] = 2;
$refund = Db::name('Refund')->where($where_refund)->value('content');
}else{
$final['is_resume'] = 3;
}
}
}else{
$final['is_resume'] = 0;
}
$final['refund'] = $refund;
// 轮播图
$where_banner['status'] = array('neq',9);
$where_banner['type'] = 2;
$banner = Db::name('Banner')->where($where_banner)->order('score desc,create_time desc')->limit(3)->select()->toArray();
$final['banner'] = $banner;
// 我的位置
$config = $this->getSignPackage();
$this->assign('config',$config);
// 雇佣事项
$where_select['status'] = array('neq',9);
$where_select['type'] = 2;
$select = Db::name('Select')->where($where_select)->order('score desc,create_time desc')->field('id as value, name as label')->select()->toArray();
$final['select'] = json_encode($select);
// 协议
$where_art['status'] = array('neq',9);
$where_art['type'] = 2;
$art = Db::name('Art')->where($where_art)->find();
$art['content'] = htmlspecialchars_decode($art['content']);
$final['art'] = $art;
$where_cof['status'] = array('neq',9);
$tel = Db::name('Config')->where($where_cof)->value('tel');
$final['tel'] = $tel;
$this->assign('final',$final);
return $this->fetch('postjob');
}
// 我要雇人表单提交
public function hire()
{
$data = $this->request->param();
$validate = Loader::validate('Hire');
$start_time = str_replace("年","-",$data['start_time']);
$start_time = str_replace("月","-",$start_time);
$data['start_time'] = str_replace("日","",$start_time);
$end_time = str_replace("年","-",$data['end_time']);
$end_time = str_replace("月","-",$end_time);
$end_time = str_replace("月","-",$end_time);
$data['end_time'] = str_replace("日","",$end_time);
if(!$validate->scene('add')->check($data)){
$mes = $validate->getError();
$this->apiResponse('0',$mes);
}
$model = new HireModel();
$data['user_id'] = Session::get('uid');
$res = $model->save($data);
if($res){
$this->setOrder($model->id,$data['money'],$data['user_id']);
$this->apiResponse('1','成功');
}else{
$this->apiResponse('0','提交失败');
}
}
public function getPic(){
$get = new MemberController();
$this->apiResponse('1','成功',$get->pic($_FILES)) ;
}
// 我要兼职表单提交
public function resume()
{
$data = $this->request->param();
// 图片上传
$validate = Loader::validate('Resume');
if(!$validate->check($data)){
$mes = $validate->getError();
$this->apiResponse('0',$mes);
}
$model = new ResumeModel();
$data['user_id'] = Session::get('uid');
$data['skill'] = implode(',',$data['skill']);
$res = $model->save($data);
if($res){
$this->apiResponse('1','成功');
}else{
$this->apiResponse('0','提交失败');
}
}
// 创建订单
public function setOrder($hireId,$money,$user_id){
$orderModel = new OrderModel();
$add_order['order_sn'] = $this->getSn();
$add_order['hire_id'] = $hireId;
$add_order['money'] = $money;
$add_order['user_id'] = $user_id;
$res = $orderModel->save($add_order);
if(!$res){
$this->apiResponse('0','添加失败');
}
}
// 协议
// public function art(){
//
// return $this->fetch();
// }
}