作者 郭鑫

接口调试上传

... ... @@ -20,35 +20,35 @@ use api\portal\model\CodeModel;
class CommonController extends HomeBaseController
{
// connect 1 登录注册 ,2其他
public function _initialize()
{
if($this->request->param('connect')){
$connect = $this->request->param('connect');
}else{
$connect = 2;
}
if($connect == 2){
$where_firstMember['token'] = $this->request->param('token');
$firstMember = Db::name('Member')->where($where_firstMember)->field('id,update_time')->find();
if($firstMember){
if(($firstMember['update_time']+604800) < time() ){
$firstStr = rand(1000,9999).time().rand(100,999);
$firstData['token'] = $this->md5($firstStr);
$firstData['update_time'] = time();
$firstData['status'] = 1;
$firstLogin = Db::name('Member')->where($where_firstMember)->update($firstData);
if($firstLogin){
$this->apiResponse('0','请重新登录');
}else{
$this->apiResponse('0','token重置失败');
}
}
}else{
$this->apiResponse('0','暂未注册');
}
}
}
// public function _initialize()
// {
// if($this->request->param('connect')){
// $connect = $this->request->param('connect');
// }else{
// $connect = 2;
// }
// if($connect == 2){
// $where_firstMember['token'] = $this->request->param('token');
// $firstMember = Db::name('Member')->where($where_firstMember)->field('id,update_time')->find();
// if($firstMember){
// if(($firstMember['update_time']+604800) < time() ){
// $firstStr = rand(1000,9999).time().rand(100,999);
// $firstData['token'] = $this->md5($firstStr);
// $firstData['update_time'] = time();
// $firstData['status'] = 1;
// $firstLogin = Db::name('Member')->where($where_firstMember)->update($firstData);
// if($firstLogin){
// $this->apiResponse('0','请重新登录');
// }else{
// $this->apiResponse('0','token重置失败');
// }
// }
// }else{
// $this->apiResponse('0','暂未注册');
// }
// }
//
// }
/**
* API返回信息格式函数 ;0失败,1成功,-1需要登录
* @param string $code
... ... @@ -90,6 +90,10 @@ class CommonController extends HomeBaseController
// $code = 'SMS_137416617';
$modelVal = rand(1000,9999);
$sendResult = $this->sendLogin($tel,$code,$modelVal);
$mes = $sendResult->Message;
if($mes != 'OK'){
$this->apiResponse('0',$mes);
}
$add_code['tel'] = $tel;
$add_code['code'] = $modelVal;
$add_code['type'] = $type;
... ... @@ -100,6 +104,8 @@ class CommonController extends HomeBaseController
}
if(($sendResult->Code) != 'OK'){
$this->apiResponse('0','注册失败');
}else{
$this->apiResponse('1','获取成功');
}
}
... ...
... ... @@ -36,7 +36,7 @@ class IntermediaryController extends CommonController
//sure_password 确认密码
//name 真实姓名
/**
* @title 房产中介注册
* @title 房产中介注册(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/join
... ... @@ -44,30 +44,33 @@ class IntermediaryController extends CommonController
* @param name:name type:int require:1 default: other: desc:姓名
* @param name:tel type:int require:1 default: other: desc:手机号
* @param name:password type:int require:1 default: other: desc:密码
* @param name:sure_password type:int require:1 default: other: desc:确认密码
* @param name:code type:int require:1 default: other: desc:验证码
* @param name:city type:int require:1 default: other: desc:城市
* @param name:company type:int require:1 default: other: desc:所属公司
* @param name:store type:int require:1 default: other: desc:门店
* @param name:quarters type:int require:1 default: other: desc:服务小区
* @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:1
*/
public function join(Request $request)
{
if($request->Post()){
$data = $request->Post();
if(!empty($data['name'])){
// 验证
$validate = Loader::validate('User');
if(!$validate->scene('intermediary')->check($_POST)){
if(!$validate->scene('intermediary')->check($data)){
return json(array('code'=>0,'msg'=>$validate->getError()));
}
$data['password'] = $this->md5($_POST['password']);
$sure_password = $this->md5($_POST['sure_password']);
$data['password'] = $this->md5($data['password']);
$sure_password = $this->md5($data['sure_password']);
// 确认密码
if($data['password'] != $sure_password){
$this->apiResponse('0','两次密码不一致');
}
// 验证码
$data['tel'] = $_POST['tel'];
// $data['tel'] = $_POST['tel'];
$code = $request->param('code');
$where_code['tel'] = $data['tel'];
$where_code['type'] = 1;
... ... @@ -81,7 +84,7 @@ class IntermediaryController extends CommonController
}else{
Db::name('Code')->where($where_code)->delete();
}
$data['name'] = $_POST['name'];
// $data['name'] = $_POST['name'];
// 判断手机号是否已注册
$user = new MemberModel();
... ... @@ -128,7 +131,7 @@ class IntermediaryController extends CommonController
public function left($token){
$where_member['token'] = $token;
$where_member['status'] = 1;
$member = Db::name('Member')->where($where_member)->field('name,id,start,reputation,company,store,quarters,tel,city')->find();
$member = Db::name('Member')->where($where_member)->field('name,id,start,reputation,company,store,quarters,tel,city,pic,money,get_money')->find();
if(!$member){
$this->apiResponse('0','用户信息错误');
}
... ... @@ -147,7 +150,7 @@ class IntermediaryController extends CommonController
/**
* @title 中介个人中心首页(over
* @title 中介个人中心首页(sure
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/myIndex
... ... @@ -174,7 +177,7 @@ class IntermediaryController extends CommonController
/**
* @title 中介个人中心匹配需求详情(over
* @title 中介个人中心匹配需求详情(sure
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/mySend
... ... @@ -192,7 +195,7 @@ class IntermediaryController extends CommonController
$where_need['id'] = $request->param('need_id');
$where_need['status'] = 2;
$need_list = Db::name('UserNeed')->where($where_need)
->field("id,user_id,city,quarters,room,floor,house_type,renovation,area,is_first,loan,contract,quotation_time,create_time,people")
->field("id,user_id,city,quarters,room,floor,house_type,renovation,area,is_first,loan,contract,quotation_time,create_time,people,else")
->find();
if($need_list){
$final['intermediary_need'] = $need_list;
... ... @@ -294,7 +297,7 @@ class IntermediaryController extends CommonController
}
/**
* @title 中介个人中心我的报价
* @title 中介个人中心我的报价(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/myMoney
... ... @@ -306,10 +309,21 @@ class IntermediaryController extends CommonController
$data = $request->param();
$my = $this->left($data['token']);
$final['intermediary'] = $my;
$where_need['agency_id'] = $my['id'];
$where_need['a.agency_id'] = $my['id'];
$page = $data['page'];
$need = Db::name('Agency')->where($where_need)->limit(10)->page($page)->select()->toArray();
$need = Db::name('Agency')->alias('a')
->where($where_need)
->join("UserNeed n",'n.id = a.need_id')
->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,
a.all_price,a.create_time,a.status,a.id as intermediaryNeed_id
")
->limit(10)->page($page)
->select()->toArray();
if($need){
foreach ($need as $nk=>$nv){
$changeInt = (int)$nv['all_price'];
$need[$nk]['intPrice'] = substr($changeInt,0,-4);
}
$final['need'] = $need;
}else{
$final['need'] = array();
... ... @@ -318,23 +332,26 @@ class IntermediaryController extends CommonController
}
/**
* @title 中介个人中心我的报价详情
* @title 中介个人中心我的报价详情(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/myDetail
* @method POST
* @param name:token type:int require:1 default: other: desc:token
* @param name:intermediaryNeed_id type:int require:1 default: other: desc:报价id
* @param name:intermediary_id type:int require:1 default: other: desc:报价id
*/
public function myDetail(Request $request){
$data = $request->param();
$my = $this->left($data['token']);
$final['intermediary'] = $my;
$where_need['agency_id'] = $my['id'];
$where_need['i.id'] = $data['intermediaryNeed_id'];
$where_need['i.id'] = $data['intermediary_id'];
$need = Db::name('Agency')->alias('i')
->where($where_need)
->join("hp_user_need u",'u.id = i.need_id')
->field("i.id as intermediaryNeed_id ,i.*,
u.status as need_status ,u.*
")
->find();
if($need){
$final['need'] = $need;
... ... @@ -344,16 +361,47 @@ class IntermediaryController extends CommonController
$this->apiResponse('1','成功',$final);
}
/**
* @title 中介个人中心查看评价(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/comment
* @method POST
* @param name:token type:int require:1 default: other: desc:token
* @param name:intermediary_id type:int require:1 default: other: desc:报价id
*/
public function comment(Request $request){
$data = $request->param();
// $my = $this->left($data['token']);
if(empty($data['intermediary_id'])){
$this->apiResponse('0','报价id不能为空');
}
$where_agency['id'] = $data['intermediary_id'];
$agency = Db::name('Agency')->where($where_agency)->find();
if($agency){
$where_comment['need_id'] = $agency['need_id'];
$where_comment['agency_id'] = $agency['id'];
$where_comment['intermediary_id'] = $agency['agency_id'];
$where_comment['status'] = 1;
$comment = Db::name('Comment')->where($where_comment)->find();
if($comment){
$this->apiResponse('1','成功',$comment);
}else{
$this->apiResponse('0','暂无评价');
}
}else{
$this->apiResponse('0','状态错误');
}
}
/**
* @title 中介个人中心我的资料
* @title 中介个人中心我的资料(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/myDetail
* @method POST
* @param name:token type:int require:1 default: other: desc:token
* @param name:intermediaryNeed_id type:int require:1 default: other: desc:报价id
*/
public function mySelf(Request $request){
$data = $request->param();
... ... @@ -367,7 +415,7 @@ class IntermediaryController extends CommonController
}
/**
* @title 中介资料修改
* @title 中介资料修改(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/myIndex
... ... @@ -396,7 +444,7 @@ class IntermediaryController extends CommonController
/**
* @title 中介签到
* @title 中介签到(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/checkIn
... ... @@ -429,6 +477,32 @@ class IntermediaryController extends CommonController
}
}
/**
* @title 我的账户(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediary/orderDetail
* @method POST
* @param name:token type:int require:1 default: other: desc:token
*/
public function orderDetail(Request $request){
$data = $request->param();
$user = $this->left($data['token']);
$where_umoney['user_id'] = $user['id'];
$where_umoney['status'] = 1;
$order_list = Db::name('AmoenyDetail')->where($where_umoney)->select()->toArray();
$final['user'] = $user;
if($order_list){
$final['detail'] = $order_list;
}else{
$final['detail'] = array();
}
if($final){
$this->apiResponse('1','成功',$final);
}else{
$this->apiResponse('0','失败');
}
}
... ...
... ... @@ -45,11 +45,10 @@ class IntermediaryneedController extends CommonController
* @param name:housing_price type:int require:1 default: other: desc:房价
* @param name:token type:int require:1 default: other: desc:token
*/
public function payMoney(Request $request){
$data = $request->param();
public function payMoney($housing_price){
$where_inteRule['status'] = 1;
$where_inteRule['low'] = array('gt',$data['housing_price']);
$where_inteRule['height'] = array('lt',$data['housing_price']);
$where_inteRule['low'] = array('gt',$housing_price);
$where_inteRule['height'] = array('lt',$housing_price);
$inte_money = Db::name('IntermediaryRule')->where($where_inteRule)->field('money')->find();
if(!$inte_money){
$this->apiResponse('0','保证金获取失败');
... ... @@ -98,7 +97,7 @@ class IntermediaryneedController extends CommonController
}
/**
* @title 中介报价
* @title 中介报价(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/Intermediaryneed/send
... ... @@ -150,6 +149,7 @@ class IntermediaryneedController extends CommonController
$this->apiResponse('0','保证金获取失败');
}else{
$data['deposit'] = $inte_money['money'];
$final['pay_money'] = $data['deposit'];
}
unset($data['token']);
$save = $model->save($data);
... ...
... ... @@ -9,6 +9,8 @@
namespace api\portal\controller;
use api\portal\model\AgencyModel;
use api\portal\model\UserNeedModel;
use cmf\controller\HomeBaseController;
use api\portal\model\PortalPostModel;
use cmf\controller\RestBaseController;
... ... @@ -75,21 +77,21 @@ class ThirdsendController extends HomeBaseController
// 30分钟后发布
// 30分钟后发布(sure)(分钟执行)
public function thirdSend(){
Db::startTrans();
$where_need['status'] = 1;
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,create_time')->select()->toArray();
$where_need['status'] = 2;
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,pay_time')->select()->toArray();
$time = time();
$change_arr = array();
foreach ($userNeedList as $userk=>$userv){
if($userv['create_time'] <= ($time+60) && $userv['create_time'] >= $time){
if($time >= $userv['pay_time']+1800){
$change_arr[] = $userv['id'];
}
}
if($change_arr){
$where_save['id'] = array('in',$change_arr);
$save['status'] = 2;
$save['status'] = 3;
$save['update_time'] = time();
$fianl_save = Db::name('UserNeed')->where($where_save)->update($save);
if($fianl_save){
... ... @@ -100,23 +102,21 @@ class ThirdsendController extends HomeBaseController
}
}
// 规定时间结束报价
// 规定时间结束报价(sure)(分钟执行)
public function over()
{
Db::startTrans();
// 查询用户发布需求信息
$where_need['status'] = 2;
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time')->select()->toArray();
$change_arr = array();
$where_need['status'] = 3;
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time,pay_time,user_id')->select()->toArray();
$time = time();
$time = '1529734985';
// 循环需求,查询相应报价
foreach ($userNeedList as $uNeedk => $uNeedv) {
$final_time = $uNeedv['create_time'] + $uNeedv['quotation_time'] * 86400;
if ($final_time <= ($time + 60) && $final_time >= $time) {
$final_time = $uNeedv['pay_time'] + $uNeedv['quotation_time'] * 86400;
if ($time >= $final_time) {
$us_middleid = $uNeedv['id'];
$where_agency['a.status'] = 2;
$where_agency['a.create_time'] = array('lt', time());
$where_agency['a.pay_time'] = array('lt', time());
$where_agency['a.need_id'] = $uNeedv['id'];
$where_agency['m.type'] = 2;
$where_agency['m.status'] = 1;
... ... @@ -133,6 +133,7 @@ class ThirdsendController extends HomeBaseController
if ($agency_list) {
// 判断是否超过三个报价人
if (count($agency_list) >= 3) {
// 查询三人中是否有品牌中介
// 循环匹配品牌企业
foreach ($agency_list as $agencyk => $agencyv) {
... ... @@ -161,6 +162,7 @@ class ThirdsendController extends HomeBaseController
asort($money_list);
$k = 0;
foreach ($money_list as $mok => $mov) {
$else_changeList[] = $mok;
if ($k < 3) {
$fin_list[$k]['id'] = $mok;
$fin_list[$k]['money'] = $mov;
... ... @@ -168,61 +170,281 @@ class ThirdsendController extends HomeBaseController
}
$k += 1;
}
$ag_id = implode(',', $fin_arr);
$userSave_status['status'] = 5;
$agencySave_status['status'] = 4;
if($agen_arr){
if(!in_array($agen_arr[0]['id'],$fin_arr)){
// 品牌中介不在取出三个最低价中
$middle_agen[0] = $agen_arr[0]['id'];
$get_list = array_merge($fin_arr,$middle_agen);
}else{
$get_list = $fin_arr;
}
}
foreach ($else_changeList as $getk=>$getv){
if(in_array($getv,$get_list)){
$change_final['id'] = $getv;
$change_final['status'] = 4;
}else{
$change_final['id'] = $getv;
$change_final['status'] = 3;
}
$agencyModel = new AgencyModel();
$fianl_AgsaveFirst = $agencyModel->isUpdate(true)->save($change_final);
if(!$fianl_AgsaveFirst){
Db::rollback();
}
}
// 报价成功,更改状态
$userSave_statusFirst['id'] = $uNeedv['id'];
$userSave_statusFirst['status'] = 5;
$userSave_statusFirst['choose_time'] = time();
$userNeedModel = new UserNeedModel();
$fianl_Ussave = $userNeedModel->isUpdate(true)->save($userSave_statusFirst);
if(!$fianl_Ussave){
Db::rollback();
}
} else {
// 报价小于3人,更改订单状态,报价失败
foreach ($agency_list as $changeka=>$changeva){
$change_final['id'] = $changeva['id'];
$change_final['status'] = 7;
$agencyModel = new AgencyModel();
$fianl_AgsaveNext = $agencyModel->isUpdate(true)->save($change_final);
if(!$fianl_AgsaveNext){
Db::rollback();
}
// 退回中介保证金
$add_a['user_id'] = $changeva['agency_id'];
$add_a['title'] = '报价人数不足';
$add_a['type'] = 1;
$add_a['money'] = $changeva['deposit'];
$add_a['create_time'] = time();
$add_a['update_time'] = time();
$amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
if (!$amoney_id) {
Db::rollback();
}
// 用户表增加金额
$where_member['type'] = 2;
$where_member['id'] = $changeva['agency_id'];
$add_money = Db::name('Member')->where($where_member)->setInc('money',$changeva['deposit']);
if (!$add_money) {
Db::rollback();
}
}
$userSave_status['id'] = $uNeedv['id'];
$userSave_status['status'] = 4;
$agencySave_status['status'] = 7;
$userNeedModel = new UserNeedModel();
$fianl_Ussave = $userNeedModel->isUpdate(true)->save($userSave_status);
if(!$fianl_Ussave){
Db::rollback();
}
// 退回保证金
// 用户
// 加用户金额明细表
$add_del['need_id'] = $uNeedv['id'];
$add_del['user_id'] = $uNeedv['user_id'];
$add_del['title'] = '报价人数不足';
$add_del['type'] = 1;
$add_del['money'] = $uNeedv['pay_money'];
$add_del['create_time'] = time();
$add_del['update_time'] = time();
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
if (!$umoney_id) {
Db::rollback();
}
$where_memberNext['type'] = 1;
$where_memberNext['id'] = $uNeedv['user_id'];
$add_moneyNext = Db::name('Member')->where($where_memberNext)->setInc('money',$uNeedv['pay_money']);
if (!$add_moneyNext) {
Db::rollback();
}
}
} else {
// 没有报价
$userSave_status['id'] = $uNeedv['id'];
$userSave_status['status'] = 4;
$agencySave_status['status'] = 7;
$userNeedModel = new UserNeedModel();
$fianl_Ussave = $userNeedModel->isUpdate(true)->save($userSave_status);
if(!$fianl_Ussave){
Db::rollback();
}
// 退回保证金
// 用户
// 加用户金额明细表
$add_del['need_id'] = $uNeedv['id'];
$add_del['user_id'] = $uNeedv['user_id'];
$add_del['title'] = '报价人数不足';
$add_del['type'] = 1;
$add_del['money'] = $uNeedv['pay_money'];
$add_del['create_time'] = time();
$add_del['update_time'] = time();
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
if (!$umoney_id) {
Db::rollback();
}
$where_memberNext['type'] = 1;
$where_memberNext['id'] = $uNeedv['user_id'];
$add_moneyNext = Db::name('Member')->where($where_memberNext)->setInc('money',$uNeedv['pay_money']);
if (!$add_moneyNext) {
Db::rollback();
}
}
$us_id = implode(',', $us_middleid);
// 插入数据库
// 用户需求表
$where_us['id'] = array('in', $us_id);
$fianl_Ussave = Db::name('UserNeed')->where($where_us)->update($userSave_status);
if(!$fianl_Ussave){
Db::rollback();
}
// $userNeedModel = new UserNeedModel();
// foreach ($userSave_status as $fck=>$fcv){
// $fianl_Ussave = $userNeedModel->isUpdate(true)->save($fcv);
// if(!$fianl_Ussave){
// Db::rollback();
// }
// }
// 中介报价表
$where_ag['id'] = array('in', $ag_id);
$fianl_Agsave = Db::name('Agency')->where($where_ag)->update($agencySave_status);
if(!$fianl_Agsave){
Db::rollback();
}else{
Db::commit();
}
Db::commit();
}
}
}
// 三天用户选择
// 三天用户选择(sure)(天执行)
public function userChoose(){
Db::startTrans();
// 查询用户发布需求信息
$where_need['status'] = 2;
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,quotation_time,create_time')->select()->toArray();
$where_need['status'] = 5;
$userNeedList = Db::name('UserNeed')->where($where_need)->field('id,choose_time,user_id,pay_money,choose_time')->select()->toArray();
if($userNeedList){
foreach ($userNeedList as $needk=>$needv) {
if (time() >= ($needv['choose_time'] + 259200)) {
$where_agency['need_id'] = $needv['id'];
$where_agency['status'] = 4;
$agency_list = Db::name('Agency')->where($where_agency)->select()->toArray();
if ($agency_list) {
$where_agencyUpdate['need_id'] = $needv['id'];
$where_agencyUpdate['status'] = 4;
$agency_save['status'] = 8;
$agency_save['update_time'] = time();
$agency_result = Db::name('Agency')->where($where_agencyUpdate)->update($agency_save);
if (!$agency_result) {
Db::rollback();
}
}
$where_needUpdate['id'] = $needv['id'];
$needUpdate['status'] = 6;
$need_result = Db::name('UserNeed')->where($where_needUpdate)->update($needUpdate);
if (!$need_result) {
Db::rollback();
} else {
// 加用户金额明细表
$add_del['need_id'] = $needv['id'];
$add_del['user_id'] = $needv['user_id'];
$add_del['title'] = '未选择中介';
$add_del['type'] = 2;
$add_del['money'] = $needv['pay_money'];
$add_del['create_time'] = time();
$add_del['update_time'] = time();
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
if (!$umoney_id) {
Db::rollback();
}
// 中介金额明细表
foreach ($agency_list as $agenk=>$agenv){
$add_a['ag_id'] = $agenv['id'];
$add_a['user_id'] = $agenv['agency_id'];
$add_a['title'] = '用户未选择中介';
$add_a['type'] = 1;
$add_a['money'] = $agenv['deposit'];
$add_a['create_time'] = time();
$add_a['update_time'] = time();
$amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
if (!$amoney_id) {
Db::rollback();
}
$where_member['type'] = 2;
$where_member['id'] = $agenv['agency_id'];
$add_money = Db::name('Member')->where($where_member)->setInc('money',$agenv['deposit']);
if (!$add_money) {
Db::rollback();
}
}
}
}
}
}
Db::commit();
}
// 三天中介确认
public function intermediaryChoose(){
}
public function intermediaryChoose(){
Db::startTrans();
$where_need['status'] = 7;
$need_list = Db::name('UserNeed')->where($where_need)->field('id,choose_time')->select()->toArray();
if($need_list){
foreach ($need_list as $needk=>$needv){
if(time() >= ($needv['choose_time']+259200)){
$where_agency['status'] = 5;
$where_agency['need_id'] = $needv['id'];
$agency = Db::name('Agency')->where($where_agency)->find();
// 修改中介报价状态
if($agency){
$where_changeAgency['id'] = $agency['id'];
$changeAgency['status'] = 10;
$changeAgency['update_time'] = time();
$update_a = Db::name('Agency')->where($where_changeAgency)->update($changeAgency);
if(!$update_a){
Db::rollback();
}
}
// 增加中介保证金变化
$add_a['ag_id'] = $agency['id'];
$add_a['user_id'] = $agency['agency_id'];
$add_a['title'] = '中介未确认';
$add_a['type'] = 2;
$add_a['money'] = $agency['deposit'];
$add_a['create_time'] = time();
$add_a['update_time'] = time();
$amoney_id = Db::name('AmoenyDetail')->insertGetId($add_a);
if (!$amoney_id) {
Db::rollback();
}
// 修改用户需求状态
$where_needChange['id'] = $needv['id'];
$update_need['status'] = 8;
$update_need['update_time'] = time();
$change_needFinal = Db::name('UserNeed')->where($where_needChange)->update($update_need);
if (!$change_needFinal) {
Db::rollback();
}
// 增加用户保证金,余额
$add_del['need_id'] = $needv['id'];
$add_del['user_id'] = $needv['user_id'];
$add_del['title'] = '中介未确认';
$add_del['type'] = 1;
$add_del['money'] = $needv['pay_money'];
$add_del['create_time'] = time();
$add_del['update_time'] = time();
$umoney_id = Db::name('UmoenyDetail')->insertGetId($add_del);
if (!$umoney_id) {
Db::rollback();
}
$where_member['type'] = 1;
$where_member['id'] = $needv['user_id'];
$add_money = Db::name('Member')->where($where_member)->setInc('money',$needv['pay_money']);
if (!$add_money) {
Db::rollback();
}
}
}
Db::commit();
}
}
... ...
... ... @@ -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','失败');
}
}
... ...
... ... @@ -35,7 +35,7 @@ class UserneedController extends CommonController
}
/**
* @title 用户发布需求时保证金金额(填完地区,小区调用;每次修改重新调用)
* @title 用户发布需求时保证金金额(填完地区,小区调用;每次修改重新调用)(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/UserNeed/payMoney
... ... @@ -77,7 +77,7 @@ class UserneedController extends CommonController
/**
* @title 用户发布需求
* @title 用户发布需求(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/UserNeed/send
... ... @@ -97,7 +97,7 @@ class UserneedController extends CommonController
* @param name:tel type:varchar require:1 default: other: desc:联系人电话
* @param name:code type:int require:1 default: other: desc:验证码
* @param name:else type:int require:1 default: other: desc:备注
* @param name:need_id type:int require:1 default: other:修改需求时传 desc:需求id
* @param name:token type:varchar require:1 default: other: desc:token
* @return data:''@
* @data type:'1->包干价,2->问答'
* @data need_id:'需求id'
... ... @@ -163,7 +163,8 @@ class UserneedController extends CommonController
$list[$lk]['content'] = htmlspecialchars_decode($lv['content']);
}
if($list){
$this->apiResponse('1','成功',$list);
$final['answer'] = $list;
$this->apiResponse('1','成功',$final);
}else{
$this->apiResponse('0','暂无内容');
}
... ... @@ -172,10 +173,10 @@ class UserneedController extends CommonController
}
}
/**
* @title 用户修改需求
* @title 用户修改需求(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/UserNeed/send
* @url /api/portal/UserNeed/changesend
* @method POST
* @param name:city type:varchar require:1 default: other: desc:地区(省-市-区)
* @param name:quarters type:varchar require:1 default: other: desc:小区
... ... @@ -193,6 +194,7 @@ class UserneedController extends CommonController
* @param name:code type:int require:1 default: other: desc:验证码
* @param name:else type:int require:1 default: other: desc:备注
* @param name:need_id type:int require:1 default: other:修改需求时传 desc:需求id
* @param name:token type:varchar require:1 default: other: desc:token
* @return data:''@
* @data type:'1->包干价,2->问答'
* @data need_id:'需求id'
... ... @@ -239,7 +241,7 @@ class UserneedController extends CommonController
$model = new UserNeedModel();
// 修改
$where_need['userNeed_id'] = $request->param('need_id');
$where_need['id'] = $request->param('need_id');
$where_need['status'] = 1;
$need = Db::name('UserNeed')->where($where_need)->find();
if(!$need){
... ... @@ -252,15 +254,18 @@ class UserneedController extends CommonController
$save = $model->isUpdate(true)->allowField(true)->save($data);
}
if($save){
$final['need_id'] = $model->getLastInsID();;
$this->apiResponse('1','添加成功',$final);
$final['need_id'] = $model->id;
$this->apiResponse('1','修改成功',$final);
}else{
$this->apiResponse('0','添加失败');
$this->apiResponse('0','修改失败');
}
}else{
$data = $request->param();
if(empty($data['need_id'])){
$this->apiResponse('0','需求id不可為空');
}
$where_need['id'] = $request->param('need_id');
$where_need['status'] = 1;
$where_mem['token'] = $data['token'];
... ... @@ -272,11 +277,13 @@ class UserneedController extends CommonController
}
// 问答内容
$where_pro['status'] = 1;
$list['list'] = Db::name('NeedAnswer')->where($where_pro)->order("update_time desc")->field("title,content,id,type")->select()->toArray();
foreach ($list as $lk=>$lv){
$list[$lk]['content'] = htmlspecialchars_decode($lv['content']);
$answer = Db::name('NeedAnswer')->where($where_pro)->order("update_time desc")->field("title,content,id,type")->select()->toArray();
foreach ($answer as $lk=>$lv){
$answer[$lk]['content'] = htmlspecialchars_decode($lv['content']);
}
$list['answer'] = $answer;
if($list){
$this->apiResponse('1','成功',$list);
}else{
$this->apiResponse('0','暂无内容');
... ...
... ... @@ -17,7 +17,7 @@ class UserValidate extends Validate
protected $rule = [
'name' => ['require','length:2,4','chs'],
'password' => ['require','length:6,16'],
'tel' => ['regex'=>'/13[123569]{1}\d{8}|15[1235689]\d{8}|18\d{9}/','require'],
'tel' => ['regex'=>'/^1(3|4|5|7|8)\d{9}$/','require'],
'sure_password' => 'require',
'city' => 'require',
... ...
... ... @@ -80,9 +80,14 @@ class CaptchaController
$config = array_merge($defaultCaptchaConfig, $config);
}
ob_clean();//解决验证码不显示问题
$rand = $request->param('rand');
$captcha = new Captcha($config);
ob_clean();// 清除输出缓存
// $final_return['img'] = $captcha->entry($id,$rand);
// $final_return['rand'] = $rand;
return $captcha->entry($id);
// return $final_return;
}
}
... ...
... ... @@ -182,6 +182,7 @@ class Session
$value = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
}
}
return $value;
}
... ...
... ... @@ -11,6 +11,7 @@
namespace think\captcha;
use think\Db;
use think\Session;
class Captcha
... ... @@ -112,7 +113,6 @@ class Captcha
if (empty($code) || empty($secode)) {
return false;
}
// session 过期
if (time() - $secode['verify_time'] > $this->expire) {
Session::delete($key, '');
... ... @@ -126,6 +126,8 @@ class Captcha
return false;
}
/**
* 输出验证码并把验证码的值保存的session中
* 验证码保存到session的格式为: array('verify_code' => '验证码值', 'verify_time' => '验证码创建时间');
... ... @@ -199,14 +201,28 @@ class Captcha
$secode['verify_code'] = $code; // 把校验码保存到session
$secode['verify_time'] = time(); // 验证码创建时间
Session::set($key . $id, $secode, '');
$rand = str_replace(".","",substr(microtime(true),-5)).rand(1000,9999);
if(!empty($rand)){
$img_add['code'] = $code;
$img_add['time'] = time();
$img_add['rand'] = $rand;
$img_add['create_time'] = time();
Db::name('Imgcode')->insertGetId($img_add);
session('verify_code',$code);
session('verify_time',time());
}
ob_start();
// 输出图像
imagepng($this->_image);
$content = ob_get_clean();
imagedestroy($this->_image);
return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/png');
// return response($content, 200, ['Content-Length' => strlen($content),'rand' => $rand])->contentType('image/png');
$re = response($content, 200, ['Content-Length' => strlen($content),'rand' => $rand])->contentType('image/png');
return $re;
}
/**
... ...
... ... @@ -8,7 +8,7 @@ class Doc
'version'=>'1.0.0',
'copyright'=>'Powered By Zhangweiwei',
'password' => '',
'static_path' => 'http://localhost/housePrice/simplewind/vendor/weiwei/api-doc/src/assets',
'static_path' => 'http://192.168.1.15/simplewind/vendor/weiwei/api-doc/src/assets',
'controller' => [
'api\\portal\\controller\\IndexController',
'api\\portal\\controller\\ArticleController',
... ...