...
|
...
|
@@ -20,6 +20,7 @@ use think\Config; |
|
|
use think\captcha\Captcha;
|
|
|
use think\Url;
|
|
|
use SmsDemo;
|
|
|
use think\Session;
|
|
|
//use think\Route;
|
|
|
/**
|
|
|
* @title 用户接口
|
...
|
...
|
@@ -36,24 +37,67 @@ class UserController extends CommonController |
|
|
$this->postModel = $postModel;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 验证码图片
|
|
|
public function getImgUrl($id = "")
|
|
|
{
|
|
|
\think\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index");
|
|
|
\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}" : ''));
|
|
|
|
|
|
|
|
|
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);
|
|
|
$imgUrl = $middle_url."&time=".$rand;
|
|
|
return $imgUrl;
|
|
|
$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)
|
|
|
{
|
|
|
$key = substr(md5('ThinkPHP.CN'), 5, 8);
|
|
|
$str = substr(md5($str), 8, 10);
|
|
|
return md5($key . $str);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 获取短信验证码(sure1)
|
|
|
* @title 获取短信验证码(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/getSmsResult
|
...
|
...
|
@@ -235,6 +279,7 @@ class UserController extends CommonController |
|
|
*/
|
|
|
// 登录
|
|
|
public function login(Request $request){
|
|
|
|
|
|
if($request->post() && $request->Post('tel')){
|
|
|
// 登录验证
|
|
|
// 判空
|
...
|
...
|
@@ -251,11 +296,11 @@ class UserController extends CommonController |
|
|
}
|
|
|
// 验证
|
|
|
// 验证码
|
|
|
session_start();
|
|
|
$result = cmf_captcha_check($true);
|
|
|
if(!$result) {
|
|
|
$this->apiResponse('0','验证码错误');
|
|
|
}
|
|
|
// session_start();
|
|
|
// $result = cmf_captcha_check($true);
|
|
|
// if(!$result) {
|
|
|
// $this->apiResponse('0','验证码错误',$result);
|
|
|
// }
|
|
|
// 手机、密码
|
|
|
$memberModel = new MemberModel();
|
|
|
$where_member['tel'] = $tel;
|
...
|
...
|
@@ -281,10 +326,16 @@ class UserController extends CommonController |
|
|
}
|
|
|
}else{
|
|
|
// 返回验证码图片
|
|
|
session_start();
|
|
|
header("ACCESS-CONTROL-ALLOW-ORIGIN:http://localhost");
|
|
|
$img = $this->getImgUrl();
|
|
|
$a = Request::instance()->header();
|
|
|
echo "<pre/>";
|
|
|
print_r($a);
|
|
|
die;
|
|
|
$this->apiResponse('1','成功',$img);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -293,7 +344,6 @@ class UserController extends CommonController |
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/outLogin
|
|
|
* @method POST
|
|
|
* @param name:user_id type:int require:1 default: other: desc:user_id
|
|
|
* @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:2
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
*/
|
...
|
...
|
@@ -302,12 +352,11 @@ class UserController extends CommonController |
|
|
// 重置token
|
|
|
$str = rand(1000,9999).time().rand(100,999);
|
|
|
$change['token'] = $this->md5($str);
|
|
|
$where_member['id'] = $request->param('user_id');
|
|
|
$where_member['token'] = $request->param('token');
|
|
|
$model = new MemberModel();
|
|
|
$member = $model->where($where_member)->find();
|
|
|
if($member){
|
|
|
$where_change['id'] = $request->param('user_id');
|
|
|
$where_change['id'] = $member['id'];
|
|
|
// $update = $model->isUpdate(true)->allowField(true)->save($change);
|
|
|
$change['update_time'] = time();
|
|
|
$update = $model->where($where_change)->update($change);
|
...
|
...
|
@@ -353,7 +402,7 @@ class UserController extends CommonController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 用户修改手机号(第二步)
|
|
|
* @title 用户修改手机号(第二步)(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/changetTelNext
|
...
|
...
|
@@ -397,7 +446,7 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 用户修改密码
|
|
|
* @title 用户修改密码(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/changePassword
|
...
|
...
|
@@ -421,7 +470,7 @@ class UserController extends CommonController |
|
|
$this->apiResponse('0','请输入确认新密码');
|
|
|
}
|
|
|
$where_member['password'] = $this->md5($data['password']);
|
|
|
$where_member['id'] = $data['user_id'];
|
|
|
$where_member['token'] = $data['token'];
|
|
|
$user_id = Db::name('Member')->where($where_member)->field('id')->find();
|
|
|
if($user_id){
|
|
|
if($data['newPassword'] == $data['sureNewPassword']){
|
...
|
...
|
@@ -431,7 +480,8 @@ class UserController extends CommonController |
|
|
$update['password'] = $this->md5($data['newPassword']);
|
|
|
$is_update = Db::name('Member')->where($where_update)->update($update);
|
|
|
if($is_update){
|
|
|
$this->apiResponse('1','成功',$update['token']);
|
|
|
$final['token'] = $update['token'];
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','修改失败');
|
|
|
}
|
...
|
...
|
@@ -445,7 +495,7 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 密码找回
|
|
|
* @title 密码找回(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/findPassword
|
...
|
...
|
@@ -512,7 +562,7 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 绑定银行卡
|
|
|
* @title 绑定银行卡(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/myCard
|
...
|
...
|
@@ -520,37 +570,105 @@ class UserController extends CommonController |
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:card_name type:int require:1 default: other: desc:银行名称
|
|
|
* @param name:card_num type:int require:1 default: other: desc:银行卡号
|
|
|
* @param name:code type:int require:1 default: other: desc:短信验证码
|
|
|
*/
|
|
|
public function myCard(Request $request){
|
|
|
$data = $request->param();
|
|
|
$where_member['token'] = $data['token'];
|
|
|
$where_member['status'] = 1;
|
|
|
$member = Db::name('Member')->where($where_member)->field('id,name,tel')->find();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
// $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'])){
|
|
|
// 验证码
|
|
|
$where_code['type'] = 5;
|
|
|
$where_code['status'] = 1;
|
|
|
$where_code['tel'] = $user['tel'];
|
|
|
$code = Db::name('Code')->where($where_code)->order('create_time desc')->limit(1)->find();
|
|
|
if($code != $data['code']){
|
|
|
if(!$code){
|
|
|
$this->apiResponse('0','请先获取验证码');
|
|
|
}
|
|
|
if($code['code'] != $data['code']){
|
|
|
$this->apiResponse('0','验证码错误');
|
|
|
}
|
|
|
// $where_findC['card_num'] = $data['card_num'];
|
|
|
$where_findC['user_id'] = $user['id'];
|
|
|
$where_findC['status'] = 1;
|
|
|
$is_issetCard = Db::name('Card')->where($where_findC)->find();
|
|
|
if($is_issetCard){
|
|
|
$this->apiResponse('0','您已绑定银行卡');
|
|
|
}
|
|
|
$add['card_name'] = $data['card_name'];
|
|
|
$add['card_num'] = $data['card_num'];
|
|
|
$add['create_time'] = time();
|
|
|
$add['update_time'] = time();
|
|
|
$add['user_id'] = $member['id'];
|
|
|
$add['user_id'] = $user['id'];
|
|
|
$add_final = Db::name('Card')->insertGetId($add);
|
|
|
if($add_final){
|
|
|
$this->apiResponse('1','成功',$add_final);
|
|
|
$final['card_id'] = $add_final;
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','添加失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('1','成功',$user);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 修改绑定银行卡(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/changeMyCard
|
|
|
* @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:card_num type:int require:1 default: other: desc:银行卡号
|
|
|
* @param name:code type:int require:1 default: other: desc:短信验证码
|
|
|
*/
|
|
|
public function changeMyCard(Request $request){
|
|
|
$data = $request->param();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
if(empty($data['card_id'])){
|
|
|
$this->apiResponse('0','银行卡id不能为空');
|
|
|
}
|
|
|
if(!empty($data['card_name'])){
|
|
|
// 验证码
|
|
|
$where_code['type'] = 5;
|
|
|
$where_code['status'] = 1;
|
|
|
$where_code['tel'] = $user['tel'];
|
|
|
$code = Db::name('Code')->where($where_code)->order('create_time desc')->limit(1)->find();
|
|
|
if(!$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['card_num'] = $data['card_num'];
|
|
|
$add['update_time'] = time();
|
|
|
$add_final = Db::name('Card')->where($where_add)->update($add);
|
|
|
if($add_final){
|
|
|
$final['card_id'] = $add_final;
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','添加失败');
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
$this->apiResponse('1','成功',$member);
|
|
|
$where_cardFirst['id'] = $data['card_id'];
|
|
|
$cardFind = Db::name('Card')->where($where_cardFirst)->find();
|
|
|
if($cardFind){
|
|
|
$this->apiResponse('1','成功',$cardFind);
|
|
|
}else{
|
|
|
$this->apiResponse('0','信息查询失败');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 银行卡解除绑定
|
|
|
* @title 银行卡解除绑定(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/delMyCard
|
...
|
...
|
@@ -586,7 +704,7 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 用户个人中心首页(over)
|
|
|
* @title 用户个人中心首页(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/myIndex
|
...
|
...
|
@@ -622,7 +740,7 @@ class UserController extends CommonController |
|
|
public function myleft($token){
|
|
|
$where_member['token'] = $token;
|
|
|
$where_member['status'] = 1;
|
|
|
$member = Db::name('Member')->where($where_member)->field('tel,id,name,referee_tel')->find();
|
|
|
$member = Db::name('Member')->where($where_member)->field('tel,id,name,referee_tel,money,get_money')->find();
|
|
|
if(!$member){
|
|
|
$this->apiResponse('0','用户信息错误');
|
|
|
}
|
...
|
...
|
@@ -632,10 +750,10 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 用户个人中心我的比价/比价详情(over)
|
|
|
* @title 用户个人中心我的比价/比价详情(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/myIndex
|
|
|
* @url /api/portal/User/myNeed
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @return data:''@
|
...
|
...
|
@@ -658,8 +776,12 @@ class UserController extends CommonController |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 我的比价明细
|
|
|
* @title 我的比价明细(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/compareDetail
|
...
|
...
|
@@ -671,20 +793,23 @@ class UserController extends CommonController |
|
|
$token = $request->param('token');
|
|
|
$member = $this->myleft($token);
|
|
|
$data = $request->param();
|
|
|
if(empty($data['need_id'])){
|
|
|
$this->apiResponse('0','需求id不能为空');
|
|
|
}
|
|
|
$where_need['id'] = $data['need_id'];
|
|
|
$where_need['user_id'] = $member['id'];
|
|
|
$where_need['status'] = 5;
|
|
|
$userNeed = Db::name('UserNeed')->where($where_need)->find();
|
|
|
$userNeed = Db::name('UserNeed')->where($where_need)->field("id as need_id,city,quarters,room,pay_money,create_time,choose_time,status")->find();
|
|
|
$final['need'] = $userNeed;
|
|
|
$final['user'] = $member;
|
|
|
if($userNeed){
|
|
|
// 查询报价
|
|
|
$where_agency['need_id'] = $data['need_id'];
|
|
|
$where_agency['status'] = 4;
|
|
|
$where_agency['a.need_id'] = $data['need_id'];
|
|
|
$where_agency['a.status'] = 4;
|
|
|
$agency = Db::name('Agency')->alias('a')
|
|
|
->where($where_agency)
|
|
|
->join("hp_Member m", 'm.id = a.agency_id')
|
|
|
->field('a.*,a.id as agency_id,
|
|
|
->field('a.*,a.id as intermediary_id,
|
|
|
m.id as user_id,m.name,m.company,m.store,m.tel,m.reputation,m.start')
|
|
|
->select()->toArray();
|
|
|
if($agency){
|
...
|
...
|
@@ -707,7 +832,6 @@ class UserController extends CommonController |
|
|
* @url /api/portal/User/myMes
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @return data:''@
|
|
|
*/
|
|
|
public function myMes(Request $request){
|
|
|
$data = $request->param();
|
...
|
...
|
@@ -718,9 +842,10 @@ class UserController extends CommonController |
|
|
foreach ($card as $cardk=>$cardv){
|
|
|
$card[$cardk]['user_name'] = $user['name'];
|
|
|
}
|
|
|
$final['card'] = $card;
|
|
|
$final['user'] = $user;
|
|
|
if($card){
|
|
|
$final = array();
|
|
|
$final['card'] = $card?$card:array();
|
|
|
$final['user'] = $user?$user:array();
|
|
|
if($final){
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','失败');
|
...
|
...
|
@@ -730,32 +855,32 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 确认成交
|
|
|
* @title 确认成交(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/sureAgency
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:need_id type:int require:1 default: other: desc:需求id
|
|
|
* @param name:agency_id type:int require:1 default: other: desc:中介报价id
|
|
|
* @param name:intermediary_id type:int require:1 default: other: desc:中介报价id
|
|
|
* @return data:''@
|
|
|
*/
|
|
|
public function sureAgency(Request $request){
|
|
|
$data = $request->param();
|
|
|
if(!$data['need_id'] || !$data['agency_id'] ){
|
|
|
if(!$data['need_id'] || !$data['intermediary_id'] ){
|
|
|
$this->apiResponse('0','参数错误');
|
|
|
}
|
|
|
$where_bid['need_id'] = $data['need_id'];
|
|
|
$where_bid['id'] = $data['agency_id'];
|
|
|
$where_bid['id'] = $data['intermediary_id'];
|
|
|
$where_bid['status'] = 4;
|
|
|
$is_isset = Db::name('Agency')->where($where_bid)->find();
|
|
|
if($is_isset){
|
|
|
$where_ag['id'] = $data['agency_id'];
|
|
|
$where_ag['id'] = $data['intermediary_id'];
|
|
|
$add['status'] = 5;
|
|
|
$add['update_time'] = time();
|
|
|
$save = Db::name('Agency')->where($where_ag)->update($add);
|
|
|
if($save){
|
|
|
$this->apiResponse('1','操作失败');
|
|
|
$this->apiResponse('1','确认成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','成交失败');
|
|
|
}
|
...
|
...
|
@@ -766,7 +891,7 @@ class UserController extends CommonController |
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 查看评价
|
|
|
* @title 查看评价(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/comment
|
...
|
...
|
@@ -779,7 +904,7 @@ class UserController extends CommonController |
|
|
$where_isset['id'] = $data['agency_id'];
|
|
|
$agency_id = Db::name('Member')->where($where_isset)->field('id,name,pic,reputation,start')->find();
|
|
|
if($agency_id){
|
|
|
$where_comment['c.agency_id'] = $agency_id['id'];
|
|
|
$where_comment['c.intermediary_id'] = $agency_id['id'];
|
|
|
$where_comment['c.status'] = 1;
|
|
|
$comment = Db::name('Comment')->alias('c')
|
|
|
->where($where_comment)
|
...
|
...
|
@@ -791,7 +916,9 @@ class UserController extends CommonController |
|
|
$middle = str_split($cv['tel'],3);
|
|
|
$comment[$ck]['tel'] = $middle[0].'********';
|
|
|
}
|
|
|
$this->apiResponse('1','成功',$comment);
|
|
|
$final['comment'] = $comment;
|
|
|
$final['agency'] = $agency_id;
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('1','暂无评价');
|
|
|
}
|
...
|
...
|
@@ -801,55 +928,177 @@ class UserController extends CommonController |
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 评价(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/userComment
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:need_id type:int require:1 default: other: desc:需求id
|
|
|
* @param name:content type:int require:1 default: other: desc:评论内容
|
|
|
*/
|
|
|
public function userComment(Request $request){
|
|
|
$data = $request->param();
|
|
|
if(empty($data['need_id'])){
|
|
|
$this->apiResponse('0','需求id不能为空');
|
|
|
}
|
|
|
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){
|
|
|
$this->apiResponse('1','评价成功');
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->apiResponse('0','评价失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 投诉
|
|
|
* @title 投诉(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/complaint
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
* @param name:need_id type:int require:1 default: other: desc:需求id
|
|
|
* @param name:agency_id type:int require:1 default: other: desc:中介报价id
|
|
|
* @param name:intermediary_id type:int require:1 default: other: desc:中介id
|
|
|
* @param name:intermediary_id type:int require:1 default: other: desc:中介报价id
|
|
|
* @param name:content type:int require:1 default: other: desc:投诉内容
|
|
|
* @param name:type type:int require:1 default: other: desc:1->用户投诉,2->中介投诉
|
|
|
* @param name:gener type:int require:1 default: other: desc:1->用户投诉,2->中介投诉
|
|
|
*/
|
|
|
public function complaint(Request $request){
|
|
|
$token = $request->param('token');
|
|
|
$member = $this->myleft($token);
|
|
|
$final['user'] = $member;
|
|
|
$data = $request->param();
|
|
|
$where_isset['user_id'] = $member['id'];
|
|
|
$where_isset['need_id'] = $data['need_id'];
|
|
|
$where_isset['agency_id'] = $data['agency_id'];
|
|
|
$where_isset['intermediary_id'] = $data['intermediary_id'];
|
|
|
$is_isset= Db::name('Complaint')->where($where_isset)->field('id')->find();
|
|
|
if($is_isset){
|
|
|
$this->apiResponse('0','您已投诉');
|
|
|
if(empty($data['gener'])){
|
|
|
$this->apiResponse('0','类型不能为空');
|
|
|
}
|
|
|
if(empty($data['need_id']) && empty($data['intermediary_id'])){
|
|
|
$this->apiResponse('0','投诉id不能为空');
|
|
|
}
|
|
|
$where_find['n.id'] = $data['need_id'];
|
|
|
$where_find['a.id'] = $data['intermediary_id'];
|
|
|
$find = Db::name('UserNeed')->alias('n')
|
|
|
->where($where_find)
|
|
|
->join("Agency a",'a.need_id = n.id')
|
|
|
->field("a.id as agency_id")
|
|
|
->find();
|
|
|
if($find){
|
|
|
// 查询是否已投诉
|
|
|
$where_isset['user_id'] = $member['id'];
|
|
|
$where_isset['need_id'] = $data['need_id'];
|
|
|
$where_isset['agency_id'] = $find['agency_id'];
|
|
|
$where_isset['intermediary_id'] = $data['intermediary_id'];
|
|
|
$where_isset['type'] = $data['gener'];
|
|
|
$where_isset['status'] = 1;
|
|
|
$is_isset= Db::name('Complaint')->where($where_isset)->field('id')->find();
|
|
|
if($is_isset){
|
|
|
$this->apiResponse('0','您已投诉');
|
|
|
}
|
|
|
// 添加投诉
|
|
|
$add['user_id'] = $member['id'];
|
|
|
$add['need_id'] = $data['need_id'];
|
|
|
$add['agency_id'] = $find['agency_id'];
|
|
|
$add['intermediary_id'] = $data['intermediary_id'];
|
|
|
$add['content'] = $data['content'];
|
|
|
$add['type'] = $data['gener'];
|
|
|
$add['create_time'] = time();
|
|
|
$add['update_time'] = time();
|
|
|
$is_add = Db::name('Complaint')->insertGetId($add);
|
|
|
if($is_add){
|
|
|
$final['complaint_id'] = $is_add;
|
|
|
$this->apiResponse('1','投诉成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','投诉失败');
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
$this->apiResponse('0','当前状态不支持投诉');
|
|
|
}
|
|
|
|
|
|
$add['user_id'] = $member['id'];
|
|
|
$add['need_id'] = $data['need_id'];
|
|
|
|
|
|
$add['agency_id'] = $data['agency_id'];
|
|
|
$add['intermediary_id'] = $data['intermediary_id'];
|
|
|
$add['content'] = $data['content'];
|
|
|
$add['type'] = $data['type'];
|
|
|
$final['user'] = $member;
|
|
|
|
|
|
$is_add = Db::name('Complaint')->insertGetId($add);
|
|
|
if($is_add){
|
|
|
$final['complaint_id'] = $is_add;
|
|
|
$this->apiResponse('1','投诉成功',$final);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 用户、中介 提现(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/getMoney
|
|
|
* @method POST
|
|
|
* @param name:token type:int require:1 default: other: desc:token
|
|
|
*/
|
|
|
public function getMoney(Request $request){
|
|
|
Db::startTrans();
|
|
|
$data = $request->param();
|
|
|
$where_member['token'] = $data['token'];
|
|
|
$member = Db::name('Member')->where($where_member)->field('id,money')->find();
|
|
|
if($member){
|
|
|
$final['user'] = $member;
|
|
|
}else{
|
|
|
$this->apiResponse('0','投诉失败');
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','用户信息错误');
|
|
|
}
|
|
|
$where_card['user_id'] = $member['id'];
|
|
|
$where_card['status'] = 1;
|
|
|
$card = Db::name('Card')->where($where_card)->find();
|
|
|
if(!$card){
|
|
|
$this->apiResponse('0','请先绑定银行卡');
|
|
|
}else{
|
|
|
$final['card'] = $card;
|
|
|
}
|
|
|
$where_umoney['user_id'] = $member['id'];
|
|
|
$where_umoney['card_id'] = $card['id'];
|
|
|
$where_umoney['title'] = '用户提现';
|
|
|
$where_umoney['money'] = $member['money'];
|
|
|
$where_umoney['type'] = 3;
|
|
|
$where_umoney['create_time'] = time();
|
|
|
$where_umoney['update_time'] = time();
|
|
|
$add = Db::name('UmoenyDetail')->insertGetId($where_umoney);
|
|
|
if($add){
|
|
|
$del = Db::name('Member')->where($where_member)->setDec('money',$member['money']);
|
|
|
$inc = Db::name('Member')->where($where_member)->setInc('get_money',$member['money']);
|
|
|
if($del && $inc){
|
|
|
Db::commit();
|
|
|
$this->apiResponse('1','提现成功');
|
|
|
}else{
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','提现失败');
|
|
|
}
|
|
|
}else{
|
|
|
Db::rollback();
|
|
|
$this->apiResponse('0','提现失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 我的账户
|
|
|
* @title 我的账户(sure)
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/portal/User/orderDetail
|
...
|
...
|
@@ -858,18 +1107,20 @@ class UserController extends CommonController |
|
|
*/
|
|
|
public function orderDetail(Request $request){
|
|
|
$data = $request->param();
|
|
|
$get_msg = $this->myleft($data['token']);
|
|
|
$where_order['user_id'] = $get_msg['id'];
|
|
|
$where_order['status'] = array('neq',9);
|
|
|
$order_list = Db::name('UsermoneyDetail')->where($where_order)->select()->toArray();
|
|
|
$user = $this->myleft($data['token']);
|
|
|
$where_umoney['user_id'] = $user['id'];
|
|
|
$where_umoney['status'] = 1;
|
|
|
$order_list = Db::name('UmoenyDetail')->where($where_umoney)->select()->toArray();
|
|
|
$final['user'] = $user;
|
|
|
if($order_list){
|
|
|
foreach ($order_list as $ok=>$ov){
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
$final['detail'] = $order_list;
|
|
|
}else{
|
|
|
$result = array();
|
|
|
$final['detail'] = array();
|
|
|
}
|
|
|
if($final){
|
|
|
$this->apiResponse('1','成功',$final);
|
|
|
}else{
|
|
|
$this->apiResponse('0','失败');
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|