...
|
...
|
@@ -18,6 +18,7 @@ use think\Request; |
|
|
use think\Loader;
|
|
|
use think\Config;
|
|
|
use think\captcha\Captcha;
|
|
|
use think\Response;
|
|
|
use think\Url;
|
|
|
use SmsDemo;
|
|
|
use think\Session;
|
...
|
...
|
@@ -40,54 +41,18 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
// 验证码图片
|
|
|
public function getImgUrl($id = "")
|
|
|
public function getImgUrl($rand = '',$id = "")
|
|
|
{
|
|
|
\think\Route::get('captcha/[:id]/rand/[:rand]', "\\think\\captcha\\CaptchaController@index");
|
|
|
\think\Validate::extend('captcha', function ($value, $id = "") {
|
|
|
return captcha_check($value, $id, (array)\think\Config::get('captcha'));
|
|
|
});
|
|
|
|
|
|
$middle_url = \think\Url::build('/captcha/new' . ($id ? "/{$id}" : ''));
|
|
|
|
|
|
|
|
|
$middle_url = \think\Url::build('/captcha/new' . ($id ? "/{$id}" : '').'?rand='.$rand);
|
|
|
return cmf_get_image_url($middle_url);
|
|
|
// $rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
|
|
|
// $imgUrl = $middle_url."&time=".$rand;
|
|
|
// return cmf_get_image_url($imgUrl);
|
|
|
// return $id;
|
|
|
}
|
|
|
|
|
|
public function a(){
|
|
|
$true = $this->request->param();
|
|
|
// $session = $this->request->session();
|
|
|
if(!empty($true['code'])){
|
|
|
session_start();
|
|
|
$result = cmf_captcha_check($true['code']);
|
|
|
if(!$result) {
|
|
|
$this->apiResponse('0','验证码错误',$result);
|
|
|
}
|
|
|
}else{
|
|
|
session_start();
|
|
|
$rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
|
|
|
$img = $this->getImgUrl();
|
|
|
// $cc = file_get_contents($img);
|
|
|
$cc = $this->curl($img);
|
|
|
echo "<pre/>";
|
|
|
print_r($cc);
|
|
|
die;
|
|
|
// cmf_captcha_check($true['code']);
|
|
|
|
|
|
$html = "<img src='".$img."'>";
|
|
|
// $key = $this->authcode($this->seKey);
|
|
|
// $secode = Session::get($key, '');
|
|
|
// echo "<pre/>";
|
|
|
//// print_r($img);
|
|
|
// print_r($html);
|
|
|
// print_r($_SESSION);
|
|
|
// die;
|
|
|
}
|
|
|
}
|
|
|
private function authcode($str)
|
|
|
|
|
|
public function authcode($str)
|
|
|
{
|
|
|
$key = substr(md5('ThinkPHP.CN'), 5, 8);
|
|
|
$str = substr(md5($str), 8, 10);
|
...
|
...
|
@@ -134,13 +99,26 @@ public function a(){ |
|
|
// 验证图形验证码
|
|
|
// 验证码
|
|
|
session_start();
|
|
|
if(!$request->param('imgCode')){
|
|
|
if(empty($data['imgCode'])){
|
|
|
$this->apiResponse('0','请先输入图形验证码');
|
|
|
}
|
|
|
$result = cmf_captcha_check($request->param('imgCode'));
|
|
|
if(!$result) {
|
|
|
$this->apiResponse('0','验证码错误');
|
|
|
// 验证码
|
|
|
$first = explode('?',$data['rand']);
|
|
|
$next = explode('=',$first[1]);
|
|
|
$third = explode('.',$next[1]);
|
|
|
$postImg = $this->authcode(strtoupper($data['imgCode']));
|
|
|
$where_imgcode['rand'] = $third[0];
|
|
|
$find_code = Db::name('Imgcode')->where($where_imgcode)->find();
|
|
|
if($find_code){
|
|
|
if($find_code['code'] != $postImg){
|
|
|
$this->apiResponse('0','验证码错误1');
|
|
|
}else{
|
|
|
Db::name('Imgcode')->where($where_imgcode)->delete();
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','验证码错误2');
|
|
|
}
|
|
|
|
|
|
$code = 'SMS_137411611';
|
|
|
$type = 2;
|
|
|
}else if($genre == 3 ){
|
...
|
...
|
@@ -160,6 +138,8 @@ public function a(){ |
|
|
$this->SmsResult($tel,$code,$type);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 用户注册(sure)
|
|
|
* @description 接口说明
|
...
|
...
|
@@ -273,6 +253,7 @@ public function a(){ |
|
|
* @param name:tel type:int require:1 default: other: desc:手机号
|
|
|
* @param name:password type:int require:1 default: other: desc:密码
|
|
|
* @param name:imgCode type:int require:1 default: other: desc:验证码
|
|
|
* @param name:rand type:int require:1 default: other: desc:随机数
|
|
|
* @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:1
|
|
|
* @return data:''@
|
|
|
* @data type:'1->用户,2->中介'
|
...
|
...
|
@@ -281,11 +262,12 @@ public function a(){ |
|
|
public function login(Request $request){
|
|
|
|
|
|
if($request->post() && $request->Post('tel')){
|
|
|
$getData = $request->param();
|
|
|
// 登录验证
|
|
|
// 判空
|
|
|
$tel = $request->param('tel');
|
|
|
$password = $request->param('password');
|
|
|
$true = $request->param('imgCode');
|
|
|
$tel = $getData['tel'];
|
|
|
$password = $getData['password'];
|
|
|
$true = $getData['imgCode'];
|
|
|
if(empty($tel)){
|
|
|
$this->apiResponse('0','手机号不能为空');
|
|
|
}else if(empty($password)){
|
...
|
...
|
@@ -294,13 +276,27 @@ public function a(){ |
|
|
if(empty($true)){
|
|
|
$this->apiResponse('0','验证码不能为空');
|
|
|
}
|
|
|
if(empty($getData['rand'])){
|
|
|
$this->apiResponse('0','随机数不能为空');
|
|
|
}
|
|
|
// 验证
|
|
|
// 验证码
|
|
|
// session_start();
|
|
|
// $result = cmf_captcha_check($true);
|
|
|
// if(!$result) {
|
|
|
// $this->apiResponse('0','验证码错误',$result);
|
|
|
// }
|
|
|
$first = explode('?',$getData['rand']);
|
|
|
$next = explode('=',$first[1]);
|
|
|
$third = explode('.',$next[1]);
|
|
|
$postImg = $this->authcode(strtoupper($true));
|
|
|
$where_imgcode['rand'] = $third[0];
|
|
|
$find_code = Db::name('Imgcode')->where($where_imgcode)->find();
|
|
|
if($find_code){
|
|
|
if($find_code['code'] != $postImg){
|
|
|
$this->apiResponse('0','验证码错误1');
|
|
|
}
|
|
|
// else{
|
|
|
// Db::name('Imgcode')->where($where_imgcode)->delete();
|
|
|
// }
|
|
|
}else{
|
|
|
$this->apiResponse('0','验证码错误2');
|
|
|
}
|
|
|
// 手机、密码
|
|
|
$memberModel = new MemberModel();
|
|
|
$where_member['tel'] = $tel;
|
...
|
...
|
@@ -315,24 +311,22 @@ public function a(){ |
|
|
$member = $memberModel->isUpdate(true)->save($update_member);
|
|
|
if($member){
|
|
|
session('uid',$uid['id']);
|
|
|
session('token',$uid['token']);
|
|
|
$final['token'] = $uid['token'];
|
|
|
session('token',$update_member['token']);
|
|
|
$final['token'] = $update_member['token'];
|
|
|
$final['uid'] = $uid['id'];
|
|
|
$final['type'] = $uid['type'];
|
|
|
$this->apiResponse('1','登录成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','您输入的账号或密码不正确');
|
|
|
$this->apiResponse('0','登录失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','您输入的账号或密码不正确');
|
|
|
}
|
|
|
}else{
|
|
|
// 返回验证码图片
|
|
|
session_start();
|
|
|
header("ACCESS-CONTROL-ALLOW-ORIGIN:http://localhost");
|
|
|
$img = $this->getImgUrl();
|
|
|
$a = Request::instance()->header();
|
|
|
echo "<pre/>";
|
|
|
print_r($a);
|
|
|
die;
|
|
|
$rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
|
|
|
$img = $this->getImgUrl($rand);
|
|
|
$this->apiResponse('1','成功',$img);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -568,7 +562,7 @@ die; |
|
|
* @url /api/portal/User/myCard
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:card_name type:int require:1 default: other: desc:银行名称
|
|
|
* @param name:bank_id type:int require:1 default: other: desc:银行id
|
|
|
* @param name:card_num type:int require:1 default: other: desc:银行卡号
|
|
|
* @param name:code type:int require:1 default: other: desc:短信验证码
|
|
|
*/
|
...
|
...
|
@@ -578,7 +572,7 @@ die; |
|
|
// $where_member['token'] = $data['token'];
|
|
|
// $where_member['status'] = 1;
|
|
|
// $member = Db::name('Member')->where($where_member)->field('id,name,tel')->find();
|
|
|
if(!empty($data['card_num'])){
|
|
|
if(!empty($data['bank_id']) && !empty($data['card_num'])){
|
|
|
// 验证码
|
|
|
$where_code['type'] = 5;
|
|
|
$where_code['status'] = 1;
|
...
|
...
|
@@ -587,6 +581,9 @@ die; |
|
|
if(!$code){
|
|
|
$this->apiResponse('0','请先获取验证码');
|
|
|
}
|
|
|
if(empty($data['code'])){
|
|
|
$this->apiResponse('0','请先获取验证码');
|
|
|
}
|
|
|
if($code['code'] != $data['code']){
|
|
|
$this->apiResponse('0','验证码错误');
|
|
|
}
|
...
|
...
|
@@ -597,7 +594,7 @@ die; |
|
|
if($is_issetCard){
|
|
|
$this->apiResponse('0','您已绑定银行卡');
|
|
|
}
|
|
|
$add['card_name'] = $data['card_name'];
|
|
|
$add['bank_id'] = $data['bank_id'];
|
|
|
$add['card_num'] = $data['card_num'];
|
|
|
$add['create_time'] = time();
|
|
|
$add['update_time'] = time();
|
...
|
...
|
@@ -610,7 +607,11 @@ die; |
|
|
$this->apiResponse('0','添加失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('1','成功',$user);
|
|
|
$where_bank['status'] = 1;
|
|
|
$bank = Db::name('Bank')->where($where_bank)->order('score desc,create_time desc')->select();
|
|
|
$final['bank'] = $bank;
|
|
|
$final['user'] = $user;
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -622,7 +623,7 @@ die; |
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:card_id type:int require:1 default: other: desc:银行卡id
|
|
|
* @param name:card_name type:int require:1 default: other: desc:银行名称
|
|
|
* @param name:bank_id type:int require:1 default: other: desc:银行id
|
|
|
* @param name:card_num type:int require:1 default: other: desc:银行卡号
|
|
|
* @param name:code type:int require:1 default: other: desc:短信验证码
|
|
|
*/
|
...
|
...
|
@@ -632,7 +633,7 @@ die; |
|
|
if(empty($data['card_id'])){
|
|
|
$this->apiResponse('0','银行卡id不能为空');
|
|
|
}
|
|
|
if(!empty($data['card_name'])){
|
|
|
if(!empty($data['bank_id'])){
|
|
|
// 验证码
|
|
|
$where_code['type'] = 5;
|
|
|
$where_code['status'] = 1;
|
...
|
...
|
@@ -641,11 +642,14 @@ die; |
|
|
if(!$code){
|
|
|
$this->apiResponse('0','请先获取验证码');
|
|
|
}
|
|
|
if(empty($data['code'])){
|
|
|
$this->apiResponse('0','请先获取验证码');
|
|
|
}
|
|
|
if($code['code'] != $data['code']){
|
|
|
$this->apiResponse('0','验证码错误');
|
|
|
}
|
|
|
$where_add['id'] = $data['card_id'];
|
|
|
$add['card_name'] = $data['card_name'];
|
|
|
$add['bank_id'] = $data['bank_id'];
|
|
|
$add['card_num'] = $data['card_num'];
|
|
|
$add['update_time'] = time();
|
|
|
$add_final = Db::name('Card')->where($where_add)->update($add);
|
...
|
...
|
@@ -657,10 +661,18 @@ die; |
|
|
}
|
|
|
|
|
|
}else{
|
|
|
$where_cardFirst['id'] = $data['card_id'];
|
|
|
$cardFind = Db::name('Card')->where($where_cardFirst)->find();
|
|
|
$where_cardFirst['c.id'] = $data['card_id'];
|
|
|
$cardFind = Db::name('Card')->alias('c')
|
|
|
->where($where_cardFirst)
|
|
|
->join("Bank b",'b.id = c.bank_id')
|
|
|
->field('c.*,b.name')
|
|
|
->find();
|
|
|
$where_bank['status'] = 1;
|
|
|
$bank = Db::name('Bank')->where($where_bank)->order('score desc,create_time desc')->select();
|
|
|
$final['bank'] = $bank;
|
|
|
$final['card'] = $cardFind;
|
|
|
if($cardFind){
|
|
|
$this->apiResponse('1','成功',$cardFind);
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','信息查询失败');
|
|
|
}
|
...
|
...
|
@@ -756,17 +768,46 @@ die; |
|
|
* @url /api/portal/User/myNeed
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:page type:int require:1 default: other: desc:分页
|
|
|
* @return data:''@
|
|
|
* @data status:'状态(1->待发布,2->已发布,待报价,3->已成交,4->未交保证金,5->已过期,6->未选择中介,7->中介未确认,8->报价人数不足,9->删除)'
|
|
|
* @data status:'状态(1->待发布,2->未交保证金,3->已发布,待报价,4->报价人数不足,5->待选择中介,6->未选择中介,7->已选择中介,待中介确认,8->中介未确认,9->删除,10->已成交,中介已确认)'
|
|
|
* @data comment:'剩余评价次数'
|
|
|
*/
|
|
|
public function myNeed(Request $request){
|
|
|
$token = $request->param('token');
|
|
|
$member = $this->myleft($token);
|
|
|
$data = $request->param();
|
|
|
$page = $data['page']?$data['page']:1;
|
|
|
|
|
|
$final['user'] = $member;
|
|
|
$where_userNeed['user_id'] = $member['id'];
|
|
|
$where_userNeed['status'] = array('neq',9);
|
|
|
$user_need = Db::name('UserNeed')->where($where_userNeed)->order('create_time desc')->select();
|
|
|
$user_need = Db::name('UserNeed')->where($where_userNeed)
|
|
|
->order('create_time desc')
|
|
|
->page($page)
|
|
|
->select()->toArray();
|
|
|
if($user_need){
|
|
|
foreach ($user_need as $unk=>$unv){
|
|
|
$where_comment['need_id'] = $unv['id'];
|
|
|
$where_comment['user_id'] = $unv['user_id'];
|
|
|
$where_comment['status'] = 1;
|
|
|
$comment = Db::name('Comment')->where($where_comment)->field('is_comment,create_time')->find();
|
|
|
if($comment){
|
|
|
// 判断是否超过30天
|
|
|
if(time() > ($comment['create_time'] + 2592000)){
|
|
|
$user_need[$unk]['comment'] = 0;
|
|
|
}else{
|
|
|
if($comment['is_comment'] == 1){
|
|
|
$user_need[$unk]['comment'] = 0;
|
|
|
}else{
|
|
|
$user_need[$unk]['comment'] = 1;
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
$user_need[$unk]['comment'] = 2;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
$final['user_need'] = $user_need;
|
|
|
}else{
|
|
|
$final['user_need'] = array();
|
...
|
...
|
@@ -776,10 +817,6 @@ die; |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 我的比价明细(sure)
|
|
|
* @description 接口说明
|
...
|
...
|
@@ -836,9 +873,13 @@ die; |
|
|
public function myMes(Request $request){
|
|
|
$data = $request->param();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
$where_card['status'] = 1;
|
|
|
$where_card['user_id'] = $user['id'];
|
|
|
$card = Db::name('Card')->where($where_card)->field('id,card_name,card_num')->select()->toArray();
|
|
|
$where_card['c.status'] = 1;
|
|
|
$where_card['c.user_id'] = $user['id'];
|
|
|
$card = Db::name('Card')->alias('c')
|
|
|
->where($where_card)
|
|
|
->join("Bank b",'b.id = c.bank_id')
|
|
|
->field('c.id,b.name,c.card_num')
|
|
|
->select()->toArray();
|
|
|
foreach ($card as $cardk=>$cardv){
|
|
|
$card[$cardk]['user_name'] = $user['name'];
|
|
|
}
|
...
|
...
|
@@ -963,7 +1004,13 @@ die; |
|
|
$add['update_time'] = time();
|
|
|
$add_result = Db::name('Comment')->insertGetId($add);
|
|
|
if($add_result){
|
|
|
$this->apiResponse('1','评价成功');
|
|
|
$change_status['status'] = 11;
|
|
|
$change_com = Db::name('UserNeed')->where($where_need)->update($change_status);
|
|
|
if($change_com){
|
|
|
$this->apiResponse('1','评价成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
...
|
...
|
@@ -975,6 +1022,84 @@ die; |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 修改评价(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/changeUserComment
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:comment_id type:int require:1 default: other: desc:评论id
|
|
|
* @param name:content type:int require:1 default: other: desc:评论内容
|
|
|
*/
|
|
|
public function changeUserComment(Request $request){
|
|
|
$data = $request->param();
|
|
|
if(empty($data['comment_id'])){
|
|
|
$this->apiResponse('0','评论id不能为空');
|
|
|
}
|
|
|
if(empty($data['content'])){
|
|
|
$where_change['id'] = $data['comment_id'];
|
|
|
$where_change['status'] = 1;
|
|
|
$where_change['is_comment'] = 0;
|
|
|
$find_comment = Db::name('Comment')->where($where_change)->find();
|
|
|
if($find_comment){
|
|
|
$this->apiResponse('1','成功',$find_comment);
|
|
|
}else{
|
|
|
$this->apiResponse('0','该评价不可修改');
|
|
|
}
|
|
|
}else{
|
|
|
$where_update['id'] = $data['comment_id'];
|
|
|
$where_update['status'] = 1;
|
|
|
$update['content'] = $data['content'];
|
|
|
$update['is_comment'] = 1;
|
|
|
$update_result = Db::name('Comment')->where($where_update)->update($update);
|
|
|
if($update_result){
|
|
|
$this->apiResponse('1','修改成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','修改失败');
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
if(empty($data['content'])){
|
|
|
$this->apiResponse('0','评论内容不能为空');
|
|
|
}
|
|
|
$where_need['status'] = 10;
|
|
|
$where_need['id'] = $data['need_id'];
|
|
|
$need = Db::name('UserNeed')->where($where_need)->find();
|
|
|
if($need){
|
|
|
$where_agency['status'] = 11;
|
|
|
$where_agency['need_id'] = $need['id'];
|
|
|
$agency = Db::name('Agency')->where($where_agency)->find();
|
|
|
if($agency){
|
|
|
$add['need_id'] = $need['id'];
|
|
|
$add['agency_id'] = $agency['id'];
|
|
|
$add['intermediary_id'] = $agency['agency_id'];
|
|
|
$add['user_id'] = $need['user_id'];
|
|
|
$add['content'] = $data['content'];
|
|
|
$add['create_time'] = time();
|
|
|
$add['update_time'] = time();
|
|
|
$add_result = Db::name('Comment')->insertGetId($add);
|
|
|
if($add_result){
|
|
|
$change_status['status'] = 11;
|
|
|
$change_com = Db::name('UserNeed')->where($where_need)->update($change_status);
|
|
|
if($change_com){
|
|
|
$this->apiResponse('1','评价成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 投诉(sure)
|
...
|
...
|
|