|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\appapi\controller\v1;
|
|
|
|
|
|
|
|
|
|
use app\appapi\ApiController;
|
|
|
|
|
@ -10,96 +11,149 @@ use app\service\Sso;
|
|
|
|
|
|
|
|
|
|
class User extends ApiController
|
|
|
|
|
{
|
|
|
|
|
public function getUserInfo(){
|
|
|
|
|
$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')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->find();
|
|
|
|
|
/*
|
|
|
|
|
* 取得用戶資料
|
|
|
|
|
*/
|
|
|
|
|
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')
|
|
|
|
|
// ->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)
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
//使用者不存在,至SSO Server取得,並加入會員資料表
|
|
|
|
|
if(!$user){
|
|
|
|
|
if (!$user) {
|
|
|
|
|
$user_data = [
|
|
|
|
|
'user_id' => $this->uid
|
|
|
|
|
];
|
|
|
|
|
$sso = Sso::getUserInfo($user_data);
|
|
|
|
|
if(!$sso['code']==200){
|
|
|
|
|
|
|
|
|
|
$sso = Sso::getUserInfo($user_data);
|
|
|
|
|
if (!$sso['code'] == 200) {
|
|
|
|
|
return $this->error('get sso user info error!!!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sso_data = $sso['data'];
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
$sso_data['level'] = 2;
|
|
|
|
|
$sso_data['status'] = 1;
|
|
|
|
|
$sso_data['overdue_time'] = strtotime(date('Y-m-d',time() + (60 * 60 * 24 * 7)));
|
|
|
|
|
$sso_data['overdue_time'] = strtotime(date('Y-m-d', time() + (60 * 60 * 24 * 7)));
|
|
|
|
|
$sso_data['cus_card'] = '';
|
|
|
|
|
$sso_data['create_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->insert($sso_data);
|
|
|
|
|
->insert($sso_data);
|
|
|
|
|
|
|
|
|
|
$user=Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
unset($sso_data);
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->error($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新預開卡狀態
|
|
|
|
|
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([]);
|
|
|
|
|
if(strlen(trim($user['uniqid']))>0){
|
|
|
|
|
$params = urlencode($aes->encrypt('verify_code='.$user['uniqid']));
|
|
|
|
|
}else{
|
|
|
|
|
$params = urlencode($aes->encrypt('user_id='.$user['user_id']));
|
|
|
|
|
if (strlen(trim($user['uniqid'])) > 0) {
|
|
|
|
|
$params = urlencode($aes->encrypt('verify_code=' . $user['uniqid']));
|
|
|
|
|
} else {
|
|
|
|
|
$params = urlencode($aes->encrypt('user_id=' . $user['user_id']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user['nfcurl'] = getUrl().'/card/?params='.$params;
|
|
|
|
|
$user['nfcurl'] = getUrl() . '/card/?params=' . $params;
|
|
|
|
|
|
|
|
|
|
// $user['level_name'] = Db::name('user_level')->where('agent_id',$user['agent_id'])->where('level_id',$user['level'])->value('name');
|
|
|
|
|
|
|
|
|
|
// $user['overdue_time'] = date('Y-m-d H:i:s',$user['overdue_time']);
|
|
|
|
|
if(time()>$user['overdue_time']){
|
|
|
|
|
if (time() > $user['overdue_time']) {
|
|
|
|
|
//更新用戶level
|
|
|
|
|
Db::name('user')->where('user_id',$this->uid)->update(['level'=>0]);
|
|
|
|
|
Db::name('user')->where('user_id', $this->uid)->update(['level' => 0]);
|
|
|
|
|
$user['level'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch($user['level']){
|
|
|
|
|
switch ($user['level']) {
|
|
|
|
|
case 0:
|
|
|
|
|
$user['level_name']='未付費用戶';
|
|
|
|
|
$user['level_name'] = '未付費用戶';
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
$user['level_name']='付費用戶';
|
|
|
|
|
$user['level_name'] = '付費用戶';
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
$user['level_name']='試用用戶';
|
|
|
|
|
$user['level_name'] = '試用用戶';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user['nc_func'] = explode(',',$user['nc_func']);
|
|
|
|
|
$user['nc_func'] = explode(',', $user['nc_func']);
|
|
|
|
|
|
|
|
|
|
$user['agent_prefix'] = Db::name('agent')->where('id',$user['agent_id'])->value('prefix');
|
|
|
|
|
$user['agent_prefix'] = Db::name('agent')->where('id', $user['agent_id'])->value('prefix');
|
|
|
|
|
|
|
|
|
|
return $this->Success($user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUserCompany(){
|
|
|
|
|
if(!$this->uid){
|
|
|
|
|
public function getUserCompany()
|
|
|
|
|
{
|
|
|
|
|
if (!$this->uid) {
|
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addUserCompany(){
|
|
|
|
|
if(!$this->uid){
|
|
|
|
|
public function addUserCompany()
|
|
|
|
|
{
|
|
|
|
|
if (!$this->uid) {
|
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -108,108 +162,107 @@ class User extends ApiController
|
|
|
|
|
unset($ucData['uid']);
|
|
|
|
|
unset($ucData['action']);
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
if(isset($ucData['is_default']) && $ucData['is_default']){
|
|
|
|
|
try {
|
|
|
|
|
if (isset($ucData['is_default']) && $ucData['is_default']) {
|
|
|
|
|
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update(['is_default'=>0]);
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update(['is_default' => 0]);
|
|
|
|
|
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => isset($ucData['uc_name'])?$ucData['uc_name']:'',
|
|
|
|
|
'title' => isset($ucData['uc_title'])?$ucData['uc_title']:'',
|
|
|
|
|
'tel' => isset($ucData['uc_tel'])?$ucData['uc_tel']:'',
|
|
|
|
|
'address' => isset($ucData['uc_address'])?$ucData['uc_address']:'',
|
|
|
|
|
'url' => isset($ucData['uc_url'])?$ucData['uc_url']:'',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => isset($ucData['uc_name']) ? $ucData['uc_name'] : '',
|
|
|
|
|
'title' => isset($ucData['uc_title']) ? $ucData['uc_title'] : '',
|
|
|
|
|
'tel' => isset($ucData['uc_tel']) ? $ucData['uc_tel'] : '',
|
|
|
|
|
'address' => isset($ucData['uc_address']) ? $ucData['uc_address'] : '',
|
|
|
|
|
'url' => isset($ucData['uc_url']) ? $ucData['uc_url'] : '',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->insert($ucData);
|
|
|
|
|
->insert($ucData);
|
|
|
|
|
|
|
|
|
|
$result = Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
print_r($e);
|
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setUCDefault(){
|
|
|
|
|
if(!$this->uid){
|
|
|
|
|
public function setUCDefault()
|
|
|
|
|
{
|
|
|
|
|
if (!$this->uid) {
|
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update(['is_default'=>0]);
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update(['is_default' => 0]);
|
|
|
|
|
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->where('id',input('id'))
|
|
|
|
|
->update(['is_default'=>1]);
|
|
|
|
|
->where('id', input('id'))
|
|
|
|
|
->update(['is_default' => 1]);
|
|
|
|
|
|
|
|
|
|
$res = Db::name('user_company')
|
|
|
|
|
->where('id',input('id'))
|
|
|
|
|
->find();
|
|
|
|
|
->where('id', input('id'))
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => $res['uc_name'],
|
|
|
|
|
'title' => $res['uc_title'],
|
|
|
|
|
'tel' => $res['uc_tel'],
|
|
|
|
|
'address' => $res['uc_address'],
|
|
|
|
|
'url' => $res['uc_url'],
|
|
|
|
|
]);
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => $res['uc_name'],
|
|
|
|
|
'title' => $res['uc_title'],
|
|
|
|
|
'tel' => $res['uc_tel'],
|
|
|
|
|
'address' => $res['uc_address'],
|
|
|
|
|
'url' => $res['uc_url'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//更新用戶資料
|
|
|
|
|
$result = Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
print_r($e);
|
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updateUserCompany(){
|
|
|
|
|
if(!$this->uid){
|
|
|
|
|
public function updateUserCompany()
|
|
|
|
|
{
|
|
|
|
|
if (!$this->uid) {
|
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
|
}
|
|
|
|
|
$ucData = input('post.');
|
|
|
|
|
unset($ucData['action']);
|
|
|
|
|
unset($ucData['uid']);
|
|
|
|
|
unset($ucData['id']);
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if(isset($ucData['is_default']) && $ucData['is_default']){
|
|
|
|
|
if (isset($ucData['is_default']) && $ucData['is_default']) {
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update(['is_default'=>0]);
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update(['is_default' => 0]);
|
|
|
|
|
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => $ucData['uc_name'],
|
|
|
|
|
'title' => $ucData['uc_title'],
|
|
|
|
|
'tel' => $ucData['uc_tel'],
|
|
|
|
|
'address' => $ucData['uc_address'],
|
|
|
|
|
'url' => $ucData['uc_url'],
|
|
|
|
|
]);
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => $ucData['uc_name'],
|
|
|
|
|
'title' => $ucData['uc_title'],
|
|
|
|
|
'tel' => $ucData['uc_tel'],
|
|
|
|
|
'address' => $ucData['uc_address'],
|
|
|
|
|
'url' => $ucData['uc_url'],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->where('id',input('id'))
|
|
|
|
|
->where('id', input('id'))
|
|
|
|
|
->update($ucData);
|
|
|
|
|
|
|
|
|
|
// $res = Db::name('user_company')
|
|
|
|
|
@ -218,80 +271,79 @@ class User extends ApiController
|
|
|
|
|
|
|
|
|
|
//更新用戶資料
|
|
|
|
|
$result = Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
print_r($e);
|
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteUserCompany(){
|
|
|
|
|
if(!$this->uid){
|
|
|
|
|
public function deleteUserCompany()
|
|
|
|
|
{
|
|
|
|
|
if (!$this->uid) {
|
|
|
|
|
$this->error('用戶ID錯誤');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
Db::name('user_company')
|
|
|
|
|
->where('id',input('id'))
|
|
|
|
|
->delete();
|
|
|
|
|
->where('id', input('id'))
|
|
|
|
|
->delete();
|
|
|
|
|
|
|
|
|
|
//更新用戶資料
|
|
|
|
|
$result = Db::name('user_company')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
if(count($result)==0){
|
|
|
|
|
if (count($result) == 0) {
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => '',
|
|
|
|
|
'title' => '',
|
|
|
|
|
'tel' => '',
|
|
|
|
|
'address' => '',
|
|
|
|
|
'url' => '',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update([
|
|
|
|
|
'company' => '',
|
|
|
|
|
'title' => '',
|
|
|
|
|
'tel' => '',
|
|
|
|
|
'address' => '',
|
|
|
|
|
'url' => '',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
return $this->success($result);
|
|
|
|
|
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->error('操作錯誤');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setUserLevel(){
|
|
|
|
|
$result=Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update(['level'=>input('level')]);
|
|
|
|
|
public function setUserLevel()
|
|
|
|
|
{
|
|
|
|
|
$result = Db::name('user')
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update(['level' => input('level')]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->Success($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setUserTpl(){
|
|
|
|
|
try{
|
|
|
|
|
$result=Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update(['nc_template'=>input('tpl')]);
|
|
|
|
|
}catch(\Excenption $e){
|
|
|
|
|
public function setUserTpl()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$result = Db::name('user')
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update(['nc_template' => input('tpl')]);
|
|
|
|
|
} catch (\Excenption $e) {
|
|
|
|
|
return $this->Error('更新失敗');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->Success($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function uploadAvatar(){
|
|
|
|
|
public function uploadAvatar()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$files = request()->file('file');
|
|
|
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile( input('user_id'), $files);
|
|
|
|
|
$files = request()->file('file');
|
|
|
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile(input('user_id'), $files);
|
|
|
|
|
|
|
|
|
|
$avatar = getUrl().'/storage/'.$savename;
|
|
|
|
|
$avatar = getUrl() . '/storage/' . $savename;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Db::name('user')
|
|
|
|
|
@ -301,101 +353,103 @@ class User extends ApiController
|
|
|
|
|
return $this->Success($avatar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updateSendCount(){
|
|
|
|
|
public function updateSendCount()
|
|
|
|
|
{
|
|
|
|
|
$user_id = input('userid');
|
|
|
|
|
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->where('user_id',input('userid'))
|
|
|
|
|
->exp('send_count', 'send_count+1')
|
|
|
|
|
->update();
|
|
|
|
|
->where('user_id', input('userid'))
|
|
|
|
|
->exp('send_count', 'send_count+1')
|
|
|
|
|
->update();
|
|
|
|
|
// ->inc('send_count',1);
|
|
|
|
|
|
|
|
|
|
return $this->Success('更新成功');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addFavorite(){
|
|
|
|
|
try{
|
|
|
|
|
public function addFavorite()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$is_exist = Db::name('user_favorite')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->where('uf_user_id',input('userid'))
|
|
|
|
|
->count();
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->where('uf_user_id', input('userid'))
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
if(!$is_exist){
|
|
|
|
|
if (!$is_exist) {
|
|
|
|
|
Db::name('user_favorite')
|
|
|
|
|
->insert(['user_id'=>$this->uid,'uf_user_id'=>input('userid')]);
|
|
|
|
|
->insert(['user_id' => $this->uid, 'uf_user_id' => input('userid')]);
|
|
|
|
|
}
|
|
|
|
|
return $this->success('操作成功');
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->error('操作失敗');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function delFavorite(){
|
|
|
|
|
try{
|
|
|
|
|
public function delFavorite()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
Db::name('user_favorite')
|
|
|
|
|
->where('id',input('id'))
|
|
|
|
|
->delete();
|
|
|
|
|
->where('id', input('id'))
|
|
|
|
|
->delete();
|
|
|
|
|
|
|
|
|
|
return $this->success('操作成功');
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->error('操作失敗');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function uploadConnections(){
|
|
|
|
|
try{
|
|
|
|
|
public function uploadConnections()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->update(['connections'=>input('uc')]);
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->update(['connections' => input('uc')]);
|
|
|
|
|
|
|
|
|
|
return $this->success('操作成功');
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
print_r($e);
|
|
|
|
|
return $this->error('操作失敗');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFavorite(){
|
|
|
|
|
try{
|
|
|
|
|
public function getFavorite()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$uf = Db::name('user_favorite')
|
|
|
|
|
->alias('uf')
|
|
|
|
|
->leftjoin('user u','uf.uf_user_id = u.user_id')
|
|
|
|
|
->field('uf.id as ufid,u.*')
|
|
|
|
|
->where('uf.user_id',$this->uid)
|
|
|
|
|
->select()
|
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
// print_r(Db::getLastSql());
|
|
|
|
|
// print_r($uf);
|
|
|
|
|
// return;
|
|
|
|
|
->alias('uf')
|
|
|
|
|
->leftjoin('user u', 'uf.uf_user_id = u.user_id')
|
|
|
|
|
->field('uf.id as ufid,u.*')
|
|
|
|
|
->where('uf.user_id', $this->uid)
|
|
|
|
|
->select()
|
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
$aes = new Aes([]);
|
|
|
|
|
|
|
|
|
|
foreach($uf as $key=>$val){
|
|
|
|
|
foreach ($uf as $key => $val) {
|
|
|
|
|
|
|
|
|
|
if(strlen($val['uniqid'])>0){
|
|
|
|
|
$params = urlencode($aes->encrypt('verify_code='.$val['uniqid']));
|
|
|
|
|
}else{
|
|
|
|
|
$params = urlencode($aes->encrypt('user_id='.$val['user_id']));
|
|
|
|
|
if (strlen($val['uniqid']) > 0) {
|
|
|
|
|
$params = urlencode($aes->encrypt('verify_code=' . $val['uniqid']));
|
|
|
|
|
} else {
|
|
|
|
|
$params = urlencode($aes->encrypt('user_id=' . $val['user_id']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$uf[$key]['nfcurl'] = getUrl().'/card/?params='.$params;
|
|
|
|
|
|
|
|
|
|
$uf[$key]['nfcurl'] = getUrl() . '/card/?params=' . $params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->success($uf);
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->error('操作失敗');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getConnections(){
|
|
|
|
|
try{
|
|
|
|
|
public function getConnections()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$result = Db::name('user')
|
|
|
|
|
->where('user_id',$this->uid)
|
|
|
|
|
->value('connections');
|
|
|
|
|
->where('user_id', $this->uid)
|
|
|
|
|
->value('connections');
|
|
|
|
|
|
|
|
|
|
return $this->success($result);
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->error('操作失敗');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|