This commit is contained in:
aozhiwei 2024-06-26 14:00:57 +08:00
parent c369ef48cf
commit 4b6d3498e6
4 changed files with 0 additions and 160 deletions

View File

@ -3,7 +3,6 @@ use phpcommon\SqlHelper;
require_once('models/Nft.php');
require_once('models/User.php');
require_once('models/Hero.php');
require_once('models/GoldBullion.php');
require_once('mt/NftDesc.php');
require_once('mt/Hero.php');
require_once('mt/EconomyAttribute.php');
@ -11,7 +10,6 @@ require_once('mt/EconomyAttribute.php');
use models\Nft;
use models\User;
use models\Hero;
use models\GoldBullion;
class OutAppNftController extends BaseController {

View File

@ -1,114 +0,0 @@
<?php
namespace models;
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
require_once('services/MailApiService.php');
class GoldBullion extends BaseModel {
const OPEN_STATUS_SENT = 1;
const OPEN_STATUS_PENDING = 2;
const OPEN_STATUS_SEND_BEGIN = 3;
const OPEN_STATUS_SEND_END = 4;
public static function onLogin()
{
$address = myself()->_getAddress();
if (empty($address)) {
return;
}
$rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_gold_bullion',
array(
'open_address' => myself()->_getAddress(),
'open_status' => self::OPEN_STATUS_PENDING,
'returned' => 0,
)
);
if (count($rows) > 0) {
$confirmedRows = array();
foreach ($rows as $row) {
$uniqId = self::genUniqId();
SqlHelper::update(
myself()->_getSelfMysql(),
't_gold_bullion',
array(
'idx' => $row['idx'],
'open_status' => self::OPEN_STATUS_PENDING
),
array(
'open_status' => self::OPEN_STATUS_SEND_BEGIN,
'open_uniqid' => $uniqId
)
);
$newRow = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_gold_bullion',
array(
'idx' => $row['idx'],
)
);
if (!empty($newRow) && $newRow['open_uniqid'] == $uniqId) {
array_push($confirmedRows, $row);
}
self::doSendAward($confirmedRows);
}
}
}
public static function doSendAward($confirmedRows)
{
$propertyChgService = new services\PropertyChgService();
$awardService = new services\AwardService();
if (empty($confirmedRows)) {
return;
}
foreach ($confirmedRows as $row) {
$items = array(
array(
'item_id' => V_ITEM_GOLD,
'item_num' => $row['gold']
)
);
myself()->_addItems($items, $awardService, $propertyChgService);
SqlHelper::update(
myself()->_getSelfMysql(),
't_gold_bullion',
array(
'idx' => $row['idx'],
),
array(
'account_id' => myself()->_getAccountId(),
'open_status' => self::OPEN_STATUS_SEND_END,
)
);
$content = "[Item Name] has been used successfully, you have received 100,000 gold";
services\MailApiService::sendOpenGold($row['net_id'],
$row['token_id'],
'',
$content);
}
}
public static function findByTokenId($tokenId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_gold_bullion',
array(
'token_id' => $tokenId,
)
);
return $row;
}
private static function genUniqId()
{
$uniqId = uniqid(md5(rand() . rand() . rand() . myself()->_getSessionId()), true);
return $uniqId;
}
}

View File

@ -2,15 +2,10 @@
namespace services;
require_once('models/GoldBullion.php');
use models\GoldBullion;
class LoginService extends BaseService {
public function onLogon()
{
GoldBullion::onLogin();
}
}

View File

@ -8,7 +8,6 @@ class MailApiService extends BaseService {
const SELL_UNIKEY_PRE = 'ingame.market.sell:';
const BUY_UNIKEY_PRE = 'ingame.market.buy:';
const OPEN_GOLD_BULLION_UNIKEY_PRE = 'gold_bullion:open:';
const SELL_MAIL_SUBJECT = 'Item successfully sold';
/*
@ -99,44 +98,6 @@ class MailApiService extends BaseService {
);
}
/*
netId: netId
tokenIdtokenid
to邮件接受方account_id
subject: 邮件标题
content: 邮件正文
*/
public function sendOpenGold($netId, $tokenId, $subject, $content)
{
$unikey = self::OPEN_GOLD_BULLION_UNIKEY_PRE . $netId . '_' . $tokenId;
SqlHelper::upsert
(myself()->_getMailMysql(),
't_sys_mail',
array(
'unikey' => $unikey
),
array(
),
array(
'unikey' => $unikey,
'subject' => $subject,
'content' => $content,
'recipients' => json_encode(array(
$to
)),
'attachments' => json_encode(array()),
'tag1' => 1,
'tag2' => 3,
'sendtime' => myself()->_getNowTime(),
'expiretime' => myself()->_getNowTime() + 3600 * 24 * 365 * 10,
'user_reg_start_time' => 0,
'user_reg_end_time' => myself()->_getNowTime() + 3600 * 24 * 365 * 10,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
private function adjustAttachments(&$attachments)
{
if (empty($attachments)) {