作者 郭鑫

接口调试上传

@@ -20,35 +20,35 @@ use api\portal\model\CodeModel; @@ -20,35 +20,35 @@ use api\portal\model\CodeModel;
20 class CommonController extends HomeBaseController 20 class CommonController extends HomeBaseController
21 { 21 {
22 // connect 1 登录注册 ,2其他 22 // connect 1 登录注册 ,2其他
23 - public function _initialize()  
24 - {  
25 - if($this->request->param('connect')){  
26 - $connect = $this->request->param('connect');  
27 - }else{  
28 - $connect = 2;  
29 - }  
30 - if($connect == 2){  
31 - $where_firstMember['token'] = $this->request->param('token');  
32 - $firstMember = Db::name('Member')->where($where_firstMember)->field('id,update_time')->find();  
33 - if($firstMember){  
34 - if(($firstMember['update_time']+604800) < time() ){  
35 - $firstStr = rand(1000,9999).time().rand(100,999);  
36 - $firstData['token'] = $this->md5($firstStr);  
37 - $firstData['update_time'] = time();  
38 - $firstData['status'] = 1;  
39 - $firstLogin = Db::name('Member')->where($where_firstMember)->update($firstData);  
40 - if($firstLogin){  
41 - $this->apiResponse('0','请重新登录');  
42 - }else{  
43 - $this->apiResponse('0','token重置失败');  
44 - }  
45 - }  
46 - }else{  
47 - $this->apiResponse('0','暂未注册');  
48 - }  
49 - }  
50 -  
51 - } 23 +// public function _initialize()
  24 +// {
  25 +// if($this->request->param('connect')){
  26 +// $connect = $this->request->param('connect');
  27 +// }else{
  28 +// $connect = 2;
  29 +// }
  30 +// if($connect == 2){
  31 +// $where_firstMember['token'] = $this->request->param('token');
  32 +// $firstMember = Db::name('Member')->where($where_firstMember)->field('id,update_time')->find();
  33 +// if($firstMember){
  34 +// if(($firstMember['update_time']+604800) < time() ){
  35 +// $firstStr = rand(1000,9999).time().rand(100,999);
  36 +// $firstData['token'] = $this->md5($firstStr);
  37 +// $firstData['update_time'] = time();
  38 +// $firstData['status'] = 1;
  39 +// $firstLogin = Db::name('Member')->where($where_firstMember)->update($firstData);
  40 +// if($firstLogin){
  41 +// $this->apiResponse('0','请重新登录');
  42 +// }else{
  43 +// $this->apiResponse('0','token重置失败');
  44 +// }
  45 +// }
  46 +// }else{
  47 +// $this->apiResponse('0','暂未注册');
  48 +// }
  49 +// }
  50 +//
  51 +// }
52 /** 52 /**
53 * API返回信息格式函数 ;0失败,1成功,-1需要登录 53 * API返回信息格式函数 ;0失败,1成功,-1需要登录
54 * @param string $code 54 * @param string $code
@@ -90,6 +90,10 @@ class CommonController extends HomeBaseController @@ -90,6 +90,10 @@ class CommonController extends HomeBaseController
90 // $code = 'SMS_137416617'; 90 // $code = 'SMS_137416617';
91 $modelVal = rand(1000,9999); 91 $modelVal = rand(1000,9999);
92 $sendResult = $this->sendLogin($tel,$code,$modelVal); 92 $sendResult = $this->sendLogin($tel,$code,$modelVal);
  93 + $mes = $sendResult->Message;
  94 + if($mes != 'OK'){
  95 + $this->apiResponse('0',$mes);
  96 + }
93 $add_code['tel'] = $tel; 97 $add_code['tel'] = $tel;
94 $add_code['code'] = $modelVal; 98 $add_code['code'] = $modelVal;
95 $add_code['type'] = $type; 99 $add_code['type'] = $type;
@@ -100,6 +104,8 @@ class CommonController extends HomeBaseController @@ -100,6 +104,8 @@ class CommonController extends HomeBaseController
100 } 104 }
101 if(($sendResult->Code) != 'OK'){ 105 if(($sendResult->Code) != 'OK'){
102 $this->apiResponse('0','注册失败'); 106 $this->apiResponse('0','注册失败');
  107 + }else{
  108 + $this->apiResponse('1','获取成功');
103 } 109 }
104 } 110 }
105 111
@@ -36,7 +36,7 @@ class IntermediaryController extends CommonController @@ -36,7 +36,7 @@ class IntermediaryController extends CommonController
36 //sure_password 确认密码 36 //sure_password 确认密码
37 //name 真实姓名 37 //name 真实姓名
38 /** 38 /**
39 - * @title 房产中介注册 39 + * @title 房产中介注册(sure)
40 * @description 接口说明 40 * @description 接口说明
41 * @author 开发者 41 * @author 开发者
42 * @url /api/portal/Intermediary/join 42 * @url /api/portal/Intermediary/join
@@ -44,30 +44,33 @@ class IntermediaryController extends CommonController @@ -44,30 +44,33 @@ class IntermediaryController extends CommonController
44 * @param name:name type:int require:1 default: other: desc:姓名 44 * @param name:name type:int require:1 default: other: desc:姓名
45 * @param name:tel type:int require:1 default: other: desc:手机号 45 * @param name:tel type:int require:1 default: other: desc:手机号
46 * @param name:password type:int require:1 default: other: desc:密码 46 * @param name:password type:int require:1 default: other: desc:密码
  47 + * @param name:sure_password type:int require:1 default: other: desc:确认密码
47 * @param name:code type:int require:1 default: other: desc:验证码 48 * @param name:code type:int require:1 default: other: desc:验证码
48 * @param name:city type:int require:1 default: other: desc:城市 49 * @param name:city type:int require:1 default: other: desc:城市
49 * @param name:company type:int require:1 default: other: desc:所属公司 50 * @param name:company type:int require:1 default: other: desc:所属公司
50 * @param name:store type:int require:1 default: other: desc:门店 51 * @param name:store type:int require:1 default: other: desc:门店
51 * @param name:quarters type:int require:1 default: other: desc:服务小区 52 * @param name:quarters type:int require:1 default: other: desc:服务小区
  53 + * @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:1
52 */ 54 */
53 55
54 public function join(Request $request) 56 public function join(Request $request)
55 { 57 {
56 - if($request->Post()){ 58 + $data = $request->Post();
  59 + if(!empty($data['name'])){
57 // 验证 60 // 验证
58 $validate = Loader::validate('User'); 61 $validate = Loader::validate('User');
59 - if(!$validate->scene('intermediary')->check($_POST)){ 62 + if(!$validate->scene('intermediary')->check($data)){
60 return json(array('code'=>0,'msg'=>$validate->getError())); 63 return json(array('code'=>0,'msg'=>$validate->getError()));
61 } 64 }
62 - $data['password'] = $this->md5($_POST['password']);  
63 - $sure_password = $this->md5($_POST['sure_password']); 65 + $data['password'] = $this->md5($data['password']);
  66 + $sure_password = $this->md5($data['sure_password']);
64 // 确认密码 67 // 确认密码
65 if($data['password'] != $sure_password){ 68 if($data['password'] != $sure_password){
66 $this->apiResponse('0','两次密码不一致'); 69 $this->apiResponse('0','两次密码不一致');
67 } 70 }
68 71
69 // 验证码 72 // 验证码
70 - $data['tel'] = $_POST['tel']; 73 +// $data['tel'] = $_POST['tel'];
71 $code = $request->param('code'); 74 $code = $request->param('code');
72 $where_code['tel'] = $data['tel']; 75 $where_code['tel'] = $data['tel'];
73 $where_code['type'] = 1; 76 $where_code['type'] = 1;
@@ -81,7 +84,7 @@ class IntermediaryController extends CommonController @@ -81,7 +84,7 @@ class IntermediaryController extends CommonController
81 }else{ 84 }else{
82 Db::name('Code')->where($where_code)->delete(); 85 Db::name('Code')->where($where_code)->delete();
83 } 86 }
84 - $data['name'] = $_POST['name']; 87 +// $data['name'] = $_POST['name'];
85 88
86 // 判断手机号是否已注册 89 // 判断手机号是否已注册
87 $user = new MemberModel(); 90 $user = new MemberModel();
@@ -128,7 +131,7 @@ class IntermediaryController extends CommonController @@ -128,7 +131,7 @@ class IntermediaryController extends CommonController
128 public function left($token){ 131 public function left($token){
129 $where_member['token'] = $token; 132 $where_member['token'] = $token;
130 $where_member['status'] = 1; 133 $where_member['status'] = 1;
131 - $member = Db::name('Member')->where($where_member)->field('name,id,start,reputation,company,store,quarters,tel,city')->find(); 134 + $member = Db::name('Member')->where($where_member)->field('name,id,start,reputation,company,store,quarters,tel,city,pic,money,get_money')->find();
132 if(!$member){ 135 if(!$member){
133 $this->apiResponse('0','用户信息错误'); 136 $this->apiResponse('0','用户信息错误');
134 } 137 }
@@ -147,7 +150,7 @@ class IntermediaryController extends CommonController @@ -147,7 +150,7 @@ class IntermediaryController extends CommonController
147 150
148 151
149 /** 152 /**
150 - * @title 中介个人中心首页(over 153 + * @title 中介个人中心首页(sure
151 * @description 接口说明 154 * @description 接口说明
152 * @author 开发者 155 * @author 开发者
153 * @url /api/portal/Intermediary/myIndex 156 * @url /api/portal/Intermediary/myIndex
@@ -174,7 +177,7 @@ class IntermediaryController extends CommonController @@ -174,7 +177,7 @@ class IntermediaryController extends CommonController
174 177
175 178
176 /** 179 /**
177 - * @title 中介个人中心匹配需求详情(over 180 + * @title 中介个人中心匹配需求详情(sure
178 * @description 接口说明 181 * @description 接口说明
179 * @author 开发者 182 * @author 开发者
180 * @url /api/portal/Intermediary/mySend 183 * @url /api/portal/Intermediary/mySend
@@ -192,7 +195,7 @@ class IntermediaryController extends CommonController @@ -192,7 +195,7 @@ class IntermediaryController extends CommonController
192 $where_need['id'] = $request->param('need_id'); 195 $where_need['id'] = $request->param('need_id');
193 $where_need['status'] = 2; 196 $where_need['status'] = 2;
194 $need_list = Db::name('UserNeed')->where($where_need) 197 $need_list = Db::name('UserNeed')->where($where_need)
195 - ->field("id,user_id,city,quarters,room,floor,house_type,renovation,area,is_first,loan,contract,quotation_time,create_time,people") 198 + ->field("id,user_id,city,quarters,room,floor,house_type,renovation,area,is_first,loan,contract,quotation_time,create_time,people,else")
196 ->find(); 199 ->find();
197 if($need_list){ 200 if($need_list){
198 $final['intermediary_need'] = $need_list; 201 $final['intermediary_need'] = $need_list;
@@ -294,7 +297,7 @@ class IntermediaryController extends CommonController @@ -294,7 +297,7 @@ class IntermediaryController extends CommonController
294 } 297 }
295 298
296 /** 299 /**
297 - * @title 中介个人中心我的报价 300 + * @title 中介个人中心我的报价(sure)
298 * @description 接口说明 301 * @description 接口说明
299 * @author 开发者 302 * @author 开发者
300 * @url /api/portal/Intermediary/myMoney 303 * @url /api/portal/Intermediary/myMoney
@@ -306,10 +309,21 @@ class IntermediaryController extends CommonController @@ -306,10 +309,21 @@ class IntermediaryController extends CommonController
306 $data = $request->param(); 309 $data = $request->param();
307 $my = $this->left($data['token']); 310 $my = $this->left($data['token']);
308 $final['intermediary'] = $my; 311 $final['intermediary'] = $my;
309 - $where_need['agency_id'] = $my['id']; 312 + $where_need['a.agency_id'] = $my['id'];
310 $page = $data['page']; 313 $page = $data['page'];
311 - $need = Db::name('Agency')->where($where_need)->limit(10)->page($page)->select()->toArray(); 314 + $need = Db::name('Agency')->alias('a')
  315 + ->where($where_need)
  316 + ->join("UserNeed n",'n.id = a.need_id')
  317 + ->field("n.city,n.quarters,n.room,n.floor,n.house_type,n.renovation,n.status as need_status,n.create_time as need_time,n.quotation_time,
  318 + a.all_price,a.create_time,a.status,a.id as intermediaryNeed_id
  319 + ")
  320 + ->limit(10)->page($page)
  321 + ->select()->toArray();
312 if($need){ 322 if($need){
  323 + foreach ($need as $nk=>$nv){
  324 + $changeInt = (int)$nv['all_price'];
  325 + $need[$nk]['intPrice'] = substr($changeInt,0,-4);
  326 + }
313 $final['need'] = $need; 327 $final['need'] = $need;
314 }else{ 328 }else{
315 $final['need'] = array(); 329 $final['need'] = array();
@@ -318,23 +332,26 @@ class IntermediaryController extends CommonController @@ -318,23 +332,26 @@ class IntermediaryController extends CommonController
318 } 332 }
319 333
320 /** 334 /**
321 - * @title 中介个人中心我的报价详情 335 + * @title 中介个人中心我的报价详情(sure)
322 * @description 接口说明 336 * @description 接口说明
323 * @author 开发者 337 * @author 开发者
324 * @url /api/portal/Intermediary/myDetail 338 * @url /api/portal/Intermediary/myDetail
325 * @method POST 339 * @method POST
326 * @param name:token type:int require:1 default: other: desc:token 340 * @param name:token type:int require:1 default: other: desc:token
327 - * @param name:intermediaryNeed_id type:int require:1 default: other: desc:报价id 341 + * @param name:intermediary_id type:int require:1 default: other: desc:报价id
328 */ 342 */
329 public function myDetail(Request $request){ 343 public function myDetail(Request $request){
330 $data = $request->param(); 344 $data = $request->param();
331 $my = $this->left($data['token']); 345 $my = $this->left($data['token']);
332 $final['intermediary'] = $my; 346 $final['intermediary'] = $my;
333 $where_need['agency_id'] = $my['id']; 347 $where_need['agency_id'] = $my['id'];
334 - $where_need['i.id'] = $data['intermediaryNeed_id']; 348 + $where_need['i.id'] = $data['intermediary_id'];
335 $need = Db::name('Agency')->alias('i') 349 $need = Db::name('Agency')->alias('i')
336 ->where($where_need) 350 ->where($where_need)
337 ->join("hp_user_need u",'u.id = i.need_id') 351 ->join("hp_user_need u",'u.id = i.need_id')
  352 + ->field("i.id as intermediaryNeed_id ,i.*,
  353 + u.status as need_status ,u.*
  354 + ")
338 ->find(); 355 ->find();
339 if($need){ 356 if($need){
340 $final['need'] = $need; 357 $final['need'] = $need;
@@ -344,16 +361,47 @@ class IntermediaryController extends CommonController @@ -344,16 +361,47 @@ class IntermediaryController extends CommonController
344 $this->apiResponse('1','成功',$final); 361 $this->apiResponse('1','成功',$final);
345 } 362 }
346 363
  364 + /**
  365 + * @title 中介个人中心查看评价(sure)
  366 + * @description 接口说明
  367 + * @author 开发者
  368 + * @url /api/portal/Intermediary/comment
  369 + * @method POST
  370 + * @param name:token type:int require:1 default: other: desc:token
  371 + * @param name:intermediary_id type:int require:1 default: other: desc:报价id
  372 + */
  373 + public function comment(Request $request){
  374 + $data = $request->param();
  375 +// $my = $this->left($data['token']);
  376 + if(empty($data['intermediary_id'])){
  377 + $this->apiResponse('0','报价id不能为空');
  378 + }
  379 + $where_agency['id'] = $data['intermediary_id'];
  380 + $agency = Db::name('Agency')->where($where_agency)->find();
  381 + if($agency){
  382 + $where_comment['need_id'] = $agency['need_id'];
  383 + $where_comment['agency_id'] = $agency['id'];
  384 + $where_comment['intermediary_id'] = $agency['agency_id'];
  385 + $where_comment['status'] = 1;
  386 + $comment = Db::name('Comment')->where($where_comment)->find();
  387 + if($comment){
  388 + $this->apiResponse('1','成功',$comment);
  389 + }else{
  390 + $this->apiResponse('0','暂无评价');
  391 + }
  392 + }else{
  393 + $this->apiResponse('0','状态错误');
  394 + }
  395 + }
347 396
348 397
349 /** 398 /**
350 - * @title 中介个人中心我的资料 399 + * @title 中介个人中心我的资料(sure)
351 * @description 接口说明 400 * @description 接口说明
352 * @author 开发者 401 * @author 开发者
353 * @url /api/portal/Intermediary/myDetail 402 * @url /api/portal/Intermediary/myDetail
354 * @method POST 403 * @method POST
355 * @param name:token type:int require:1 default: other: desc:token 404 * @param name:token type:int require:1 default: other: desc:token
356 - * @param name:intermediaryNeed_id type:int require:1 default: other: desc:报价id  
357 */ 405 */
358 public function mySelf(Request $request){ 406 public function mySelf(Request $request){
359 $data = $request->param(); 407 $data = $request->param();
@@ -367,7 +415,7 @@ class IntermediaryController extends CommonController @@ -367,7 +415,7 @@ class IntermediaryController extends CommonController
367 } 415 }
368 416
369 /** 417 /**
370 - * @title 中介资料修改 418 + * @title 中介资料修改(sure)
371 * @description 接口说明 419 * @description 接口说明
372 * @author 开发者 420 * @author 开发者
373 * @url /api/portal/Intermediary/myIndex 421 * @url /api/portal/Intermediary/myIndex
@@ -396,7 +444,7 @@ class IntermediaryController extends CommonController @@ -396,7 +444,7 @@ class IntermediaryController extends CommonController
396 444
397 445
398 /** 446 /**
399 - * @title 中介签到 447 + * @title 中介签到(sure)
400 * @description 接口说明 448 * @description 接口说明
401 * @author 开发者 449 * @author 开发者
402 * @url /api/portal/Intermediary/checkIn 450 * @url /api/portal/Intermediary/checkIn
@@ -429,6 +477,32 @@ class IntermediaryController extends CommonController @@ -429,6 +477,32 @@ class IntermediaryController extends CommonController
429 } 477 }
430 } 478 }
431 479
  480 + /**
  481 + * @title 我的账户(sure)
  482 + * @description 接口说明
  483 + * @author 开发者
  484 + * @url /api/portal/Intermediary/orderDetail
  485 + * @method POST
  486 + * @param name:token type:int require:1 default: other: desc:token
  487 + */
  488 + public function orderDetail(Request $request){
  489 + $data = $request->param();
  490 + $user = $this->left($data['token']);
  491 + $where_umoney['user_id'] = $user['id'];
  492 + $where_umoney['status'] = 1;
  493 + $order_list = Db::name('AmoenyDetail')->where($where_umoney)->select()->toArray();
  494 + $final['user'] = $user;
  495 + if($order_list){
  496 + $final['detail'] = $order_list;
  497 + }else{
  498 + $final['detail'] = array();
  499 + }
  500 + if($final){
  501 + $this->apiResponse('1','成功',$final);
  502 + }else{
  503 + $this->apiResponse('0','失败');
  504 + }
  505 + }
432 506
433 507
434 508
@@ -45,11 +45,10 @@ class IntermediaryneedController extends CommonController @@ -45,11 +45,10 @@ class IntermediaryneedController extends CommonController
45 * @param name:housing_price type:int require:1 default: other: desc:房价 45 * @param name:housing_price type:int require:1 default: other: desc:房价
46 * @param name:token type:int require:1 default: other: desc:token 46 * @param name:token type:int require:1 default: other: desc:token
47 */ 47 */
48 - public function payMoney(Request $request){  
49 - $data = $request->param(); 48 + public function payMoney($housing_price){
50 $where_inteRule['status'] = 1; 49 $where_inteRule['status'] = 1;
51 - $where_inteRule['low'] = array('gt',$data['housing_price']);  
52 - $where_inteRule['height'] = array('lt',$data['housing_price']); 50 + $where_inteRule['low'] = array('gt',$housing_price);
  51 + $where_inteRule['height'] = array('lt',$housing_price);
53 $inte_money = Db::name('IntermediaryRule')->where($where_inteRule)->field('money')->find(); 52 $inte_money = Db::name('IntermediaryRule')->where($where_inteRule)->field('money')->find();
54 if(!$inte_money){ 53 if(!$inte_money){
55 $this->apiResponse('0','保证金获取失败'); 54 $this->apiResponse('0','保证金获取失败');
@@ -98,7 +97,7 @@ class IntermediaryneedController extends CommonController @@ -98,7 +97,7 @@ class IntermediaryneedController extends CommonController
98 } 97 }
99 98
100 /** 99 /**
101 - * @title 中介报价 100 + * @title 中介报价(sure)
102 * @description 接口说明 101 * @description 接口说明
103 * @author 开发者 102 * @author 开发者
104 * @url /api/portal/Intermediaryneed/send 103 * @url /api/portal/Intermediaryneed/send
@@ -150,6 +149,7 @@ class IntermediaryneedController extends CommonController @@ -150,6 +149,7 @@ class IntermediaryneedController extends CommonController
150 $this->apiResponse('0','保证金获取失败'); 149 $this->apiResponse('0','保证金获取失败');
151 }else{ 150 }else{
152 $data['deposit'] = $inte_money['money']; 151 $data['deposit'] = $inte_money['money'];
  152 + $final['pay_money'] = $data['deposit'];
153 } 153 }
154 unset($data['token']); 154 unset($data['token']);
155 $save = $model->save($data); 155 $save = $model->save($data);
@@ -9,6 +9,8 @@ @@ -9,6 +9,8 @@
9 namespace api\portal\controller; 9 namespace api\portal\controller;
10 10
11 11
  12 +use api\portal\model\AgencyModel;
  13 +use api\portal\model\UserNeedModel;
12 use cmf\controller\HomeBaseController; 14 use cmf\controller\HomeBaseController;
13 use api\portal\model\PortalPostModel; 15 use api\portal\model\PortalPostModel;
14 use cmf\controller\RestBaseController; 16 use cmf\controller\RestBaseController;
@@ -75,21 +77,21 @@ class ThirdsendController extends HomeBaseController @@ -75,21 +77,21 @@ class ThirdsendController extends HomeBaseController
75 77
76 78
77 79
78 -// 30分钟后发布 80 +// 30分钟后发布(sure)(分钟执行)
79 public function thirdSend(){ 81 public function thirdSend(){
80 Db::startTrans(); 82 Db::startTrans();
81 - $where_need['status'] = 1;  
82 - $userNeedList = Db::name('UserNeed')->where($where_need)->field('id,create_time')->select()->toArray(); 83 + $where_need['status'] = 2;
  84 + $userNeedList = Db::name('UserNeed')->where($where_need)->field('id,pay_time')->select()->toArray();
83 $time = time(); 85 $time = time();
84 $change_arr = array(); 86 $change_arr = array();
85 foreach ($userNeedList as $userk=>$userv){ 87 foreach ($userNeedList as $userk=>$userv){
86 - if($userv['create_time'] <= ($time+60) && $userv['create_time'] >= $time){ 88 + if($time >= $userv['pay_time']+1800){
87 $change_arr[] = $userv['id']; 89 $change_arr[] = $userv['id'];
88 } 90 }
89 } 91 }
90 if($change_arr){ 92 if($change_arr){
91 $where_save['id'] = array('in',$change_arr); 93 $where_save['id'] = array('in',$change_arr);
92 - $save['status'] = 2; 94 + $save['status'] = 3;
93 $save['update_time'] = time(); 95 $save['update_time'] = time();
94 $fianl_save = Db::name('UserNeed')->where($where_save)->update($save); 96 $fianl_save = Db::name('UserNeed')->where($where_save)->update($save);
95 if($fianl_save){ 97 if($fianl_save){
@@ -100,23 +102,21 @@ class ThirdsendController extends HomeBaseController @@ -100,23 +102,21 @@ class ThirdsendController extends HomeBaseController
100 } 102 }
101 } 103 }
102 104
103 -// 规定时间结束报价 105 +// 规定时间结束报价(sure)(分钟执行)
104 public function over() 106 public function over()
105 { 107 {
106 Db::startTrans(); 108 Db::startTrans();
107 // 查询用户发布需求信息 109 // 查询用户发布需求信息
108 - $where_need['status'] = 2;  
109 - $userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time')->select()->toArray();  
110 - $change_arr = array(); 110 + $where_need['status'] = 3;
  111 + $userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time,pay_time,user_id')->select()->toArray();
111 $time = time(); 112 $time = time();
112 - $time = '1529734985';  
113 // 循环需求,查询相应报价 113 // 循环需求,查询相应报价
114 foreach ($userNeedList as $uNeedk => $uNeedv) { 114 foreach ($userNeedList as $uNeedk => $uNeedv) {
115 - $final_time = $uNeedv['create_time'] + $uNeedv['quotation_time'] * 86400;  
116 - if ($final_time <= ($time + 60) && $final_time >= $time) { 115 + $final_time = $uNeedv['pay_time'] + $uNeedv['quotation_time'] * 86400;
  116 + if ($time >= $final_time) {
117 $us_middleid = $uNeedv['id']; 117 $us_middleid = $uNeedv['id'];
118 $where_agency['a.status'] = 2; 118 $where_agency['a.status'] = 2;
119 - $where_agency['a.create_time'] = array('lt', time()); 119 + $where_agency['a.pay_time'] = array('lt', time());
120 $where_agency['a.need_id'] = $uNeedv['id']; 120 $where_agency['a.need_id'] = $uNeedv['id'];
121 $where_agency['m.type'] = 2; 121 $where_agency['m.type'] = 2;
122 $where_agency['m.status'] = 1; 122 $where_agency['m.status'] = 1;
@@ -133,6 +133,7 @@ class ThirdsendController extends HomeBaseController @@ -133,6 +133,7 @@ class ThirdsendController extends HomeBaseController
133 if ($agency_list) { 133 if ($agency_list) {
134 // 判断是否超过三个报价人 134 // 判断是否超过三个报价人
135 if (count($agency_list) >= 3) { 135 if (count($agency_list) >= 3) {
  136 +
136 // 查询三人中是否有品牌中介 137 // 查询三人中是否有品牌中介
137 // 循环匹配品牌企业 138 // 循环匹配品牌企业
138 foreach ($agency_list as $agencyk => $agencyv) { 139 foreach ($agency_list as $agencyk => $agencyv) {
@@ -161,6 +162,7 @@ class ThirdsendController extends HomeBaseController @@ -161,6 +162,7 @@ class ThirdsendController extends HomeBaseController
161 asort($money_list); 162 asort($money_list);
162 $k = 0; 163 $k = 0;
163 foreach ($money_list as $mok => $mov) { 164 foreach ($money_list as $mok => $mov) {
  165 + $else_changeList[] = $mok;
164 if ($k < 3) { 166 if ($k < 3) {
165 $fin_list[$k]['id'] = $mok; 167 $fin_list[$k]['id'] = $mok;
166 $fin_list[$k]['money'] = $mov; 168 $fin_list[$k]['money'] = $mov;
@@ -168,61 +170,281 @@ class ThirdsendController extends HomeBaseController @@ -168,61 +170,281 @@ class ThirdsendController extends HomeBaseController
168 } 170 }
169 $k += 1; 171 $k += 1;
170 } 172 }
171 - $ag_id = implode(',', $fin_arr);  
172 - $userSave_status['status'] = 5;  
173 - $agencySave_status['status'] = 4;  
174 - 173 + if($agen_arr){
  174 + if(!in_array($agen_arr[0]['id'],$fin_arr)){
  175 +// 品牌中介不在取出三个最低价中
  176 + $middle_agen[0] = $agen_arr[0]['id'];
  177 + $get_list = array_merge($fin_arr,$middle_agen);
  178 + }else{
  179 + $get_list = $fin_arr;
  180 + }
  181 + }
  182 + foreach ($else_changeList as $getk=>$getv){
  183 + if(in_array($getv,$get_list)){
  184 + $change_final['id'] = $getv;
  185 + $change_final['status'] = 4;
  186 + }else{
  187 + $change_final['id'] = $getv;
  188 + $change_final['status'] = 3;
  189 + }
  190 + $agencyModel = new AgencyModel();
  191 + $fianl_AgsaveFirst = $agencyModel->isUpdate(true)->save($change_final);
  192 + if(!$fianl_AgsaveFirst){
  193 + Db::rollback();
  194 + }
  195 + }
  196 +// 报价成功,更改状态
  197 + $userSave_statusFirst['id'] = $uNeedv['id'];
  198 + $userSave_statusFirst['status'] = 5;
  199 + $userSave_statusFirst['choose_time'] = time();
  200 + $userNeedModel = new UserNeedModel();
  201 + $fianl_Ussave = $userNeedModel->isUpdate(true)->save($userSave_statusFirst);
  202 + if(!$fianl_Ussave){
  203 + Db::rollback();
  204 + }
175 } else { 205 } else {
176 // 报价小于3人,更改订单状态,报价失败 206 // 报价小于3人,更改订单状态,报价失败
  207 + foreach ($agency_list as $changeka=>$changeva){
  208 + $change_final['id'] = $changeva['id'];
  209 + $change_final['status'] = 7;
  210 + $agencyModel = new AgencyModel();
  211 + $fianl_AgsaveNext = $agencyModel->isUpdate(true)->save($change_final);
  212 + if(!$fianl_AgsaveNext){
  213 + Db::rollback();
  214 + }
  215 +// 退回中介保证金
  216 + $add_a['user_id'] = $changeva['agency_id'];
  217 + $add_a['title'] = '报价人数不足';
  218 + $add_a['type'] = 1;
  219 + $add_a['money'] = $changeva['deposit'];
  220 + $add_a['create_time'] = time();
  221 + $add_a['update_time'] = time();
  222 + $amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
  223 + if (!$amoney_id) {
  224 + Db::rollback();
  225 + }
  226 +// 用户表增加金额
  227 + $where_member['type'] = 2;
  228 + $where_member['id'] = $changeva['agency_id'];
  229 + $add_money = Db::name('Member')->where($where_member)->setInc('money',$changeva['deposit']);
  230 + if (!$add_money) {
  231 + Db::rollback();
  232 + }
  233 +
  234 + }
  235 + $userSave_status['id'] = $uNeedv['id'];
177 $userSave_status['status'] = 4; 236 $userSave_status['status'] = 4;
178 - $agencySave_status['status'] = 7; 237 + $userNeedModel = new UserNeedModel();
  238 + $fianl_Ussave = $userNeedModel->isUpdate(true)->save($userSave_status);
  239 + if(!$fianl_Ussave){
  240 + Db::rollback();
  241 + }
  242 +
  243 +// 退回保证金
  244 +// 用户
  245 +// 加用户金额明细表
  246 + $add_del['need_id'] = $uNeedv['id'];
  247 + $add_del['user_id'] = $uNeedv['user_id'];
  248 + $add_del['title'] = '报价人数不足';
  249 + $add_del['type'] = 1;
  250 + $add_del['money'] = $uNeedv['pay_money'];
  251 + $add_del['create_time'] = time();
  252 + $add_del['update_time'] = time();
  253 + $umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
  254 + if (!$umoney_id) {
  255 + Db::rollback();
  256 + }
  257 + $where_memberNext['type'] = 1;
  258 + $where_memberNext['id'] = $uNeedv['user_id'];
  259 + $add_moneyNext = Db::name('Member')->where($where_memberNext)->setInc('money',$uNeedv['pay_money']);
  260 + if (!$add_moneyNext) {
  261 + Db::rollback();
  262 + }
  263 +
179 } 264 }
180 } else { 265 } else {
181 // 没有报价 266 // 没有报价
  267 + $userSave_status['id'] = $uNeedv['id'];
182 $userSave_status['status'] = 4; 268 $userSave_status['status'] = 4;
183 - $agencySave_status['status'] = 7; 269 + $userNeedModel = new UserNeedModel();
  270 + $fianl_Ussave = $userNeedModel->isUpdate(true)->save($userSave_status);
  271 + if(!$fianl_Ussave){
  272 + Db::rollback();
  273 + }
  274 +
  275 +// 退回保证金
  276 +// 用户
  277 +// 加用户金额明细表
  278 + $add_del['need_id'] = $uNeedv['id'];
  279 + $add_del['user_id'] = $uNeedv['user_id'];
  280 + $add_del['title'] = '报价人数不足';
  281 + $add_del['type'] = 1;
  282 + $add_del['money'] = $uNeedv['pay_money'];
  283 + $add_del['create_time'] = time();
  284 + $add_del['update_time'] = time();
  285 + $umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
  286 + if (!$umoney_id) {
  287 + Db::rollback();
  288 + }
  289 + $where_memberNext['type'] = 1;
  290 + $where_memberNext['id'] = $uNeedv['user_id'];
  291 + $add_moneyNext = Db::name('Member')->where($where_memberNext)->setInc('money',$uNeedv['pay_money']);
  292 + if (!$add_moneyNext) {
  293 + Db::rollback();
  294 + }
184 295
185 } 296 }
186 - $us_id = implode(',', $us_middleid);  
187 // 插入数据库 297 // 插入数据库
188 // 用户需求表 298 // 用户需求表
189 - $where_us['id'] = array('in', $us_id);  
190 - $fianl_Ussave = Db::name('UserNeed')->where($where_us)->update($userSave_status);  
191 - if(!$fianl_Ussave){  
192 - Db::rollback();  
193 - } 299 +// $userNeedModel = new UserNeedModel();
  300 +// foreach ($userSave_status as $fck=>$fcv){
  301 +// $fianl_Ussave = $userNeedModel->isUpdate(true)->save($fcv);
  302 +// if(!$fianl_Ussave){
  303 +// Db::rollback();
  304 +// }
  305 +// }
194 // 中介报价表 306 // 中介报价表
195 - $where_ag['id'] = array('in', $ag_id);  
196 - $fianl_Agsave = Db::name('Agency')->where($where_ag)->update($agencySave_status);  
197 - if(!$fianl_Agsave){  
198 - Db::rollback();  
199 - }else{  
200 - Db::commit();  
201 - }  
202 - 307 + Db::commit();
203 } 308 }
204 309
205 } 310 }
206 } 311 }
207 312
208 -// 三天用户选择 313 +// 三天用户选择(sure)(天执行)
209 public function userChoose(){ 314 public function userChoose(){
210 Db::startTrans(); 315 Db::startTrans();
211 // 查询用户发布需求信息 316 // 查询用户发布需求信息
212 - $where_need['status'] = 2;  
213 - $userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time')->select()->toArray(); 317 + $where_need['status'] = 5;
  318 + $userNeedList = Db::name('UserNeed')->where($where_need)->field('id,choose_time,user_id,pay_money,choose_time')->select()->toArray();
  319 + if($userNeedList){
  320 + foreach ($userNeedList as $needk=>$needv) {
  321 + if (time() >= ($needv['choose_time'] + 259200)) {
  322 + $where_agency['need_id'] = $needv['id'];
  323 + $where_agency['status'] = 4;
  324 + $agency_list = Db::name('Agency')->where($where_agency)->select()->toArray();
  325 + if ($agency_list) {
  326 + $where_agencyUpdate['need_id'] = $needv['id'];
  327 + $where_agencyUpdate['status'] = 4;
  328 + $agency_save['status'] = 8;
  329 + $agency_save['update_time'] = time();
  330 + $agency_result = Db::name('Agency')->where($where_agencyUpdate)->update($agency_save);
  331 + if (!$agency_result) {
  332 + Db::rollback();
  333 + }
  334 + }
  335 + $where_needUpdate['id'] = $needv['id'];
  336 + $needUpdate['status'] = 6;
  337 + $need_result = Db::name('UserNeed')->where($where_needUpdate)->update($needUpdate);
  338 + if (!$need_result) {
  339 + Db::rollback();
  340 + } else {
  341 +// 加用户金额明细表
  342 + $add_del['need_id'] = $needv['id'];
  343 + $add_del['user_id'] = $needv['user_id'];
  344 + $add_del['title'] = '未选择中介';
  345 + $add_del['type'] = 2;
  346 + $add_del['money'] = $needv['pay_money'];
  347 + $add_del['create_time'] = time();
  348 + $add_del['update_time'] = time();
  349 + $umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
  350 + if (!$umoney_id) {
  351 + Db::rollback();
  352 + }
  353 +// 中介金额明细表
  354 + foreach ($agency_list as $agenk=>$agenv){
  355 + $add_a['ag_id'] = $agenv['id'];
  356 + $add_a['user_id'] = $agenv['agency_id'];
  357 + $add_a['title'] = '用户未选择中介';
  358 + $add_a['type'] = 1;
  359 + $add_a['money'] = $agenv['deposit'];
  360 + $add_a['create_time'] = time();
  361 + $add_a['update_time'] = time();
  362 + $amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
  363 + if (!$amoney_id) {
  364 + Db::rollback();
  365 + }
  366 + $where_member['type'] = 2;
  367 + $where_member['id'] = $agenv['agency_id'];
  368 + $add_money = Db::name('Member')->where($where_member)->setInc('money',$agenv['deposit']);
  369 + if (!$add_money) {
  370 + Db::rollback();
  371 + }
  372 + }
214 373
  374 + }
  375 + }
  376 + }
  377 + }
  378 + Db::commit();
215 379
216 380
217 } 381 }
218 382
219 383
220 -  
221 -  
222 // 三天中介确认 384 // 三天中介确认
223 - public function intermediaryChoose(){  
224 -  
225 - } 385 + public function intermediaryChoose(){
  386 + Db::startTrans();
  387 + $where_need['status'] = 7;
  388 + $need_list = Db::name('UserNeed')->where($where_need)->field('id,choose_time')->select()->toArray();
  389 + if($need_list){
  390 + foreach ($need_list as $needk=>$needv){
  391 + if(time() >= ($needv['choose_time']+259200)){
  392 + $where_agency['status'] = 5;
  393 + $where_agency['need_id'] = $needv['id'];
  394 + $agency = Db::name('Agency')->where($where_agency)->find();
  395 +// 修改中介报价状态
  396 + if($agency){
  397 + $where_changeAgency['id'] = $agency['id'];
  398 + $changeAgency['status'] = 10;
  399 + $changeAgency['update_time'] = time();
  400 + $update_a = Db::name('Agency')->where($where_changeAgency)->update($changeAgency);
  401 + if(!$update_a){
  402 + Db::rollback();
  403 + }
  404 + }
  405 +// 增加中介保证金变化
  406 + $add_a['ag_id'] = $agency['id'];
  407 + $add_a['user_id'] = $agency['agency_id'];
  408 + $add_a['title'] = '中介未确认';
  409 + $add_a['type'] = 2;
  410 + $add_a['money'] = $agency['deposit'];
  411 + $add_a['create_time'] = time();
  412 + $add_a['update_time'] = time();
  413 + $amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
  414 + if (!$amoney_id) {
  415 + Db::rollback();
  416 + }
  417 +// 修改用户需求状态
  418 + $where_needChange['id'] = $needv['id'];
  419 + $update_need['status'] = 8;
  420 + $update_need['update_time'] = time();
  421 + $change_needFinal = Db::name('UserNeed')->where($where_needChange)->update($update_need);
  422 + if (!$change_needFinal) {
  423 + Db::rollback();
  424 + }
  425 +// 增加用户保证金,余额
  426 + $add_del['need_id'] = $needv['id'];
  427 + $add_del['user_id'] = $needv['user_id'];
  428 + $add_del['title'] = '中介未确认';
  429 + $add_del['type'] = 1;
  430 + $add_del['money'] = $needv['pay_money'];
  431 + $add_del['create_time'] = time();
  432 + $add_del['update_time'] = time();
  433 + $umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
  434 + if (!$umoney_id) {
  435 + Db::rollback();
  436 + }
  437 + $where_member['type'] = 1;
  438 + $where_member['id'] = $needv['user_id'];
  439 + $add_money = Db::name('Member')->where($where_member)->setInc('money',$needv['pay_money']);
  440 + if (!$add_money) {
  441 + Db::rollback();
  442 + }
  443 + }
  444 + }
  445 + Db::commit();
  446 + }
  447 + }
226 448
227 449
228 450
@@ -20,6 +20,7 @@ use think\Config; @@ -20,6 +20,7 @@ use think\Config;
20 use think\captcha\Captcha; 20 use think\captcha\Captcha;
21 use think\Url; 21 use think\Url;
22 use SmsDemo; 22 use SmsDemo;
  23 +use think\Session;
23 //use think\Route; 24 //use think\Route;
24 /** 25 /**
25 * @title 用户接口 26 * @title 用户接口
@@ -36,24 +37,67 @@ class UserController extends CommonController @@ -36,24 +37,67 @@ class UserController extends CommonController
36 $this->postModel = $postModel; 37 $this->postModel = $postModel;
37 } 38 }
38 39
  40 +
  41 +
39 // 验证码图片 42 // 验证码图片
40 public function getImgUrl($id = "") 43 public function getImgUrl($id = "")
41 { 44 {
42 - \think\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index"); 45 + \think\Route::get('captcha/[:id]/rand/[:rand]', "\\think\\captcha\\CaptchaController@index");
43 \think\Validate::extend('captcha', function ($value, $id = "") { 46 \think\Validate::extend('captcha', function ($value, $id = "") {
44 return captcha_check($value, $id, (array)\think\Config::get('captcha')); 47 return captcha_check($value, $id, (array)\think\Config::get('captcha'));
45 }); 48 });
46 49
47 $middle_url = \think\Url::build('/captcha/new' . ($id ? "/{$id}" : '')); 50 $middle_url = \think\Url::build('/captcha/new' . ($id ? "/{$id}" : ''));
  51 +
  52 +
  53 + return cmf_get_image_url($middle_url);
  54 +// $rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
  55 +// $imgUrl = $middle_url."&time=".$rand;
  56 +// return cmf_get_image_url($imgUrl);
  57 +// return $id;
  58 + }
  59 +
  60 +public function a(){
  61 + $true = $this->request->param();
  62 +// $session = $this->request->session();
  63 + if(!empty($true['code'])){
  64 + session_start();
  65 + $result = cmf_captcha_check($true['code']);
  66 + if(!$result) {
  67 + $this->apiResponse('0','验证码错误',$result);
  68 + }
  69 + }else{
  70 + session_start();
48 $rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999); 71 $rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
49 - $imgUrl = $middle_url."&time=".$rand;  
50 - return $imgUrl; 72 + $img = $this->getImgUrl();
  73 +// $cc = file_get_contents($img);
  74 + $cc = $this->curl($img);
  75 + echo "<pre/>";
  76 + print_r($cc);
  77 + die;
  78 +// cmf_captcha_check($true['code']);
  79 +
  80 + $html = "<img src='".$img."'>";
  81 +// $key = $this->authcode($this->seKey);
  82 +// $secode = Session::get($key, '');
  83 +// echo "<pre/>";
  84 +//// print_r($img);
  85 +// print_r($html);
  86 +// print_r($_SESSION);
  87 +// die;
  88 + }
  89 +}
  90 + private function authcode($str)
  91 + {
  92 + $key = substr(md5('ThinkPHP.CN'), 5, 8);
  93 + $str = substr(md5($str), 8, 10);
  94 + return md5($key . $str);
51 } 95 }
52 96
53 97
54 98
55 /** 99 /**
56 - * @title 获取短信验证码(sure1) 100 + * @title 获取短信验证码(sure)
57 * @description 接口说明 101 * @description 接口说明
58 * @author 开发者 102 * @author 开发者
59 * @url /api/portal/User/getSmsResult 103 * @url /api/portal/User/getSmsResult
@@ -235,6 +279,7 @@ class UserController extends CommonController @@ -235,6 +279,7 @@ class UserController extends CommonController
235 */ 279 */
236 // 登录 280 // 登录
237 public function login(Request $request){ 281 public function login(Request $request){
  282 +
238 if($request->post() && $request->Post('tel')){ 283 if($request->post() && $request->Post('tel')){
239 // 登录验证 284 // 登录验证
240 // 判空 285 // 判空
@@ -251,11 +296,11 @@ class UserController extends CommonController @@ -251,11 +296,11 @@ class UserController extends CommonController
251 } 296 }
252 // 验证 297 // 验证
253 // 验证码 298 // 验证码
254 - session_start();  
255 - $result = cmf_captcha_check($true);  
256 - if(!$result) {  
257 - $this->apiResponse('0','验证码错误');  
258 - } 299 +// session_start();
  300 +// $result = cmf_captcha_check($true);
  301 +// if(!$result) {
  302 +// $this->apiResponse('0','验证码错误',$result);
  303 +// }
259 // 手机、密码 304 // 手机、密码
260 $memberModel = new MemberModel(); 305 $memberModel = new MemberModel();
261 $where_member['tel'] = $tel; 306 $where_member['tel'] = $tel;
@@ -281,10 +326,16 @@ class UserController extends CommonController @@ -281,10 +326,16 @@ class UserController extends CommonController
281 } 326 }
282 }else{ 327 }else{
283 // 返回验证码图片 328 // 返回验证码图片
  329 + session_start();
  330 + header("ACCESS-CONTROL-ALLOW-ORIGIN:http://localhost");
284 $img = $this->getImgUrl(); 331 $img = $this->getImgUrl();
  332 + $a = Request::instance()->header();
  333 +echo "<pre/>";
  334 +print_r($a);
  335 +die;
285 $this->apiResponse('1','成功',$img); 336 $this->apiResponse('1','成功',$img);
286 } 337 }
287 - } 338 +}
288 339
289 340
290 /** 341 /**
@@ -293,7 +344,6 @@ class UserController extends CommonController @@ -293,7 +344,6 @@ class UserController extends CommonController
293 * @author 开发者 344 * @author 开发者
294 * @url /api/portal/User/outLogin 345 * @url /api/portal/User/outLogin
295 * @method POST 346 * @method POST
296 - * @param name:user_id type:int require:1 default: other: desc:user_id  
297 * @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:2 347 * @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:2
298 * @param name:token type:int require:1 default: other: desc:token 348 * @param name:token type:int require:1 default: other: desc:token
299 */ 349 */
@@ -302,12 +352,11 @@ class UserController extends CommonController @@ -302,12 +352,11 @@ class UserController extends CommonController
302 // 重置token 352 // 重置token
303 $str = rand(1000,9999).time().rand(100,999); 353 $str = rand(1000,9999).time().rand(100,999);
304 $change['token'] = $this->md5($str); 354 $change['token'] = $this->md5($str);
305 - $where_member['id'] = $request->param('user_id');  
306 $where_member['token'] = $request->param('token'); 355 $where_member['token'] = $request->param('token');
307 $model = new MemberModel(); 356 $model = new MemberModel();
308 $member = $model->where($where_member)->find(); 357 $member = $model->where($where_member)->find();
309 if($member){ 358 if($member){
310 - $where_change['id'] = $request->param('user_id'); 359 + $where_change['id'] = $member['id'];
311 // $update = $model->isUpdate(true)->allowField(true)->save($change); 360 // $update = $model->isUpdate(true)->allowField(true)->save($change);
312 $change['update_time'] = time(); 361 $change['update_time'] = time();
313 $update = $model->where($where_change)->update($change); 362 $update = $model->where($where_change)->update($change);
@@ -353,7 +402,7 @@ class UserController extends CommonController @@ -353,7 +402,7 @@ class UserController extends CommonController
353 } 402 }
354 403
355 /** 404 /**
356 - * @title 用户修改手机号(第二步) 405 + * @title 用户修改手机号(第二步)(sure)
357 * @description 接口说明 406 * @description 接口说明
358 * @author 开发者 407 * @author 开发者
359 * @url /api/portal/User/changetTelNext 408 * @url /api/portal/User/changetTelNext
@@ -397,7 +446,7 @@ class UserController extends CommonController @@ -397,7 +446,7 @@ class UserController extends CommonController
397 446
398 447
399 /** 448 /**
400 - * @title 用户修改密码 449 + * @title 用户修改密码(sure)
401 * @description 接口说明 450 * @description 接口说明
402 * @author 开发者 451 * @author 开发者
403 * @url /api/portal/User/changePassword 452 * @url /api/portal/User/changePassword
@@ -421,7 +470,7 @@ class UserController extends CommonController @@ -421,7 +470,7 @@ class UserController extends CommonController
421 $this->apiResponse('0','请输入确认新密码'); 470 $this->apiResponse('0','请输入确认新密码');
422 } 471 }
423 $where_member['password'] = $this->md5($data['password']); 472 $where_member['password'] = $this->md5($data['password']);
424 - $where_member['id'] = $data['user_id']; 473 + $where_member['token'] = $data['token'];
425 $user_id = Db::name('Member')->where($where_member)->field('id')->find(); 474 $user_id = Db::name('Member')->where($where_member)->field('id')->find();
426 if($user_id){ 475 if($user_id){
427 if($data['newPassword'] == $data['sureNewPassword']){ 476 if($data['newPassword'] == $data['sureNewPassword']){
@@ -431,7 +480,8 @@ class UserController extends CommonController @@ -431,7 +480,8 @@ class UserController extends CommonController
431 $update['password'] = $this->md5($data['newPassword']); 480 $update['password'] = $this->md5($data['newPassword']);
432 $is_update = Db::name('Member')->where($where_update)->update($update); 481 $is_update = Db::name('Member')->where($where_update)->update($update);
433 if($is_update){ 482 if($is_update){
434 - $this->apiResponse('1','成功',$update['token']); 483 + $final['token'] = $update['token'];
  484 + $this->apiResponse('1','成功',$final);
435 }else{ 485 }else{
436 $this->apiResponse('0','修改失败'); 486 $this->apiResponse('0','修改失败');
437 } 487 }
@@ -445,7 +495,7 @@ class UserController extends CommonController @@ -445,7 +495,7 @@ class UserController extends CommonController
445 495
446 496
447 /** 497 /**
448 - * @title 密码找回 498 + * @title 密码找回(sure)
449 * @description 接口说明 499 * @description 接口说明
450 * @author 开发者 500 * @author 开发者
451 * @url /api/portal/User/findPassword 501 * @url /api/portal/User/findPassword
@@ -512,7 +562,7 @@ class UserController extends CommonController @@ -512,7 +562,7 @@ class UserController extends CommonController
512 562
513 563
514 /** 564 /**
515 - * @title 绑定银行卡 565 + * @title 绑定银行卡(sure)
516 * @description 接口说明 566 * @description 接口说明
517 * @author 开发者 567 * @author 开发者
518 * @url /api/portal/User/myCard 568 * @url /api/portal/User/myCard
@@ -520,37 +570,105 @@ class UserController extends CommonController @@ -520,37 +570,105 @@ class UserController extends CommonController
520 * @param name:token type:int require:1 default: other: desc:token 570 * @param name:token type:int require:1 default: other: desc:token
521 * @param name:card_name type:int require:1 default: other: desc:银行名称 571 * @param name:card_name type:int require:1 default: other: desc:银行名称
522 * @param name:card_num type:int require:1 default: other: desc:银行卡号 572 * @param name:card_num type:int require:1 default: other: desc:银行卡号
  573 + * @param name:code type:int require:1 default: other: desc:短信验证码
523 */ 574 */
524 public function myCard(Request $request){ 575 public function myCard(Request $request){
525 $data = $request->param(); 576 $data = $request->param();
526 - $where_member['token'] = $data['token'];  
527 - $where_member['status'] = 1;  
528 - $member = Db::name('Member')->where($where_member)->field('id,name,tel')->find(); 577 + $user = $this->myleft($data['token']);
  578 +// $where_member['token'] = $data['token'];
  579 +// $where_member['status'] = 1;
  580 +// $member = Db::name('Member')->where($where_member)->field('id,name,tel')->find();
529 if(!empty($data['card_num'])){ 581 if(!empty($data['card_num'])){
530 // 验证码 582 // 验证码
531 $where_code['type'] = 5; 583 $where_code['type'] = 5;
  584 + $where_code['status'] = 1;
  585 + $where_code['tel'] = $user['tel'];
532 $code = Db::name('Code')->where($where_code)->order('create_time desc')->limit(1)->find(); 586 $code = Db::name('Code')->where($where_code)->order('create_time desc')->limit(1)->find();
533 - if($code != $data['code']){ 587 + if(!$code){
  588 + $this->apiResponse('0','请先获取验证码');
  589 + }
  590 + if($code['code'] != $data['code']){
534 $this->apiResponse('0','验证码错误'); 591 $this->apiResponse('0','验证码错误');
535 } 592 }
  593 +// $where_findC['card_num'] = $data['card_num'];
  594 + $where_findC['user_id'] = $user['id'];
  595 + $where_findC['status'] = 1;
  596 + $is_issetCard = Db::name('Card')->where($where_findC)->find();
  597 + if($is_issetCard){
  598 + $this->apiResponse('0','您已绑定银行卡');
  599 + }
536 $add['card_name'] = $data['card_name']; 600 $add['card_name'] = $data['card_name'];
537 $add['card_num'] = $data['card_num']; 601 $add['card_num'] = $data['card_num'];
538 $add['create_time'] = time(); 602 $add['create_time'] = time();
539 $add['update_time'] = time(); 603 $add['update_time'] = time();
540 - $add['user_id'] = $member['id']; 604 + $add['user_id'] = $user['id'];
541 $add_final = Db::name('Card')->insertGetId($add); 605 $add_final = Db::name('Card')->insertGetId($add);
542 if($add_final){ 606 if($add_final){
543 - $this->apiResponse('1','成功',$add_final); 607 + $final['card_id'] = $add_final;
  608 + $this->apiResponse('1','成功',$final);
  609 + }else{
  610 + $this->apiResponse('0','添加失败');
  611 + }
  612 + }else{
  613 + $this->apiResponse('1','成功',$user);
  614 + }
  615 + }
  616 +
  617 + /**
  618 + * @title 修改绑定银行卡(sure)
  619 + * @description 接口说明
  620 + * @author 开发者
  621 + * @url /api/portal/User/changeMyCard
  622 + * @method POST
  623 + * @param name:token type:int require:1 default: other: desc:token
  624 + * @param name:card_id type:int require:1 default: other: desc:银行卡id
  625 + * @param name:card_name type:int require:1 default: other: desc:银行名称
  626 + * @param name:card_num type:int require:1 default: other: desc:银行卡号
  627 + * @param name:code type:int require:1 default: other: desc:短信验证码
  628 + */
  629 + public function changeMyCard(Request $request){
  630 + $data = $request->param();
  631 + $user = $this->myleft($data['token']);
  632 + if(empty($data['card_id'])){
  633 + $this->apiResponse('0','银行卡id不能为空');
  634 + }
  635 + if(!empty($data['card_name'])){
  636 + // 验证码
  637 + $where_code['type'] = 5;
  638 + $where_code['status'] = 1;
  639 + $where_code['tel'] = $user['tel'];
  640 + $code = Db::name('Code')->where($where_code)->order('create_time desc')->limit(1)->find();
  641 + if(!$code){
  642 + $this->apiResponse('0','请先获取验证码');
  643 + }
  644 + if($code['code'] != $data['code']){
  645 + $this->apiResponse('0','验证码错误');
  646 + }
  647 + $where_add['id'] = $data['card_id'];
  648 + $add['card_name'] = $data['card_name'];
  649 + $add['card_num'] = $data['card_num'];
  650 + $add['update_time'] = time();
  651 + $add_final = Db::name('Card')->where($where_add)->update($add);
  652 + if($add_final){
  653 + $final['card_id'] = $add_final;
  654 + $this->apiResponse('1','成功',$final);
544 }else{ 655 }else{
545 $this->apiResponse('0','添加失败'); 656 $this->apiResponse('0','添加失败');
546 } 657 }
  658 +
547 }else{ 659 }else{
548 - $this->apiResponse('1','成功',$member); 660 + $where_cardFirst['id'] = $data['card_id'];
  661 + $cardFind = Db::name('Card')->where($where_cardFirst)->find();
  662 + if($cardFind){
  663 + $this->apiResponse('1','成功',$cardFind);
  664 + }else{
  665 + $this->apiResponse('0','信息查询失败');
  666 + }
549 } 667 }
550 } 668 }
551 669
552 /** 670 /**
553 - * @title 银行卡解除绑定 671 + * @title 银行卡解除绑定(sure)
554 * @description 接口说明 672 * @description 接口说明
555 * @author 开发者 673 * @author 开发者
556 * @url /api/portal/User/delMyCard 674 * @url /api/portal/User/delMyCard
@@ -586,7 +704,7 @@ class UserController extends CommonController @@ -586,7 +704,7 @@ class UserController extends CommonController
586 704
587 705
588 /** 706 /**
589 - * @title 用户个人中心首页(over) 707 + * @title 用户个人中心首页(sure)
590 * @description 接口说明 708 * @description 接口说明
591 * @author 开发者 709 * @author 开发者
592 * @url /api/portal/User/myIndex 710 * @url /api/portal/User/myIndex
@@ -622,7 +740,7 @@ class UserController extends CommonController @@ -622,7 +740,7 @@ class UserController extends CommonController
622 public function myleft($token){ 740 public function myleft($token){
623 $where_member['token'] = $token; 741 $where_member['token'] = $token;
624 $where_member['status'] = 1; 742 $where_member['status'] = 1;
625 - $member = Db::name('Member')->where($where_member)->field('tel,id,name,referee_tel')->find(); 743 + $member = Db::name('Member')->where($where_member)->field('tel,id,name,referee_tel,money,get_money')->find();
626 if(!$member){ 744 if(!$member){
627 $this->apiResponse('0','用户信息错误'); 745 $this->apiResponse('0','用户信息错误');
628 } 746 }
@@ -632,10 +750,10 @@ class UserController extends CommonController @@ -632,10 +750,10 @@ class UserController extends CommonController
632 750
633 751
634 /** 752 /**
635 - * @title 用户个人中心我的比价/比价详情(over 753 + * @title 用户个人中心我的比价/比价详情(sure
636 * @description 接口说明 754 * @description 接口说明
637 * @author 开发者 755 * @author 开发者
638 - * @url /api/portal/User/myIndex 756 + * @url /api/portal/User/myNeed
639 * @method POST 757 * @method POST
640 * @param name:token type:int require:1 default: other: desc:token 758 * @param name:token type:int require:1 default: other: desc:token
641 * @return data:''@ 759 * @return data:''@
@@ -658,8 +776,12 @@ class UserController extends CommonController @@ -658,8 +776,12 @@ class UserController extends CommonController
658 } 776 }
659 777
660 778
  779 +
  780 +
  781 +
  782 +
661 /** 783 /**
662 - * @title 我的比价明细 784 + * @title 我的比价明细(sure)
663 * @description 接口说明 785 * @description 接口说明
664 * @author 开发者 786 * @author 开发者
665 * @url /api/portal/User/compareDetail 787 * @url /api/portal/User/compareDetail
@@ -671,20 +793,23 @@ class UserController extends CommonController @@ -671,20 +793,23 @@ class UserController extends CommonController
671 $token = $request->param('token'); 793 $token = $request->param('token');
672 $member = $this->myleft($token); 794 $member = $this->myleft($token);
673 $data = $request->param(); 795 $data = $request->param();
  796 + if(empty($data['need_id'])){
  797 + $this->apiResponse('0','需求id不能为空');
  798 + }
674 $where_need['id'] = $data['need_id']; 799 $where_need['id'] = $data['need_id'];
675 $where_need['user_id'] = $member['id']; 800 $where_need['user_id'] = $member['id'];
676 $where_need['status'] = 5; 801 $where_need['status'] = 5;
677 - $userNeed = Db::name('UserNeed')->where($where_need)->find(); 802 + $userNeed = Db::name('UserNeed')->where($where_need)->field("id as need_id,city,quarters,room,pay_money,create_time,choose_time,status")->find();
678 $final['need'] = $userNeed; 803 $final['need'] = $userNeed;
679 $final['user'] = $member; 804 $final['user'] = $member;
680 if($userNeed){ 805 if($userNeed){
681 // 查询报价 806 // 查询报价
682 - $where_agency['need_id'] = $data['need_id'];  
683 - $where_agency['status'] = 4; 807 + $where_agency['a.need_id'] = $data['need_id'];
  808 + $where_agency['a.status'] = 4;
684 $agency = Db::name('Agency')->alias('a') 809 $agency = Db::name('Agency')->alias('a')
685 ->where($where_agency) 810 ->where($where_agency)
686 ->join("hp_Member m", 'm.id = a.agency_id') 811 ->join("hp_Member m", 'm.id = a.agency_id')
687 - ->field('a.*,a.id as agency_id, 812 + ->field('a.*,a.id as intermediary_id,
688 m.id as user_id,m.name,m.company,m.store,m.tel,m.reputation,m.start') 813 m.id as user_id,m.name,m.company,m.store,m.tel,m.reputation,m.start')
689 ->select()->toArray(); 814 ->select()->toArray();
690 if($agency){ 815 if($agency){
@@ -707,7 +832,6 @@ class UserController extends CommonController @@ -707,7 +832,6 @@ class UserController extends CommonController
707 * @url /api/portal/User/myMes 832 * @url /api/portal/User/myMes
708 * @method POST 833 * @method POST
709 * @param name:token type:int require:1 default: other: desc:token 834 * @param name:token type:int require:1 default: other: desc:token
710 - * @return data:''@  
711 */ 835 */
712 public function myMes(Request $request){ 836 public function myMes(Request $request){
713 $data = $request->param(); 837 $data = $request->param();
@@ -718,9 +842,10 @@ class UserController extends CommonController @@ -718,9 +842,10 @@ class UserController extends CommonController
718 foreach ($card as $cardk=>$cardv){ 842 foreach ($card as $cardk=>$cardv){
719 $card[$cardk]['user_name'] = $user['name']; 843 $card[$cardk]['user_name'] = $user['name'];
720 } 844 }
721 - $final['card'] = $card;  
722 - $final['user'] = $user;  
723 - if($card){ 845 + $final = array();
  846 + $final['card'] = $card?$card:array();
  847 + $final['user'] = $user?$user:array();
  848 + if($final){
724 $this->apiResponse('1','成功',$final); 849 $this->apiResponse('1','成功',$final);
725 }else{ 850 }else{
726 $this->apiResponse('0','失败'); 851 $this->apiResponse('0','失败');
@@ -730,32 +855,32 @@ class UserController extends CommonController @@ -730,32 +855,32 @@ class UserController extends CommonController
730 855
731 856
732 /** 857 /**
733 - * @title 确认成交 858 + * @title 确认成交(sure)
734 * @description 接口说明 859 * @description 接口说明
735 * @author 开发者 860 * @author 开发者
736 * @url /api/portal/User/sureAgency 861 * @url /api/portal/User/sureAgency
737 * @method POST 862 * @method POST
738 * @param name:token type:int require:1 default: other: desc:token 863 * @param name:token type:int require:1 default: other: desc:token
739 * @param name:need_id type:int require:1 default: other: desc:需求id 864 * @param name:need_id type:int require:1 default: other: desc:需求id
740 - * @param name:agency_id type:int require:1 default: other: desc:中介报价id 865 + * @param name:intermediary_id type:int require:1 default: other: desc:中介报价id
741 * @return data:''@ 866 * @return data:''@
742 */ 867 */
743 public function sureAgency(Request $request){ 868 public function sureAgency(Request $request){
744 $data = $request->param(); 869 $data = $request->param();
745 - if(!$data['need_id'] || !$data['agency_id'] ){ 870 + if(!$data['need_id'] || !$data['intermediary_id'] ){
746 $this->apiResponse('0','参数错误'); 871 $this->apiResponse('0','参数错误');
747 } 872 }
748 $where_bid['need_id'] = $data['need_id']; 873 $where_bid['need_id'] = $data['need_id'];
749 - $where_bid['id'] = $data['agency_id']; 874 + $where_bid['id'] = $data['intermediary_id'];
750 $where_bid['status'] = 4; 875 $where_bid['status'] = 4;
751 $is_isset = Db::name('Agency')->where($where_bid)->find(); 876 $is_isset = Db::name('Agency')->where($where_bid)->find();
752 if($is_isset){ 877 if($is_isset){
753 - $where_ag['id'] = $data['agency_id']; 878 + $where_ag['id'] = $data['intermediary_id'];
754 $add['status'] = 5; 879 $add['status'] = 5;
755 $add['update_time'] = time(); 880 $add['update_time'] = time();
756 $save = Db::name('Agency')->where($where_ag)->update($add); 881 $save = Db::name('Agency')->where($where_ag)->update($add);
757 if($save){ 882 if($save){
758 - $this->apiResponse('1','操作失败'); 883 + $this->apiResponse('1','确认成功');
759 }else{ 884 }else{
760 $this->apiResponse('0','成交失败'); 885 $this->apiResponse('0','成交失败');
761 } 886 }
@@ -766,7 +891,7 @@ class UserController extends CommonController @@ -766,7 +891,7 @@ class UserController extends CommonController
766 891
767 892
768 /** 893 /**
769 - * @title 查看评价 894 + * @title 查看评价(sure)
770 * @description 接口说明 895 * @description 接口说明
771 * @author 开发者 896 * @author 开发者
772 * @url /api/portal/User/comment 897 * @url /api/portal/User/comment
@@ -779,7 +904,7 @@ class UserController extends CommonController @@ -779,7 +904,7 @@ class UserController extends CommonController
779 $where_isset['id'] = $data['agency_id']; 904 $where_isset['id'] = $data['agency_id'];
780 $agency_id = Db::name('Member')->where($where_isset)->field('id,name,pic,reputation,start')->find(); 905 $agency_id = Db::name('Member')->where($where_isset)->field('id,name,pic,reputation,start')->find();
781 if($agency_id){ 906 if($agency_id){
782 - $where_comment['c.agency_id'] = $agency_id['id']; 907 + $where_comment['c.intermediary_id'] = $agency_id['id'];
783 $where_comment['c.status'] = 1; 908 $where_comment['c.status'] = 1;
784 $comment = Db::name('Comment')->alias('c') 909 $comment = Db::name('Comment')->alias('c')
785 ->where($where_comment) 910 ->where($where_comment)
@@ -791,7 +916,9 @@ class UserController extends CommonController @@ -791,7 +916,9 @@ class UserController extends CommonController
791 $middle = str_split($cv['tel'],3); 916 $middle = str_split($cv['tel'],3);
792 $comment[$ck]['tel'] = $middle[0].'********'; 917 $comment[$ck]['tel'] = $middle[0].'********';
793 } 918 }
794 - $this->apiResponse('1','成功',$comment); 919 + $final['comment'] = $comment;
  920 + $final['agency'] = $agency_id;
  921 + $this->apiResponse('1','成功',$final);
795 }else{ 922 }else{
796 $this->apiResponse('1','暂无评价'); 923 $this->apiResponse('1','暂无评价');
797 } 924 }
@@ -801,55 +928,177 @@ class UserController extends CommonController @@ -801,55 +928,177 @@ class UserController extends CommonController
801 928
802 } 929 }
803 930
804 - 931 + /**
  932 + * @title 评价(sure)
  933 + * @description 接口说明
  934 + * @author 开发者
  935 + * @url /api/portal/User/userComment
  936 + * @method POST
  937 + * @param name:token type:int require:1 default: other: desc:token
  938 + * @param name:need_id type:int require:1 default: other: desc:需求id
  939 + * @param name:content type:int require:1 default: other: desc:评论内容
  940 + */
  941 + public function userComment(Request $request){
  942 + $data = $request->param();
  943 + if(empty($data['need_id'])){
  944 + $this->apiResponse('0','需求id不能为空');
  945 + }
  946 + if(empty($data['content'])){
  947 + $this->apiResponse('0','评论内容不能为空');
  948 + }
  949 + $where_need['status'] = 10;
  950 + $where_need['id'] = $data['need_id'];
  951 + $need = Db::name('UserNeed')->where($where_need)->find();
  952 + if($need){
  953 + $where_agency['status'] = 11;
  954 + $where_agency['need_id'] = $need['id'];
  955 + $agency = Db::name('Agency')->where($where_agency)->find();
  956 + if($agency){
  957 + $add['need_id'] = $need['id'];
  958 + $add['agency_id'] = $agency['id'];
  959 + $add['intermediary_id'] = $agency['agency_id'];
  960 + $add['user_id'] = $need['user_id'];
  961 + $add['content'] = $data['content'];
  962 + $add['create_time'] = time();
  963 + $add['update_time'] = time();
  964 + $add_result = Db::name('Comment')->insertGetId($add);
  965 + if($add_result){
  966 + $this->apiResponse('1','评价成功');
  967 + }else{
  968 + $this->apiResponse('0','评价失败');
  969 + }
  970 + }else{
  971 + $this->apiResponse('0','评价失败');
  972 + }
  973 + }else{
  974 + $this->apiResponse('0','评价失败');
  975 + }
  976 + }
805 977
806 978
807 /** 979 /**
808 - * @title 投诉 980 + * @title 投诉(sure)
809 * @description 接口说明 981 * @description 接口说明
810 * @author 开发者 982 * @author 开发者
811 * @url /api/portal/User/complaint 983 * @url /api/portal/User/complaint
812 * @method POST 984 * @method POST
813 * @param name:token type:int require:1 default: other: desc:token 985 * @param name:token type:int require:1 default: other: desc:token
814 * @param name:need_id type:int require:1 default: other: desc:需求id 986 * @param name:need_id type:int require:1 default: other: desc:需求id
815 - * @param name:agency_id type:int require:1 default: other: desc:中介报价id  
816 - * @param name:intermediary_id type:int require:1 default: other: desc:中介id 987 + * @param name:intermediary_id type:int require:1 default: other: desc:中介报价id
817 * @param name:content type:int require:1 default: other: desc:投诉内容 988 * @param name:content type:int require:1 default: other: desc:投诉内容
818 - * @param name:type type:int require:1 default: other: desc:1->用户投诉,2->中介投诉 989 + * @param name:gener type:int require:1 default: other: desc:1->用户投诉,2->中介投诉
819 */ 990 */
820 public function complaint(Request $request){ 991 public function complaint(Request $request){
821 $token = $request->param('token'); 992 $token = $request->param('token');
822 $member = $this->myleft($token); 993 $member = $this->myleft($token);
823 - $final['user'] = $member;  
824 $data = $request->param(); 994 $data = $request->param();
825 - $where_isset['user_id'] = $member['id'];  
826 - $where_isset['need_id'] = $data['need_id'];  
827 - $where_isset['agency_id'] = $data['agency_id'];  
828 - $where_isset['intermediary_id'] = $data['intermediary_id'];  
829 - $is_isset= Db::name('Complaint')->where($where_isset)->field('id')->find();  
830 - if($is_isset){  
831 - $this->apiResponse('0','您已投诉'); 995 + if(empty($data['gener'])){
  996 + $this->apiResponse('0','类型不能为空');
  997 + }
  998 + if(empty($data['need_id']) && empty($data['intermediary_id'])){
  999 + $this->apiResponse('0','投诉id不能为空');
  1000 + }
  1001 + $where_find['n.id'] = $data['need_id'];
  1002 + $where_find['a.id'] = $data['intermediary_id'];
  1003 + $find = Db::name('UserNeed')->alias('n')
  1004 + ->where($where_find)
  1005 + ->join("Agency a",'a.need_id = n.id')
  1006 + ->field("a.id as agency_id")
  1007 + ->find();
  1008 + if($find){
  1009 +// 查询是否已投诉
  1010 + $where_isset['user_id'] = $member['id'];
  1011 + $where_isset['need_id'] = $data['need_id'];
  1012 + $where_isset['agency_id'] = $find['agency_id'];
  1013 + $where_isset['intermediary_id'] = $data['intermediary_id'];
  1014 + $where_isset['type'] = $data['gener'];
  1015 + $where_isset['status'] = 1;
  1016 + $is_isset= Db::name('Complaint')->where($where_isset)->field('id')->find();
  1017 + if($is_isset){
  1018 + $this->apiResponse('0','您已投诉');
  1019 + }
  1020 +// 添加投诉
  1021 + $add['user_id'] = $member['id'];
  1022 + $add['need_id'] = $data['need_id'];
  1023 + $add['agency_id'] = $find['agency_id'];
  1024 + $add['intermediary_id'] = $data['intermediary_id'];
  1025 + $add['content'] = $data['content'];
  1026 + $add['type'] = $data['gener'];
  1027 + $add['create_time'] = time();
  1028 + $add['update_time'] = time();
  1029 + $is_add = Db::name('Complaint')->insertGetId($add);
  1030 + if($is_add){
  1031 + $final['complaint_id'] = $is_add;
  1032 + $this->apiResponse('1','投诉成功',$final);
  1033 + }else{
  1034 + $this->apiResponse('0','投诉失败');
  1035 + }
  1036 +
  1037 +
  1038 +
  1039 + }else{
  1040 + $this->apiResponse('0','当前状态不支持投诉');
832 } 1041 }
833 1042
834 - $add['user_id'] = $member['id'];  
835 - $add['need_id'] = $data['need_id'];  
836 1043
837 - $add['agency_id'] = $data['agency_id'];  
838 - $add['intermediary_id'] = $data['intermediary_id'];  
839 - $add['content'] = $data['content'];  
840 - $add['type'] = $data['type']; 1044 + $final['user'] = $member;
841 1045
842 - $is_add = Db::name('Complaint')->insertGetId($add);  
843 - if($is_add){  
844 - $final['complaint_id'] = $is_add;  
845 - $this->apiResponse('1','投诉成功',$final); 1046 +
  1047 + }
  1048 +
  1049 + /**
  1050 + * @title 用户、中介 提现(sure)
  1051 + * @description 接口说明
  1052 + * @author 开发者
  1053 + * @url /api/portal/User/getMoney
  1054 + * @method POST
  1055 + * @param name:token type:int require:1 default: other: desc:token
  1056 + */
  1057 + public function getMoney(Request $request){
  1058 + Db::startTrans();
  1059 + $data = $request->param();
  1060 + $where_member['token'] = $data['token'];
  1061 + $member = Db::name('Member')->where($where_member)->field('id,money')->find();
  1062 + if($member){
  1063 + $final['user'] = $member;
846 }else{ 1064 }else{
847 - $this->apiResponse('0','投诉失败'); 1065 + Db::rollback();
  1066 + $this->apiResponse('0','用户信息错误');
  1067 + }
  1068 + $where_card['user_id'] = $member['id'];
  1069 + $where_card['status'] = 1;
  1070 + $card = Db::name('Card')->where($where_card)->find();
  1071 + if(!$card){
  1072 + $this->apiResponse('0','请先绑定银行卡');
  1073 + }else{
  1074 + $final['card'] = $card;
  1075 + }
  1076 + $where_umoney['user_id'] = $member['id'];
  1077 + $where_umoney['card_id'] = $card['id'];
  1078 + $where_umoney['title'] = '用户提现';
  1079 + $where_umoney['money'] = $member['money'];
  1080 + $where_umoney['type'] = 3;
  1081 + $where_umoney['create_time'] = time();
  1082 + $where_umoney['update_time'] = time();
  1083 + $add = Db::name('UmoenyDetail')->insertGetId($where_umoney);
  1084 + if($add){
  1085 + $del = Db::name('Member')->where($where_member)->setDec('money',$member['money']);
  1086 + $inc = Db::name('Member')->where($where_member)->setInc('get_money',$member['money']);
  1087 + if($del && $inc){
  1088 + Db::commit();
  1089 + $this->apiResponse('1','提现成功');
  1090 + }else{
  1091 + Db::rollback();
  1092 + $this->apiResponse('0','提现失败');
  1093 + }
  1094 + }else{
  1095 + Db::rollback();
  1096 + $this->apiResponse('0','提现失败');
848 } 1097 }
849 } 1098 }
850 1099
851 /** 1100 /**
852 - * @title 我的账户 1101 + * @title 我的账户(sure)
853 * @description 接口说明 1102 * @description 接口说明
854 * @author 开发者 1103 * @author 开发者
855 * @url /api/portal/User/orderDetail 1104 * @url /api/portal/User/orderDetail
@@ -858,18 +1107,20 @@ class UserController extends CommonController @@ -858,18 +1107,20 @@ class UserController extends CommonController
858 */ 1107 */
859 public function orderDetail(Request $request){ 1108 public function orderDetail(Request $request){
860 $data = $request->param(); 1109 $data = $request->param();
861 - $get_msg = $this->myleft($data['token']);  
862 - $where_order['user_id'] = $get_msg['id'];  
863 - $where_order['status'] = array('neq',9);  
864 - $order_list = Db::name('UsermoneyDetail')->where($where_order)->select()->toArray(); 1110 + $user = $this->myleft($data['token']);
  1111 + $where_umoney['user_id'] = $user['id'];
  1112 + $where_umoney['status'] = 1;
  1113 + $order_list = Db::name('UmoenyDetail')->where($where_umoney)->select()->toArray();
  1114 + $final['user'] = $user;
865 if($order_list){ 1115 if($order_list){
866 - foreach ($order_list as $ok=>$ov){  
867 -  
868 - }  
869 -  
870 - 1116 + $final['detail'] = $order_list;
871 }else{ 1117 }else{
872 - $result = array(); 1118 + $final['detail'] = array();
  1119 + }
  1120 + if($final){
  1121 + $this->apiResponse('1','成功',$final);
  1122 + }else{
  1123 + $this->apiResponse('0','失败');
873 } 1124 }
874 } 1125 }
875 1126
@@ -35,7 +35,7 @@ class UserneedController extends CommonController @@ -35,7 +35,7 @@ class UserneedController extends CommonController
35 } 35 }
36 36
37 /** 37 /**
38 - * @title 用户发布需求时保证金金额(填完地区,小区调用;每次修改重新调用) 38 + * @title 用户发布需求时保证金金额(填完地区,小区调用;每次修改重新调用)(sure)
39 * @description 接口说明 39 * @description 接口说明
40 * @author 开发者 40 * @author 开发者
41 * @url /api/portal/UserNeed/payMoney 41 * @url /api/portal/UserNeed/payMoney
@@ -77,7 +77,7 @@ class UserneedController extends CommonController @@ -77,7 +77,7 @@ class UserneedController extends CommonController
77 77
78 78
79 /** 79 /**
80 - * @title 用户发布需求 80 + * @title 用户发布需求(sure)
81 * @description 接口说明 81 * @description 接口说明
82 * @author 开发者 82 * @author 开发者
83 * @url /api/portal/UserNeed/send 83 * @url /api/portal/UserNeed/send
@@ -97,7 +97,7 @@ class UserneedController extends CommonController @@ -97,7 +97,7 @@ class UserneedController extends CommonController
97 * @param name:tel type:varchar require:1 default: other: desc:联系人电话 97 * @param name:tel type:varchar require:1 default: other: desc:联系人电话
98 * @param name:code type:int require:1 default: other: desc:验证码 98 * @param name:code type:int require:1 default: other: desc:验证码
99 * @param name:else type:int require:1 default: other: desc:备注 99 * @param name:else type:int require:1 default: other: desc:备注
100 - * @param name:need_id type:int require:1 default: other:修改需求时传 desc:需求id 100 + * @param name:token type:varchar require:1 default: other: desc:token
101 * @return data:''@ 101 * @return data:''@
102 * @data type:'1->包干价,2->问答' 102 * @data type:'1->包干价,2->问答'
103 * @data need_id:'需求id' 103 * @data need_id:'需求id'
@@ -163,7 +163,8 @@ class UserneedController extends CommonController @@ -163,7 +163,8 @@ class UserneedController extends CommonController
163 $list[$lk]['content'] = htmlspecialchars_decode($lv['content']); 163 $list[$lk]['content'] = htmlspecialchars_decode($lv['content']);
164 } 164 }
165 if($list){ 165 if($list){
166 - $this->apiResponse('1','成功',$list); 166 + $final['answer'] = $list;
  167 + $this->apiResponse('1','成功',$final);
167 }else{ 168 }else{
168 $this->apiResponse('0','暂无内容'); 169 $this->apiResponse('0','暂无内容');
169 } 170 }
@@ -172,10 +173,10 @@ class UserneedController extends CommonController @@ -172,10 +173,10 @@ class UserneedController extends CommonController
172 } 173 }
173 } 174 }
174 /** 175 /**
175 - * @title 用户修改需求 176 + * @title 用户修改需求(sure)
176 * @description 接口说明 177 * @description 接口说明
177 * @author 开发者 178 * @author 开发者
178 - * @url /api/portal/UserNeed/send 179 + * @url /api/portal/UserNeed/changesend
179 * @method POST 180 * @method POST
180 * @param name:city type:varchar require:1 default: other: desc:地区(省-市-区) 181 * @param name:city type:varchar require:1 default: other: desc:地区(省-市-区)
181 * @param name:quarters type:varchar require:1 default: other: desc:小区 182 * @param name:quarters type:varchar require:1 default: other: desc:小区
@@ -193,6 +194,7 @@ class UserneedController extends CommonController @@ -193,6 +194,7 @@ class UserneedController extends CommonController
193 * @param name:code type:int require:1 default: other: desc:验证码 194 * @param name:code type:int require:1 default: other: desc:验证码
194 * @param name:else type:int require:1 default: other: desc:备注 195 * @param name:else type:int require:1 default: other: desc:备注
195 * @param name:need_id type:int require:1 default: other:修改需求时传 desc:需求id 196 * @param name:need_id type:int require:1 default: other:修改需求时传 desc:需求id
  197 + * @param name:token type:varchar require:1 default: other: desc:token
196 * @return data:''@ 198 * @return data:''@
197 * @data type:'1->包干价,2->问答' 199 * @data type:'1->包干价,2->问答'
198 * @data need_id:'需求id' 200 * @data need_id:'需求id'
@@ -239,7 +241,7 @@ class UserneedController extends CommonController @@ -239,7 +241,7 @@ class UserneedController extends CommonController
239 $model = new UserNeedModel(); 241 $model = new UserNeedModel();
240 242
241 // 修改 243 // 修改
242 - $where_need['userNeed_id'] = $request->param('need_id'); 244 + $where_need['id'] = $request->param('need_id');
243 $where_need['status'] = 1; 245 $where_need['status'] = 1;
244 $need = Db::name('UserNeed')->where($where_need)->find(); 246 $need = Db::name('UserNeed')->where($where_need)->find();
245 if(!$need){ 247 if(!$need){
@@ -252,15 +254,18 @@ class UserneedController extends CommonController @@ -252,15 +254,18 @@ class UserneedController extends CommonController
252 $save = $model->isUpdate(true)->allowField(true)->save($data); 254 $save = $model->isUpdate(true)->allowField(true)->save($data);
253 } 255 }
254 if($save){ 256 if($save){
255 - $final['need_id'] = $model->getLastInsID();;  
256 - $this->apiResponse('1','添加成功',$final); 257 + $final['need_id'] = $model->id;
  258 + $this->apiResponse('1','修改成功',$final);
257 }else{ 259 }else{
258 - $this->apiResponse('0','添加失败'); 260 + $this->apiResponse('0','修改失败');
259 } 261 }
260 262
261 263
262 }else{ 264 }else{
263 $data = $request->param(); 265 $data = $request->param();
  266 + if(empty($data['need_id'])){
  267 + $this->apiResponse('0','需求id不可為空');
  268 + }
264 $where_need['id'] = $request->param('need_id'); 269 $where_need['id'] = $request->param('need_id');
265 $where_need['status'] = 1; 270 $where_need['status'] = 1;
266 $where_mem['token'] = $data['token']; 271 $where_mem['token'] = $data['token'];
@@ -272,11 +277,13 @@ class UserneedController extends CommonController @@ -272,11 +277,13 @@ class UserneedController extends CommonController
272 } 277 }
273 // 问答内容 278 // 问答内容
274 $where_pro['status'] = 1; 279 $where_pro['status'] = 1;
275 - $list['list'] = Db::name('NeedAnswer')->where($where_pro)->order("update_time desc")->field("title,content,id,type")->select()->toArray();  
276 - foreach ($list as $lk=>$lv){  
277 - $list[$lk]['content'] = htmlspecialchars_decode($lv['content']); 280 + $answer = Db::name('NeedAnswer')->where($where_pro)->order("update_time desc")->field("title,content,id,type")->select()->toArray();
  281 + foreach ($answer as $lk=>$lv){
  282 + $answer[$lk]['content'] = htmlspecialchars_decode($lv['content']);
278 } 283 }
  284 + $list['answer'] = $answer;
279 if($list){ 285 if($list){
  286 +
280 $this->apiResponse('1','成功',$list); 287 $this->apiResponse('1','成功',$list);
281 }else{ 288 }else{
282 $this->apiResponse('0','暂无内容'); 289 $this->apiResponse('0','暂无内容');
@@ -17,7 +17,7 @@ class UserValidate extends Validate @@ -17,7 +17,7 @@ class UserValidate extends Validate
17 protected $rule = [ 17 protected $rule = [
18 'name' => ['require','length:2,4','chs'], 18 'name' => ['require','length:2,4','chs'],
19 'password' => ['require','length:6,16'], 19 'password' => ['require','length:6,16'],
20 - 'tel' => ['regex'=>'/13[123569]{1}\d{8}|15[1235689]\d{8}|18\d{9}/','require'], 20 + 'tel' => ['regex'=>'/^1(3|4|5|7|8)\d{9}$/','require'],
21 'sure_password' => 'require', 21 'sure_password' => 'require',
22 22
23 'city' => 'require', 23 'city' => 'require',
@@ -80,9 +80,14 @@ class CaptchaController @@ -80,9 +80,14 @@ class CaptchaController
80 $config = array_merge($defaultCaptchaConfig, $config); 80 $config = array_merge($defaultCaptchaConfig, $config);
81 } 81 }
82 ob_clean();//解决验证码不显示问题 82 ob_clean();//解决验证码不显示问题
  83 + $rand = $request->param('rand');
83 $captcha = new Captcha($config); 84 $captcha = new Captcha($config);
84 85
85 ob_clean();// 清除输出缓存 86 ob_clean();// 清除输出缓存
  87 +// $final_return['img'] = $captcha->entry($id,$rand);
  88 +// $final_return['rand'] = $rand;
  89 +
86 return $captcha->entry($id); 90 return $captcha->entry($id);
  91 +// return $final_return;
87 } 92 }
88 } 93 }
@@ -182,6 +182,7 @@ class Session @@ -182,6 +182,7 @@ class Session
182 $value = isset($_SESSION[$name]) ? $_SESSION[$name] : null; 182 $value = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
183 } 183 }
184 } 184 }
  185 +
185 return $value; 186 return $value;
186 } 187 }
187 188
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 11
12 namespace think\captcha; 12 namespace think\captcha;
13 13
  14 +use think\Db;
14 use think\Session; 15 use think\Session;
15 16
16 class Captcha 17 class Captcha
@@ -112,7 +113,6 @@ class Captcha @@ -112,7 +113,6 @@ class Captcha
112 if (empty($code) || empty($secode)) { 113 if (empty($code) || empty($secode)) {
113 return false; 114 return false;
114 } 115 }
115 -  
116 // session 过期 116 // session 过期
117 if (time() - $secode['verify_time'] > $this->expire) { 117 if (time() - $secode['verify_time'] > $this->expire) {
118 Session::delete($key, ''); 118 Session::delete($key, '');
@@ -126,6 +126,8 @@ class Captcha @@ -126,6 +126,8 @@ class Captcha
126 return false; 126 return false;
127 } 127 }
128 128
  129 +
  130 +
129 /** 131 /**
130 * 输出验证码并把验证码的值保存的session中 132 * 输出验证码并把验证码的值保存的session中
131 * 验证码保存到session的格式为: array('verify_code' => '验证码值', 'verify_time' => '验证码创建时间'); 133 * 验证码保存到session的格式为: array('verify_code' => '验证码值', 'verify_time' => '验证码创建时间');
@@ -199,14 +201,28 @@ class Captcha @@ -199,14 +201,28 @@ class Captcha
199 $secode['verify_code'] = $code; // 把校验码保存到session 201 $secode['verify_code'] = $code; // 把校验码保存到session
200 $secode['verify_time'] = time(); // 验证码创建时间 202 $secode['verify_time'] = time(); // 验证码创建时间
201 Session::set($key . $id, $secode, ''); 203 Session::set($key . $id, $secode, '');
  204 + $rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
  205 + if(!empty($rand)){
  206 + $img_add['code'] = $code;
  207 + $img_add['time'] = time();
  208 + $img_add['rand'] = $rand;
  209 + $img_add['create_time'] = time();
  210 + Db::name('Imgcode')->insertGetId($img_add);
  211 + session('verify_code',$code);
  212 + session('verify_time',time());
  213 + }
202 214
203 ob_start(); 215 ob_start();
  216 +
  217 +
  218 +
204 // 输出图像 219 // 输出图像
205 imagepng($this->_image); 220 imagepng($this->_image);
206 $content = ob_get_clean(); 221 $content = ob_get_clean();
207 imagedestroy($this->_image); 222 imagedestroy($this->_image);
208 -  
209 - return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/png'); 223 +// return response($content, 200, ['Content-Length' => strlen($content),'rand' => $rand])->contentType('image/png');
  224 + $re = response($content, 200, ['Content-Length' => strlen($content),'rand' => $rand])->contentType('image/png');
  225 + return $re;
210 } 226 }
211 227
212 /** 228 /**
@@ -8,7 +8,7 @@ class Doc @@ -8,7 +8,7 @@ class Doc
8 'version'=>'1.0.0', 8 'version'=>'1.0.0',
9 'copyright'=>'Powered By Zhangweiwei', 9 'copyright'=>'Powered By Zhangweiwei',
10 'password' => '', 10 'password' => '',
11 - 'static_path' => 'http://localhost/housePrice/simplewind/vendor/weiwei/api-doc/src/assets', 11 + 'static_path' => 'http://192.168.1.15/simplewind/vendor/weiwei/api-doc/src/assets',
12 'controller' => [ 12 'controller' => [
13 'api\\portal\\controller\\IndexController', 13 'api\\portal\\controller\\IndexController',
14 'api\\portal\\controller\\ArticleController', 14 'api\\portal\\controller\\ArticleController',