first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
fef947fe-2d1e-4d17-8534-a5fe191e30f0
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: NING MEI
|
||||
* Date: 2020/4/13
|
||||
* Time: 10:58
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
use app\lib\exception\ParamException;
|
||||
use app\common\controller\Encryption;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* 验证用户token并返回用户id
|
||||
* @param $token
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function verifyToken()
|
||||
{
|
||||
$token = $this->request->header('token','');
|
||||
$userInfo = Cache::store('redis')->get($token);
|
||||
|
||||
if($userInfo){
|
||||
$userInfo = json_decode($userInfo,true);
|
||||
if(is_array($userInfo)){
|
||||
$user_id = $userInfo['uid'];
|
||||
}else{
|
||||
$user_id = $userInfo;
|
||||
}
|
||||
|
||||
return $user_id;
|
||||
}
|
||||
else{
|
||||
throw new ParamException([
|
||||
'code'=>401,
|
||||
'msg' => '登录过期,请重新登录!',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* rsa加密
|
||||
* */
|
||||
public function rsaEncry($data){
|
||||
$encry = new Encryption();
|
||||
$res = $encry->encrypt($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
* rsa解密
|
||||
* */
|
||||
public function rsaDecipher($data){
|
||||
$encry = new Encryption();
|
||||
$res = $encry->decrypt($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
* 检查用户登录信息
|
||||
* 根据身份信息检查用户登录必填参数
|
||||
* */
|
||||
public function checkUserParam($array){
|
||||
$proSubArr = config('setsub.diffProTest');
|
||||
if(!empty($array['userPro'])){
|
||||
$userPro = $array['userPro'];
|
||||
}else{
|
||||
if(!empty($array['province'])){
|
||||
$userPro = config('province.province')[$array['province']*10000]['code'];
|
||||
}
|
||||
}
|
||||
if(!empty($userPro)){
|
||||
//type 1普通高考 2新高考 3特殊高考
|
||||
if(in_array($userPro,$proSubArr[1])){
|
||||
if(!intval($array['mySub']) || !intval($array['subType'])){
|
||||
throw new ParamException([
|
||||
'code'=>400,
|
||||
'msg' => '文理科或科目必选',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
}elseif(in_array($userPro,$proSubArr[2])){
|
||||
if(!intval($array['mySub'])){
|
||||
throw new ParamException([
|
||||
'code'=>400,
|
||||
'msg' => '科目必选',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
if(!intval($array['subType'])){
|
||||
throw new ParamException([
|
||||
'code'=>400,
|
||||
'msg' => '文理科必选',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
124
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Info.php
Normal file
124
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Info.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 19:34
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\Province;
|
||||
use app\api\model\Batchs;
|
||||
use app\api\model\ProScoreRank;
|
||||
use app\api\validate\BatchsValidate;
|
||||
use app\api\validate\IDMustValidate;
|
||||
use think\Db;
|
||||
|
||||
class Info extends BaseController
|
||||
{
|
||||
/*
|
||||
* 区域查询
|
||||
* */
|
||||
public function getAreaInfo(){
|
||||
$type = input('type',1);
|
||||
$result = Province::getAreaInfo($type);
|
||||
return api_return("获取成功",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 院校类型和院校特色
|
||||
* */
|
||||
public function getSchoolTypeInfo(){
|
||||
//院校类型
|
||||
$result = Db::table('school_cates')->cache(3600)->select();
|
||||
$res['schoolType'] = $result;
|
||||
//院校特色
|
||||
$res['schoolFeature'] = config('setsub.schoolFeature');
|
||||
//院校性质
|
||||
$res['schoolPub'] = config('setsub.is_pub');
|
||||
return api_return("获取成功",$res);
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据省份和年份,文理、分数查询最新批次
|
||||
* @param province int 省份code
|
||||
* */
|
||||
public function getBatchsByProvince(){
|
||||
//参数验证
|
||||
(new BatchsValidate())->goCheck();
|
||||
$provinceID = input('province');
|
||||
$score = input('score');
|
||||
$subType = input('subType',0);
|
||||
$result = Batchs::getBatchsByProvince($provinceID,$score,$subType);
|
||||
if(empty($result)){
|
||||
return api_error('暂无批次');
|
||||
}else{
|
||||
return api_return('获取成功',$result);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* 根据省份获取科目相关数据
|
||||
* @Param int provinceID
|
||||
* */
|
||||
public function getProSubject(){
|
||||
//参数验证
|
||||
(new IDMustValidate())->goCheck();
|
||||
$provinceID = input('id');
|
||||
//找出该省份高考类型并返回科目
|
||||
$proSubArr = config('setsub.diffProTest');
|
||||
$result = array();
|
||||
|
||||
//type 1普通高考 2新高考 3特殊高考
|
||||
if(in_array($provinceID,$proSubArr[1])){
|
||||
$result['subType'] = config('setsub.subType');
|
||||
$result['type'] = 3;
|
||||
$result['specialTestSub'] = config('setsub.specialTestSub');
|
||||
}elseif(in_array($provinceID,$proSubArr[2])){
|
||||
$result['type'] = 2;
|
||||
$result['newTestSub'] = config('setsub.newTestSub');
|
||||
}else{
|
||||
$result['type'] = 1;
|
||||
$result['subType'] = config('setsub.subType');
|
||||
}
|
||||
|
||||
|
||||
return api_return("获取成功!",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据省份和分数,文理科查询位次
|
||||
* */
|
||||
public function getUserProRank(){
|
||||
(new BatchsValidate())->goCheck();
|
||||
$array = input('');
|
||||
$result = ProScoreRank::getProRankByScore($array);
|
||||
return api_return("ok",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 图片上传
|
||||
* */
|
||||
public function uploadImage()
|
||||
{
|
||||
$this->verifyToken();
|
||||
// 获取上传文件
|
||||
$file = request()->file('imageName');
|
||||
$path = './uploads';
|
||||
// 移动到框架应用根目录/public/uploads/ 目录下
|
||||
$info = $file->validate(['size'=>41943040,'ext'=>'jpg,png,gif'])->move($path);
|
||||
|
||||
// 获取表单上传文件
|
||||
if ($info) {
|
||||
$infopath = str_replace("\\","/",$info->getSaveName());
|
||||
// 成功上传后 获取上传信息
|
||||
return api_return('ok',$infopath);
|
||||
} else {
|
||||
return api_error('upload fail');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
139
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Login.php
Normal file
139
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Login.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User:
|
||||
* Date: 2020/4/13
|
||||
* Time: 13:27
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\service\UserToken;
|
||||
use app\api\validate\LoginValidate;
|
||||
use app\lib\exception\ParamException;
|
||||
use app\api\service\SendMessage;
|
||||
use app\api\model\User;
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
|
||||
class Login extends BaseController
|
||||
{
|
||||
/**
|
||||
* 非小程序登录
|
||||
* @url api/appLogin
|
||||
* @return string
|
||||
*/
|
||||
public function appLogin()
|
||||
{
|
||||
|
||||
//参数验证
|
||||
(new LoginValidate())->goCheck();
|
||||
//解密手机号和验证码验证
|
||||
$telnum = $this->rsaDecipher($telnum = input('telnum'));
|
||||
|
||||
/* $code = input('code');
|
||||
$codeCache = Cache::store('redis')->get($telnum);
|
||||
if($code != $codeCache){
|
||||
throw new ParamException([
|
||||
'code' => 400,
|
||||
'msg' => '验证码错误',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}*/
|
||||
//手机号正则验证
|
||||
$check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
|
||||
if (!preg_match($check, $telnum)){
|
||||
throw new ParamException([
|
||||
'code' => 400,
|
||||
'msg' => '手机号格式不正确',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
|
||||
//查询数据库是否有该用户,有获取token,无新增并获取token
|
||||
$userInfo = User::getUserInfoByPhone($telnum);
|
||||
|
||||
|
||||
if($userInfo){
|
||||
|
||||
$ut = new UserToken('');
|
||||
$token['token'] = $ut->LoginToken($userInfo['uid']);
|
||||
$userInfo['token'] = $token['token'];
|
||||
$userInfo['phone'] = substr_replace($userInfo['phone'],'****',3,4);
|
||||
|
||||
//查看用户数据库是否有分数,没有返回false,前端判断给弹出填志愿信息框
|
||||
if(empty($userInfo['score'])){
|
||||
$res['phone'] = $userInfo['phone'];
|
||||
$res['user_name'] = $userInfo['user_name'];
|
||||
$res['token'] = $token['token'];
|
||||
return api_return('分数必填',$res);
|
||||
}
|
||||
|
||||
return api_return('获取成功',$userInfo);
|
||||
}else{
|
||||
//定义数组
|
||||
$array = input('');
|
||||
$array['phone'] = $telnum;
|
||||
//参数再次验证
|
||||
$this->checkUserParam($array);
|
||||
//数据库插入数据
|
||||
$userInfo = User::addUserInfo($array);
|
||||
|
||||
$ut = new UserToken('');
|
||||
$userInfo['token'] = $ut->LoginToken($userInfo['uid']);
|
||||
return api_return('登录成功',$userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改用户信息
|
||||
* */
|
||||
public function modifyUserInfo(){
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('');
|
||||
//参数验证
|
||||
$this->checkUserParam($array);
|
||||
$array['user_id'] = $user_id;
|
||||
|
||||
$array['token'] = $this->request->header('token','');
|
||||
$result = User::editUserInfo($array);
|
||||
if($result){
|
||||
return api_return("修改成功",$result);
|
||||
}else{
|
||||
return api_return("修改失败",$result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @url api/sendCode
|
||||
* 发送手机号验证码
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function sendMobileCode()
|
||||
{
|
||||
$telnum = input('telnum');
|
||||
if(empty($telnum)){
|
||||
throw new ParamException([
|
||||
'code' => 400,
|
||||
'msg' => '手机号参数必须',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
//解密手机号
|
||||
$telnum = $this->rsaDecipher($telnum);
|
||||
//手机号正则验证
|
||||
$check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
|
||||
if (!preg_match($check, $telnum)){
|
||||
return api_error('手机号格式错误');
|
||||
}
|
||||
$code = rand(1000,9999);
|
||||
Cache::store("redis")->set($telnum,$code,300);
|
||||
$res = SendMessage::sendAliMessage($telnum,config('alidayu.signName'),config('alidayu.msgSms'),['code'=>$code]);
|
||||
if($res['status'] == 1)
|
||||
return api_return('发送成功');
|
||||
else
|
||||
return api_error('发送失败');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 19:01
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\validate\DefaultMajorValidate;
|
||||
use app\api\validate\MajorSchValidate;
|
||||
use app\api\validate\MajorValidate;
|
||||
use app\api\validate\NewMajorSchValidate;
|
||||
use app\api\validate\NewSchMajorValidate;
|
||||
use app\api\validate\SearchAboutValidate;
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Db;
|
||||
use app\api\model\Major as MajorModel;
|
||||
use app\api\model\NewMajor;
|
||||
class Major extends BaseController
|
||||
{
|
||||
|
||||
/*
|
||||
* 专业搜索框下拉
|
||||
* */
|
||||
public function getSearchAbout(){
|
||||
(new SearchAboutValidate())->goCheck();
|
||||
$title = input('title');
|
||||
$result = Db::table('yzy_majors')->field('title')->where([['title','like',$title . '%'],['level','=',3]])->select();
|
||||
return api_return("ok",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 搜索专业
|
||||
* */
|
||||
public function getMajorInfo(){
|
||||
(new MajorValidate())->goCheck();
|
||||
$page = input('page',1);;
|
||||
$array = input();
|
||||
$result = MajorModel::getMajorInfoByTitle($array,$page);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取专业搜索页默认值
|
||||
* */
|
||||
public function getDefaultMajor(){
|
||||
(new DefaultMajorValidate())->goCheck();
|
||||
$userPro = input('userPro');
|
||||
$array = input();
|
||||
$result = MajorModel::getDefaultMajor($array);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 普通高考查询外省向本省招收专业的学校
|
||||
* */
|
||||
public function getMajorSchool(){
|
||||
(new MajorSchValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
$page = input('page',1);
|
||||
$result = MajorModel::getMajorSch($array,$user_id,$page);
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考查询外省向本省招收专业的学校
|
||||
* */
|
||||
public function getNewMajorSch(){
|
||||
(new NewMajorSchValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
$page = input('page',1);
|
||||
$result = NewMajor::getNewMajorSch($array,$user_id,$page);
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/26
|
||||
* Time: 14:46
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\User;
|
||||
use app\api\model\RecZhejiangMajor;
|
||||
use app\api\validate\NewMajorValidate;
|
||||
use app\api\validate\NewSchMajorValidate;
|
||||
use app\api\model\NewSchMajor;
|
||||
|
||||
class NewTypeMajor extends BaseController
|
||||
{
|
||||
/*
|
||||
* 新高考专业查询
|
||||
* */
|
||||
public function getNewMajor(){
|
||||
//参数验证
|
||||
(new NewMajorValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
$vipType = 0;
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$user_id = $this->verifyToken();
|
||||
//验证用户
|
||||
$limit = 5;
|
||||
//用户已登录验证是否具有查看概率权限
|
||||
$resAuth = User::checkUserAuthByUserID($user_id,$array['type'],$array['userPro'],$array['score'],0,$array['mySub']);
|
||||
if($resAuth == 0){
|
||||
$limit = 10;
|
||||
$vipType = 1;
|
||||
}
|
||||
|
||||
}else{
|
||||
$limit = 2;
|
||||
$user_id = 0;
|
||||
}
|
||||
|
||||
$page = $array['page'];
|
||||
$result = RecZhejiangMajor::getNewMajorBy($array,$page,$limit,$user_id,$vipType);
|
||||
return api_return($result['msg'],$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 返回专业数量
|
||||
* */
|
||||
public function getNewMajorCount(){
|
||||
//参数验证
|
||||
(new NewMajorValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$this->verifyToken();
|
||||
}
|
||||
$result = RecZhejiangMajor::getNewMajorCount($array);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考院校查询
|
||||
* */
|
||||
public function getNewMajorSchool(){
|
||||
//参数验证
|
||||
(new NewMajorValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
$vipType = 0;
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$user_id = $this->verifyToken();
|
||||
//验证用户
|
||||
$limit = 5;
|
||||
//用户已登录验证是否具有查看概率权限
|
||||
$resAuth = User::checkUserAuthByUserID($user_id,$array['type'],$array['userPro'],$array['score'],0,$array['mySub']);
|
||||
if($resAuth == 0){
|
||||
$limit = 10;
|
||||
$vipType = 1;
|
||||
}
|
||||
|
||||
}else{
|
||||
$limit = 2;
|
||||
$user_id = 0;
|
||||
}
|
||||
|
||||
$page = $array['page'];
|
||||
$result = RecZhejiangMajor::getNewMajorSch($array,$page,$limit,$user_id,$vipType);
|
||||
return api_return($result['msg'],$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 查询新高考学校的专业
|
||||
* */
|
||||
public function getNewSchMajor(){
|
||||
(new NewSchMajorValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
$user_id = 0;
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$user_id = $this->verifyToken();
|
||||
}
|
||||
$result = NewSchMajor::getNewSchoolMajors($array,$user_id);
|
||||
if($result){
|
||||
return api_return('ok',$result);
|
||||
}else{
|
||||
return api_return('暂无数据');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回新高考院校数量
|
||||
* */
|
||||
public function getNewSchoolCount(){
|
||||
//参数验证
|
||||
(new NewMajorValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$this->verifyToken();
|
||||
}
|
||||
$result = RecZhejiangMajor::getNewSchoolCount($array);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
111
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Order.php
Normal file
111
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Order.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 13:24
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\service\Order as OrderService;
|
||||
use app\api\validate\OrderValidate;
|
||||
use app\api\service\UserToken;
|
||||
use app\api\model\User;
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class Order extends BaseController
|
||||
{
|
||||
/*
|
||||
* 创建订单
|
||||
* */
|
||||
public function placeOrder(){
|
||||
|
||||
(new OrderValidate())->goCheck();
|
||||
//获取传递参数
|
||||
$orderInfo = input('post.');
|
||||
|
||||
$orderInfo['subType'] = input('post.subType',0);
|
||||
$orderInfo['mySub'] = input('post.mySub',0);
|
||||
$uid = $this->verifyToken();
|
||||
//解密手机号
|
||||
$orderInfo['telnum'] = $this->rsaDecipher($telnum = input('telnum'));
|
||||
//手机号正则验证
|
||||
$check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
|
||||
if (!preg_match($check, $orderInfo['telnum'])){
|
||||
throw new ParamException([
|
||||
'code' => 400,
|
||||
'msg' => '手机号格式不正确',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
|
||||
$order = new OrderService();
|
||||
$result['status'] = $order->place($uid,$orderInfo);
|
||||
|
||||
return api_return('下单成功',$result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//未登录处理
|
||||
private function checkNoLogin($orderInfo){
|
||||
//检查参数并创建用户
|
||||
$this->checkUserParam($orderInfo);
|
||||
//解密手机号
|
||||
$orderInfo['phone'] = $this->rsaDecipher($telnum = input('telnum'));
|
||||
//手机号正则验证
|
||||
$check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
|
||||
if (!preg_match($check, $orderInfo['phone'])){
|
||||
throw new ParamException([
|
||||
'code' => 400,
|
||||
'msg' => '手机号格式不正确',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
|
||||
//检测手机号是否已注册,注册则登录,否则添加新数据
|
||||
$userCount = User::checkUserByTelnum( $orderInfo['phone']);
|
||||
if($userCount){
|
||||
throw new ParamException([
|
||||
'msg' => '手机号已注册!请登录',
|
||||
'errorCode' => 10000,
|
||||
'code' => 400,
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
}else{
|
||||
$resUser = User::addUserInfo($orderInfo);
|
||||
return $resUser;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询顶订单是否支付成功
|
||||
* */
|
||||
public function checkOrderPay(){
|
||||
$user_id = $this->verifyToken();
|
||||
$orderID = input('order_id');
|
||||
//参数验证
|
||||
if(!intval($orderID)){
|
||||
throw new ParamException([
|
||||
'msg' => '订单id参数错误',
|
||||
'errorCode' => 10000,
|
||||
'code' => 400
|
||||
]);
|
||||
}
|
||||
|
||||
$result = Db::table("orders")->field('status')->where([['user_id','=',$user_id],['id','=',$orderID]])->find();
|
||||
|
||||
if(empty($result)){
|
||||
throw new ParamException([
|
||||
'msg' => '订单不存在',
|
||||
'errorCode' => 10004,
|
||||
'code' => 404
|
||||
]);
|
||||
}
|
||||
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 20:27
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\model\Order as OrderModel;
|
||||
use app\api\service\WxNotify;
|
||||
use app\api\service\Pay as PayService;
|
||||
use think\facade\Log;
|
||||
|
||||
|
||||
class Pay extends BaseController
|
||||
{
|
||||
/*
|
||||
* 支付
|
||||
* */
|
||||
public function prePayOrder(){
|
||||
$user_id = $this->verifyToken();
|
||||
$payType = input('post.pay_type',1);
|
||||
$payWay = input('post.pay_way',1);
|
||||
//订单ID
|
||||
$orderID = input('post.order_id');
|
||||
//支付后返回页面
|
||||
$rebackUrl = input('post.rebackUrl');
|
||||
|
||||
//验证订单信息并返回订单号
|
||||
$pay = new PayService($orderID,$payType,$payWay);
|
||||
//payType1是移动支付,2是pc支付,PayWay 1是微信支付2是支付宝
|
||||
$res = [];
|
||||
if($payWay == 1){
|
||||
$result = $payType == 2?$pay->codePay($user_id):$pay->wapPay($user_id,$rebackUrl);
|
||||
$res['url'] = $result;
|
||||
$res['pay_way'] = 1;
|
||||
}else{
|
||||
$result = $payType == 2?$pay->alipay_pc($user_id,$rebackUrl):$pay->alipay_wap($user_id,$rebackUrl);
|
||||
$res['url'] = $result;
|
||||
$res['pay_way'] = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return api_return('成功',$res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//微信支付回调
|
||||
public function receiveNotify(){
|
||||
//2..更新订单状态
|
||||
$notify = new WxNotify();
|
||||
$notify->Handle();
|
||||
|
||||
}
|
||||
|
||||
//支付宝异步回调
|
||||
public function alipayNotifyUrl()
|
||||
{
|
||||
$params=$_POST;
|
||||
//获取支付成功后支付宝返回的参数
|
||||
$out_trade_no = htmlspecialchars($params['out_trade_no']);//商户订单号
|
||||
$total_amount = htmlspecialchars($params['total_amount']);//价格
|
||||
$trade_status = htmlspecialchars($params['trade_status']);//交易状态
|
||||
$gmt_payment = htmlspecialchars($params['gmt_payment']);//交易付款时间
|
||||
|
||||
if ($trade_status == "TRADE_SUCCESS" || $trade_status == "TRADE_FINISHED") {//支付成功
|
||||
|
||||
$data['status'] = 1;
|
||||
$data['pay_way'] = 2;
|
||||
$data['pay_time'] = strtotime($gmt_payment);
|
||||
OrderModel::where([['ord_no','=',$out_trade_no],['money','=',$total_amount]])->update($data);
|
||||
|
||||
echo "success"; //请不要修改或删除
|
||||
} else {
|
||||
echo "fail";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 17:38
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
class Product extends BaseController
|
||||
{
|
||||
/*
|
||||
* 返回商品价格
|
||||
* */
|
||||
public function getProductPrice(){
|
||||
$result = config('product.vipType');
|
||||
return api_return("ok",$result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/5/11
|
||||
* Time: 12:01
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
class Protest
|
||||
{
|
||||
//获取试题类型
|
||||
public function getPart(){
|
||||
$array = array(
|
||||
1 => "请认真选择您所感兴趣的活动",
|
||||
2 => "请认真您所擅长的活动",
|
||||
3 => "请认真选择你所喜欢的职业",
|
||||
4 => "请根据对每一题目的第一印象作答"
|
||||
);
|
||||
$partId = mt_rand(1,3);
|
||||
$result = array(
|
||||
'partId' => $partId,
|
||||
'title' => $array[$partId]
|
||||
);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取试题
|
||||
* */
|
||||
public function getPaper(){
|
||||
$partId = input("post.partId");
|
||||
$result = Db::table('question')->where('part','=',$partId)->select();
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 测试结果
|
||||
* */
|
||||
public function getResult(){
|
||||
$array = input('post.testNum');
|
||||
$sortNum = array_column($array, 'num');
|
||||
array_multisort($sortNum, SORT_DESC, $array);
|
||||
/* $qq = $array[0]['type'].$array[1]['type'].$array[2]['type'];
|
||||
$testConfig = config('protest.testresult');
|
||||
$resTest =$testConfig[$qq];*/
|
||||
$result = [];
|
||||
//统计数据
|
||||
$resultCount[0]['num'] = Db::table('pro_majors')->where([['level','=',3],['is'.$array[0]['type'],'=',1]])->count();
|
||||
$resultCount[0]['type'] = $array[0]['type'];
|
||||
$resultCount[1]['num'] = Db::table('pro_majors')->where([['level','=',3],['is'.$array[1]['type'],'=',1]])->count();
|
||||
$resultCount[1]['type'] = $array[1]['type'];
|
||||
$resultCount[2]['num'] = Db::table('pro_majors')->where([['level','=',3],['is'.$array[2]['type'],'=',1],['is'.$array[0]['type'],'=',0],['is'.$array[1]['type'],'=',0]])->count();
|
||||
$resultCount[2]['type'] = $array[2]['type'];
|
||||
|
||||
//获取特征数据
|
||||
$resultFeature[0]= Db::table('question_type')->field('type,title,feature')->where('type','=',$array[0]['type'])->find();
|
||||
$resultFeature[1]= Db::table('question_type')->field('type,title,feature')->where('type','=',$array[1]['type'])->find();
|
||||
$resultFeature[2]= Db::table('question_type')->field('type,title,feature')->where('type','=',$array[2]['type'])->find();
|
||||
//柱状图饼状图
|
||||
//获取类型名称
|
||||
$typeName = config('protest.typeName');
|
||||
foreach($array as $key=>$val){
|
||||
$array[$key]['percent'] = $val['num']/10*100;
|
||||
$array[$key]['typeName'] = $typeName[$val['type']];
|
||||
}
|
||||
$result['typePic'] = $array;
|
||||
$result['typeCount'] = $resultCount;
|
||||
$result['feature'] = $resultFeature;
|
||||
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取二级专业
|
||||
* */
|
||||
public function getParentLevel(){
|
||||
$data = input('post.');
|
||||
|
||||
$array = $data['testNum'];
|
||||
|
||||
$page = input("post.page",1);
|
||||
|
||||
$limit = 10;
|
||||
|
||||
switch ($data['recType']){
|
||||
case 1:
|
||||
$count = Db::table('pro_majors')->where([['level','=',2],['is'.$array[0]['type'],'=',1]])->count();
|
||||
$result = Db::table('pro_majors')->field('id,title')->where([['level','=',2],['is'.$array[0]['type'],'=',1]])->page($page,$limit)->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
foreach ($result as $key=>$val){
|
||||
$result[$key]['countSon'] = Db::table('pro_majors')->where([['pid','=',$val['id']],['level','=',3],['is'.$array[0]['type'],'=',1]])->count();
|
||||
$result[$key]['pid'] = $val['id'];
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
$count = Db::table('pro_majors')->where([['level','=',2],['is'.$array[1]['type'],'=',1]])->count();
|
||||
$result = Db::table('pro_majors')->field('id,title')->where([['level','=',2],['is'.$array[1]['type'],'=',1]])->page($page,$limit)->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
foreach ($result as $key=>$val){
|
||||
$result[$key]['countSon'] = Db::table('pro_majors')->where([['pid','=',$val['id']],['level','=',3],['is'.$array[1]['type'],'=',1]])->count();
|
||||
$result[$key]['pid'] = $val['id'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$count = Db::table('pro_majors')->where([['level','=',3],['is'.$array[2]['type'],'=',1],['is'.$array[0]['type'],'=',0],['is'.$array[1]['type'],'=',0]])->group('pid')->count();
|
||||
$result = Db::table('pro_majors')->field('pid')
|
||||
->where([['level','=',3],['is'.$array[2]['type'],'=',1],['is'.$array[0]['type'],'=',0],['is'.$array[1]['type'],'=',0]])->group('pid')
|
||||
->page($page,$limit)->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
foreach ($result as $key=>$val){
|
||||
$result[$key]['countSon'] = Db::table('pro_majors')->where([['pid','=',$val['pid']],['level','=',3],['is'.$array[2]['type'],'=',1],['is'.$array[0]['type'],'=',0],['is'.$array[1]['type'],'=',0]])->count();
|
||||
$resTitle = Db::table('pro_majors')->field('title')->where('id','=',$val['pid'])->find();
|
||||
$result[$key]['title'] = $resTitle['title'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'data' => $result,
|
||||
];
|
||||
return api_return('ok',$list);
|
||||
|
||||
}
|
||||
|
||||
//获取子级专业
|
||||
public function getSonLevel(){
|
||||
$data = input('post.');
|
||||
$pid = $data['pid'];
|
||||
$array = $data['testNum'];
|
||||
switch ($data['recType']){
|
||||
case 1:
|
||||
$result = Db::table('pro_majors')->field('id,title')->where([['pid','=',$pid],['level','=',3],['is'.$array[0]['type'],'=',1]])->select();
|
||||
|
||||
break;
|
||||
case 2:
|
||||
$result = Db::table('pro_majors')->field('id,title')->where([['pid','=',$pid],['level','=',3],['is'.$array[1]['type'],'=',1]])->select();
|
||||
|
||||
break;
|
||||
default:
|
||||
$result = Db::table('pro_majors')->field('id,title')
|
||||
->where([['pid','=',$pid],['level','=',3],['is'.$array[2]['type'],'=',1],['is'.$array[0]['type'],'=',0],['is'.$array[1]['type'],'=',0]])
|
||||
->select();
|
||||
|
||||
break;
|
||||
}
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/15
|
||||
* Time: 11:42
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\model\SchoolChoice as ChoiceModel;
|
||||
use app\api\model\SchScore;
|
||||
use app\api\validate\IDMustValidate;
|
||||
use app\api\validate\SchEnrollValidate;
|
||||
use app\api\validate\SchMajorValidate;
|
||||
use app\api\validate\SchoolChoiceValidate;
|
||||
use app\api\model\User;
|
||||
use app\api\model\Major;
|
||||
use think\facade\Log;
|
||||
|
||||
class SchoolChoice extends BaseController
|
||||
{
|
||||
/*
|
||||
* 院校查询
|
||||
* */
|
||||
public function getSchoolBy(){
|
||||
//参数验证
|
||||
(new SchoolChoiceValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
$vipType = 0;
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$user_id = $this->verifyToken();
|
||||
//验证用户
|
||||
$limit = 5;
|
||||
//用户已登录验证是否具有查看概率权限
|
||||
$resAuth = User::checkUserAuthByUserID($user_id,$array['type'],$array['userPro'],$array['score'],$array['subType']);
|
||||
if($resAuth == 0){
|
||||
$vipType = 1;
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
}else{
|
||||
$limit = 2;
|
||||
$user_id = 0;
|
||||
}
|
||||
|
||||
$page = $array['page'];
|
||||
$result = ChoiceModel::getSchoolByCondition($array,$page,$limit,$user_id,$vipType);
|
||||
return api_return($result['msg'],$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 返回院校数量
|
||||
* */
|
||||
public function getSchoolCount(){
|
||||
//参数验证
|
||||
(new SchoolChoiceValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$this->verifyToken();
|
||||
}
|
||||
$result = ChoiceModel::getSchoolCount($array);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询学校的专业
|
||||
* */
|
||||
public function getSchMajorBy(){
|
||||
(new SchMajorValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
$user_id = 0;
|
||||
//判断用户是否登录
|
||||
if($array['is_login']){
|
||||
$user_id = $this->verifyToken();
|
||||
}
|
||||
$result = Major::getSchMajorBy($array,$user_id);
|
||||
if($result){
|
||||
return api_return('ok',$result);
|
||||
}else{
|
||||
return api_return('暂无数据');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 查询院校历年招生情况
|
||||
* */
|
||||
public function getSchEnrollByYear(){
|
||||
(new SchEnrollValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
|
||||
$result = SchScore::getSchEnrollByYear($array);
|
||||
if($result){
|
||||
return api_return('ok',$result);
|
||||
}else{
|
||||
return api_return('暂无数据');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 11:04
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\UserCollect as CollectModel;
|
||||
use app\api\validate\AllCollectSelValidate;
|
||||
use app\api\validate\CollectMajorValidate;
|
||||
use app\api\validate\CollectValidate;
|
||||
use app\api\validate\ColNewMajorValidate;
|
||||
use app\api\validate\ColNewSchValidate;
|
||||
use app\api\validate\IDMustValidate;
|
||||
use app\api\validate\ScoreGradeValidate;
|
||||
use app\lib\exception\ParamException;
|
||||
use app\api\model\CollectMajor;
|
||||
use app\api\model\CollectNewMajor;
|
||||
use app\api\model\CollectNewSch;
|
||||
use think\Db;
|
||||
|
||||
class UserCollect extends BaseController
|
||||
{
|
||||
/*
|
||||
* 收藏学校
|
||||
* */
|
||||
public function addCollectSch(){
|
||||
(new CollectValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
//检查是否已添加收藏
|
||||
CollectModel::checkMyCollectSch($array['rec_id'],$user_id);
|
||||
$result = CollectModel::addUserCollectSch($user_id,$array);
|
||||
return api_return('收藏成功!',$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 我的收藏院校
|
||||
* */
|
||||
public function getMyCollectSchool(){
|
||||
(new AllCollectSelValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
$page = input('page');
|
||||
$result = CollectModel::getMyCollectSch($array,$user_id,$page);
|
||||
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 移除收藏院校
|
||||
* */
|
||||
public function delMyCollectSchool(){
|
||||
(new IDMustValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$id = input('id');
|
||||
$result = CollectModel::delMyCollectSch($id,$user_id);
|
||||
if($result){
|
||||
return api_return('移除成功!',$result);
|
||||
}else{
|
||||
return api_return('移除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 收藏专业
|
||||
* */
|
||||
public function addCollectMajor(){
|
||||
(new CollectMajorValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
//检查是否已添过收藏
|
||||
CollectMajor::checkMyCollectMajor($array['sch_id'],$array['userPro'],$array['majorCode'],$array['subType'],$array['score'],$user_id);
|
||||
$result = CollectMajor::addUserCollectMajor($user_id,$array);
|
||||
return api_return('收藏成功!',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 移除收藏专业
|
||||
* */
|
||||
public function delMyCollectMajor(){
|
||||
(new IDMustValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$id = input('id');
|
||||
$result = CollectMajor::delMyCollectMajor($id,$user_id);
|
||||
if($result){
|
||||
return api_return('移除成功!',$result);
|
||||
}else{
|
||||
return api_return('移除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 我的收藏专业
|
||||
* */
|
||||
public function getMyCollectMajor(){
|
||||
(new AllCollectSelValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
$page = input('page');
|
||||
|
||||
|
||||
$result = CollectMajor::getMyCollectMajor($array,$user_id,$page);
|
||||
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////新高考/////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* 新高考收藏专业
|
||||
* */
|
||||
public function addNewMajor(){
|
||||
(new colNewMajorValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
//检查是否已添过收藏
|
||||
CollectNewMajor::checkMyNewMajor($array['plan_id'],$user_id);
|
||||
$result = CollectNewMajor::addUserNewMajor($user_id,$array);
|
||||
return api_return('收藏成功!',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考移除收藏专业
|
||||
* */
|
||||
public function delNewMajor(){
|
||||
(new IDMustValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$id = input('id');
|
||||
$result = CollectNewMajor::delMyNewMajor($id,$user_id);
|
||||
if($result){
|
||||
return api_return('移除成功!',$result);
|
||||
}else{
|
||||
return api_return('移除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考我的收藏专业
|
||||
* */
|
||||
public function getNewMajor(){
|
||||
(new AllCollectSelValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
$page = input('page');
|
||||
|
||||
$result = CollectNewMajor::getMyNewMajor($array,$user_id,$page);
|
||||
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 新高考收藏院校
|
||||
* */
|
||||
public function addNewSch(){
|
||||
(new colNewSchValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
//检查是否已添过收藏
|
||||
CollectNewSch::checkMyNewSch($array['plan_id'],$user_id);
|
||||
$result = CollectNewSch::addUserNewSch($user_id,$array);
|
||||
return api_return('收藏成功!',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考移除收藏院校
|
||||
* */
|
||||
public function delNewSch(){
|
||||
(new IDMustValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$id = input('id');
|
||||
$result = CollectNewSch::delMyNewSch($id,$user_id);
|
||||
if($result){
|
||||
return api_return('移除成功!',$result);
|
||||
}else{
|
||||
return api_return('移除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考我的收藏院校
|
||||
* */
|
||||
public function getNewSch(){
|
||||
(new AllCollectSelValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
$page = input('page');
|
||||
$result = CollectNewSch::getMyNewSch($array,$user_id,$page);
|
||||
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 普通高考和新高考院校和专业收藏分数段条件
|
||||
* */
|
||||
|
||||
public function getScoreGrade(){
|
||||
(new ScoreGradeValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$array = input('post.');
|
||||
if($array['is_sch']){
|
||||
$table = $array['provinceType'] == 2 ? "user_collect_new_school":"user_collect_school";
|
||||
}else{
|
||||
$table = $array['provinceType'] == 2 ? "user_collect_new_major":"user_collect_major";
|
||||
}
|
||||
|
||||
$result = Db::table($table)->field('score')->where([['user_id','=',$user_id],['userPro','=',$array['userPro']]])->group('score')->select();
|
||||
|
||||
return api_return('ok',$result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/16
|
||||
* Time: 8:56
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\User;
|
||||
use app\api\model\Order as OrderModel;
|
||||
use app\api\validate\MessageValidate;
|
||||
use app\api\validate\UserAuthValidate;
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Db;
|
||||
|
||||
class UserInfo extends BaseController
|
||||
{
|
||||
/*
|
||||
* 查询用户是否具有权限
|
||||
* */
|
||||
public function checkUserAuth(){
|
||||
(new UserAuthValidate())->goCheck();
|
||||
$user_id = $this->verifyToken();
|
||||
$type = input('type');
|
||||
$province =input('province');
|
||||
$score = input('score');
|
||||
$subType = input('subType',0);
|
||||
$mySub = input('mySub',0);
|
||||
$result = User::checkUserAuthByUserID($user_id,$type,$province,$score,$subType,$mySub);
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 个人中心 ->订单数据
|
||||
* */
|
||||
public function myOrderList(){
|
||||
$user_id = $this->verifyToken();
|
||||
|
||||
//未支付分數
|
||||
$resultNoPay = OrderModel::getOrders($user_id,0);
|
||||
|
||||
//已支付分數
|
||||
$resultPay = OrderModel::getOrders($user_id,1);
|
||||
|
||||
|
||||
$resultPay = $this->combinePayOrder($resultPay);
|
||||
|
||||
$result['NoPayOrder'] = $resultNoPay;
|
||||
$result['payOrder'] = $resultPay;
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 已支付订单同属性权限合并处理
|
||||
* */
|
||||
private function combinePayOrder($data){
|
||||
$payArr = [];
|
||||
foreach($data as $key =>$val){
|
||||
if(array_key_exists($val['stu_yzy_province'].'_'.$val['wenli'].'_'.$val['mykemu'].'_'.$val['score'],$payArr)){
|
||||
if($payArr[$val['stu_yzy_province'].'_'.$val['wenli'].'_'.$val['mykemu'].'_'.$val['score']]['vip'] != $val['vip']){
|
||||
|
||||
$payArr[$val['stu_yzy_province'].'_'.$val['wenli'].'_'.$val['mykemu'].'_'.$val['score']]['vip'] .= ','.$val['vip'];
|
||||
}
|
||||
}else{
|
||||
$payArr[$val['stu_yzy_province'].'_'.$val['wenli'].'_'.$val['mykemu'].'_'.$val['score']] = $data[$key];
|
||||
}
|
||||
}
|
||||
//键值序列化
|
||||
$payArr = array_values($payArr);
|
||||
return $payArr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 返回联系客服类型
|
||||
* */
|
||||
public function getMessageType(){
|
||||
$result = config('setmes.mesType');
|
||||
return api_return('ok',$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户留言和提交工单
|
||||
* @param type int type=0是用户留言,其他是联系客服
|
||||
* */
|
||||
public function addUserMessage(){
|
||||
(new MessageValidate())->goCheck();
|
||||
$array = input('post.');
|
||||
$array['user_id'] = $this->verifyToken();
|
||||
//解密手机号和验证码验证
|
||||
$array['telnum'] = $this->rsaDecipher($telnum = $array['telnum']);
|
||||
//手机号正则验证
|
||||
$check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
|
||||
|
||||
if (!preg_match($check, $array['telnum'])){
|
||||
throw new ParamException([
|
||||
'code' => 400,
|
||||
'msg' => '手机号格式不正确',
|
||||
'errorCode' => 10000
|
||||
]);
|
||||
}
|
||||
$array['add_time'] = time();
|
||||
$result = Db::table('user_message')->insert($array);
|
||||
if($result){
|
||||
return api_return('留言成功,管理员会尽快给您回复!',$result);
|
||||
}else{
|
||||
return api_return('留言失败');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 工单查询
|
||||
* */
|
||||
public function getUserMessage(){
|
||||
$user_id = $this->verifyToken();
|
||||
$result = Db::table('user_message')->where([['user_id','=',$user_id],['type','in',('1,2,3,4')]])->select();
|
||||
|
||||
foreach($result as $key => $val){
|
||||
$content = [];
|
||||
$result[$key]['add_time'] = date('Y-m-d H:i:s',$val['add_time']);
|
||||
$result[$key]['reply_time'] = 0 ? 0:date('Y-m-d H:i:s',$val['reply_time']);
|
||||
|
||||
$result[$key]['status'] = $val['status'] == 1 ? '待回复':'已回复';
|
||||
$content[0]['title'] = '用户';
|
||||
$content[0]['desc'] = $val['content'];
|
||||
|
||||
$content[0]['imgArr'][] = empty($val['img1'])? '':config('secure.mpic_url'). $val['img1'];
|
||||
$content[0]['imgArr'][] = empty($val['img2'])? '':config('secure.mpic_url'). $val['img2'];
|
||||
|
||||
|
||||
$content[1]['title'] = '管理员';
|
||||
$content[1]['desc'] = empty($val['reply'])? '待回复':$val['reply'];
|
||||
$content[1]['imgArr'] = '';
|
||||
|
||||
|
||||
unset($val['content']);
|
||||
unset($val['img1']);
|
||||
unset($val['img2']);
|
||||
|
||||
$result[$key]['info'] = $content;
|
||||
|
||||
|
||||
|
||||
}
|
||||
if ($result){
|
||||
return api_return('ok',$result);
|
||||
}else{
|
||||
return api_error('暂无工单');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user