Commit a56e3081 authored by wangzhengwen's avatar wangzhengwen

企业验证

parent 20609579
......@@ -4,6 +4,7 @@ namespace app\api\controller;
use app\api\middleware\Auth;
use app\api\service\AlipayTradeService;
use app\api\service\UtilService;
use app\BaseController;
use app\model\Payment;
use think\facade\Log;
......@@ -24,6 +25,11 @@ class PayController
*/
public function create($params)
{
$userRole = UtilService::checkUserRole($params['user_id']);
if ($userRole!=1)
{
return json(['code' => 0, 'msg' => '企业账号不能购买']);
}
// 在调用 PayService::createPayment() 之前先检查是否存在有效支付记录
$existingPayment = Db::name('payment')
......
......@@ -35,6 +35,12 @@ class CertOrder extends BaseController
unset($data['pay_type']);
$userRole = UtilService::checkUserRole($data['user_id']);
if ($userRole!=1)
{
return json(['code' => 0, 'msg' => '企业账号不能报名']);
}
$where = ['is_del'=>0,'user_id'=>$data['user_id'],'cert_id'=>$data['cert_id']];
$count = OrderModel::where($where)->count();
if ($count > 0) {
......
......@@ -3,6 +3,7 @@
namespace app\api\controller\project;
use app\api\middleware\Auth;
use app\api\service\UtilService;
use app\api\validate\ProjectValidate;
use app\BaseController;
use think\Request;
......@@ -28,6 +29,12 @@ class ProjectPut extends BaseController
$data = $request->only(['project_id','user_desc','file_id_str']);
$userRole = UtilService::checkUserRole($request->userId);
if ($userRole!=1)
{
return json(['code' => 0, 'msg' => '企业账号不能申请']);
}
$projectData = ProjectModel::where(['id'=>$data['project_id']])->find();
if ($projectData['status']!=1)
{
......
......@@ -5,6 +5,7 @@ namespace app\api\service;
use app\model\CourseClass;
use app\model\Payment;
use think\facade\Cache;
use think\facade\Db;
class UtilService
{
......@@ -133,4 +134,9 @@ class UtilService
'order_id' => $productId
])->count();
}
public static function checkUserRole($userId = 0)
{
return Db::name('user')->where(['id' => $userId])->value('role');
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment