first commit
This commit is contained in:
1
芳林公司项目/www.zhiyuanhelp.com/application/api/.pydio
Normal file
1
芳林公司项目/www.zhiyuanhelp.com/application/api/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
c613e1fd-7c05-43af-9bcd-74c50b2b73b8
|
||||
@@ -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('暂无工单');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1
芳林公司项目/www.zhiyuanhelp.com/application/api/model/.pydio
Normal file
1
芳林公司项目/www.zhiyuanhelp.com/application/api/model/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
a294644e-0e11-4dea-ac7d-2e3eb2172436
|
||||
33
芳林公司项目/www.zhiyuanhelp.com/application/api/model/Batchs.php
Normal file
33
芳林公司项目/www.zhiyuanhelp.com/application/api/model/Batchs.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 23:29
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Batchs extends Model
|
||||
{
|
||||
protected $table = 'yzy_batchs';
|
||||
|
||||
/*
|
||||
* 根据省份和年份,文理、分数查询最新批次
|
||||
* @param provinceID int 省份ID
|
||||
* */
|
||||
public static function getBatchsByProvince($provinceID,$score,$subType = 0){
|
||||
//获取配置表的年份
|
||||
$year = config('setsub.year');
|
||||
$result = self::field('batch,batchName')->where([['yzy_province','=',$provinceID],['year','=',$year],['batch','<>',0],
|
||||
['score','<=',$score],['wenli','=',$subType]])->group('batchName')->order('batch asc')->select()->toArray();
|
||||
//判断数组是否大于3,批次大于3的话去掉最低批次
|
||||
if(count($result)>2){
|
||||
array_pop($result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/21
|
||||
* Time: 19:37
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class CollectMajor extends Model
|
||||
{
|
||||
protected $table = 'user_collect_major';
|
||||
|
||||
/*
|
||||
* 收藏专业
|
||||
* @param userID int 用户id
|
||||
* @param data 收藏内容
|
||||
* @return | bool
|
||||
* */
|
||||
public static function addUserCollectMajor($userID, $data)
|
||||
{
|
||||
|
||||
$data['user_id'] = $userID;
|
||||
$data['add_time'] = time();
|
||||
$result = self::insertGetId($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 检查是否已收藏过该专业
|
||||
* */
|
||||
public static function checkMyCollectMajor($sch_id,$userPro,$majorCode,$subType,$score,$userID)
|
||||
{
|
||||
$result = self::where([['user_id', '=', $userID],['sch_id', '=', $sch_id],['is_collect', '=', 1],['userPro','=',$userPro],['majorCode','=',$majorCode],['subType','=',$subType],['score','=',$score]])->count();
|
||||
if($result){
|
||||
throw new ParamException([
|
||||
'code' => 401,
|
||||
'msg' => '已收藏过该专业',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据用户id查询用户收藏的全部专业学校id
|
||||
* */
|
||||
public static function getUserCollectMajor($userID,$userPro,$subType,$score)
|
||||
{
|
||||
$result = self::field('majorCode,sch_id,code')->where([['user_id', '=', $userID], ['is_collect', '=', 1],['userPro','=',$userPro],['subType','=',$subType],['score','=',$score]])->select()->toArray();
|
||||
if ($result) {
|
||||
foreach($result as $key => $val){
|
||||
$result[$key]['majorCode'] = $val['sch_id']."_".$val['majorCode']."_".$val['code'];
|
||||
}
|
||||
$result = array_column($result, 'majorCode');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 移除收藏的专业
|
||||
* */
|
||||
public static function delMyCollectMajor($id, $userID)
|
||||
{
|
||||
$result = self::where([['id', '=', $id], ['user_id', '=', $userID]])->update(['is_collect' => 2]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 查询我收藏的专业
|
||||
* */
|
||||
public static function getMyCollectMajor($data,$userID,$page = 1, $limit = 10)
|
||||
{
|
||||
$where [] = empty($data['score'])?
|
||||
[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1]]:[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1],['score','=',$data['score']]];
|
||||
//统计收藏专业数量
|
||||
$count = self::where($where)->count();
|
||||
//查询专业数据
|
||||
$result = self::where($where)
|
||||
->page($page, $limit)->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
];
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/27
|
||||
* Time: 15:28
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Model;
|
||||
|
||||
class CollectNewMajor extends Model
|
||||
{
|
||||
protected $table = 'user_collect_new_major';
|
||||
|
||||
/*
|
||||
* 新高考收藏专业
|
||||
* @param userID int 用户id
|
||||
* @param data 收藏内容
|
||||
* @return | bool
|
||||
* */
|
||||
public static function addUserNewMajor($userID, $data)
|
||||
{
|
||||
|
||||
$data['user_id'] = $userID;
|
||||
$data['add_time'] = time();
|
||||
$result = self::insertGetId($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 检查是否已收藏过该专业
|
||||
* */
|
||||
public static function checkMyNewMajor($plan_id, $userID)
|
||||
{
|
||||
$result = self::where([['plan_id', '=', $plan_id], ['user_id', '=', $userID],['is_collect','=',1]])->count();
|
||||
if($result){
|
||||
throw new ParamException([
|
||||
'code' => 401,
|
||||
'msg' => '已收藏过该专业',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据用户id查询用户收藏的全部专业学校id
|
||||
* */
|
||||
public static function getUserNewMajor($userID)
|
||||
{
|
||||
$result = self::field('plan_id,professionCode,majorCode')->where([['user_id', '=', $userID], ['is_collect', '=', 1]])->select()->toArray();
|
||||
if ($result) {
|
||||
foreach($result as $key => $val){
|
||||
$result[$key]['majorCode'] = $val['plan_id']."_".$val['majorCode']."_".$val['professionCode'];
|
||||
}
|
||||
$result = array_column($result, 'majorCode');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 新高考移除收藏的专业
|
||||
* */
|
||||
public static function delMyNewMajor($id, $userID)
|
||||
{
|
||||
$result = self::where([['id', '=', $id], ['user_id', '=', $userID]])->update(['is_collect' => 2]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 新高考查询我收藏的专业
|
||||
* */
|
||||
public static function getMyNewMajor($data,$userID,$page = 1, $limit = 10)
|
||||
{
|
||||
$where [] = empty($data['score'])?
|
||||
[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1]]:[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1],['score','=',$data['score']]];
|
||||
//统计收藏专业数量
|
||||
$count = self::where([['user_id', '=', $userID], ['is_collect', '=', 1]])->count();
|
||||
//查询专业数据
|
||||
$result = self::where([['user_id', '=', $userID],['is_collect', '=', 1]])
|
||||
->page($page, $limit)->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
];
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/27
|
||||
* Time: 16:49
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Model;
|
||||
|
||||
class CollectNewSch extends Model
|
||||
{
|
||||
protected $table = 'user_collect_new_school';
|
||||
|
||||
/*
|
||||
* 新高考收藏院校
|
||||
* @param userID int 用户id
|
||||
* @param data 收藏内容
|
||||
* @return | bool
|
||||
* */
|
||||
public static function addUserNewSch($userID, $data)
|
||||
{
|
||||
|
||||
$data['user_id'] = $userID;
|
||||
$data['add_time'] = time();
|
||||
$result = self::insertGetId($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 检查是否已收藏过该院校
|
||||
* */
|
||||
public static function checkMyNewSch($plan_id, $userID)
|
||||
{
|
||||
$result = self::where([['user_id', '=', $userID],['plan_id', '=', $plan_id],['is_collect','=',1]])->count();
|
||||
if($result){
|
||||
throw new ParamException([
|
||||
'code' => 401,
|
||||
'msg' => '已收藏过该院校',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据用户id查询用户收藏的全部专业学校id
|
||||
* */
|
||||
public static function getNewUserSch($userID)
|
||||
{
|
||||
$result = self::field('plan_id')->where([['user_id', '=', $userID], ['is_collect', '=', 1]])->select()->toArray();
|
||||
if ($result) {
|
||||
$result = array_column($result, 'plan_id');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 新高考移除收藏的院校
|
||||
* */
|
||||
public static function delMyNewSch($id, $userID)
|
||||
{
|
||||
$result = self::where([['id', '=', $id], ['user_id', '=', $userID]])->update(['is_collect' => 2]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 新高考查询我收藏的院校
|
||||
* */
|
||||
public static function getMyNewSch($data,$userID,$page = 1, $limit = 10)
|
||||
{
|
||||
$where [] = empty($data['score'])?
|
||||
[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1]]:[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1],['score','=',$data['score']]];
|
||||
//统计收藏院校数量
|
||||
$count = self::where($where)->count();
|
||||
//查询院校数据
|
||||
$result = self::where($where)
|
||||
->page($page, $limit)->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
];
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
280
芳林公司项目/www.zhiyuanhelp.com/application/api/model/Major.php
Normal file
280
芳林公司项目/www.zhiyuanhelp.com/application/api/model/Major.php
Normal file
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 19:39
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Major extends Model
|
||||
{
|
||||
protected $table = 'yzy_majors';
|
||||
|
||||
/*
|
||||
* 通过title搜索专业数据
|
||||
* */
|
||||
public static function getMajorInfoByTitle($array,$page,$limit = 10){
|
||||
//获取配置表的年份
|
||||
$year = config('setsub.year');
|
||||
$title = $array['title'];
|
||||
//搜索条件
|
||||
unset($array['page']);
|
||||
unset($array['type']);
|
||||
unset($array['title']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'userPro':
|
||||
$where[] = ['yzy_province', '=', $value];
|
||||
break;
|
||||
case 'subType':
|
||||
$where[] = ['wenli', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$where[] = ['province', 'in', ($value)];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$count = self::where([['title','like','%'.$title . '%'],['level','=',3]])->cache(3600)
|
||||
->count();
|
||||
|
||||
//查询在本省招生专业的数据
|
||||
$result = self::field('title,pid,code')
|
||||
->where([['title','like','%'.$title . '%'],['level','=',3]])
|
||||
->cache(3600)
|
||||
->page($page,$limit)
|
||||
->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
foreach($result as $key => $val){
|
||||
//查询向本省招该专业的院校数量
|
||||
$result[$key]['countSch'] = Db::table('yzy_major_plan')->where($where)->where([['majorCode','=',$val['code']],['year','=',$year]])->count();
|
||||
$result[$key]['sumPlan'] = Db::table('yzy_major_plan')->where($where)->where([['majorCode','=',$val['code']],['year','=',$year]])->sum('planNum');
|
||||
|
||||
//获取类别
|
||||
$majorType = self::field('title')->where('id','=',$val['pid'])->find();
|
||||
$result[$key]['typeName'] = $majorType['title'];
|
||||
|
||||
//获取专业相关信息
|
||||
$resContent = Db::table('yzy_major_content')->field('batch,year_length,degree,sex_bili,year_length')->where('major_code','=',$val['code'])->find();
|
||||
$result[$key]['learnYear'] = $resContent['year_length'];
|
||||
$result[$key]['batch'] = $resContent['batch'];
|
||||
$result[$key]['degree'] = $resContent['degree'];
|
||||
$result[$key]['sex_bili'] = $resContent['sex_bili'];
|
||||
}
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
];
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 专业搜索默认显示数据
|
||||
* */
|
||||
|
||||
public static function getDefaultMajor($array){
|
||||
|
||||
//获取配置表的年份
|
||||
$year = config('setsub.year');
|
||||
$majorArr = config('major.defaultMajor');
|
||||
//搜索条件
|
||||
|
||||
unset($array['title']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'userPro':
|
||||
$where[] = ['yzy_province', '=', $value];
|
||||
break;
|
||||
case 'subType':
|
||||
$where[] = ['wenli', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$where[] = ['province', 'in', ($value)];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//查询在本省招生专业的数据
|
||||
$result = self::field('title,pid,code')
|
||||
->where([['code','in',$majorArr],['level','=',3]])
|
||||
->cache(3600)
|
||||
->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
foreach($result as $key => $val){
|
||||
|
||||
//查询向本省招该专业的院校数量
|
||||
$result[$key]['countSch'] = Db::table('yzy_major_plan')->where($where)->where([['majorCode','=',$val['code']],['year','=',$year]])->count();
|
||||
$result[$key]['sumPlan'] = Db::table('yzy_major_plan')->where($where)->where([['majorCode','=',$val['code']],['year','=',$year]])->sum('planNum');
|
||||
|
||||
//获取类别
|
||||
$majorType = self::field('title')->where('id','=',$val['pid'])->find();
|
||||
$result[$key]['typeName'] = $majorType['title'];
|
||||
|
||||
//获取专业相关信息
|
||||
$resContent = Db::table('yzy_major_content')->field('batch,year_length,degree,sex_bili,year_length')->where('major_code','=',$val['code'])->find();
|
||||
$result[$key]['batch'] = $resContent['batch'];
|
||||
$result[$key]['learnYear'] = $resContent['year_length'];
|
||||
$result[$key]['degree'] = $resContent['degree'];
|
||||
$result[$key]['sex_bili'] = $resContent['sex_bili'];
|
||||
}
|
||||
|
||||
$res['majorContent'] = $result;
|
||||
$res['majorTitle'] = config('major.major');
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 查询外省向本省招收专业的学校
|
||||
* */
|
||||
public static function getMajorSch($data,$user_id,$page = 1, $limit = 5){
|
||||
//获取配置表的年份
|
||||
$year = 2018;
|
||||
$where[] = ['year','=',$year];
|
||||
|
||||
//搜索条件
|
||||
unset($data['page']);
|
||||
foreach ($data as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'code':
|
||||
$where[] = ['majorCode', '=', $value];
|
||||
break;
|
||||
case 'userPro':
|
||||
$where[] = ['yzy_province', '=', $value];
|
||||
break;
|
||||
case 'subType':
|
||||
$where[] = ['wenli', '=', $value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$count = Db::table('yzy_major_score')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
//查询在本省招生专业的数据
|
||||
$result = Db::table('yzy_major_score')
|
||||
->field('id,sch_id,batchName,batch,majorCode,major,minScore,lowSort,enterNum,planNum,typeName,cost,sch_name,code')
|
||||
->where($where)
|
||||
->page($page,$limit)
|
||||
->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
foreach($result as $key => $val){
|
||||
$result[$key]['title'] = $val['major'];
|
||||
$result[$key]['lowestRank'] = $val['lowSort'];
|
||||
$result[$key]['tags'] = $val['typeName'];
|
||||
$result[$key]['title'] = $val['major'];
|
||||
unset($result[$key]['major']);
|
||||
unset($result[$key]['lowSort']);
|
||||
}
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'data' => $result,
|
||||
];
|
||||
return $list;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询院校的专业
|
||||
* */
|
||||
public static function getSchMajorBy($data,$user_id){
|
||||
//调用配置表年份
|
||||
$year = config('setsub.year');
|
||||
if($data['userPro'] == 1){
|
||||
$tableMajor = $data['subType'] == 1 ? 'rec_js_wen_major':'rec_js_li_major';
|
||||
}else{
|
||||
$tableMajor = $data['subType'] == 1 ? 'rec_wen_major':'rec_li_major';
|
||||
}
|
||||
|
||||
//查询用户收藏的专业
|
||||
$resCollect = [];
|
||||
if($user_id){
|
||||
$resCollect = CollectMajor::getUserCollectMajor($user_id,$data['userPro'],$data['subType'],$data['score']);
|
||||
}
|
||||
|
||||
$result = Db::table($tableMajor)->where('rec_id','=',$data['id'])->find();
|
||||
if(empty($result)){
|
||||
$arr = [];
|
||||
}else{
|
||||
$res = json_decode($result['professions']);
|
||||
|
||||
foreach ($res as $key => $val){
|
||||
|
||||
$arr[$key]['probability'] = $val->probability;
|
||||
$arr[$key]['title'] = $val->alias;
|
||||
$arr[$key]['cost'] = $val->cost;
|
||||
$arr[$key]['code'] = $val->code;
|
||||
$arr[$key]['enterNum'] = $val->enterNum;
|
||||
$arr[$key]['planNum'] = $val->planNum;
|
||||
$arr[$key]['majorCode'] = $val->majorCode;
|
||||
$arr[$key]['rec_id'] = $result['rec_id'];
|
||||
$resRank = json_decode($val->extended);
|
||||
$arr[$key]['lowestRank'] = $resRank[0]->ls;
|
||||
$arr[$key]['minScore'] = $resRank[0]->ms;
|
||||
$arr[$key]['is_collect'] = 0;//收藏默认0,后期修改
|
||||
$resType = self::alias('a')->field('b.title')
|
||||
->join('yzy_majors b','a.pid = b.id','left')
|
||||
->where('a.code','=',$val->majorCode)
|
||||
->find();
|
||||
$arr[$key]['tags'] = $resType['title'];
|
||||
$arr[$key]['is_collect'] = 0;
|
||||
|
||||
if(is_array($resCollect)){
|
||||
if(in_array($data['sch_id'].'_'.$val->majorCode.'_'.$val->code,$resCollect)){
|
||||
$arr[$key]['is_collect'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
103
芳林公司项目/www.zhiyuanhelp.com/application/api/model/NewMajor.php
Normal file
103
芳林公司项目/www.zhiyuanhelp.com/application/api/model/NewMajor.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/30
|
||||
* Time: 0:28
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class NewMajor extends Model
|
||||
{
|
||||
/*
|
||||
* 新高考向本省招收的专业学校
|
||||
* */
|
||||
public static function getNewMajorSch($array,$user_id,$page = 1, $limit = 10){
|
||||
$where = [];
|
||||
//搜索条件
|
||||
unset($array['page']);
|
||||
unset($array['type']);
|
||||
unset($array['reType']);
|
||||
unset($array['userPro']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'code':
|
||||
$where[] = ['majorCode', '=', ($value)];
|
||||
break;
|
||||
case 'score':
|
||||
$where[] = ['myscore', '=', $value];
|
||||
break;
|
||||
case 'mySub':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
$val = preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$where[] = ['chooseNums', 'in', ($val[0].','.$val[1].','.$val[2].','.$val[0].$val[1].','.$val[0].$val[2].','.$val[1].$val[2].','.$val[0].$val[1].$val[2].',999')];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//计算总数
|
||||
$count = Db::table('rec_zhejiang_majors')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
|
||||
//查询数据
|
||||
$result = Db::table('rec_zhejiang_majors')
|
||||
->field('collegeName,probability,rankOfCn,professionCode,is985,is211,issyl,provinceName,estimatedRanking,minScore,collegeId,id,batch,planNum,chooseCns,classify,professionName,majorCode')
|
||||
->where($where)
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
//查询用户收藏的专业
|
||||
$resCollect = [];
|
||||
if($user_id){
|
||||
$resCollect = CollectNewMajor::getUserNewMajor($user_id);
|
||||
}
|
||||
//查询位次和院校排名
|
||||
foreach ($result as $key =>$val) {
|
||||
$result[$key]['tags'] = $val['provinceName']." ".$val['classify'];
|
||||
//判断211,985,双一流是否是1
|
||||
if($val['is985'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."985";
|
||||
if($val['is211'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."211";
|
||||
if($val['issyl'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."双一流";
|
||||
//收藏赋值
|
||||
$result[$key]['is_collect'] = 0;
|
||||
if(is_array($resCollect)){
|
||||
if(in_array($val['id']."_".$val['majorCode']."_".$val['professionCode'],$resCollect)){
|
||||
$result[$key]['is_collect'] = 1;
|
||||
}
|
||||
}
|
||||
$result[$key]['lowestRank'] = $result[$key]['estimatedRanking'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result
|
||||
];
|
||||
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/27
|
||||
* Time: 19:26
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\api\model\CollectNewMajor;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class NewSchMajor extends Model
|
||||
{
|
||||
|
||||
/*
|
||||
* 新高考查询学校专业
|
||||
* */
|
||||
public static function getNewSchoolMajors($array,$user_id){
|
||||
|
||||
unset($array['userPro']);
|
||||
|
||||
$result = Db::table('rec_zhejiang_schs_majors')->field('rec_id,professions')->where('rec_id','=',$array['id'])->find();
|
||||
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
//查询用户收藏的专业
|
||||
$resCollect = [];
|
||||
if($user_id){
|
||||
$resCollect = CollectNewMajor::getUserNewMajor($user_id);
|
||||
}
|
||||
if(empty($result)){
|
||||
$arr = [];
|
||||
}else{
|
||||
$res = json_decode($result['professions']);
|
||||
foreach ($res as $key => $val){
|
||||
|
||||
$arr[$key]['probability'] = $val->probability;
|
||||
$arr[$key]['professionName'] = $val->professionName;
|
||||
$arr[$key]['cost'] = $val->cost;
|
||||
$arr[$key]['professionCode'] = $val->professionCode;
|
||||
$arr[$key]['enterNum'] = $val->enterNum;
|
||||
$arr[$key]['planNum'] = $val->planNum;
|
||||
$arr[$key]['majorCode'] = $val->majorCode;
|
||||
$arr[$key]['recommendType'] = $val->recommendType;
|
||||
$arr[$key]['chooseCns'] = $val->chooseCns;
|
||||
$arr[$key]['rec_id'] = $result['rec_id'];
|
||||
$arr[$key]['lowestRank'] = $val->minSort;;
|
||||
$arr[$key]['minScore'] = $val->minScore;
|
||||
$arr[$key]['is_collect'] = 0;//收藏默认0,后期修改
|
||||
if(is_array($resCollect)){
|
||||
if(in_array($result['rec_id'].'_'.$val->majorCode.'_'.$val->professionCode,$resCollect)){
|
||||
$arr[$key]['is_collect'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
47
芳林公司项目/www.zhiyuanhelp.com/application/api/model/Order.php
Normal file
47
芳林公司项目/www.zhiyuanhelp.com/application/api/model/Order.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 18:02
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
protected $table = 'orders';
|
||||
/*
|
||||
* 下单时判断订单是否已支付
|
||||
* */
|
||||
public static function checkOrder($user_id,$score,$userPro,$vipType,$subType = 0, $mySub = 0){
|
||||
$resOrder = self::field('id,status')->where([['user_id','=',$user_id],['stu_yzy_province','=',$userPro],['score','=',$score],
|
||||
['wenli','=',$subType],['mykemu','=',$mySub],['vip','=',$vipType]])->find();
|
||||
return $resOrder;
|
||||
}
|
||||
|
||||
/*
|
||||
* 个人中心订单数据查询
|
||||
* @param $userID int 用户id
|
||||
* @param $status int 支付状态
|
||||
* */
|
||||
public static function getOrders($userID,$status){
|
||||
$result = self::field('vip,stu_yzy_province,province_title,score,mykemustr,mykemu,wenli,stu_province')->where([['user_id','=',$userID],['status','=',$status]])->select();
|
||||
foreach ($result as $key => $val){
|
||||
if($val['wenli']){
|
||||
$result[$key]['subTypeName'] = config('setsub.subTypeName')[$val['wenli']];
|
||||
}
|
||||
|
||||
if($val['mykemu']){
|
||||
$result[$key]['subName'] = $val['mykemustr'];
|
||||
unset($val['mykemustr']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/15
|
||||
* Time: 9:20
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class ProScoreRank extends Model
|
||||
{
|
||||
protected $table = 'yzy_weici';
|
||||
|
||||
/*
|
||||
* 根据省份,文理科,分数查询用户排名
|
||||
* @param $data['province'] int 省份code
|
||||
* @param $data['subType'] int 文理科或其他0
|
||||
* @param $data['score'] int 分数
|
||||
* return @array
|
||||
* */
|
||||
public static function getProRankByScore($data){
|
||||
//调用配置里面的年份
|
||||
$year = config('setsub.year');
|
||||
|
||||
$result = self::field('lowestRank,minScore')->where([['yzy_province','=',$data['province']],
|
||||
['wenli','=',$data['subType']],['year','=',$year],['minScore','<=',$data['score']],['maxScore','>=',$data['score']]])->cache(3600)->find();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 19:36
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Province extends Model
|
||||
{
|
||||
protected $table = 'yzy_province';
|
||||
|
||||
/*
|
||||
* 获取区域
|
||||
* return array
|
||||
* */
|
||||
public static function getAreaInfo($type = 1){
|
||||
$res = self::field('id,code,title,real_code')->order('firsts ASC')->cache(3600)->select()->toArray();
|
||||
|
||||
if($type == 2) {
|
||||
foreach ($res as $key => $val) {
|
||||
if ($val['title'] == "西藏") {
|
||||
unset($res[$key]);
|
||||
}
|
||||
}
|
||||
$res = array_values($res);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/26
|
||||
* Time: 14:36
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\facade\Log;
|
||||
use think\Model;
|
||||
|
||||
class RecZhejiangMajor extends Model
|
||||
{
|
||||
|
||||
/*
|
||||
* 新高考专业查询
|
||||
* */
|
||||
public static function getNewMajorBy($array,$page = 1,$limit =10 ,$user_id,$vipType)
|
||||
{
|
||||
$where = [];
|
||||
//方便统计总数定义推荐类型
|
||||
$whereType = [];
|
||||
//推薦類型默認0
|
||||
$type = 0;
|
||||
$year = config('setsub.year');
|
||||
//默认排序条件
|
||||
$sort = 'dataType desc';
|
||||
//搜索条件
|
||||
unset($array['is_login']);
|
||||
unset($array['page']);
|
||||
unset($array['type']);
|
||||
unset($array['userPro']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'score':
|
||||
$where[] = ['myscore', '=', $value];
|
||||
break;
|
||||
case 'mySub':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
$val = preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$where[] = ['chooseNums', 'in', ($val[0].','.$val[1].','.$val[2].','.$val[0].$val[1].','.$val[0].$val[2].','.$val[1].$val[2].','.$val[0].$val[1].$val[2].',999')];
|
||||
break;
|
||||
case 'reType':
|
||||
$type = $value;
|
||||
$value = $value - 1;
|
||||
//未购买权限limit-1
|
||||
if (($value == 0 || $value == 1) && ($limit == 2 || $limit == 5)) {
|
||||
$limit = $limit - 1;
|
||||
}
|
||||
$whereType[] = ['dataType', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$value = changeCode($value);
|
||||
$where[] = ['provinceId', 'in', ($value)];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
|
||||
case 'schoolType':
|
||||
$where[] = ['collegeType', 'in', ($value)];
|
||||
break;
|
||||
case 'is_985':
|
||||
$where[] = ['is985', '=', $value];
|
||||
break;
|
||||
case 'is_211':
|
||||
$where[] = ['is211', '=', $value];
|
||||
break;
|
||||
case 'is_yldx':
|
||||
$where[] = ['is_yldx', '=', $value];
|
||||
break;
|
||||
case 'is_ylxk':
|
||||
$where[] = ['is_ylxk', '=', $value];
|
||||
break;
|
||||
case 'is_public':
|
||||
$where[] = ['is_public', '=', $value];
|
||||
break;
|
||||
case 'sort':
|
||||
$sort = config('setsub.sort')[$value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算总数
|
||||
if($vipType == 1){
|
||||
$count = Db::table('rec_zhejiang_majors')
|
||||
->where($where)
|
||||
->where($whereType)//提上去加索引
|
||||
->count();
|
||||
}else{
|
||||
$count = $limit;
|
||||
}
|
||||
//查询院校总数,可保底,稳妥,冲
|
||||
$resNum = self::getMajorNum($where,$limit,$vipType,$type);
|
||||
|
||||
//查询数据
|
||||
$result = Db::table('rec_zhejiang_majors')
|
||||
->field('collegeName,probability,rankOfCn,professionCode,is985,is211,issyl,provinceName,estimatedRanking,minScore,collegeId,id,batch,planNum,chooseCns,classify,professionName,majorCode')
|
||||
->where($where)
|
||||
->where($whereType)
|
||||
->page($page, $limit)
|
||||
->order($sort)
|
||||
->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
//查询用户收藏的专业
|
||||
$resCollect = [];
|
||||
if($user_id){
|
||||
$resCollect = CollectNewMajor::getUserNewMajor($user_id);
|
||||
}
|
||||
//查询位次和院校排名
|
||||
foreach ($result as $key =>$val) {
|
||||
$result[$key]['tags'] = $val['provinceName']." ".$val['classify'];
|
||||
//判断211,985,双一流是否是1
|
||||
if($val['is985'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."985";
|
||||
if($val['is211'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."211";
|
||||
if($val['issyl'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."双一流";
|
||||
//收藏赋值
|
||||
$result[$key]['is_collect'] = 0;
|
||||
if(is_array($resCollect)){
|
||||
if(in_array($val['id']."_".$val['majorCode']."_".$val['professionCode'],$resCollect)){
|
||||
$result[$key]['is_collect'] = 1;
|
||||
}
|
||||
}
|
||||
$result[$key]['lowestRank'] = $result[$key]['estimatedRanking'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
'countSchool' => $resNum
|
||||
];
|
||||
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
//获取新高考專業总数和保底,稳妥、推荐
|
||||
public static function getMajorNum($where,$limit,$vipType,$type){
|
||||
$arrNomalCount = array();
|
||||
$arrNomalCount[1] = 0;
|
||||
$arrNomalCount[2] = 0;
|
||||
$arrNomalCount[3] = 0;
|
||||
$arrLimitCount = array();
|
||||
$result = array();
|
||||
$cacheTime = empty($vipType)?3600:false;
|
||||
//总数
|
||||
$arrNomalCount[0] = Db::table('rec_zhejiang_majors')
|
||||
->where($where)->cache($cacheTime)
|
||||
->count();
|
||||
if($vipType == 0){
|
||||
//保底数量
|
||||
$arrNomalCount[3] = Db::table('rec_zhejiang_majors')
|
||||
->where($where)->where('dataType','=',2)->cache($cacheTime)
|
||||
->count();
|
||||
//稳妥数量
|
||||
$arrNomalCount[2] = Db::table('rec_zhejiang_majors')
|
||||
->where($where)->where('dataType','=',1)->cache($cacheTime)
|
||||
->count();
|
||||
//冲刺数量
|
||||
$arrNomalCount[1] = Db::table('rec_zhejiang_majors')
|
||||
->where($where)->where('dataType','=',0)->cache($cacheTime)
|
||||
->count();
|
||||
|
||||
//未购买权限的底部数据
|
||||
$arrLimitCount['3'] = $arrNomalCount[3] - $limit;
|
||||
$arrLimitCount['3']= $arrLimitCount['3']>0? $arrLimitCount['3']:0;
|
||||
$arrLimitCount['2'] = $arrNomalCount[2] - $limit;
|
||||
$arrLimitCount['2']= $arrLimitCount['2']>0? $arrLimitCount['2']:0;
|
||||
$arrLimitCount['1'] = $arrNomalCount[1] - $limit;
|
||||
$arrLimitCount['1']= $arrLimitCount['1']>0? $arrLimitCount['1']:0;
|
||||
|
||||
}else{
|
||||
if($type){
|
||||
$arrNomalCount[$type] = Db::table('rec_zhejiang_majors')
|
||||
->where($where)->where('dataType','=',$type-1)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result['topNumCount'] = $arrNomalCount;
|
||||
$result['bottomNumCount'] = $arrLimitCount;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 新高考院校查询
|
||||
* */
|
||||
public static function getNewMajorSch($array,$page = 1,$limit =10 ,$user_id,$vipType)
|
||||
{
|
||||
$where = [];
|
||||
$year = config('setsub.year');
|
||||
//默认排序条件
|
||||
$sort = "id ASC";
|
||||
//搜索条件
|
||||
unset($array['is_login']);
|
||||
unset($array['page']);
|
||||
unset($array['type']);
|
||||
unset($array['reType']);
|
||||
unset($array['userPro']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'score':
|
||||
$where[] = ['myscore', '=', $value];
|
||||
break;
|
||||
case 'mySub':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$value = changeCode($value);
|
||||
$where[] = ['provinceId', 'in', ($value)];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
case 'schoolType':
|
||||
$where[] = ['collegeType', 'in', ($value)];
|
||||
break;
|
||||
case 'is_985':
|
||||
$where[] = ['is985', '=', $value];
|
||||
break;
|
||||
case 'is_211':
|
||||
$where[] = ['is211', '=', $value];
|
||||
break;
|
||||
case 'is_yldx':
|
||||
$where[] = ['is_yldx', '=', $value];
|
||||
break;
|
||||
case 'is_ylxk':
|
||||
$where[] = ['is_ylxk', '=', $value];
|
||||
break;
|
||||
case 'is_public':
|
||||
$where[] = ['is_public', '=', $value];
|
||||
break;
|
||||
case 'sort':
|
||||
$sort = config('setsub.sort')[$value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$hideCount = 0;
|
||||
//计算总数
|
||||
if($vipType == 1){
|
||||
$count = Db::table('rec_zhejiang_schs')
|
||||
->where($where)
|
||||
->count();
|
||||
}else{
|
||||
$count = $limit;
|
||||
$hideCount = Db::table('rec_zhejiang_schs')
|
||||
->where($where)
|
||||
->count();
|
||||
$hideCount = $hideCount - $limit;
|
||||
$hideCount = $hideCount<0?0:$hideCount;
|
||||
}
|
||||
|
||||
//查询数据
|
||||
$result = Db::table('rec_zhejiang_schs')
|
||||
->field('collegeName,rankOfCn,provinceName,collegeId,id,planNum,classify,collegeCode,majorNum')
|
||||
->where($where)
|
||||
->page($page, $limit)
|
||||
->order($sort)
|
||||
->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
//查询用户收藏的专业
|
||||
$resCollect = [];
|
||||
if($user_id){
|
||||
$resCollect = CollectNewSch::getNewUserSch($user_id);
|
||||
}
|
||||
//查询位次和院校排名
|
||||
foreach ($result as $key =>$val) {
|
||||
$result[$key]['logo'] = '';
|
||||
$result[$key]['tags'] = $val['provinceName']." ".$val['classify'];
|
||||
$result[$key]['is_sch'] = 1;
|
||||
//收藏赋值
|
||||
$result[$key]['is_collect'] = 0;
|
||||
if(is_array($resCollect)){
|
||||
if(in_array($val['id'],$resCollect)){
|
||||
$result[$key]['is_collect'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$result[$key]['lowestRank'] = Db::table('yzy_zj_major_score')->where([['sch_id','=',$val['collegeId']],['year','=',$year]])->min('estimatedRanking');
|
||||
$result[$key]['minScore'] = Db::table('yzy_zj_major_score')->where([['sch_id','=',$val['collegeId']],['year','=',$year]])->min('minScore');
|
||||
}
|
||||
|
||||
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
'hideCount' => $hideCount
|
||||
];
|
||||
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 根据条件获取新高考专业数量
|
||||
* */
|
||||
public static function getNewMajorCount($array)
|
||||
{
|
||||
$where = [];
|
||||
//搜索条件
|
||||
unset($array['is_login']);
|
||||
unset($array['type']);
|
||||
unset($array['userPro']);
|
||||
unset($array['page']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'score':
|
||||
$where[] = ['myscore', '=', $value];
|
||||
break;
|
||||
case 'mySub':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
$val = $mySub = preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$where[] = ['chooseNums', 'in', ($val[0].','.$val[1].','.$val[2].','.$val[0].$val[1].','.$val[0].$val[2].','.$val[1].$val[2].','.$val[0].$val[1].$val[2].',999')];
|
||||
break;
|
||||
case 'reType':
|
||||
$where[] = ['dataType', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$value = changeCode($value);
|
||||
$where[] = ['provinceId', 'in', ($value)];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
case 'schoolType':
|
||||
$where[] = ['collegeType', 'in', ($value)];
|
||||
break;
|
||||
case 'is_985':
|
||||
$where[] = ['is985', '=', $value];
|
||||
break;
|
||||
case 'is_211':
|
||||
$where[] = ['is211', '=', $value];
|
||||
break;
|
||||
case 'is_yldx':
|
||||
$where[] = ['is_yldx', '=', $value];
|
||||
break;
|
||||
case 'is_ylxk':
|
||||
$where[] = ['is_ylxk', '=', $value];
|
||||
break;
|
||||
case 'is_public':
|
||||
$where[] = ['is_public', '=', $value];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算总数
|
||||
|
||||
$count = Db::table('rec_zhejiang_majors')
|
||||
->where($where)
|
||||
->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据条件获取新高考院校数量
|
||||
* */
|
||||
public static function getNewSchoolCount($array)
|
||||
{
|
||||
$where = [];
|
||||
//搜索条件
|
||||
unset($array['is_login']);
|
||||
unset($array['type']);
|
||||
unset($array['userPro']);
|
||||
unset($array['page']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'score':
|
||||
$where[] = ['myscore', '=', $value];
|
||||
break;
|
||||
case 'mySub':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$value = changeCode($value);
|
||||
$where[] = ['provinceId', 'in', ($value)];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
case 'schoolType':
|
||||
$where[] = ['collegeType', 'in', ($value)];
|
||||
break;
|
||||
case 'is_985':
|
||||
$where[] = ['is985', '=', $value];
|
||||
break;
|
||||
case 'is_211':
|
||||
$where[] = ['is211', '=', $value];
|
||||
break;
|
||||
case 'is_yldx':
|
||||
$where[] = ['is_yldx', '=', $value];
|
||||
break;
|
||||
case 'is_ylxk':
|
||||
$where[] = ['is_ylxk', '=', $value];
|
||||
break;
|
||||
case 'is_public':
|
||||
$where[] = ['is_public', '=', $value];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算总数
|
||||
$count = Db::table('rec_zhejiang_schs')
|
||||
->where($where)
|
||||
->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/24
|
||||
* Time: 10:57
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class SchScore extends Model
|
||||
{
|
||||
protected $table = 'yzy_sch_score';
|
||||
|
||||
/*
|
||||
* 查询往年学院录取情况
|
||||
* */
|
||||
public static function getSchEnrollByYear($data){
|
||||
|
||||
$result = self::field('year,batchName,enterNum,minScore,lowSort')
|
||||
->where([['province','=',$data['userPro']],['sch_id','=',$data['sch_id']],['wenli','=',$data['subType']],['batch','=',$data['batch']]])
|
||||
->order('year desc')->select();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/15
|
||||
* Time: 16:58
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\facade\Log;
|
||||
use think\Model;
|
||||
use app\api\model\UserCollect;
|
||||
|
||||
class SchoolChoice extends Model
|
||||
{
|
||||
/*
|
||||
* 院校查询
|
||||
* */
|
||||
public static function getSchoolByCondition($array,$page = 1,$limit =10 ,$user_id,$vipType){
|
||||
if($array['userPro'] == 1){
|
||||
$table = 'rec_js';
|
||||
$tableMajor = 'rec_js_major';
|
||||
}else{
|
||||
$table = $array['subType'] == 1 ? 'rec_wen':'rec_li';
|
||||
$tableMajor = $array['subType'] == 1 ? 'rec_wen_major':'rec_li_major';
|
||||
}
|
||||
$where = [];
|
||||
//方便统计总数定义推荐类型
|
||||
$whereType = [];
|
||||
//推薦類型默認0
|
||||
$type = 0;
|
||||
$year = config('setsub.year');
|
||||
//默认排序条件
|
||||
$sort = 'recommendType desc';
|
||||
//搜索条件
|
||||
unset($array['is_login']);
|
||||
unset($array['page']);
|
||||
unset($array['type']);
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'userPro':
|
||||
$where[] = ['yzy_province', '=', $value];
|
||||
break;
|
||||
case 'subType':
|
||||
$where[] = ['wenli', '=', $value];
|
||||
break;
|
||||
case 'score':
|
||||
$where[] = [$key, '=', $value];
|
||||
break;
|
||||
case 'reType':
|
||||
//未购买权限limit-1
|
||||
if(($value == 1 || $value ==2) && ($limit == 2 || $limit ==5)){
|
||||
$limit = $limit - 1;
|
||||
}
|
||||
$type = $value;
|
||||
$whereType[] = ['recommendType', '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$where[] = ['sch_province', 'in', ($value)];
|
||||
break;
|
||||
case 'chooseLevel':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
case 'schoolType':
|
||||
$where[] = ['sch_cate_id', 'in', ($value)];
|
||||
break;
|
||||
case 'is_985':
|
||||
$where[] = ['is_985', '=', $value];
|
||||
break;
|
||||
case 'is_211':
|
||||
$where[] = ['is_211', '=', $value];
|
||||
break;
|
||||
case 'is_yldx':
|
||||
$where[] = ['is_yldx', '=', $value];
|
||||
break;
|
||||
case 'is_ylxk':
|
||||
$where[] = ['is_ylxk', '=', $value];
|
||||
break;
|
||||
case 'is_public':
|
||||
$where[] = ['is_public', '=', $value];
|
||||
break;
|
||||
case 'sort':
|
||||
$sort = config('setsub.sort')[$value];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算总数
|
||||
if($vipType == 1){
|
||||
$count = Db::table($table)
|
||||
->where($where)
|
||||
->where($whereType)
|
||||
->count();
|
||||
}else{
|
||||
$count = $limit;
|
||||
}
|
||||
|
||||
|
||||
//查询院校总数,可保底,稳妥,冲
|
||||
$resNum = self::getSchoolNum($where,$limit,$vipType,$table,$type);
|
||||
//查询数据
|
||||
$result = Db::table($table)->alias('a')
|
||||
->field('alias,probability,rankOfCn,sch_province_title,sch_cate_title,is_985,is_syl,is_211,tags,sch_province,sch_id,id,enterNum,batch,batch_title,recommendType,majorNum')
|
||||
->where($where)
|
||||
->where($whereType)
|
||||
->page($page, $limit)
|
||||
->order($sort)
|
||||
->select();
|
||||
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
//查询用户收藏的院校
|
||||
$resCollect = [];
|
||||
if($user_id){
|
||||
$resCollect = UserCollect::getUserCollect($user_id,1);
|
||||
}
|
||||
|
||||
//查询位次和院校排名
|
||||
foreach ($result as $key =>$val){
|
||||
$result[$key]['logo'] = '';
|
||||
|
||||
$result[$key]['tags'] = $val['sch_province_title']." ".$val['sch_cate_title'];
|
||||
//判断211,985,双一流是否是1
|
||||
if($val['is_985'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."985";
|
||||
if($val['is_211'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."211";
|
||||
if($val['is_syl'])
|
||||
$result[$key]['tags'] = $result[$key]['tags']." "."双一流";
|
||||
$resSeat = Db::table('yzy_sch_score')->field('lowSort as lowestRank,minScore')
|
||||
->where([
|
||||
['province','=',$array['userPro']],
|
||||
['wenli','=',$array['subType']],
|
||||
['batch','=',$val['batch']],
|
||||
['sch_id','=',$val['sch_id']],
|
||||
['year','=',$year]
|
||||
])->find();
|
||||
|
||||
$result[$key]['lowestRank'] = $resSeat['lowestRank'];
|
||||
$result[$key]['minScore'] = $resSeat['minScore'];
|
||||
|
||||
|
||||
//收藏赋值
|
||||
$result[$key]['is_collect'] = 0;
|
||||
if(is_array($resCollect)){
|
||||
if(in_array($val['id'],$resCollect)){
|
||||
$result[$key]['is_collect'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'res' => $result,
|
||||
'countSchool' => $resNum
|
||||
];
|
||||
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
//获取院校总数和保底,稳妥、推荐
|
||||
public static function getSchoolNum($where,$limit,$vipType,$table,$type){
|
||||
$arrNomalCount = array();
|
||||
$arrNomalCount[1] = 0;
|
||||
$arrNomalCount[2] = 0;
|
||||
$arrNomalCount[3] = 0;
|
||||
$arrLimitCount = array();
|
||||
$result = array();
|
||||
$cacheTime = empty($vipType)?3600:false;
|
||||
//总数
|
||||
$arrNomalCount[0] = Db::table($table)
|
||||
->where($where)->cache($cacheTime)
|
||||
->count();
|
||||
if($vipType == 0){
|
||||
//保底数量
|
||||
$arrNomalCount[3] = Db::table($table)
|
||||
->where($where)->where('recommendType','=',3)->cache($cacheTime)
|
||||
->count();
|
||||
//稳妥数量
|
||||
$arrNomalCount[2] = Db::table($table)
|
||||
->where($where)->where('recommendType','=',2)->cache($cacheTime)
|
||||
->count();
|
||||
//冲刺数量
|
||||
$arrNomalCount[1] = Db::table($table)
|
||||
->where($where)->where('recommendType','=',1)->cache($cacheTime)
|
||||
->count();
|
||||
|
||||
//未购买权限的底部数据
|
||||
$arrLimitCount['3'] = $arrNomalCount[3] - $limit;
|
||||
$arrLimitCount['3']= $arrLimitCount['3']>0? $arrLimitCount['3']:0;
|
||||
$arrLimitCount['2'] = $arrNomalCount[2] - $limit;
|
||||
$arrLimitCount['2']= $arrLimitCount['2']>0? $arrLimitCount['2']:0;
|
||||
$arrLimitCount['1'] = $arrNomalCount[1] - $limit;
|
||||
$arrLimitCount['1']= $arrLimitCount['1']>0? $arrLimitCount['1']:0;
|
||||
|
||||
}else{
|
||||
if($type){
|
||||
$arrNomalCount[$type] = Db::table($table)
|
||||
->where($where)->where('recommendType','=',$type)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result['topNumCount'] = $arrNomalCount;
|
||||
$result['bottomNumCount'] = $arrLimitCount;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取院校数量
|
||||
* */
|
||||
|
||||
public static function getSchoolCount($array){
|
||||
if($array['userPro'] == 1){
|
||||
$table = 'rec_js';
|
||||
}else{
|
||||
$table = $array['subType'] == 1 ? 'rec_wen':'rec_li';
|
||||
}
|
||||
$where = [];
|
||||
unset($array['is_login']);
|
||||
unset($array['type']);
|
||||
unset($array['page']);
|
||||
//搜索条件
|
||||
foreach ($array as $key => $value) {
|
||||
if (!empty($value)) {
|
||||
switch ($key) {
|
||||
case 'userPro':
|
||||
$where[] = ['yzy_province', '=', $value];
|
||||
break;
|
||||
case 'subType':
|
||||
$where[] = ['wenli', '=', $value];
|
||||
break;
|
||||
case 'score':
|
||||
$where[] = [$key, '=', $value];
|
||||
break;
|
||||
case 'province':
|
||||
$where[] = ['sch_province', 'in', ($value)];
|
||||
break;
|
||||
case 'chooseLevel':
|
||||
$where[] = ['mykemu', '=', $value];
|
||||
break;
|
||||
case 'batch':
|
||||
$where[] = ['batch', 'in', ($value)];
|
||||
break;
|
||||
case 'reType':
|
||||
$where[] = ['recommendType', '=', $value];
|
||||
break;
|
||||
case 'schoolType':
|
||||
$where[] = ['sch_cate_id', 'in', ($value)];
|
||||
break;
|
||||
case 'is_985':
|
||||
$where[] = ['is_985', '=', $value];
|
||||
break;
|
||||
case 'is_211':
|
||||
$where[] = ['is_211', '=', $value];
|
||||
break;
|
||||
case 'is_yldx':
|
||||
$where[] = ['is_yldx', '=', $value];
|
||||
break;
|
||||
case 'is_ylxk':
|
||||
$where[] = ['is_ylxk', '=', $value];
|
||||
break;
|
||||
case 'is_public':
|
||||
$where[] = ['is_public', '=', $value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算总数
|
||||
$count = Db::table($table)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
}
|
||||
201
芳林公司项目/www.zhiyuanhelp.com/application/api/model/User.php
Normal file
201
芳林公司项目/www.zhiyuanhelp.com/application/api/model/User.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 15:27
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = 'users';
|
||||
|
||||
/*
|
||||
* 用户登录并返回信息
|
||||
* @param $data array 插入用户信息,并返回用户信息
|
||||
* */
|
||||
public static function addUserInfo($data){
|
||||
|
||||
$array = array();
|
||||
$array['phone'] = $data['phone'];
|
||||
$array['wenli'] = $data['subType'];
|
||||
$array['chooseLevel'] = $data['chooseLevel'];
|
||||
$array['mykemu'] = sortStr($data['mySub']);
|
||||
$array['score'] = $data['score'];
|
||||
$array['province'] = $data['province']*10000;
|
||||
$array['add_time'] = time();
|
||||
|
||||
//默认普通高考,检测并返回高考类型
|
||||
if($array['province']){
|
||||
$array['provinceType'] = 3;
|
||||
$proSubArr = config('setsub.diffProTest');
|
||||
$provinceID = config('province.province')[$array['province']]['code'];
|
||||
if(in_array($provinceID,$proSubArr[1])){
|
||||
$array['provinceType'] = 1;
|
||||
}elseif(in_array($provinceID,$proSubArr[2])){
|
||||
$array['provinceType'] = 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//科目中文取
|
||||
$array['subName'] = empty(($array['mykemu']))?'':changeSubString($array['mykemu']);
|
||||
|
||||
|
||||
//手机号16进制转62进制并加随机两位数据生成昵称
|
||||
$array['user_name'] = from10_to62($data['phone']).getRandChar(2);
|
||||
unset($data['code']);
|
||||
$resInfo = self::insertGetId($array);
|
||||
|
||||
if($resInfo){
|
||||
//省份配置表
|
||||
$proConfig = config('province.province');
|
||||
$array['uid'] = $resInfo;
|
||||
$array['phone'] = substr_replace($array['phone'],'****',3,4);
|
||||
unset($array['add_time']);
|
||||
unset($array['last_edit_gaokao']);
|
||||
//文理科文字返回
|
||||
if($array['wenli']){
|
||||
$array['subTypeName'] = $array['wenli'] == 1 ? '文科' : '理科';
|
||||
unset($array['subName']);
|
||||
}
|
||||
//省份code和文字获取
|
||||
if($array['province']){
|
||||
$array['proName'] = $proConfig[$array['province']]['title'];
|
||||
$array['userPro'] = $proConfig[$array['province']]['code'];
|
||||
}
|
||||
return $array;
|
||||
}else{
|
||||
return api_return("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 通过手机号查询用户信息
|
||||
* */
|
||||
public static function getUserInfoByPhone($telnum){
|
||||
|
||||
$result = self::field('id as uid,phone,user_name,score,wenli,province,mykemu,chooseLevel,subName,provinceType')->where('phone','=',$telnum)->find();
|
||||
if($result){
|
||||
$proConfig = config('province.province');
|
||||
//文理科文字返回
|
||||
if($result['wenli']){
|
||||
$result['subTypeName'] = $result['wenli'] == 1 ? '文科' : '理科';
|
||||
unset($result['subName']);
|
||||
}
|
||||
|
||||
//省份code和文字获取
|
||||
if($result['province']){
|
||||
$result['proName'] = $proConfig[$result['province']]['title'];
|
||||
$result['userPro'] = $proConfig[$result['province']]['code'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
*通过手机号查询用户是否存在
|
||||
* */
|
||||
public static function checkUserByTelnum($telnum){
|
||||
$count = self::where('phone','=',$telnum)->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改用户信息
|
||||
* */
|
||||
public static function editUserInfo($data){
|
||||
$array = array();
|
||||
$array['wenli'] = $data['subType'];
|
||||
$array['chooseLevel'] = $data['chooseLevel'];
|
||||
$array['mykemu'] = sortStr($data['mySub']);
|
||||
$array['province'] = $data['province']*10000;
|
||||
$array['score'] = $data['score'];
|
||||
$array['last_edit_gaokao'] = time();
|
||||
|
||||
//默认普通高考,检测并返回高考类型
|
||||
$array['provinceType'] = 3;
|
||||
$proSubArr = config('setsub.diffProTest');
|
||||
$provinceID = config('province.province')[$array['province']]['code'];
|
||||
if(in_array($provinceID,$proSubArr[1])){
|
||||
$array['provinceType'] = 1;
|
||||
}elseif(in_array($provinceID,$proSubArr[2])){
|
||||
$array['provinceType'] = 2;
|
||||
}
|
||||
|
||||
//科目中文取
|
||||
$array['subName'] = empty(($array['mykemu']))?'':changeSubString($array['mykemu']);
|
||||
|
||||
$result = self::where('id','=',$data['user_id'])->update($array);
|
||||
|
||||
//返回数据给前端
|
||||
if($result){
|
||||
$resUser = self::field('id as uid,phone,user_name,score,wenli,province,mykemu,chooseLevel,subName,provinceType')->where('id','=',$data['user_id'])->find();
|
||||
$proConfig = config('province.province');
|
||||
$resUser['phone'] = substr_replace($resUser['phone'],'****',3,4);
|
||||
$resUser['token'] = $data['token'];
|
||||
|
||||
//文理科文字返回
|
||||
if($resUser['wenli']){
|
||||
$resUser['subTypeName'] = $resUser['wenli']== 1 ? '文科' : '理科';
|
||||
unset($resUser['subName']);
|
||||
}
|
||||
|
||||
//省份code和文字获取
|
||||
if($resUser['province']){
|
||||
$resUser['proName'] = $proConfig[$resUser['province']]['title'];
|
||||
$resUser['userPro'] = $proConfig[$resUser['province']]['code'];
|
||||
}
|
||||
}else{
|
||||
$resUser = $result;
|
||||
}
|
||||
return $resUser;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查看用户是否具有查询权限
|
||||
* @param $type 权限类型
|
||||
* */
|
||||
public static function checkUserAuthByUserID($userID,$type,$province,$score,$subType = 0,$mySub = 0){
|
||||
$result = Db::table('orders')->field('vip')->where([['user_id','=',$userID],['stu_yzy_province','=',$province],['score','=',$score],['status','=',1],
|
||||
['wenli','=',$subType],['mykemu','=',$mySub],['vip','in',('1,2,3')]])
|
||||
->select();
|
||||
$resVip = array_column($result, 'vip');
|
||||
$tips = 0;
|
||||
switch ($type){
|
||||
case 1:
|
||||
if(!in_array($type,$resVip)){
|
||||
$tips = 1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(!in_array(1,$resVip)){
|
||||
$tips = 1;
|
||||
}elseif(!in_array($type,$resVip)){
|
||||
$tips = 2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(!in_array(1,$resVip)){
|
||||
$tips = 1;
|
||||
}elseif(!in_array($type,$resVip)){
|
||||
$tips = 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $tips;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
108
芳林公司项目/www.zhiyuanhelp.com/application/api/model/UserCollect.php
Normal file
108
芳林公司项目/www.zhiyuanhelp.com/application/api/model/UserCollect.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 10:23
|
||||
*/
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Db;
|
||||
use think\facade\Log;
|
||||
use think\Model;
|
||||
|
||||
class UserCollect extends Model
|
||||
{
|
||||
protected $table = 'user_collect_school';
|
||||
|
||||
/*
|
||||
* 收藏院校
|
||||
* @param userID int 用户id
|
||||
* @param data 收藏内容
|
||||
* @return | bool
|
||||
* */
|
||||
public static function addUserCollectSch($userID, $data)
|
||||
{
|
||||
|
||||
$data['user_id'] = $userID;
|
||||
$data['add_time'] = time();
|
||||
$result = self::insertGetId($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 移除收藏院校
|
||||
* */
|
||||
public static function delMyCollectSch($id, $userID)
|
||||
{
|
||||
$result = self::where([['id', '=', $id], ['user_id', '=', $userID]])->update(['is_collect' => 2]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 检查是否已收藏该院校
|
||||
* */
|
||||
public static function checkMyCollectSch($rec_id, $userID)
|
||||
{
|
||||
$result = self::where([['rec_id', '=', $rec_id], ['user_id', '=', $userID],['is_collect','=',1]])->count();
|
||||
if($result){
|
||||
throw new ParamException([
|
||||
'code' => 401,
|
||||
'msg' => '已收藏过该院校',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
* 根据用户id查询用户收藏的全部学校的分数段id
|
||||
* */
|
||||
public static function getUserCollect($userID)
|
||||
{
|
||||
$result = self::field('rec_id')->where([['user_id', '=', $userID], ['is_collect', '=', 1]])->select()->toArray();
|
||||
if ($result) {
|
||||
$result = array_column($result, 'rec_id');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询我的收藏院校
|
||||
* */
|
||||
public static function getMyCollectSch($data,$userID,$page = 1, $limit = 10)
|
||||
{
|
||||
|
||||
$where [] = empty($data['score'])?
|
||||
[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1]]:[['user_id','=',$userID],['userPro','=',$data['userPro']],['score','=',$data['score']],['is_collect','=',1]];
|
||||
//获取配置表年份
|
||||
$year = config('setsub.year');
|
||||
//统计收藏学校数量
|
||||
$count = self::where($where)->count();
|
||||
//查询收藏数据
|
||||
$result = self::where($where)
|
||||
->page($page, $limit)->select();
|
||||
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
|
||||
|
||||
//分页数据
|
||||
$info = [
|
||||
'limit' => $limit,
|
||||
'page_current' => $page,
|
||||
'page_sum' => ceil($count / $limit),
|
||||
];
|
||||
//组合返回
|
||||
$list = [
|
||||
'msg' => $msg,
|
||||
'count' => $count,
|
||||
'info' => $info,
|
||||
'data' => $result,
|
||||
];
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
41317f36-53f7-47a0-ad5d-d0e65a032eae
|
||||
131
芳林公司项目/www.zhiyuanhelp.com/application/api/service/Order.php
Normal file
131
芳林公司项目/www.zhiyuanhelp.com/application/api/service/Order.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 13:26
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
use app\api\model\Order as OrderModel;
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Log;
|
||||
|
||||
class Order
|
||||
{
|
||||
protected $uid;
|
||||
protected $totalMoney;
|
||||
/**
|
||||
* @param array $orderInfo 下单信息
|
||||
* @return array 订单状态
|
||||
* @throws Exception
|
||||
*/
|
||||
public function place($uid,$orderInfo)
|
||||
{
|
||||
$this->uid = $uid;
|
||||
//判断是否有该权限商品
|
||||
$this->getProductByType($orderInfo['vip_type']);
|
||||
//判断订单是否已购买
|
||||
$resOrder = $this->checkOrderStatus($uid,$orderInfo);
|
||||
//有待支付的订单提交支付,没有则创建新订单
|
||||
if($resOrder){
|
||||
$status = [
|
||||
'order_id' => $resOrder
|
||||
];
|
||||
}else{
|
||||
//创建订单
|
||||
$status = self::createOrderBy($orderInfo);
|
||||
|
||||
}
|
||||
$status['pass'] = true;
|
||||
return $status;
|
||||
}
|
||||
|
||||
//创建订单
|
||||
private function createOrderBy($orderInfo)
|
||||
{
|
||||
|
||||
$orderNo = $this->makeOrderNo();
|
||||
$order = new OrderModel();
|
||||
$order->user_id = $this->uid;
|
||||
$order->ord_no = $orderNo;
|
||||
$order->money = $this->totalMoney;
|
||||
$order->score = $orderInfo['score'];
|
||||
$order->telnum = $orderInfo['telnum'];
|
||||
$order->wenli = $orderInfo['subType'];
|
||||
$order->mykemu = $orderInfo['mySub'];
|
||||
$order->stu_yzy_province = $orderInfo['userPro'];
|
||||
$order->stu_province = $orderInfo['province']*10000;
|
||||
$order->province_title = config('province.province')[$order->stu_province]['title'];
|
||||
if($order->mykemu){
|
||||
$order->mykemu = sortStr($orderInfo['mySub']);
|
||||
$order->mykemustr = changeSubString($order->mykemu);
|
||||
}else{
|
||||
$order->mykemustr = '';
|
||||
}
|
||||
$order->vip = $orderInfo['vip_type'];
|
||||
$order->add_time = time();
|
||||
|
||||
$order->save();
|
||||
if($order->id){
|
||||
return [
|
||||
'order_no' => $orderNo,
|
||||
'order_id' => $order->id,
|
||||
'create_time' => $order->add_time
|
||||
];
|
||||
}else{
|
||||
return api_error("订单创建失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断价格是否匹配
|
||||
* */
|
||||
private function getProductByType($type){
|
||||
$productArr = config('product.vipType');
|
||||
|
||||
if(array_key_exists($type,$productArr)){
|
||||
$this->totalMoney = $productArr[$type];
|
||||
}else{
|
||||
throw new ParamException([
|
||||
'msg' => '购买的权限不存在',
|
||||
'erroCode' => 10000,
|
||||
'code' => 404
|
||||
]);
|
||||
}
|
||||
}
|
||||
//生成订单号
|
||||
public static function makeOrderNo()
|
||||
{
|
||||
$yCode = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
|
||||
$orderSn =
|
||||
$yCode[intval(date('Y')) - 2019] . strtoupper(dechex(date('m'))) . date(
|
||||
'd') . substr(time(), -5) . substr(microtime(), 2, 5) . sprintf(
|
||||
'%02d', rand(0, 99));
|
||||
return $orderSn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断用户是否购买该分数下的订单
|
||||
* */
|
||||
public function checkOrderStatus($uid,$orderInfo){
|
||||
|
||||
$result = OrderModel::checkOrder($uid,$orderInfo['score'],$orderInfo['userPro'],$orderInfo['vip_type'],$orderInfo['subType'],$orderInfo['mySub']);
|
||||
|
||||
if($result){
|
||||
if($result['status'] == 1){
|
||||
throw new ParamException([
|
||||
'msg' => '订单已存在并支付过啦',
|
||||
'erroCode' => 10000,
|
||||
'code' => 400
|
||||
]);
|
||||
}else{
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
253
芳林公司项目/www.zhiyuanhelp.com/application/api/service/Pay.php
Normal file
253
芳林公司项目/www.zhiyuanhelp.com/application/api/service/Pay.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 21:07
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
use app\api\model\Order as OrderModel;
|
||||
use app\api\service\Order as OrderService;
|
||||
use app\lib\exception\ParamException;
|
||||
use \think\facade\Log;
|
||||
|
||||
|
||||
require '../extend/WxPay/WxPay.Api.php';
|
||||
|
||||
class Pay
|
||||
{
|
||||
|
||||
private $orderNo;
|
||||
private $payWay;
|
||||
private $payType;
|
||||
private $orderID;
|
||||
function __construct($orderID,$payType,$payWay)
|
||||
{
|
||||
if (!$orderID)
|
||||
{
|
||||
throw new Exception('订单号不允许为NULL');
|
||||
}
|
||||
$this->orderID = $orderID;
|
||||
$this->payType = $payType;
|
||||
$this->payWay = $payWay;
|
||||
}
|
||||
|
||||
|
||||
//微信H5支付
|
||||
public function wapPay($user_id,$rebackUrl){
|
||||
$resOrder = $this->checkOrderValid( $this->orderID,$user_id);
|
||||
//调用统一下单接口
|
||||
$wxOrderData = new \WxPayUnifiedOrder();
|
||||
$wxOrderData->SetOut_trade_no( $resOrder['ord_no']);
|
||||
$wxOrderData->SetTrade_type('MWEB');
|
||||
$wxOrderData->SetTotal_fee($resOrder['money']*100);
|
||||
$wxOrderData->setBody('聚志愿');
|
||||
$wxOrderData->SetNotify_url(config('secure.pay_back_url'));
|
||||
$wxOrder = \WxPayApi::unifiedOrder($wxOrderData);
|
||||
$url = $wxOrder['mweb_url'].'&redirect_url='.$rebackUrl;//redirect_url 是支付完成后返回的页面
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//微信扫码支付
|
||||
public function codePay($user_id){
|
||||
//
|
||||
$resOrder = $this->checkOrderValid( $this->orderID,$user_id);
|
||||
//调用统一下单接口
|
||||
$wxOrderData = new \WxPayUnifiedOrder();
|
||||
$wxOrderData->SetOut_trade_no($resOrder['ord_no']);
|
||||
$wxOrderData->SetTrade_type('NATIVE');
|
||||
$wxOrderData->SetTime_start(date("YmdHis"));
|
||||
$wxOrderData->SetTime_expire(date("YmdHis", time() + 600));
|
||||
$wxOrderData->SetProduct_id($resOrder['vip']);
|
||||
$wxOrderData->SetTotal_fee($resOrder['money']*100);
|
||||
$wxOrderData->setBody('聚志愿');
|
||||
$wxOrderData->SetNotify_url(config('secure.pay_back_url'));
|
||||
$wxOrder = \WxPayApi::unifiedOrder($wxOrderData);
|
||||
if($wxOrder['result_code']=='SUCCESS' && $wxOrder['return_code']=='SUCCESS') {
|
||||
$url = $wxOrder["code_url"];
|
||||
return $url;
|
||||
}else{
|
||||
throw new ParamException([
|
||||
'msg' => '参数错误',
|
||||
'errorCode' => 10000,
|
||||
'code' => 400
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//支付宝wap支付
|
||||
public function alipay_wap($user_id,$rebackUrl)
|
||||
{
|
||||
|
||||
$resOrder = $this->checkOrderValid( $this->orderID,$user_id);
|
||||
require '../extend/alipay/aop/AopClient.php';// 加载交易服务
|
||||
//商品参数
|
||||
$array['body'] = "聚志愿";
|
||||
$array['subject'] = "聚志愿vip权限";
|
||||
$array['out_trade_no'] = $resOrder['ord_no'];
|
||||
$array['timeout_express'] = "5m";
|
||||
$array['total_amount'] = $resOrder['money'];
|
||||
$array['product_code'] = "QUICK_WAP_WAY";
|
||||
|
||||
$aop = new \AopClient ();
|
||||
//支付配置参数
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = config('alipay.app_id');
|
||||
$aop->rsaPrivateKey = config('alipay.merchant_private_key');
|
||||
$aop->alipayrsaPublicKey=config('alipay.alipay_public_key');
|
||||
$aop->signType='RSA2';
|
||||
$aop->format = "json";
|
||||
|
||||
require '../extend/alipay/aop/request/AlipayTradeWapPayRequest.php';// 加载交易服务
|
||||
$request = new \AlipayTradeWapPayRequest ();
|
||||
|
||||
$request->setBizContent(json_encode($array));
|
||||
//回调地址
|
||||
$request->setReturnUrl($rebackUrl);
|
||||
$request->setNotifyUrl(config('alipay.notify_url'));
|
||||
$result = $aop->pageExecute($request, "POST");
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
//支付宝pc支付
|
||||
public function alipay_pc($user_id,$rebackUrl)
|
||||
{
|
||||
$resOrder = $this->checkOrderValid( $this->orderID,$user_id);
|
||||
require '../extend/alipaypage/pagepay/service/AlipayTradeService.php';// 加载交易服务
|
||||
require '../extend/alipaypage/pagepay/buildermodel/AlipayTradePagePayContentBuilder.php';
|
||||
//商品参数
|
||||
$body = "聚志愿";
|
||||
$subject = "聚志愿vip权限";
|
||||
$out_trade_no= $resOrder['ord_no'];
|
||||
$timeout_express = "5m";
|
||||
$total_amount = $resOrder['money'];
|
||||
|
||||
|
||||
$payRequestBuilder = new \AlipayTradePagePayContentBuilder();
|
||||
$payRequestBuilder->setBody($body);
|
||||
$payRequestBuilder->setSubject($subject);
|
||||
$payRequestBuilder->setTotalAmount($total_amount);
|
||||
$payRequestBuilder->setOutTradeNo($out_trade_no);
|
||||
$payRequestBuilder->setTimeExpress($timeout_express);
|
||||
|
||||
$config = config('alipay.');
|
||||
$aop = new \AlipayTradeService($config);
|
||||
$result = $aop->pagePay($payRequestBuilder,$rebackUrl,$config['notify_url']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//小程序支付
|
||||
public function pay()
|
||||
{
|
||||
// 订单号可能不存在
|
||||
//订单号和用户不匹配
|
||||
//订单可能倍支付过
|
||||
//进行库存量检测
|
||||
$this->checkOrderValid();
|
||||
$orderService = new OrderService();
|
||||
$status = $orderService->checkOrderStock($this->orderID);
|
||||
if(!$status['pass']){
|
||||
return $status;
|
||||
}
|
||||
return $this->makeWxPreOrder($status['orderPrice']);
|
||||
}
|
||||
// 构建微信支付订单信息
|
||||
private function makeWxPreOrder($totalPrice){
|
||||
$openid = Token::getCurrentTokenVar('openid');
|
||||
if(!$openid){
|
||||
throw new TokenException();
|
||||
}
|
||||
//调用统一下单接口
|
||||
$wxOrderData = new \WxPayUnifiedOrder();
|
||||
$wxOrderData->SetOut_trade_no($this->orderNo);
|
||||
$wxOrderData->SetTrade_type('JSAPI');
|
||||
$wxOrderData->SetTotal_fee($totalPrice*100);
|
||||
$wxOrderData->setBody('伊莎商城');
|
||||
$wxOrderData->SetOpenid($openid);
|
||||
$wxOrderData->SetNotify_url(config('secure.pay_back_url'));
|
||||
return $this->getPaySignature($wxOrderData);
|
||||
}
|
||||
//向微信请求订单号并生成签名
|
||||
private function getPaySignature($wxOrderData){
|
||||
$wxOrder = \WxPayApi::unifiedOrder($wxOrderData);
|
||||
// 失败时不会返回result_code
|
||||
if($wxOrder['return_code'] != 'SUCCESS' || $wxOrder['result_code'] !='SUCCESS'){
|
||||
Log::record($wxOrder,'error');
|
||||
Log::record('获取预支付订单失败','error');
|
||||
|
||||
}
|
||||
|
||||
$this->recordPreOrder($wxOrder);
|
||||
$signature = $this->sign($wxOrder);
|
||||
return $signature;
|
||||
}
|
||||
|
||||
private function sign($wxOrder){
|
||||
$jsApiPayData = new \WxPayJsApiPay();
|
||||
$jsApiPayData->SetAppid(config('wx.app_id'));
|
||||
$jsApiPayData->SetTimeStamp((string)time());
|
||||
$rand = md5(time() . mt_rand(0, 1000));
|
||||
$jsApiPayData->SetNonceStr($rand);
|
||||
$jsApiPayData->SetPackage('prepay_id=' . $wxOrder['prepay_id']);
|
||||
$jsApiPayData->SetSignType('md5');
|
||||
$sign = $jsApiPayData->MakeSign();
|
||||
$rawValues = $jsApiPayData->GetValues();
|
||||
$rawValues['paySign'] = $sign;
|
||||
unset($rawValues['appId']);
|
||||
return $rawValues;
|
||||
}
|
||||
|
||||
private function recordPreOrder($wxOrder){
|
||||
// 必须是update,每次用户取消支付后再次对同一订单支付,prepay_id是不同的
|
||||
OrderModel::where('id', '=', $this->orderID)
|
||||
->update(['prepay_id' => $wxOrder['prepay_id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单验证
|
||||
* @return string
|
||||
* @throws OrderException
|
||||
* @throws TokenException
|
||||
*/
|
||||
private function checkOrderValid($orderTD,$userID){
|
||||
$order = OrderModel::field('id,ord_no,status,money,vip')->where([['id','=',$orderTD],['user_id','=',$userID]])
|
||||
->find();
|
||||
|
||||
if(!$order){
|
||||
throw new ParamException([
|
||||
'msg' => '订单不存在',
|
||||
'errorCode' => 10004,
|
||||
'code' => 404
|
||||
]);
|
||||
}
|
||||
if(!Token::isValidOperate($userID)){
|
||||
throw new ParamException([
|
||||
'msg' => '订单与用户信息不匹配',
|
||||
'errorCode' => 10000,
|
||||
'code' => 400
|
||||
]);
|
||||
}
|
||||
|
||||
if($order['status'] == 1){
|
||||
throw new ParamException([
|
||||
'msg' => '订单已支付过啦',
|
||||
'errorCode' => 10000,
|
||||
'code' => 400
|
||||
]);
|
||||
}
|
||||
|
||||
return $order;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 17:25
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
use app\api\controller\Basecontroller;
|
||||
use app\common\controller\SignatureHelper;
|
||||
|
||||
class SendMessage extends Basecontroller
|
||||
{
|
||||
/**
|
||||
* 短信发送api
|
||||
* @param int $phoneNums 接收短信的手机号
|
||||
* @param string $SignName 短信签名
|
||||
* @param string $TemplateCode 短信模板Code
|
||||
* @param string $code 短信变量
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public static function sendAliMessage($phoneNums,$SignName,$TemplateCode,$code="")
|
||||
{
|
||||
$params = array ();
|
||||
// *** 需用户填写部分 ***
|
||||
// fixme 必填:是否启用https
|
||||
$security = false;
|
||||
|
||||
// fixme 必填: 请参阅 https://ak-console.aliyun.com/ 取得您的AK信息
|
||||
$accessKeyId = config('alidayu.AccessKeyID');
|
||||
$accessKeySecret = config('alidayu.AccessKeySecret');
|
||||
|
||||
// fixme 必填: 短信接收号码
|
||||
$params["PhoneNumbers"] = $phoneNums;
|
||||
|
||||
// fixme 必填: 短信签名,应严格按"签名名称"填写,请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/sign
|
||||
$params["SignName"] = $SignName;
|
||||
|
||||
// fixme 必填: 短信模板Code,应严格按"模板CODE"填写, 请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/template
|
||||
$params["TemplateCode"] = $TemplateCode;
|
||||
|
||||
// fixme 可选: 设置模板参数, 假如模板中存在变量需要替换则为必填项
|
||||
if($code){
|
||||
$params['TemplateParam'] = $code;
|
||||
}
|
||||
|
||||
// fixme 可选: 设置发送短信流水号
|
||||
//$params['OutId'] = "12345";
|
||||
|
||||
// fixme 可选: 上行短信扩展码, 扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段
|
||||
//$params['SmsUpExtendCode'] = "1234567";
|
||||
|
||||
|
||||
// *** 需用户填写部分结束, 以下代码若无必要无需更改 ***
|
||||
if(!empty($params["TemplateParam"]) && is_array($params["TemplateParam"])) {
|
||||
$params["TemplateParam"] = json_encode($params["TemplateParam"], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
// 初始化SignatureHelper实例用于设置参数,签名以及发送请求
|
||||
$helper = new SignatureHelper();
|
||||
|
||||
// 此处可能会抛出异常,注意catch
|
||||
$content = $helper->request(
|
||||
$accessKeyId,
|
||||
$accessKeySecret,
|
||||
"dysmsapi.aliyuncs.com",
|
||||
array_merge($params, array(
|
||||
"RegionId" => "cn-hangzhou",
|
||||
"Action" => "SendSms",
|
||||
"Version" => "2017-05-25",
|
||||
)),
|
||||
$security
|
||||
);
|
||||
if($content->Message == 'OK')
|
||||
return ['status'=>1];
|
||||
else
|
||||
return ['status'=>0];
|
||||
}
|
||||
}
|
||||
65
芳林公司项目/www.zhiyuanhelp.com/application/api/service/Token.php
Normal file
65
芳林公司项目/www.zhiyuanhelp.com/application/api/service/Token.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Request;
|
||||
|
||||
class Token
|
||||
{
|
||||
public static function generateToken(){
|
||||
|
||||
$randChar = getRandChar(32);
|
||||
$timestamp = $_SERVER['REQUEST_TIME_FLOAT'];
|
||||
$tokenSalt = config('secure.token_salt');
|
||||
return md5($randChar . $timestamp . $tokenSalt);
|
||||
}
|
||||
public static function getCurrentTokenVar($key){
|
||||
$token = Request::header('token');
|
||||
// $vars = Cache::get($token);
|
||||
$vars = Cache::store('redis')->get($token);
|
||||
|
||||
if(!$vars){
|
||||
throw new TokenException();
|
||||
}else{
|
||||
if(!is_array($vars))
|
||||
{
|
||||
$vars = json_decode($vars, true);
|
||||
return $vars;
|
||||
}
|
||||
|
||||
if (array_key_exists($key, $vars)) {
|
||||
return $vars[$key];
|
||||
}
|
||||
else{
|
||||
throw new Exception('尝试获取的Token变量并不存在');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static function getCurrentUid(){
|
||||
|
||||
$uid = self::getCurrentTokenVar('uid');
|
||||
return $uid;
|
||||
}
|
||||
|
||||
|
||||
public static function isValidOperate($checkedUID){
|
||||
|
||||
if(!$checkedUID){
|
||||
throw new Exception('检测UID时必须传入一个被检测的UID');
|
||||
}
|
||||
|
||||
$currentOperateUID = self::getCurrentUid();
|
||||
if($currentOperateUID == $checkedUID){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
180
芳林公司项目/www.zhiyuanhelp.com/application/api/service/UserToken.php
Normal file
180
芳林公司项目/www.zhiyuanhelp.com/application/api/service/UserToken.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2019/5/25 0025
|
||||
* Time: 16:47
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
use app\lib\exception\ParamException;
|
||||
use think\Exception;
|
||||
use app\api\model\User as UserModel;
|
||||
use think\facade\Cache;
|
||||
|
||||
class UserToken extends Token
|
||||
{
|
||||
protected $code;
|
||||
protected $wxLoginUrl;
|
||||
protected $wxAppID;
|
||||
protected $wxAppSecret;
|
||||
|
||||
function __construct($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->wxAppID = config('wx.app_id');
|
||||
$this->wxAppSecret = config('wx.app_secret');
|
||||
$this->wxLoginUrl = sprintf(
|
||||
config('wx.login_url'), $this->wxAppID, $this->wxAppSecret, $this->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登陆
|
||||
* 思路1:每次调用登录接口都去微信刷新一次session_key,生成新的Token,不删除久的Token
|
||||
* 思路2:检查Token有没有过期,没有过期则直接返回当前Token
|
||||
* 思路3:重新去微信刷新session_key并删除当前Token,返回新的Token
|
||||
*/
|
||||
public function get($paramPost)
|
||||
{
|
||||
$result = curl_get($this->wxLoginUrl);
|
||||
|
||||
// 注意json_decode的第一个参数true
|
||||
// 这将使字符串被转化为数组而非对象
|
||||
|
||||
$wxResult = json_decode($result, true);
|
||||
|
||||
if (empty($wxResult)) {
|
||||
// 为什么以empty判断是否错误,这是根据微信返回
|
||||
// 规则摸索出来的
|
||||
// 这种情况通常是由于传入不合法的code
|
||||
throw new ParamException([
|
||||
'code'=>401,
|
||||
'msg' => '获取session_key及openID时异常,微信内部错误',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
else {
|
||||
// 建议用明确的变量来表示是否成功
|
||||
// 微信服务器并不会将错误标记为400,无论成功还是失败都标记成200
|
||||
// 这样非常不好判断,只能使用errcode是否存在来判断
|
||||
$loginFail = array_key_exists('errcode', $wxResult);
|
||||
if ($loginFail) {
|
||||
$this->processLoginError($wxResult);
|
||||
}
|
||||
else {
|
||||
return $this->grantToken($wxResult,$paramPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 颁发令牌
|
||||
// 只要调用登陆就颁发新令牌
|
||||
// 但旧的令牌依然可以使用
|
||||
// 所以通常令牌的有效时间比较短
|
||||
// 目前微信的express_in时间是7200秒
|
||||
// 在不设置刷新令牌(refresh_token)的情况下
|
||||
// 只能延迟自有token的过期时间超过7200秒(目前还无法确定,在express_in时间到期后
|
||||
// 还能否进行微信支付
|
||||
// 没有刷新令牌会有一个问题,就是用户的操作有可能会被突然中断
|
||||
private function grantToken($wxResult)
|
||||
{
|
||||
// 此处生成令牌使用的是TP5自带的令牌
|
||||
// 如果想要更加安全可以考虑自己生成更复杂的令牌
|
||||
// 比如使用JWT并加入盐,如果不加入盐有一定的几率伪造令牌
|
||||
$openid = $wxResult['openid'];
|
||||
$user = UserModel::getByOpenID($openid);
|
||||
if (!$user)
|
||||
// 借助微信的openid作为用户标识
|
||||
// 但在系统中的相关查询还是使用自己的uid
|
||||
{
|
||||
$uid = $this->newUser($openid);
|
||||
}
|
||||
else {
|
||||
$uid = $user->id;
|
||||
}
|
||||
$cachedValue = $this->prepareCachedValue($wxResult, $uid);
|
||||
$token = $this->saveToCache($cachedValue);
|
||||
return $token;
|
||||
}
|
||||
|
||||
private function newUser($openid){
|
||||
$user = UserModel::create([
|
||||
'openid' =>$openid
|
||||
]);
|
||||
return $user->id;
|
||||
}
|
||||
|
||||
//生成token并缓存
|
||||
private function saveToCache($wxResult){
|
||||
|
||||
$key = self::generateToken();
|
||||
$value = json_encode($wxResult);
|
||||
$request = Cache::store('redis')->set($key,$value,2592000);
|
||||
if(!$request){
|
||||
throw new ParamException([
|
||||
'code' => 401,
|
||||
'msg' => '服务起缓存异常',
|
||||
'errorCode' => 10001
|
||||
]);
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
//缓存数据预处理
|
||||
private function prepareCachedValue($wxResult, $uid)
|
||||
{
|
||||
$cachedValue = $wxResult;
|
||||
$cachedValue['uid'] = $uid;
|
||||
return $cachedValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function processLoginError($wxResult){
|
||||
throw new ParamException([
|
||||
'msg' => $wxResult['errmsg'],
|
||||
'errorCode' => $wxResult['errcode']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤微信昵称的特殊表情
|
||||
* @param $text
|
||||
* @param string $replaceTo
|
||||
* @return null|string|string[]
|
||||
*/
|
||||
public function filterEmoji($text, $replaceTo = 'x'){
|
||||
$clean_text = "";
|
||||
// Match Emoticons
|
||||
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
|
||||
$clean_text = preg_replace($regexEmoticons, $replaceTo, $text);
|
||||
// Match Miscellaneous Symbols and Pictographs
|
||||
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
|
||||
$clean_text = preg_replace($regexSymbols, $replaceTo, $clean_text);
|
||||
// Match Transport And Map Symbols
|
||||
$regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
|
||||
$clean_text = preg_replace($regexTransport, $replaceTo, $clean_text);
|
||||
// Match Miscellaneous Symbols
|
||||
$regexMisc = '/[\x{2600}-\x{26FF}]/u';
|
||||
$clean_text = preg_replace($regexMisc, $replaceTo, $clean_text);
|
||||
// Match Dingbats
|
||||
$regexDingbats = '/[\x{2700}-\x{27BF}]/u';
|
||||
$clean_text = preg_replace($regexDingbats, $replaceTo, $clean_text);
|
||||
return $clean_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非小程序登录token
|
||||
* @param $arr
|
||||
* @return string
|
||||
* @throws ParamException
|
||||
*/
|
||||
public function LoginToken($str)
|
||||
{
|
||||
$token = $this->saveToCache($str);
|
||||
return $token;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020-01-10
|
||||
* Time: 17:24
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
|
||||
use think\Log;
|
||||
|
||||
class WechatH5Pay
|
||||
{
|
||||
//use Flight;
|
||||
/**
|
||||
* 微信支付服务器端下单
|
||||
* 微信APP支付文档地址: https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=8_6
|
||||
* 使用示例
|
||||
* 构造方法参数
|
||||
* 'appid' => //填写微信分配的公众账号ID
|
||||
* 'mch_id' => //填写微信支付分配的商户号
|
||||
* 'notify_url'=> //填写微信支付结果回调地址
|
||||
* 'key' => //填写微信商户支付密钥
|
||||
* );
|
||||
* 统一下单方法
|
||||
* $WechatAppPay = new wechatAppPay($options);
|
||||
* $params['body'] = '商品描述'; //商品描述
|
||||
* $params['out_trade_no'] = '1217752501201407'; //自定义的订单号,不能重复
|
||||
* $params['total_fee'] = '100'; //订单金额 只能为整数 单位为分
|
||||
* $params['trade_type'] = 'APP'; //交易类型 JSAPI | NATIVE |APP | WAP
|
||||
* $wechatAppPay->unifiedOrder( $params );
|
||||
*/
|
||||
//接口API URL前缀
|
||||
const API_URL_PREFIX = 'https://api.mch.weixin.qq.com';
|
||||
//下单地址URL
|
||||
const UNIFIEDORDER_URL = "/pay/unifiedorder";
|
||||
//查询订单URL
|
||||
const ORDERQUERY_URL = "/pay/orderquery";
|
||||
//关闭订单URL
|
||||
const CLOSEORDER_URL = "/pay/closeorder";
|
||||
//公众账号ID
|
||||
private $appid;
|
||||
//商户号
|
||||
private $mch_id;
|
||||
//随机字符串
|
||||
private $nonce_str;
|
||||
//签名
|
||||
private $sign;
|
||||
//商品描述
|
||||
private $body;
|
||||
//商户订单号
|
||||
private $out_trade_no;
|
||||
//支付总金额
|
||||
private $total_fee;
|
||||
//终端IP
|
||||
private $spbill_create_ip;
|
||||
//支付结果回调通知地址
|
||||
private $notify_url;
|
||||
//交易类型
|
||||
private $trade_type;
|
||||
//支付密钥
|
||||
private $key;
|
||||
//证书路径
|
||||
private $SSLCERT_PATH;
|
||||
private $SSLKEY_PATH;
|
||||
//所有参数
|
||||
private $params = array();
|
||||
public function __construct($appid, $mch_id, $notify_url, $key)
|
||||
{
|
||||
$this->appid = $appid;
|
||||
$this->mch_id = $mch_id;
|
||||
$this->notify_url = $notify_url;
|
||||
$this->key = $key;
|
||||
}
|
||||
/**
|
||||
* 下单方法
|
||||
* @param $params 下单参数
|
||||
*/
|
||||
public function unifiedOrder( $params ){
|
||||
$this->body = $params['body'];
|
||||
$this->out_trade_no = $params['out_trade_no'];
|
||||
$this->total_fee = $params['total_fee'];
|
||||
$this->trade_type = $params['trade_type'];
|
||||
$this->scene_info = $params['scene_info'];
|
||||
$this->nonce_str = $this->genRandomString();
|
||||
$this->spbill_create_ip = $_SERVER['REMOTE_ADDR'];
|
||||
$this->params['appid'] = $this->appid;
|
||||
$this->params['mch_id'] = $this->mch_id;
|
||||
$this->params['nonce_str'] = $this->nonce_str;
|
||||
$this->params['body'] = $this->body;
|
||||
$this->params['out_trade_no'] = $this->out_trade_no;
|
||||
$this->params['total_fee'] = $this->total_fee;
|
||||
$this->params['spbill_create_ip'] = $this->spbill_create_ip;
|
||||
$this->params['notify_url'] = $this->notify_url;
|
||||
$this->params['trade_type'] = $this->trade_type;
|
||||
$this->params['scene_info'] = $this->scene_info;
|
||||
//获取签名数据
|
||||
$this->sign = $this->MakeSign( $this->params );
|
||||
$this->params['sign'] = $this->sign;
|
||||
$xml = $this->data_to_xml($this->params);
|
||||
$response = $this->postXmlCurl($xml, self::API_URL_PREFIX.self::UNIFIEDORDER_URL);
|
||||
if( !$response ){
|
||||
return false;
|
||||
}
|
||||
$result = $this->xml_to_data( $response );
|
||||
if( !empty($result['result_code']) && !empty($result['err_code']) ){
|
||||
$result['err_msg'] = $this->error_code( $result['err_code'] );
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param $out_trade_no 订单号
|
||||
* @return array
|
||||
*/
|
||||
public function orderQuery( $out_trade_no ){
|
||||
$this->params['appid'] = $this->appid;
|
||||
$this->params['mch_id'] = $this->mch_id;
|
||||
$this->params['nonce_str'] = $this->genRandomString();
|
||||
$this->params['out_trade_no'] = $out_trade_no;
|
||||
//获取签名数据
|
||||
$this->sign = $this->MakeSign( $this->params );
|
||||
$this->params['sign'] = $this->sign;
|
||||
$xml = $this->data_to_xml($this->params);
|
||||
$response = $this->postXmlCurl($xml, self::API_URL_PREFIX.self::ORDERQUERY_URL);
|
||||
if( !$response ){
|
||||
return false;
|
||||
}
|
||||
$result = $this->xml_to_data( $response );
|
||||
if( !empty($result['result_code']) && !empty($result['err_code']) ){
|
||||
$result['err_msg'] = $this->error_code( $result['err_code'] );
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* 关闭订单
|
||||
* @param $out_trade_no 订单号
|
||||
* @return array
|
||||
*/
|
||||
public function closeOrder( $out_trade_no ){
|
||||
$this->params['appid'] = $this->appid;
|
||||
$this->params['mch_id'] = $this->mch_id;
|
||||
$this->params['nonce_str'] = $this->genRandomString();
|
||||
$this->params['out_trade_no'] = $out_trade_no;
|
||||
//获取签名数据
|
||||
$this->sign = $this->MakeSign( $this->params );
|
||||
$this->params['sign'] = $this->sign;
|
||||
$xml = $this->data_to_xml($this->params);
|
||||
$response = $this->postXmlCurl($xml, self::API_URL_PREFIX.self::CLOSEORDER_URL);
|
||||
if( !$response ){
|
||||
return false;
|
||||
}
|
||||
$result = $this->xml_to_data( $response );
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* 获取支付结果通知数据
|
||||
* return array
|
||||
*/
|
||||
public function getNotifyData(){
|
||||
//获取通知的数据
|
||||
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
|
||||
//echo 123;die;
|
||||
$data = array();
|
||||
if( empty($xml) ){
|
||||
return false;
|
||||
}
|
||||
$data = $this->xml_to_data( $xml );
|
||||
if( !empty($data['return_code']) ){
|
||||
if( $data['return_code'] == 'FAIL' ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 接收通知成功后应答输出XML数据
|
||||
* @param string $xml
|
||||
*/
|
||||
public function replyNotify(){
|
||||
$data['return_code'] = 'SUCCESS';
|
||||
$data['return_msg'] = 'OK';
|
||||
$xml = $this->data_to_xml( $data );
|
||||
echo $xml;
|
||||
die();
|
||||
}
|
||||
/**
|
||||
* 生成APP端支付参数
|
||||
* @param $prepayid 预支付id
|
||||
*/
|
||||
public function getAppPayParams( $prepayid ){
|
||||
$data['appid'] = $this->appid;
|
||||
$data['partnerid'] = $this->mch_id;
|
||||
$data['prepayid'] = $prepayid;
|
||||
$data['package'] = 'Sign=WXPay';
|
||||
$data['noncestr'] = $this->genRandomString();
|
||||
$data['timestamp'] = time();
|
||||
$data['sign'] = $this->MakeSign( $data );
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 生成签名
|
||||
* @return 签名
|
||||
*/
|
||||
public function MakeSign( $params ){
|
||||
//签名步骤一:按字典序排序数组参数
|
||||
ksort($params);
|
||||
$string = $this->ToUrlParams($params);
|
||||
//签名步骤二:在string后加入KEY
|
||||
$string = $string . "&key=".$this->key;
|
||||
//签名步骤三:MD5加密
|
||||
$string = md5($string);
|
||||
//签名步骤四:所有字符转为大写
|
||||
$result = strtoupper($string);
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* 将参数拼接为url: key=value&key=value
|
||||
* @param $params
|
||||
* @return string
|
||||
*/
|
||||
public function ToUrlParams( $params ){
|
||||
$string = '';
|
||||
if( !empty($params) ){
|
||||
$array = array();
|
||||
foreach( $params as $key => $value ){
|
||||
$array[] = $key.'='.$value;
|
||||
}
|
||||
$string = implode("&",$array);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
/**
|
||||
* 输出xml字符
|
||||
* @param $params 参数名称
|
||||
* return string 返回组装的xml
|
||||
**/
|
||||
public function data_to_xml( $params ){
|
||||
if(!is_array($params)|| count($params) <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$xml = "<xml>";
|
||||
foreach ($params as $key=>$val)
|
||||
{
|
||||
if (is_numeric($val)){
|
||||
$xml.="<".$key.">".$val."</".$key.">";
|
||||
}else{
|
||||
$xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
|
||||
}
|
||||
}
|
||||
$xml.="</xml>";
|
||||
return $xml;
|
||||
}
|
||||
/**
|
||||
* 将xml转为array
|
||||
* @param string $xml
|
||||
* return array
|
||||
*/
|
||||
public function xml_to_data($xml){
|
||||
if(!$xml){
|
||||
return false;
|
||||
}
|
||||
//将XML转为array
|
||||
//禁止引用外部xml实体
|
||||
libxml_disable_entity_loader(true);
|
||||
$data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 获取毫秒级别的时间戳
|
||||
*/
|
||||
private static function getMillisecond(){
|
||||
//获取毫秒的时间戳
|
||||
$time = explode ( " ", microtime () );
|
||||
$time = $time[1] . ($time[0] * 1000);
|
||||
$time2 = explode( ".", $time );
|
||||
$time = $time2[0];
|
||||
return $time;
|
||||
}
|
||||
/**
|
||||
* 产生一个指定长度的随机字符串,并返回给用户
|
||||
* @param type $len 产生字符串的长度
|
||||
* @return string 随机字符串
|
||||
*/
|
||||
private function genRandomString($len = 32) {
|
||||
$chars = array(
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
|
||||
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
|
||||
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
|
||||
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
|
||||
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
|
||||
"3", "4", "5", "6", "7", "8", "9"
|
||||
);
|
||||
$charsLen = count($chars) - 1;
|
||||
// 将数组打乱
|
||||
shuffle($chars);
|
||||
$output = "";
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$output .= $chars[mt_rand(0, $charsLen)];
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* 以post方式提交xml到对应的接口url
|
||||
*
|
||||
* @param string $xml 需要post的xml数据
|
||||
* @param string $url url
|
||||
* @param bool $useCert 是否需要证书,默认不需要
|
||||
* @param int $second url执行超时时间,默认30s
|
||||
* @throws WxPayException
|
||||
*/
|
||||
private function postXmlCurl($xml, $url, $useCert = false, $second = 30){
|
||||
$ch = curl_init();
|
||||
//设置超时
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
|
||||
curl_setopt($ch,CURLOPT_URL, $url);
|
||||
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
|
||||
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);
|
||||
//设置header
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
//要求结果为字符串且输出到屏幕上
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
if($useCert == true){
|
||||
//设置证书
|
||||
//使用证书:cert 与 key 分别属于两个.pem文件
|
||||
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM');
|
||||
//curl_setopt($ch,CURLOPT_SSLCERT, WxPayConfig::SSLCERT_PATH);
|
||||
curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM');
|
||||
//curl_setopt($ch,CURLOPT_SSLKEY, WxPayConfig::SSLKEY_PATH);
|
||||
}
|
||||
//post提交方式
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
|
||||
//运行curl
|
||||
$data = curl_exec($ch);
|
||||
//返回结果
|
||||
if($data){
|
||||
curl_close($ch);
|
||||
return $data;
|
||||
} else {
|
||||
$error = curl_errno($ch);
|
||||
curl_close($ch);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 错误代码
|
||||
* @param $code 服务器输出的错误代码
|
||||
* return string
|
||||
*/
|
||||
public function error_code( $code ){
|
||||
$errList = array(
|
||||
'NOAUTH' => '商户未开通此接口权限',
|
||||
'NOTENOUGH' => '用户帐号余额不足',
|
||||
'ORDERNOTEXIST' => '订单号不存在',
|
||||
'ORDERPAID' => '商户订单已支付,无需重复操作',
|
||||
'ORDERCLOSED' => '当前订单已关闭,无法支付',
|
||||
'SYSTEMERROR' => '系统错误!系统超时',
|
||||
'APPID_NOT_EXIST' => '参数中缺少APPID',
|
||||
'MCHID_NOT_EXIST' => '参数中缺少MCHID',
|
||||
'APPID_MCHID_NOT_MATCH' => 'appid和mch_id不匹配',
|
||||
'LACK_PARAMS' => '缺少必要的请求参数',
|
||||
'OUT_TRADE_NO_USED' => '同一笔交易不能多次提交',
|
||||
'SIGNERROR' => '参数签名结果不正确',
|
||||
'XML_FORMAT_ERROR' => 'XML格式错误',
|
||||
'REQUIRE_POST_METHOD' => '未使用post传递参数 ',
|
||||
'POST_DATA_EMPTY' => 'post数据不能为空',
|
||||
'NOT_UTF8' => '未使用指定编码格式',
|
||||
);
|
||||
if( array_key_exists( $code , $errList ) ){
|
||||
return $errList[$code];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/18
|
||||
* Time: 10:49
|
||||
*/
|
||||
|
||||
namespace app\api\service;
|
||||
use app\api\model\Order as OrderModel;
|
||||
use think\Exception;
|
||||
use think\facade\Log;
|
||||
|
||||
require 'D:/wwwroot/www.zhiyuanhelp.com/extend/WxPay/WxPay.Api.php';
|
||||
class WxNotify extends \WxPayNotify
|
||||
{
|
||||
public function NotifyProcess($data, &$msg){
|
||||
if($data['result_code'] == 'SUCCESS'){
|
||||
$orderNo = $data['out_trade_no'];
|
||||
try{
|
||||
$order = OrderModel::where('ord_no','=',$orderNo)->find();
|
||||
//修改订单状态
|
||||
$resUpdate = $this->updateOrderStatus($order['id']);
|
||||
if($resUpdate){
|
||||
return true;
|
||||
}
|
||||
}catch (Exception $e){
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//更改状态
|
||||
private function updateOrderStatus($orderID){
|
||||
OrderModel::where('id','=',$orderID)
|
||||
->update(['status'=>1,'pay_way'=>1,'pay_time'=>time()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
b0466fa7-c9a0-4cc9-8b66-5e1c7afb5650
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/30
|
||||
* Time: 13:06
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class AllCollectSelValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'userPro' => 'require|isPostInt',
|
||||
'page' => 'require',
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.isPostInt' => '用户所在省份code必须是正整数',
|
||||
'page.isPostInt' => 'page必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
*/
|
||||
namespace app\api\validate;
|
||||
use app\lib\exception\ParamException;
|
||||
use think\facade\Request;
|
||||
use think\Validate;
|
||||
|
||||
class BaseValidate extends Validate
|
||||
{
|
||||
public function goCheck(){
|
||||
//获取http传入的参数
|
||||
//对这些参数做检验
|
||||
|
||||
$params = Request::param();
|
||||
|
||||
$result = $this->batch()->check($params);
|
||||
|
||||
if(!$result){
|
||||
$e = new ParamException([
|
||||
'msg' => $this->error
|
||||
]);
|
||||
throw $e;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//验证参数是否是正整数
|
||||
protected function isPostInt($value, $rule='', $data='', $field='')
|
||||
{
|
||||
if (is_numeric($value) && is_int($value + 0) && ($value + 0) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//没有使用TP的正则验证,集中在一处方便以后修改
|
||||
//不推荐使用正则,因为复用性太差
|
||||
//手机号的验证规则
|
||||
protected function isMobile($value)
|
||||
{
|
||||
$rule = '^1(3|4|5|7|8)[0-9]\d{8}$^';
|
||||
$result = preg_match($rule, $value);
|
||||
if ($result) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//验证参数是否为空
|
||||
protected function isNotEmpty($value, $rule='', $data='', $field=''){
|
||||
if(empty($value)){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arrays 通常传入request.post变量数组
|
||||
* @return array 按照规则key过滤后的变量数组
|
||||
* @throws ParameterException
|
||||
*/
|
||||
public function getDataByRule($arrays)
|
||||
{
|
||||
if (array_key_exists('user_id', $arrays) | array_key_exists('uid', $arrays)) {
|
||||
// 不允许包含user_id或者uid,防止恶意覆盖user_id外键
|
||||
throw new ParameterException([
|
||||
'msg' => '参数中包含有非法的参数名user_id或者uid'
|
||||
]);
|
||||
}
|
||||
$newArray = [];
|
||||
foreach ($this->rule as $key => $value) {
|
||||
$newArray[$key] = $arrays[$key];
|
||||
}
|
||||
return $newArray;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/14
|
||||
* Time: 15:52
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class BatchsValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'province' => 'require|isPostInt',
|
||||
'subType' => 'require',
|
||||
'score' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'province.isPostInt' => '省份编号必须是正整数',
|
||||
'score.isPostInt' => '分数必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/27
|
||||
* Time: 16:01
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class ColNewMajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'plan_id' => 'require|isPostInt',
|
||||
'majorCode' => 'require',
|
||||
'chooseCns' => 'require',
|
||||
'collegeName' => 'require',
|
||||
'probability' => 'require|isPostInt',
|
||||
'planNum' => 'require|isPostInt',
|
||||
'professionName'=> 'require',
|
||||
'tags' => 'require',
|
||||
'score' => 'require|isPostInt',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'minScore' => 'require',
|
||||
'lowestRank' => 'require',
|
||||
'rankOfCn' => 'require'
|
||||
];
|
||||
protected $message = [
|
||||
'plan_id.isPostInt' => 'plan_id必须是正整数',
|
||||
'probability.isPostInt' => 'probability必须是正整数',
|
||||
'score.isPostInt' => 'score必须是正整数',
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'planNum.isPostInt' => 'planNum必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/27
|
||||
* Time: 16:40
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class ColNewSchValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'plan_id' => 'require|isPostInt',
|
||||
'collegeName' => 'require',
|
||||
'rankOfCn' => 'require|isPostInt',
|
||||
'collegeCode' => 'require',
|
||||
'logo' => 'require',
|
||||
'planNum' => 'require',
|
||||
'tags' => 'require',
|
||||
'score' => 'require|isPostInt',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'lowestRank' => 'require',
|
||||
'minScore' => 'require',
|
||||
'majorNum' => 'require',
|
||||
];
|
||||
protected $message = [
|
||||
'plan_id.isPostInt' => 'plan_id必须是正整数',
|
||||
/* 'lowestRank.isPostInt' => 'lowestRank必须是正整数',
|
||||
'minScore.isPostInt' => 'minScore必须是正整数',
|
||||
'sch_id.isPostInt' => 'sch_id必须是正整数',*/
|
||||
'rankOfCn.require' => 'rankOfCn必须是正整数',
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'score.isPostInt' => 'score必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/21
|
||||
* Time: 19:31
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class CollectMajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'code' => 'require',
|
||||
'majorCode' => 'require',
|
||||
'title' => 'require',
|
||||
'planNum' => 'require|isPostInt',
|
||||
'sch_id' => 'require|isPostInt',
|
||||
'tags' => 'require',
|
||||
'sch_name' => 'require',
|
||||
'score' => 'require|isPostInt',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'probability' => 'require|number',
|
||||
'cost' => 'require|number',
|
||||
'minScore' => 'require',
|
||||
'lowestRank' => 'require',
|
||||
'enterNum' => 'require'
|
||||
];
|
||||
protected $message = [
|
||||
'probability.number' => 'probability必须是数字',
|
||||
'cost.number' => 'cost必须是数字',
|
||||
'planNum.isPostInt' => 'planNum必须是正整数',
|
||||
'sch_id.isPostInt' => 'sch_id必须是正整数',
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'score' => 'score必须是正整数'
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 11:18
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class CollectValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'rec_id' => 'require|isPostInt',
|
||||
'alias' => 'require',
|
||||
'logo' => 'require',
|
||||
'batch_title' => 'require',
|
||||
'lowestRank' => 'require|isPostInt',
|
||||
'minScore' => 'require|isPostInt',
|
||||
'majorNum' => 'require',
|
||||
'enterNum' => 'require',
|
||||
'sch_id' => 'require|isPostInt',
|
||||
'sch_province_title' => 'require',
|
||||
'rankOfCn' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'probability' => 'require',
|
||||
'recommendType' => 'require',
|
||||
];
|
||||
protected $message = [
|
||||
'rec_id.isPostInt' => 'rec_id必须是正整数',
|
||||
'lowestRank.isPostInt' => 'lowestRank必须是正整数',
|
||||
'minScore.isPostInt' => 'minScore必须是正整数',
|
||||
'sch_id.isPostInt' => 'sch_id必须是正整数',
|
||||
'score.isPostInt' => 'score必须是正整数',
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'rankOfCn.require' => 'rankOfCn必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/5/2
|
||||
* Time: 22:59
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class DefaultMajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'userPro' => 'require|isPostInt',
|
||||
'subType' => 'require',
|
||||
'batch' => 'require',
|
||||
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.isPostInt' => '用户所在省份code必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/14
|
||||
* Time: 9:08
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class IDMustValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'id.isPostInt' => 'id必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 18:22
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class LoginValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'telnum' => 'require',
|
||||
'code' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'telnum.require' => '手机号必须',
|
||||
'code.isPostInt' => '验证码必须是正整数'
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/21
|
||||
* Time: 13:49
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class MajorSchValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'code' => 'require',
|
||||
'subType' => 'require',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt',
|
||||
'page' => 'require|isPostInt',
|
||||
];
|
||||
protected $message = [
|
||||
'code.require' => '专业号必须',
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'score.isPostInt' => 'score必须是正整数',
|
||||
'page.isPostInt' => '页码必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 20:10
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class MajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'title' => 'require|max:20',
|
||||
'page' => 'require|isPostInt',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'subType' => 'require',
|
||||
'batch' => 'require',
|
||||
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'title.max' => '标题长度不能大于20',
|
||||
'page.isPostInt' => '页码必须是正整数',
|
||||
'userPro.isPostInt' => '用户所在省份code必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/19
|
||||
* Time: 21:56
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class MessageValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'telnum' => 'require',
|
||||
'content' => 'require',
|
||||
'type' => 'require'
|
||||
];
|
||||
protected $message = [
|
||||
'telnum.require' => '请输入手机号!',
|
||||
'content.require' => '请输入内容!',
|
||||
'type.require' => '类型必须!'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/30
|
||||
* Time: 1:02
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class NewMajorSchValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'code' => 'require',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'mySub' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt',
|
||||
'page' => 'require|isPostInt',
|
||||
];
|
||||
protected $message = [
|
||||
'code.require' => '专业号必须',
|
||||
'userPro' => 'userPro|isPostInt',
|
||||
'page.isPostInt' => '页码必须是正整数',
|
||||
'score.isPostInt' => '分数必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/26
|
||||
* Time: 14:52
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class NewMajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'is_login' => 'require',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt',
|
||||
'mySub' => 'require|length:3',
|
||||
'type' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.require' => '所在省份必须是正整数',
|
||||
'score.isPostInt' => '分数必须是正整数',
|
||||
'mySub.length' => '考生科目必须3科',
|
||||
'type.isPostInt' => '查询类型必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/27
|
||||
* Time: 17:40
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class NewSchMajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'userPro' => 'require|isPostInt',
|
||||
'is_login' => 'require',
|
||||
'id' => 'require|isPostInt',
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'id.isPostInt' => 'id必须是正整数',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/17
|
||||
* Time: 13:27
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class OrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'is_login' => 'require',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt',
|
||||
'vip_type' => 'require|isPostInt',
|
||||
'telnum' => 'require'
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.require' => '所在省份必填',
|
||||
'score.require' => '分数必填',
|
||||
'vip_type.require' => '购买类型必填',
|
||||
'userPro.isPostInt' => '所在省份必须是正整数',
|
||||
'score.isPostInt' => '分数必须是正整数',
|
||||
'vip_type.isPostInt' => '购买类型必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/24
|
||||
* Time: 10:53
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class SchEnrollValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'userPro' => 'require|isPostInt',
|
||||
'subType' => 'require',
|
||||
'sch_id' => 'require|isPostInt',
|
||||
'batch' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'sch_id.isPostInt' => 'sch_id必须是正整数',
|
||||
'batch.isPostInt' => 'batch必须是正整数',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/22
|
||||
* Time: 10:14
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class SchMajorValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'page' => 'require|isPostInt',
|
||||
'id' => 'require|isPostInt',
|
||||
'sch_id' => 'require|isPostInt',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'subType' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt'
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'page.isPostInt' => '页码必须是正整数',
|
||||
'id.isPostInt' => 'id必须是正整数',
|
||||
'sch_id.isPostInt' => 'sch_id必须是正整数',
|
||||
'userPro.isPostInt' => 'userPro必须是正整数',
|
||||
'subType.isPostInt' => 'subType必须是正整数',
|
||||
'score.isPostInt' => 'score必须是正整数'
|
||||
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/16
|
||||
* Time: 9:03
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class SchoolChoiceValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'is_login' => 'require',
|
||||
'userPro' => 'require|isPostInt',
|
||||
'score' => 'require|isPostInt',
|
||||
'subType' => 'require',
|
||||
'type' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.require' => '所在省份必须是正整数',
|
||||
'score.isPostInt' => '分数必须是正整数',
|
||||
'type.isPostInt' => '查询类型必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/30
|
||||
* Time: 12:35
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class ScoreGradeValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'userPro' => 'require|isPostInt',
|
||||
'is_sch' => 'require',
|
||||
'provinceType' => 'require|isPostInt'
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'userPro.isPostInt' => '用户所在省份code必须是正整数',
|
||||
'provinceType.isPostInt' => 'provinceType必须是正整数'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/20
|
||||
* Time: 19:22
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class SearchAboutValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'title' => 'require|max:20'
|
||||
];
|
||||
protected $message = [
|
||||
'title.max' => '标题长度不能大于20'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/16
|
||||
* Time: 14:22
|
||||
*/
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
class UserAuthValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'score' => 'require|isPostInt',
|
||||
'type' => 'require|isPostInt',
|
||||
'province' => 'require|isPostInt'
|
||||
];
|
||||
protected $message = [
|
||||
'score.require' => '分数必须是正整数',
|
||||
'type.isPostInt' => '类型必须是正整数',
|
||||
'province.isPostInt' => '省份编号必须是正整数'
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user