This commit is contained in:
aozhiwei 2024-07-09 20:08:07 +08:00
parent 05812d7725
commit c8fc15f587
2 changed files with 174 additions and 0 deletions

View File

@ -1849,3 +1849,21 @@ CREATE TABLE `t_test_punish070901` (
UNIQUE KEY `idx_account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t_gold_bullion_return`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_gold_bullion_return` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
`net_id` int(11) NOT NULL DEFAULT '0' COMMENT '链id',
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
`gold` bigint NOT NULL DEFAULT '0' COMMENT '金币',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `idx_token_id` (`token_id`),
UNIQUE KEY `idx_token_id_net_id` (`token_id`, `net_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -717,4 +717,160 @@ EOD;
);
}
public function returnGoldBullion()
{
$gameDbConn = myself()->_getMysql('');
$data = file_get_contents('php://input');
$array = explode("\r\n", $data);
foreach ($array as $accountId) {
$rows = SqlHelper::ormSelect(
$gameDbConn,
't_gold_bullion',
array(
'src_account_id' => $accountId
)
);
foreach ($rows as $row) {
if (!$this->isReturnEd($row)) {
$this->doReturn($gameDbConn, $row);
}
}
}
echo 'ok';
}
private function isReturnEd($row)
{
if ($row['activated']) {
return true;
}
if ($row['status']) {
return true;
}
if ($row['returned']) {
return true;
}
if ($row['open_status']) {
return true;
}
if ($row['createtime'] > (myself()->_getNowTime() - 3600 * 25)) {
return true;
}
return false;
}
private function doReturn($gameDbConn, $row)
{
echo json_encode($row);
return;
{
$row = SqlHelper::ormSelectOne(
$gameDbConn,
't_gold_bullion_return',
array(
'account_id' => $row['src_account_id'],
)
);
if (!empty($row)) {
return;
}
}
{
SqlHelper::upsert(
$gameDbConn,
't_gold_bullion_return',
array(
'account_id' => $row['src_account_id'],
),
array(),
array(
'account_id' => $row['src_account_id'],
'token_id' => $row['token_id'],
'net_id' => $row['net_id'],
'item_id' => $row['item_id'],
'gold' => $row['gold'],
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
{
SqlHelper::update(
$gameDbConn,
't_gold_bullion',
array(
'idx' => $row['idx'],
),
array(
'return_status' => 1,
'returned' => 1,
'return_time' => myself()->_getNowTime(),
)
);
}
{
$itemNum = $row['gold'];
if ($itemNum < 0) {
return;
}
SqlHelper::update(
$gameDbConn,
't_user',
array(
'account_id' => $row['src_account_id'],
),
array(
'gold' => function () use($itemNum) {
return "gold + ${itemNum}";
},
)
);
}
$this->sendReturnMail($row['src_account_id'], $row['token_id'], $row['gold']);
{
SqlHelper::update(
$gameDbConn,
't_gold_bullion',
array(
'idx' => $row['idx'],
),
array(
'return_status' => 2,
)
);
}
}
private function sendReturnMail($to, $tokenId, $itemNum)
{
$unikey = 'gold_return:' . $to . ":" . $tokenId;
SqlHelper::upsert
(myself()->_getMailMysql(),
't_sys_mail',
array(
'unikey' => $unikey
),
array(
),
array(
'unikey' => $unikey,
'subject' => 'reward',
'content' => 'We regret to inform you that the minting of your Gold Card has failed. The gold has been refunded to your account. Please check your balance to confirm the refund.',
'recipients' => json_encode(array(
$to
)),
'attachments' => json_encode(array(
)),
'tag1' => 1,
'tag2' => 3,
'sendtime' => myself()->_getNowTime(),
'expiretime' => myself()->_getNowTime() + 3600 * 24 * 365 * 20,
'user_reg_start_time' => 0,
'user_reg_end_time' => myself()->_getNowTime() + 3600 * 24 * 365 * 10,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}