作者 魏强

接口调试提交

... ... @@ -24,6 +24,22 @@ use think\Loader;
class ArticleController extends CommonController
{
/*
* 长度处理
* */
public function changeLen($text,$number,$numberNext){
$change_html = strip_tags(htmlspecialchars_decode($text));
$sub_text_first = mb_substr($change_html,0,$number,'utf-8');
if(strlen($change_html) >= $numberNext){
$sub_text = $sub_text_first.'...';
}else{
$sub_text = $sub_text_first;
}
return $sub_text;
}
/**
* @title 文章列表
* @description 接口说明
... ... @@ -41,11 +57,11 @@ class ArticleController extends CommonController
*/
public function index(Request $request)
{
$size = 2;
$size = 8;
$cart_arr = array();
$choose = array();
$page = $request->param('page');
$where_cate['status'] = 1;
$catrgory = Db::name('PortalCategory')->where($where_cate)->field('id,name')->select()->toArray();
$final['cate'] = $catrgory;
$where_connect['j.status'] = 1;
$where_connect['p.post_status'] = 1;
$where_connect['j.category_id'] = $_POST['articleType'];
... ... @@ -56,10 +72,29 @@ class ArticleController extends CommonController
->join("PortalPost p","p.id = j.post_id")
->page("$page,$size")
->select()->toArray();
foreach ($article_list as $artk=>$artv){
$article_list[$artk]['post_title'] = $this->changeLen($artv['post_title'],25,70);
$article_list[$artk]['create_time'] = date('Y-m-d H:i:s',$artv['create_time']);
}
$where_next['j.status'] = 1;
$where_next['p.post_status'] = 1;
$article_next = Db::name('PortalCategoryPost')->alias('j')
->where($where_next)
->field("j.post_id,j.category_id , c.name , p.post_title,p.create_time")
->join("PortalCategory c","c.id = j.category_id")
->join("PortalPost p","p.id = j.post_id")
->select()->toArray();
foreach ($article_next as $nextk=>$nextv){
if(!in_array($nextv['category_id'],$choose)){
$middle['id'] = $nextv['category_id'];
$middle['name'] = $this->changeLen($nextv['name'],10,30);
$choose[] = $nextv['category_id'];
$cart_arr[] = $middle;
}
}
$final['cate'] = $cart_arr;
if(empty($article_list)){
$this->apiResponse('1','暂无数据');
}else{
... ...
... ... @@ -57,20 +57,20 @@ class IndexController extends CommonController
->field("content")
->order('create_time desc')
->find();
$final['process']['content'] = htmlspecialchars_decode($final['process']['content']);
$final['process']['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($final['process']['content']));
// 3. 最新成交
$where_new['status'] = 1;
$final['new'] = Db::name('New')->where($where_new)->order('score desc')->select()->toArray();
// 4. 合作企业
$where_coo['status'] = 1;
$final['coop'] = Db::name('Cooperation')->where($where_coo)->order("score desc , create_time desc")->field('pic,jump')->select()->toArray();
$final['coop'] = Db::name('Cooperation')->where($where_coo)->order("score desc , create_time desc")->field('pic,jump')->limit(10)->select()->toArray();
foreach ($final['coop'] as $coopk=>$coopv){
if(empty($member['pic'])){
$pic = "../themes/simpleboot3/public/assets/images/house.jpg";
if(empty($coopv['pic'])){
$final['coop'][$coopk]['pic'] = "../themes/simpleboot3/public/assets/images/house.jpg";
}else{
$pic = $coopv['pic'];
$final['coop'][$coopk]['pic'] = cmf_get_image_url($coopv['pic']);
}
$final['coop'][$coopk]['pic'] = cmf_get_image_url($pic);
}
// 5. 文章
$where_cate['c.delete_time'] = 0;
... ...
... ... @@ -30,6 +30,18 @@ class IntermediaryController extends CommonController
parent::__construct();
$this->postModel = $postModel;
}
// 获取ip地址
function getIP(){
global $ip;
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else $ip = "Unknow";
return $ip;
}
// 登录,注册
//tel 手机号
... ... @@ -64,12 +76,12 @@ class IntermediaryController extends CommonController
// 验证
$validate = Loader::validate('User');
if(!$validate->scene('intermediary')->check($data)){
return json(array('code'=>0,'message'=>$validate->getError()));
$this->apiResponse('0',$validate->getError());
}
$data_add['password'] = $this->md5($data['password']);
$sure_password = $this->md5($data['sure_password']);
// 确认密码
if($data['password'] != $sure_password){
if($data_add['password'] != $sure_password){
$this->apiResponse('0','两次密码不一致');
}
... ... @@ -100,11 +112,16 @@ class IntermediaryController extends CommonController
$str = rand(1000,9999).time().rand(100,999);
$data_add['token'] = $this->md5($str);
$data_add['name'] = $data['name'];
$data_add['tel'] = $data['tel'];
$data_add['type'] = 2;
$data_add['reputation'] = 50;
$data_add['start'] = 50;
$data_add['city'] = $request->param('city');
$data_add['company'] = $request->param('company');
$data_add['store'] = $request->param('store');
$data_add['quarters'] = $request->param('quarters');
$data['create_ip'] = $this->getIP();
if(!empty($data['parent_id'])){
$data_add['referee_id'] = $data['parent_id'];
$data_add['referee_tel'] = $data['parent_tel'];
... ... @@ -819,7 +836,7 @@ class IntermediaryController extends CommonController
$where_addParentNext['id'] = $agency_referee;
$needReferee_addNext['money'] = $reward['number']+$agency['amoney'];
$needReferee_addNext['getmoney_id'] = $agency['amid'];
$add_parentNext = Db::name('Member')->where($needReferee_addNext)->update($needReferee_addNext);
$add_parentNext = Db::name('Member')->where($where_addParentNext)->update($needReferee_addNext);
if (!$add_parentNext) {
Db::rollback();
$this->apiResponse('0', '确认失败2');
... ...
... ... @@ -80,7 +80,7 @@ class IntermediaryneedController extends CommonController
public function sendNeed(Request $request){
$data = $request->param();
$page = $data['page'];
$size = 2;
$size = 4;
$where_member['token'] = $data['token'];
// 查询,匹配:省市区县精确匹配,小区名模糊匹配(只要有连续字匹配,就算匹配)
$member_find = Db::name('Member')->where($where_member)->field("id,city,quarters")->find();
... ...
... ... @@ -599,6 +599,107 @@ class UserController extends CommonController
/**
* @title 密码找回第一步(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/User/findPasswordFirst
* @method POST
* @param name:tel type:int require:1 default: other: desc:手机号
* @param name:imgCode type:int require:1 default: other: desc:图片验证码
* @param name:code type:int require:1 default: other: desc:短信验证码
* @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:1
*/
public function findPasswordFirst(Request $request){
$data = $request->param();
if($data){
if(empty($data['tel'])){
$this->apiResponse('0','请输入手机号');
}
if(empty($data['imgCode'])){
$this->apiResponse('0','请输入图片验证码');
}
if(empty($data['code'])){
$this->apiResponse('0','请输入短信验证码');
}
$where_mem['tel'] = $data['tel'];
$where_mem['status'] = array('neq',9);
$is = Db::name('Member')->where($where_mem)->field('id')->find();
if(!$is){
$this->apiResponse('0','该手机号暂未注册');
}
// 验证手机验证码
$where_Code['tel'] = $data['tel'];
$where_Code['type'] = 2;
$code = Db::name('Code')->where($where_Code)->order('create_time desc')->find();
if($code['code'] != $data['code']){
$this->apiResponse('0','短信验证码错误');
}else{
$this->apiResponse('1','成功');
}
}else{
// 返回验证码图片
$img = $this->getImgUrl();
$this->apiResponse('1','成功',$img);
}
}
/**
* @title 密码找回第二步(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/User/findPassword
* @method POST
* @param name:tel type:int require:1 default: other: desc:手机号
* @param name:newPassword type:int require:1 default: other: desc:新密码
* @param name:sureNewPassword type:int require:1 default: other: desc:确认新密码
* @param name:connect type:int require:1 default: other:1 登录注册 ,2其他 desc:1
*/
public function findPasswordNext(Request $request){
$data = $request->param();
if($data){
if(empty($data['tel'])){
$this->apiResponse('0','请输入手机号');
}
if(empty($data['newPassword'])){
$this->apiResponse('0','请输入新密码');
}
if(empty($data['sureNewPassword'])){
$this->apiResponse('0','请输入确认新密码');
}
$where_mem['tel'] = $data['tel'];
$where_mem['status'] = array('neq',9);
$is = Db::name('Member')->where($where_mem)->field('id')->find();
if(!$is){
$this->apiResponse('0','该手机号暂未注册');
}
if($data['newPassword'] == $data['sureNewPassword']){
$where_update['tel'] = $data['tel'];
$middleStr = rand(1000,9999).time().rand(100,999);
$update['token'] = $this->md5($middleStr);
$update['password'] = $this->md5($data['newPassword']);
$is_update = Db::name('Member')->where($where_update)->update($update);
if($is_update){
$this->apiResponse('1','成功',$update['token']);
}else{
$this->apiResponse('0','修改失败');
}
}else{
$this->apiResponse('0','两次密码输入不一致');
}
}else{
// 返回验证码图片
$img = $this->getImgUrl();
$this->apiResponse('1','成功',$img);
}
}
/**
* @title 密码找回(sure)
* @description 接口说明
* @author 开发者
... ... @@ -635,6 +736,7 @@ class UserController extends CommonController
if(!$is){
$this->apiResponse('0','该手机号暂未注册');
}
// 验证手机验证码
$where_Code['tel'] = $data['tel'];
$where_Code['type'] = 2;
... ... @@ -671,6 +773,7 @@ class UserController extends CommonController
/**
* @title 绑定银行卡(sure)
* @description 接口说明
... ... @@ -911,7 +1014,7 @@ class UserController extends CommonController
$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();
$comment = Db::name('Comment')->where($where_comment)->field('is_comment,create_time,content')->find();
if($comment){
// 判断是否超过30天
if(time() > ($comment['create_time'] + 2592000)){
... ... @@ -923,6 +1026,7 @@ class UserController extends CommonController
$user_need[$unk]['comment'] = 1;
}
}
$user_need[$unk]['comment_content'] = $comment['content'];
}else{
$user_need[$unk]['comment'] = 2;
}
... ... @@ -1029,7 +1133,7 @@ class UserController extends CommonController
->where($where_agency)
->join("hp_Member m", 'm.id = a.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')
m.id as user_id,m.name,m.company,m.pic,m.store,m.tel,m.reputation,m.start')
->select()->toArray();
if($agency){
foreach ($agency as $agek=>$agev){
... ... @@ -1040,6 +1144,9 @@ class UserController extends CommonController
$agency[$agek]['deed_tax'] = $this->getStr($agev['deed_tax']);
$agency[$agek]['personal_income_tax'] = $this->getStr($agev['personal_income_tax']);
$agency[$agek]['else_tax'] = $this->getStr($agev['else_tax']);
if(!empty($agev['pic'])) {
$agency[$agek]['pic'] = cmf_get_asset_url($agev['pic']);
}
}
$final['agency'] = $agency;
$this->apiResponse('1','成功',$final);
... ... @@ -1318,7 +1425,7 @@ class UserController extends CommonController
$find = Db::name('UserNeed')->alias('n')
->where($where_find)
->join("Agency a",'a.need_id = n.id')
->field("a.id as intermediary_id")
->field("a.agency_id,a.id as intermediary_id")
->find();
if($find){
$where_first['id'] = $data['need_id'];
... ... @@ -1377,8 +1484,17 @@ class UserController extends CommonController
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,type')->find();
$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;
}
if($member['money'] <= 0){
$this->apiResponse('0','用户余额不足');
}
... ... @@ -1388,14 +1504,7 @@ class UserController extends CommonController
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['user_type'] = $member['type'];
// if($member['type'] == 1){
... ... @@ -1446,9 +1555,15 @@ class UserController extends CommonController
->join('Bank b','b.id=c.bank_id')
->where($where_card)
->field('b.name,c.card_num')->find();
if(!$card){
$final['is_getmoney'] = 0;
}else{
$final['is_getmoney'] = 1;
}
$final['card'] = $card;
$where_umoney['user_id'] = $user['id'];
$where_umoney['status'] = array('neq',9);
$where_umoney['order_type'] = array('in','6,7');
$order_list = Db::name('MoneyDetail')->where($where_umoney)->field('id,title,money,update_time,type')->select()->toArray();
$final['user'] = $user;
if($order_list){
... ...
... ... @@ -76,6 +76,51 @@ class UserneedController extends CommonController
}
}
/**
* @title 用户发布需求验证(sure)
* @description 接口说明
* @author 开发者
* @url /api/portal/UserNeed/judge
* @method POST
* @param name:name type:varchar require:1 default: other: desc:联系人姓名
* @param name:tel type:varchar require:1 default: other: desc:联系人电话
* @param name:code type:int require:1 default: other: desc:验证码
* @param name:token type:varchar require:1 default: other: desc:token
* @return data:''
*/
public function judge(Request $request){
$data = $request->param();
if(empty($data['name'])){
$this->apiResponse('0','联系人姓名不能为空');
}
if(empty($data['tel'])){
$this->apiResponse('0','联系人电话不能为空');
}
if(empty($data['code'])){
$this->apiResponse('0','验证码不能为空');
}else{
$code = $data['code'];
}
$where_code['tel'] = $data['tel'];
$where_code['type'] = 3;
$where_code['status'] = 1;
$where_code['create_time'] = array('egt',(time()-300));
$find_code = Db::name('Code')->where($where_code)->order('create_time')->field('code')->find();
if(!$find_code){
$this->apiResponse('0','验证码错误,请重新获取');
}
if($code != $find_code['code']){
$this->apiResponse('0','验证码错误,请重新获取');
}else{
$updateCode['status'] = 9;
Db::name('Code')->where($where_code)->update($updateCode);
$this->apiResponse('1','成功');
}
}
/**
* @title 用户发布需求(sure)
... ... @@ -97,6 +142,7 @@ class UserneedController extends CommonController
* @param name:name type:varchar require:1 default: other: desc:联系人姓名
* @param name:tel type:varchar require:1 default: other: desc:联系人电话
* @param name:code type:int require:1 default: other: desc:验证码
* @param name:gener type:int require:1 default: other: desc:类型(1->PC,2->手机)
* @param name:else type:int require:1 default: other: desc:备注
* @param name:token type:varchar require:1 default: other: desc:token
* @return data:''@
... ... @@ -111,34 +157,40 @@ class UserneedController extends CommonController
// 判空,处理
$validate = Loader::validate('UserNeed');
if(!$validate->check($_POST)){
return json(array('code'=>0,'message'=>$validate->getError()));
$this->apiResponse('0',$validate->getError());
}
// 加数据库
$data = $request->Post();
if(empty($data['code'])){
Db::rollback();
$this->apiResponse('0','验证码不能为空');
}else{
$code = $data['code'];
}
$where_code['tel'] = $data['tel'];
$where_code['type'] = 3;
$where_code['status'] = 1;
$where_code['create_time'] = array('egt',(time()-300));
$find_code = Db::name('Code')->where($where_code)->order('create_time')->field('code')->find();
if(!$find_code){
Db::rollback();
$this->apiResponse('0','验证码错误,请重新获取');
}
if($code != $find_code['code']){
Db::rollback();
$this->apiResponse('0','验证码错误,请重新获取');
if(empty($data['gener'])){
$this->apiResponse('0','请传类型');
}else{
$updateCode['status'] = 9;
Db::name('Code')->where($where_code)->update($updateCode);
if($data['gener'] == 2){
if(empty($data['code'])){
Db::rollback();
$this->apiResponse('0','验证码不能为空');
}else{
$code = $data['code'];
}
$where_code['tel'] = $data['tel'];
$where_code['type'] = 3;
$where_code['status'] = 1;
$where_code['create_time'] = array('egt',(time()-300));
$find_code = Db::name('Code')->where($where_code)->order('create_time')->field('code')->find();
if(!$find_code){
Db::rollback();
$this->apiResponse('0','验证码错误,请重新获取');
}
if($code != $find_code['code']){
Db::rollback();
$this->apiResponse('0','验证码错误,请重新获取');
}else{
$updateCode['status'] = 9;
Db::name('Code')->where($where_code)->update($updateCode);
}
}
}
// 保证金
$city = $data['city'];
$area = $data['area'];
... ... @@ -175,7 +227,10 @@ class UserneedController extends CommonController
$data['user_id'] = $mem_id['id'];
$model = new UserNeedModel();
// 添加
unset($data['code']);
if($data['gener'] == 2){
unset($data['code']);
}
unset($data['gener']);
unset($data['connect']);
unset($data['token']);
$save = $model->save($data);
... ...
... ... @@ -27,7 +27,6 @@ class UserNeedValidate extends Validate
'quotation_time' => 'require',
'name' => 'require',
'tel' => 'require',
'code' => 'require',
'contract' => 'require',
];
protected $message = [
... ... @@ -43,7 +42,6 @@ class UserNeedValidate extends Validate
'quotation_time.require' => '报价时间不能为空!',
'name.require' => '联系人姓名不能为空!',
'tel.require' => '联系人电话不能为空!',
'code.require' => '验证码不能为空!',
'contract.require' => '请选择是否包干价!',
];
... ...
... ... @@ -63,7 +63,7 @@ class BannerController extends AdminBaseController
}
}
$coo_list = Db::name('Banner')->where($where_coo)->order('score desc , create_time desc')
->paginate(1,false,['query'=>$arr]);
->paginate(10,false,['query'=>$arr]);
// ->select()->toArray();
$page = $coo_list->render();
$this->assign('page',$page);
... ...
... ... @@ -41,17 +41,17 @@ class IndexController extends CommonController
// ];
// $this->redirect($back['alipay_url']);
$data = [
'out_trade_no'=>'2018072798495757',
'trade_no'=>'2018072721001004410589897579',
'out_request_no'=>'2018072798495757',
'refund_amount'=>0.01,
'refund_reason'=>'中介报价少于3人退款'
];
$alipay = controller('Alipay');
$result = $alipay->refundquery($data);
$object = $result->alipay_trade_fastpay_refund_query_response;
var_dump($result->alipay_trade_fastpay_refund_query_response);
// $data = [
// 'out_trade_no'=>'2018072798495757',
// 'trade_no'=>'2018072721001004410589897579',
// 'out_request_no'=>'2018072798495757',
// 'refund_amount'=>0.01,
// 'refund_reason'=>'中介报价少于3人退款'
// ];
// $alipay = controller('Alipay');
// $result = $alipay->refundquery($data);
// $object = $result->alipay_trade_fastpay_refund_query_response;
// var_dump($result->alipay_trade_fastpay_refund_query_response);
// echo "<pre/>";
// print_r('7777');
... ...