diff --git a/webapp/models/GoldBullion.php b/webapp/models/GoldBullion.php index 1cbc530c..a3caa176 100644 --- a/webapp/models/GoldBullion.php +++ b/webapp/models/GoldBullion.php @@ -4,6 +4,7 @@ namespace models; require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); +require_once('services/MailApiService.php'); class GoldBullion extends BaseModel { @@ -80,9 +81,15 @@ class GoldBullion extends BaseModel { '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); } } diff --git a/webapp/services/MailApiService.php b/webapp/services/MailApiService.php index 43238b63..923abd57 100644 --- a/webapp/services/MailApiService.php +++ b/webapp/services/MailApiService.php @@ -8,6 +8,7 @@ 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'; /* @@ -98,6 +99,44 @@ class MailApiService extends BaseService { ); } + /* + netId: netId + tokenId:tokenid + 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)) {