You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
996 B
40 lines
996 B
<?php
|
|
|
|
namespace app\common;
|
|
|
|
use think\facade\Db;
|
|
use app\common\lib\Aes;
|
|
|
|
class Activation
|
|
{
|
|
//驗證slashtoken
|
|
public static function checkSlashtoken($slashtoken)
|
|
{
|
|
$aes = new Aes([]);
|
|
parse_str($aes->descrypt($slashtoken), $params);
|
|
|
|
if (!isset($params['sno'])) {
|
|
return ['code' => 404, 'msg' => '預開卡不存在'];
|
|
}
|
|
|
|
$precard = Db::name('precard')
|
|
->where('serial_no', $params['sno'])
|
|
->find();
|
|
|
|
if (!$precard) {
|
|
return ['code' => 404, 'msg' => '預開卡不存在'];
|
|
}
|
|
//檢查到期日
|
|
if ($precard['expire_time'] != 0 && $precard['expire_time'] < time()) {
|
|
return ['code' => 401, 'msg' => '預開卡已過期'];
|
|
}
|
|
|
|
//檢查是否已經開卡
|
|
if ($precard['status'] != 1) {
|
|
return ['code'=>500,'msg'=>'預開卡已使用或無效'];
|
|
}
|
|
|
|
return ['code'=>0,'data'=>$precard];
|
|
}
|
|
}
|