MemberController.php
20.9 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<?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\ResumeModel;
use think\Db;
use think\Session;
class MemberController extends CommentController
{
// 个人中心
public function index()
{
$where_member['id'] = Session::get('uid');
$member = Db::name('Member')->where($where_member)->find();
$member['wx_pic'] = cmf_get_image_url($member['wx_pic']);
$this->assign('list',$member);
return $this->fetch();
}
// 编辑资料
public function changeUser(){
$where_member['id'] = Session::get('uid');
$member = Db::name('Member')->where($where_member)->find();
$member['wx_pic'] = cmf_get_image_url($member['wx_pic']);
$this->assign('list',$member);
return $this->fetch('editmaterial');
}
// 修改资料
public function change(){
$data = $this->request->param();
$final = array();
if(!empty($_FILES)){
// 图片
$res = $this->pic($_FILES);
$final[] = cmf_get_image_url($res);
$data['wx_pic'] = $res;
}
$where_member['id'] = Session::get('uid');
$data['update_time'] = time();
$res = Db::name('Member')->where($where_member)->update($data);
if($res){
$this->apiResponse('1',"成功",$final);
}else{
$this->apiResponse('0',"失败");
}
}
// 图片
public function pic($file){
if ((($file["file"]["type"] == "image/gif")
|| ($file["file"]["type"] == "image/jpeg")
|| ($file["file"]["type"] == "image/png")
|| ($file["file"]["type"] == "image/jpg"))
)
{
if ($file["file"]["error"] > 0)
{
$this->apiResponse('0',$file["file"]["error"]);
}else{
$data = './upload/';
$flodername = 'pic/' . date("Ymd", time());
$png = uniqid() . '.png';
$filename = $data.$flodername . '/' . $png;
if (!file_exists($data.$flodername)){
mkdir($data.$flodername, 0777, true);
}
move_uploaded_file($_FILES["file"]["tmp_name"],
$filename);
return $flodername . '/' . $png;
}
}else{
$this->apiResponse('0','图片格式错误');
}
}
// 我的订单
public function myOrder(){
$data = $this->request->param();
$type = 0;
if(!empty($data['type'])){
$type = $data['type'];
}
$this->assign('type',$type);
$config = $this->getSignPackage();
$this->assign('config',$config);
return $this->fetch('myorder');
}
// 我的订单内容
public function orderContent(){
$data = $this->request->param();
$where_compare['l.status'] = array('neq',9);
if(!empty($data['type'])){
if($data['type'] == 6|| $data['type'] == 7 || $data['type'] == 8 ){
$where_compare['l.status'] = $data['type'];
// if($data['type'] == 6){
// $where_order['o.status'] = array('in','6,10');
// }else {
$where_order['o.status'] = 6;
// }
}else{
$where_order['o.status'] = $data['type'];
}
}else{
$where_order['o.status'] = array('neq',9);
}
$a = array();
$where_order['h.user_id'] = Session::get('uid');
$coo_list = Db::name('Order')->alias('o')
->where($where_order)
->join("Hire h",'h.id = o.hire_id')
->join("Select s",'s.id = h.select_id')
->join("Member m",'m.id = h.user_id')
->field('h.id as hire_id,h.* , o.id as order_id,o.order_sn,o.status as orderStatus,o.create_time as cre,o.update_time as up , s.name as select_name ,m.name as member_name ')
->order('o.create_time desc')
->select()->toArray();
if($coo_list){
// 查询分配表
$log = Db::name('CompareLog')->alias('l')
->where($where_compare)
->join("Member m",'m.id = l.resume_user_id')
->field('m.name,m.tel,l.order_id,l.status,l.id')
->select()->toArray();
foreach ($coo_list as $k=>$v){
if($log){
$middle_list = $v;
foreach ($log as $lk=>$lv){
if($lv['order_id'] == $middle_list['order_id']){
$middle_list['start_time'] = date('Y.m.d',strtotime($middle_list['start_time']));
$middle_list['end_time'] = date('Y.m.d',strtotime($middle_list['end_time']));
$middle_list['orderStatus'] = $lv['status'];
$middle = $middle_list;
$middle['resume_name'] = $lv['name'];
$middle['resume_tel'] = $lv['tel'];
$middle['logId'] = $lv['id'];
$a[] = $middle;
$v = array();
}
}
if(!empty($v)) {
if(!empty($data['type'])){
if ($data['type'] == $v['orderStatus']) {
$v['start_time'] = date('Y.m.d', strtotime($v['start_time']));
$v['end_time'] = date('Y.m.d', strtotime($v['end_time']));
$v['resume_name'] = '';
$v['resume_tel'] = '';
$v['logId'] = 0;
$a[] = $v;
}
}else{
$v['start_time'] = date('Y.m.d',strtotime($v['start_time']));
$v['end_time'] = date('Y.m.d',strtotime($v['end_time']));
$v['resume_name'] = '';
$v['resume_tel'] = '';
$v['logId'] = 0;
$a[] = $v;
}
}
}else{
if(!empty($data['type'])) {
if ($data['type'] == 6 || $data['type'] == 7 || $data['type'] == 8) {
$a = array();
} else {
$a = $coo_list;
}
}else{
$a = $coo_list;
}
}
}
}
$this->apiResponse('1','成功',$a);
}
// 我的订单详情
public function detail(){
$data = $this->request->param();
if(!empty($data['logId'])){
$where_compare['l.id'] = $data['logId'];
$where_compare['l.status'] = array('neq',9);
$coo_list = Db::name('CompareLog')->alias('l')
->where($where_compare)
->join("Member m",'m.id = l.resume_user_id')
->join("Hire h",'h.id = l.hire_id')
->join("Order o",'o.id = l.order_id')
->join("Select s",'s.id = h.select_id')
->field('h.*,m.name as user_name,m.tel as user_tel,l.order_id,l.status,l.id,o.order_sn,s.name as select_name')
->find();
}else{
$where_order['o.id'] = $data['id'];
$where_order['h.user_id'] = Session::get('uid');
$coo_list = Db::name('Order')->alias('o')
->where($where_order)
->join("Hire h",'h.id = o.hire_id')
->join("Select s",'s.id = h.select_id')
->join("Member m",'m.id = h.user_id')
->field('o.id as order_id,o.order_sn,o.status as orderStatus,o.create_time as cre,o.update_time as up , h.id as hire_id,h.* , s.name as select_name ,m.name as member_name ')
->order('o.create_time desc')
->find();
if($coo_list['orderStatus'] == 4){
$where_ref['elseId'] = $coo_list['order_id'];
$where_ref['type'] = 1;
$where_ref['status'] = array('neq',9);
$refund = Db::name('Refund')->where($where_ref)->value('content');
$coo_list['refund'] = $refund;
}
}
$config = $this->getSignPackage();
$this->assign('config',$config);
$this->assign('list',$coo_list);
return $this->fetch('ordertail');
}
// 付款
public function toPay(){
$data = $this->request->param();
$pay = new SomepayController();
$where_order['o.id'] = $data['id'];
$where_order['o.user_id'] = Session::get('uid');
$where_order['o.status'] = 3;
$order = Db::name('Order')->alias('o')
->where($where_order)
->join("Member m",'m.id = o.user_id')
->field('m.openid,o.*')
->find();
if(!$order){
$this->apiResponse('0','订单错误',$where_order);
}else{
$order['money'] = 0.01;
$some_attr = $pay->pay($order['openid'],$order['money'],$order['order_sn'],url('portal/Somepay/pay_notify',['order_sn'=>$order['order_sn'],'id'=>$order['id']],'',true),'青云职上');
$this->apiResponse('1','成功',$some_attr);
}
}
// 取消订单
public function changeStatus(){
$data = $this->request->param();
// 取消
$where_order['id'] = $data['id'];
$where_order['status'] = 3;
$order = Db::name('Order')->where($where_order)->find();
if($order){
// 取消
$up['status'] = 5;
$up['update_time'] = time();
$res = Db::name('Order')->where($where_order)->update($up);
if($res){
$this->apiResponse('1',"取消成功");
}else{
$this->apiResponse('0','取消失败');
}
}else{
$this->apiResponse('0','状态错误');
}
}
// 确认完成
public function sureStatus(){
$data = $this->request->param();
Db::startTrans();
// 确认完成
$where_order['status'] = 6;
$where_order['id'] = $data['id'];
$log = Db::name('CompareLog')->where($where_order)->find();
if($log){
$up['status'] = 7;
$up['update_time'] = time();
$res = Db::name('CompareLog')->where($where_order)->update($up);
if($res){
// 发送模板消息
$where_hire['h.id'] = $log['hire_id'];
$where_hire['h.status'] = array('neq',9);
$hire_mes = Db::name('Hire')->alias('h')
->where($where_hire)
->join('Select s','s.id = h.select_id')
->join('Member m','m.id = h.user_id')
->field('s.name as select_name , m.openid')
->find();
$where_sendLog['id'] = $log['resume_user_id'];
$where_sendLog['status'] = array('neq',9);
$member_mes = Db::name('Member')->where($where_sendLog)->find();
if(empty($hire_mes['openid']) || empty($member_mes['openid'])){
$this->apiResponse('0','用户信息错误');
}
$acctoken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$acctoken;
$send = array();
$send['touser'] = $hire_mes['openid'];//OPENID
$send['template_id'] = 'D1-MOjOvcrvPovZfFD772tWdTI-XspZAMzkHrPZQv6g';
$send['url'] = 'http://yunzhi07.com/portal/Index/index/typeof/3';//模板跳转链接
$send['data']['first']['value'] = '您好,请您尽快完成评价,您的评价至关重要';//模板数据
$send['data']['keyword1']['value'] = $member_mes['name'];//模板数据
$send['data']['keyword2']['value'] = $hire_mes['select_name'];//模板数据
$send['data']['keyword3']['value'] = date('Y-m-d H:i:s',$log['create_time']);//模板数据
$send['data']['remark']['value'] = '如有其他问题,请及时与我们联系!';//模板数据
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($send));
$res = curl_exec($ch);//运行curl
$dec = json_decode($res) ;
$final = $dec->errcode;
if($final == 0){
Db::commit();
$this->apiResponse('1',"确认完成成功");
}else{
Db::rollback();
$this->apiResponse('0',$dec->errmsg);
}
}else{
Db::rollback();
$this->apiResponse('0','确认完成失败');
}
}else{
Db::rollback();
$this->apiResponse('0','状态错误');
}
}
// 评价
public function common(){
return $this->fetch('evalute');
}
// 评价提交
public function subCommon(){
$data = $this->request->param();
$where_log['id'] = $data['id'];
$where_log['status'] = 7;
$log = Db::name('CompareLog')->where($where_log)->find();
if($log){
$up['start'] = $data['start']+1;
$up['status'] = 8;
$up['common_time'] = time();
$up['update_time'] = time();
$res = Db::name('CompareLog')->where($where_log)->update($up);
if($res){
$this->apiResponse('1','评论成功');
}else{
$this->apiResponse('0','评论失败');
}
}else{
$this->apiResponse('0','订单错误');
}
}
// 我的钱包
public function myBalance(){
$where_member['id'] = Session::get('uid');
$where_member['status'] = array('neq',9);
$member = Db::name('Member')->where($where_member)->find();
$this->assign('list',$member);
return $this->fetch('myremain');
}
// 我要提现
public function getMoney(){
$where_member['id'] = Session::get('uid');
$where_member['status'] = array('neq',9);
$member = Db::name('Member')->where($where_member)->find();
$this->assign('list',$member);
return $this->fetch('mybalance');
}
// 提现
public function chooseGet(){
$data = $this->request->param();
$where_member['id'] = Session::get('uid');
$where_member['status'] = array('neq',9);
$member = Db::name('Member')->where($where_member)->find();
if((float)$member['money'] < (float)$data['money'] ){
$a['this'] = $member['money'];
$a['this2'] = $data['money'];
$this->apiResponse('0','您当前余额不足',$a);
}else{
// 创建订单
$order['type'] = 2;
$order['order_sn'] = $this->getSn();
$order['user_id'] = Session::get('uid');
$order['money'] = $data['money'];
$order['status'] = 15;
$order['create_time'] = time();
$order['update_time'] = time();
$res_order = Db::name('Order')->insertGetId($order);
if($res_order){
$add_log['order_id'] = $res_order;
$add_log['user_id'] = Session::get('uid');
$add_log['old_money'] = $member['money'];
$add_log['now_money'] = $member['money'] - $data['money'];
$add_log['money'] = $data['money'];
$add_log['status'] = 2;
$add_log['create_time'] = time();
$add_log['update_time'] = time();
$log = Db::name('GetMoney')->insertGetId($add_log);
if(!$log){
$this->apiResponse('0','订单错误');
}else{
$pay = new SomepayController();
$pay->getWxpay($member['openid'],$order['order_sn'],$order['money']);
}
}else{
$this->apiResponse('0','订单错误');
}
}
}
// 我的简历
public function myResume(){
$refund = '';
$where_member['m.id'] = Session::get('uid');
$where_member['m.status'] = array('neq',9);
$member = Db::name('Member')->alias('m')
->join("Resume r",'r.user_id = m.id')
->join("Select s",'r.select_id = s.id')
->where($where_member)
->field('m.wx_name,m.wx_pic,m.name,m.tel,m.card_num,r.*,s.name as select_name,s.id as select_id')
->order('create_time desc')
->find();
if($member){
$member['wx_pic'] = cmf_get_image_url($member['wx_pic']);
$member['just'] = cmf_get_image_url($member['just']);
$member['back'] = cmf_get_image_url($member['back']);
$member['skill'] = explode(',',$member['skill']);
}
$this->assign('list',$member);
$where_select['status'] = array('neq',9);
$where_select['type'] = 2;
$select = Db::name('Select')->where($where_select)->order('score desc,create_time desc')->select()->toArray();
$final['select'] = $select;
// 判断是否填写过
$where_resume['user_id'] = Session::get('uid');
$where_resume['status'] = array('neq',9);
$is_resume = Db::name('Resume')->where($where_resume)->order('create_time desc')->find();
if($is_resume){
if($is_resume['status'] == 4){
$where_refund['elseId'] = $is_resume['id'];
$where_refund['type'] = 2;
$refund = Db::name('Refund')->where($where_refund)->value('content');
$final['is_resume'] = 4;
}else{
$final['is_resume'] = 1;
}
}else{
$final['is_resume'] = 2;
}
$final['refund'] = $refund;
$this->assign('final',$final);
return $this->fetch('viae');
}
// 上传图片
public function getPic(){
$this->apiResponse('1','成功',$this->pic($_FILES)) ;
}
// 修改简历
public function changeResume(){
$data = $this->request->param();
$model = new ResumeModel();
// 用户
$where_member['id'] = Session::get('uid');
if($data['wx_pic']){
$add_member['wx_pic'] = $data['wx_pic'];
}
// $add_member['wx_pic'] = $data['wx_pic']?$data['wx_pic']:;
$add_member['name'] = $data['name'];
$add_member['card_num'] = $data['card_num'];
$add_member['update_time'] = time();
$res_member = Db::name('Member')->where($where_member)->update($add_member);
if(!$res_member){
$this->apiResponse('0','修改失败1');
}
// 简历
unset($data['wx_pic']);
unset($data['name']);
unset($data['card_num']);
$where_resume['user_id'] = Session::get('uid');
$where_resume['status'] = array('neq',9);;
$id = $model->where($where_resume)->order('create_time desc')->value('id');
if($id){
$where_resume['user_id'] = Session::get('uid');
$where_resume['status'] = array('neq',9);
if(!$data['just']){
unset($data['just']);
}
if(!$data['back']){
unset($data['back']);
}
$data['id'] = $id;
$data['status'] = 2;
$res = $model->isUpdate(true)->save($data);
if($res){
$this->apiResponse('1','成功');
}else{
$this->apiResponse('0','失败');
}
}else{
$this->apiResponse('0','简历错误');
}
}
// 关于我们
public function aboutUs(){
$where_art['type'] = 3;
$where_art['status'] = array('neq',9);
$content = Db::name('Art')->where($where_art)->find();
$content['pic'] = cmf_get_image_url($content['pic']);
$content['content'] = htmlspecialchars_decode($content['content']);
$this->assign('list',$content);
return $this->fetch('index/aboutus');
}
}