141 lines
3.7 KiB
PHP
141 lines
3.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace models;
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
class UserInvitationCode extends BaseModel
|
|
{
|
|
public static function findMyCode(){
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_user_invitation_code',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
)
|
|
);
|
|
return $row;
|
|
}
|
|
|
|
public static function findCodeByAccount($account){
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getMysql(''),
|
|
't_user_invitation_code',
|
|
array(
|
|
'account_id' => $account,
|
|
)
|
|
);
|
|
return $row;
|
|
}
|
|
|
|
public static function generateCode(){
|
|
$user = myself()->_getOrmUserInfo();
|
|
SqlHelper::upsert(
|
|
myself()->_getMysql(''),
|
|
't_user_invitation_code',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'invitation_code' =>$user['idx'],
|
|
'createtime' =>myself()->_getNowTime(),
|
|
'modifytime' =>myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function getMyCodeBindCount($code){
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getMysql(''),
|
|
't_user_invitation_code_bind',
|
|
array(
|
|
'invitation_code' => $code,
|
|
)
|
|
);
|
|
return $rows ? count($rows) : 0;
|
|
}
|
|
|
|
public static function verifyCode($code){
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_user_invitation_code',
|
|
array(
|
|
'invitation_code' => $code,
|
|
)
|
|
);
|
|
if ($row){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static function verifyAccountBind(){
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_user_invitation_code_bind',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
)
|
|
);
|
|
if ($row){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static function verifyAccountReward(){
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_user_invitation_code_bind',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
)
|
|
);
|
|
if ($row && $row['reward_state'] > 0){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static function addInvitationCodeBind($code){
|
|
SqlHelper::upsert(
|
|
myself()->_getSelfMysql(),
|
|
't_user_invitation_code_bind',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'invitation_code' =>$code,
|
|
'reward_state' =>0,
|
|
'createtime' =>myself()->_getNowTime(),
|
|
'modifytime' =>myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function updateRewardState(){
|
|
SqlHelper::update(
|
|
myself()->_getSelfMysql(),
|
|
't_user_invitation_code_bind',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
'reward_state' =>1,
|
|
'modifytime' =>myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
}
|