|
|
|
@ -1,4 +1,5 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace app\appapi\controller\v1;
|
|
|
|
namespace app\appapi\controller\v1;
|
|
|
|
|
|
|
|
|
|
|
|
use app\appapi\ApiController;
|
|
|
|
use app\appapi\ApiController;
|
|
|
|
@ -10,7 +11,26 @@ use app\service\Sso;
|
|
|
|
|
|
|
|
|
|
|
|
class User extends ApiController
|
|
|
|
class User extends ApiController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public function getUserInfo(){
|
|
|
|
/*
|
|
|
|
|
|
|
|
* 取得用戶資料
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getUserInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//檢查是否有serail_no
|
|
|
|
|
|
|
|
$slashToken = urldecode(input('slashToken'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$precardData = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($slashToken)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rtn = \app\common\Activation::checkSlashtoken($slashToken);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($rtn['code'] > 0) {
|
|
|
|
|
|
|
|
return $this->error($rtn['msg'], $rtn['code']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$precardData = $rtn['data'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$user = Db::name('user')
|
|
|
|
$user = Db::name('user')
|
|
|
|
// ->field('id,user_id,address,avatar,phone,email,url,facebook,ig,youtube,mark,uniqid,overdue_time,level,nc_func,agent_id,real_name,nfc_addon,company')
|
|
|
|
// ->field('id,user_id,address,avatar,phone,email,url,facebook,ig,youtube,mark,uniqid,overdue_time,level,nc_func,agent_id,real_name,nfc_addon,company')
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
@ -21,6 +41,7 @@ class User extends ApiController
|
|
|
|
$user_data = [
|
|
|
|
$user_data = [
|
|
|
|
'user_id' => $this->uid
|
|
|
|
'user_id' => $this->uid
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$sso = Sso::getUserInfo($user_data);
|
|
|
|
$sso = Sso::getUserInfo($user_data);
|
|
|
|
if (!$sso['code'] == 200) {
|
|
|
|
if (!$sso['code'] == 200) {
|
|
|
|
return $this->error('get sso user info error!!!');
|
|
|
|
return $this->error('get sso user info error!!!');
|
|
|
|
@ -37,9 +58,6 @@ class User extends ApiController
|
|
|
|
Db::name('user')
|
|
|
|
Db::name('user')
|
|
|
|
->insert($sso_data);
|
|
|
|
->insert($sso_data);
|
|
|
|
|
|
|
|
|
|
|
|
$user=Db::name('user')
|
|
|
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unset($sso_data);
|
|
|
|
unset($sso_data);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
@ -47,6 +65,40 @@ class User extends ApiController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新預開卡狀態
|
|
|
|
|
|
|
|
if($precardData){
|
|
|
|
|
|
|
|
//更新卡號,會員編號連結
|
|
|
|
|
|
|
|
Db::name('user_sno')
|
|
|
|
|
|
|
|
->insert([
|
|
|
|
|
|
|
|
'user_id'=>$this->uid,
|
|
|
|
|
|
|
|
'serial_no'=>$precardData['serial_no'],
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新用戶資料
|
|
|
|
|
|
|
|
if($precardData['days']>0){
|
|
|
|
|
|
|
|
Db::name('user')
|
|
|
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
|
|
|
->update(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'level' => 1,
|
|
|
|
|
|
|
|
'overdue_time' => Db::raw('overdue_time + '.(60 * 60 * 24 * $precardData['days']))
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新預開卡狀態
|
|
|
|
|
|
|
|
Db::name('precard')
|
|
|
|
|
|
|
|
->where('serial_no', $precardData['serial_no'])
|
|
|
|
|
|
|
|
->update([
|
|
|
|
|
|
|
|
'status'=>2,
|
|
|
|
|
|
|
|
'user_id'=>$this->uid
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$user = Db::name('user')
|
|
|
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
|
|
$aes = new Aes([]);
|
|
|
|
$aes = new Aes([]);
|
|
|
|
if (strlen(trim($user['uniqid'])) > 0) {
|
|
|
|
if (strlen(trim($user['uniqid'])) > 0) {
|
|
|
|
$params = urlencode($aes->encrypt('verify_code=' . $user['uniqid']));
|
|
|
|
$params = urlencode($aes->encrypt('verify_code=' . $user['uniqid']));
|
|
|
|
@ -86,7 +138,8 @@ class User extends ApiController
|
|
|
|
return $this->Success($user);
|
|
|
|
return $this->Success($user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getUserCompany(){
|
|
|
|
public function getUserCompany()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!$this->uid) {
|
|
|
|
if (!$this->uid) {
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -98,7 +151,8 @@ class User extends ApiController
|
|
|
|
return $this->success($result);
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function addUserCompany(){
|
|
|
|
public function addUserCompany()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!$this->uid) {
|
|
|
|
if (!$this->uid) {
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -124,7 +178,6 @@ class User extends ApiController
|
|
|
|
'address' => isset($ucData['uc_address']) ? $ucData['uc_address'] : '',
|
|
|
|
'address' => isset($ucData['uc_address']) ? $ucData['uc_address'] : '',
|
|
|
|
'url' => isset($ucData['uc_url']) ? $ucData['uc_url'] : '',
|
|
|
|
'url' => isset($ucData['uc_url']) ? $ucData['uc_url'] : '',
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Db::name('user_company')
|
|
|
|
Db::name('user_company')
|
|
|
|
->insert($ucData);
|
|
|
|
->insert($ucData);
|
|
|
|
@ -134,14 +187,14 @@ class User extends ApiController
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
print_r($e);
|
|
|
|
print_r($e);
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setUCDefault(){
|
|
|
|
public function setUCDefault()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!$this->uid) {
|
|
|
|
if (!$this->uid) {
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -175,14 +228,14 @@ class User extends ApiController
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
print_r($e);
|
|
|
|
print_r($e);
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function updateUserCompany(){
|
|
|
|
public function updateUserCompany()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!$this->uid) {
|
|
|
|
if (!$this->uid) {
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -222,14 +275,14 @@ class User extends ApiController
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
print_r($e);
|
|
|
|
print_r($e);
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function deleteUserCompany(){
|
|
|
|
public function deleteUserCompany()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!$this->uid) {
|
|
|
|
if (!$this->uid) {
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -254,18 +307,15 @@ class User extends ApiController
|
|
|
|
'address' => '',
|
|
|
|
'address' => '',
|
|
|
|
'url' => '',
|
|
|
|
'url' => '',
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($result);
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setUserLevel(){
|
|
|
|
public function setUserLevel()
|
|
|
|
|
|
|
|
{
|
|
|
|
$result = Db::name('user')
|
|
|
|
$result = Db::name('user')
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->update(['level' => input('level')]);
|
|
|
|
->update(['level' => input('level')]);
|
|
|
|
@ -274,7 +324,8 @@ class User extends ApiController
|
|
|
|
return $this->Success($result);
|
|
|
|
return $this->Success($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setUserTpl(){
|
|
|
|
public function setUserTpl()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$result = Db::name('user')
|
|
|
|
$result = Db::name('user')
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
@ -286,7 +337,8 @@ class User extends ApiController
|
|
|
|
return $this->Success($result);
|
|
|
|
return $this->Success($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function uploadAvatar(){
|
|
|
|
public function uploadAvatar()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$files = request()->file('file');
|
|
|
|
$files = request()->file('file');
|
|
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile(input('user_id'), $files);
|
|
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile(input('user_id'), $files);
|
|
|
|
@ -301,7 +353,8 @@ class User extends ApiController
|
|
|
|
return $this->Success($avatar);
|
|
|
|
return $this->Success($avatar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function updateSendCount(){
|
|
|
|
public function updateSendCount()
|
|
|
|
|
|
|
|
{
|
|
|
|
$user_id = input('userid');
|
|
|
|
$user_id = input('userid');
|
|
|
|
|
|
|
|
|
|
|
|
Db::name('user')
|
|
|
|
Db::name('user')
|
|
|
|
@ -313,7 +366,8 @@ class User extends ApiController
|
|
|
|
return $this->Success('更新成功');
|
|
|
|
return $this->Success('更新成功');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function addFavorite(){
|
|
|
|
public function addFavorite()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$is_exist = Db::name('user_favorite')
|
|
|
|
$is_exist = Db::name('user_favorite')
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
@ -330,7 +384,8 @@ class User extends ApiController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function delFavorite(){
|
|
|
|
public function delFavorite()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Db::name('user_favorite')
|
|
|
|
Db::name('user_favorite')
|
|
|
|
->where('id', input('id'))
|
|
|
|
->where('id', input('id'))
|
|
|
|
@ -342,7 +397,8 @@ class User extends ApiController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function uploadConnections(){
|
|
|
|
public function uploadConnections()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Db::name('user')
|
|
|
|
Db::name('user')
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
@ -355,7 +411,8 @@ class User extends ApiController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getFavorite(){
|
|
|
|
public function getFavorite()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$uf = Db::name('user_favorite')
|
|
|
|
$uf = Db::name('user_favorite')
|
|
|
|
->alias('uf')
|
|
|
|
->alias('uf')
|
|
|
|
@ -365,9 +422,6 @@ class User extends ApiController
|
|
|
|
->select()
|
|
|
|
->select()
|
|
|
|
->toArray();
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
|
|
// print_r(Db::getLastSql());
|
|
|
|
|
|
|
|
// print_r($uf);
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
$aes = new Aes([]);
|
|
|
|
$aes = new Aes([]);
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($uf as $key => $val) {
|
|
|
|
foreach ($uf as $key => $val) {
|
|
|
|
@ -379,7 +433,6 @@ class User extends ApiController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$uf[$key]['nfcurl'] = getUrl() . '/card/?params=' . $params;
|
|
|
|
$uf[$key]['nfcurl'] = getUrl() . '/card/?params=' . $params;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->success($uf);
|
|
|
|
return $this->success($uf);
|
|
|
|
@ -388,7 +441,8 @@ class User extends ApiController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getConnections(){
|
|
|
|
public function getConnections()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$result = Db::name('user')
|
|
|
|
$result = Db::name('user')
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|