优化代码逻辑
This commit is contained in:
parent
479631d244
commit
4a78ad9041
@ -325,7 +325,7 @@ class Teacher extends Backend
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
// $count += $item->delete();
|
$count += $item->delete();
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (PDOException|Exception $e) {
|
} catch (PDOException|Exception $e) {
|
||||||
|
@ -47,6 +47,9 @@ class User extends Api
|
|||||||
*/
|
*/
|
||||||
public function activityMiniLogin()
|
public function activityMiniLogin()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//进入日志
|
||||||
|
// file_put_contents(LOG_PATH."activityMiniLogin.log",date("Y-m-d H:i:s")." ".json_encode($this->request->post())."\n");
|
||||||
$token = $this->request->post('token');
|
$token = $this->request->post('token');
|
||||||
$time = $this->request->post('time');
|
$time = $this->request->post('time');
|
||||||
$encryption_data = $this->request->post('encryption_data');
|
$encryption_data = $this->request->post('encryption_data');
|
||||||
@ -67,13 +70,19 @@ class User extends Api
|
|||||||
$decrypted = json_decode($decrypted, true);
|
$decrypted = json_decode($decrypted, true);
|
||||||
$token = $decrypted['token'];
|
$token = $decrypted['token'];
|
||||||
$time = $decrypted['time'];
|
$time = $decrypted['time'];
|
||||||
|
// $this->error("登录授权超时!".$token);
|
||||||
//时间超2分钟则失效
|
//时间超2分钟则失效
|
||||||
if(time() - $time > 120){
|
if(time() - $time > 1200){
|
||||||
$this->error("登录授权超时!");
|
$this->error("登录授权超时!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = \app\common\model\User::loginByActivityToken($token,true);
|
try {
|
||||||
|
$user = \app\common\model\User::loginByActivityToken($token,true);
|
||||||
|
}catch (\Exception $e){
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// var_dump($user);
|
// var_dump($user);
|
||||||
if ($user->status != 'normal') {
|
if ($user->status != 'normal') {
|
||||||
$this->error(__('Account is locked'));
|
$this->error(__('Account is locked'));
|
||||||
|
@ -28,7 +28,7 @@ class Pay extends Base
|
|||||||
|
|
||||||
$this->model = new OrderModel;
|
$this->model = new OrderModel;
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->setUrlLock();
|
|
||||||
//判断登录用户是否是员工
|
//判断登录用户是否是员工
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +48,9 @@ class Pay extends Base
|
|||||||
*/
|
*/
|
||||||
public function payment()
|
public function payment()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$this->setUrlLock();
|
||||||
|
|
||||||
$order_no = $this->request->post('order_no/s');
|
$order_no = $this->request->post('order_no/s');
|
||||||
$type = $this->request->post('type/s');
|
$type = $this->request->post('type/s');
|
||||||
$method = $this->request->post('platform/s');
|
$method = $this->request->post('platform/s');
|
||||||
|
@ -29,7 +29,7 @@ class Pay extends Base
|
|||||||
|
|
||||||
$this->model = new OrderModel;
|
$this->model = new OrderModel;
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->setUrlLock();
|
|
||||||
//判断登录用户是否是员工
|
//判断登录用户是否是员工
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +48,9 @@ class Pay extends Base
|
|||||||
*/
|
*/
|
||||||
public function payment()
|
public function payment()
|
||||||
{
|
{
|
||||||
|
$this->setUrlLock();
|
||||||
|
|
||||||
|
|
||||||
$order_no = $this->request->post('order_no/s');
|
$order_no = $this->request->post('order_no/s');
|
||||||
$type = $this->request->post('type/s');
|
$type = $this->request->post('type/s');
|
||||||
$method = $this->request->post('platform/s');
|
$method = $this->request->post('platform/s');
|
||||||
|
@ -456,6 +456,8 @@ class User extends BaseModel
|
|||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
$result = json_decode($result,true);
|
$result = json_decode($result,true);
|
||||||
|
// var_dump($result);die;
|
||||||
|
|
||||||
if($result['code']==1){
|
if($result['code']==1){
|
||||||
$data = $result['data'];
|
$data = $result['data'];
|
||||||
$data['token'] = $data;
|
$data['token'] = $data;
|
||||||
@ -474,7 +476,7 @@ class User extends BaseModel
|
|||||||
|
|
||||||
//用token换取用户信息
|
//用token换取用户信息
|
||||||
$user_info = self::getUserInfoByActivityToken($token);
|
$user_info = self::getUserInfoByActivityToken($token);
|
||||||
if(!$user_info) throw new \Exception("登录失败!");
|
if(!$user_info) throw new \Exception("登录失败11!");
|
||||||
|
|
||||||
if($trans){
|
if($trans){
|
||||||
self::beginTrans();
|
self::beginTrans();
|
||||||
@ -485,7 +487,7 @@ class User extends BaseModel
|
|||||||
|
|
||||||
$user = self::where("mobile",$user_info["mobile"])->find();
|
$user = self::where("mobile",$user_info["mobile"])->find();
|
||||||
//检测更新教练下单学员账号创建状态 2022/8/27 new
|
//检测更新教练下单学员账号创建状态 2022/8/27 new
|
||||||
if(!$user)$user = (new self)->addUserByMobile($user_info["mobile"],$user_info["nickname"]);
|
if(!$user)$user = (new self)->addUserByMobile($user_info["mobile"],$user_info["nickname"],false);
|
||||||
// $user['nickname'] = $people_name;
|
// $user['nickname'] = $people_name;
|
||||||
// $user->save();
|
// $user->save();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user