emoji
This commit is contained in:
parent
6eddb8a053
commit
ba998d8363
@ -1092,6 +1092,7 @@ class Emoji(object):
|
|||||||
self.fields = [
|
self.fields = [
|
||||||
['item_id', 0, 'item_id'],
|
['item_id', 0, 'item_id'],
|
||||||
['state', 0, '1:使用 0:未使用'],
|
['state', 0, '1:使用 0:未使用'],
|
||||||
|
['left_time', 0, '剩余时间'],
|
||||||
]
|
]
|
||||||
|
|
||||||
class ChipPage(object):
|
class ChipPage(object):
|
||||||
|
@ -1006,6 +1006,8 @@ CREATE TABLE `t_emoji` (
|
|||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'itemID',
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'itemID',
|
||||||
|
`last_get_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获得时间',
|
||||||
|
`valid_time` int(11) NOT NULL DEFAULT '0' COMMENT '有效时间',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
|
20
sql/gamedb2006_migrate_240722_01.sql
Normal file
20
sql/gamedb2006_migrate_240722_01.sql
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_emoji`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_emoji` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'itemID',
|
||||||
|
`last_get_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获得时间',
|
||||||
|
`valid_time` int(11) 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 `account_item_id` (`account_id`, `item_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
insert into version (version) values(2024052101);
|
||||||
|
|
||||||
|
commit;
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('services/LogService.php');
|
require_once('services/LogService.php');
|
||||||
|
require_once('services/TimingPropService.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
@ -569,6 +570,12 @@ class BaseAuthedController extends BaseController {
|
|||||||
Avatar::addAvatar($itemMeta);
|
Avatar::addAvatar($itemMeta);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case mt\Item::TIMING_PROP_TYPE:
|
||||||
|
{
|
||||||
|
$timingObj = new \services\TimingPropService();
|
||||||
|
$timingObj->handleProp($itemMeta);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
$this->_addLog('additems', 'invalid_item', array(
|
$this->_addLog('additems', 'invalid_item', array(
|
||||||
|
@ -4,38 +4,36 @@ require_once('models/Emoji.php');
|
|||||||
use models\Emoji;
|
use models\Emoji;
|
||||||
class EmojiController extends BaseAuthedController
|
class EmojiController extends BaseAuthedController
|
||||||
{
|
{
|
||||||
// public function getEmojiList(){
|
|
||||||
// $this->_rspData(array(
|
|
||||||
// 'data' => array(
|
|
||||||
// array(
|
|
||||||
// 'item_id'=>200001,
|
|
||||||
// 'state'=>1,
|
|
||||||
// )
|
|
||||||
// ),
|
|
||||||
// 'use_emoji' => array(200001)
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function getEmojiList(){
|
public function getEmojiList(){
|
||||||
$list = Emoji::emojiList();
|
$emojiList = array();
|
||||||
|
Emoji::emojiList(function ($row) use (&$emojiList){
|
||||||
|
$tDo = Emoji::toDto($row);
|
||||||
|
if ($tDo['left_time'] > 0){
|
||||||
|
array_push($emojiList,Emoji::toDto($row));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$uses = Emoji::getUseEmoji();
|
$uses = Emoji::getUseEmoji();
|
||||||
$temp = array_map(function ($val){
|
$temp = array_map(function ($val){
|
||||||
return $val['item_id'];
|
return $val['item_id'];
|
||||||
},$uses);
|
},$uses);
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($list as $val){
|
foreach ($emojiList as $val){
|
||||||
if(in_array($val, $temp)){
|
if(in_array($val['item_id'], $temp)){
|
||||||
array_push($data,
|
array_push($data,
|
||||||
array(
|
array(
|
||||||
'item_id'=>$val,
|
'item_id'=>$val['item_id'],
|
||||||
'state'=>1,
|
'state'=>1,
|
||||||
|
'left_time'=>$val['left_time'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
array_push($data,
|
array_push($data,
|
||||||
array(
|
array(
|
||||||
'item_id'=>$val,
|
'item_id'=>$val['item_id'],
|
||||||
'state'=>0,
|
'state'=>0,
|
||||||
|
'left_time'=>$val['left_time'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -49,7 +47,16 @@ class EmojiController extends BaseAuthedController
|
|||||||
public function setEmoji(){
|
public function setEmoji(){
|
||||||
$itemId = getReqVal('item_id', '');
|
$itemId = getReqVal('item_id', '');
|
||||||
$slotId = getReqVal('slot_id', 0);
|
$slotId = getReqVal('slot_id', 0);
|
||||||
if(! in_array($itemId,Emoji::emojiList())){
|
$emojiList = array();
|
||||||
|
Emoji::emojiList(function ($row) use (&$emojiList){
|
||||||
|
$tDo = Emoji::toDto($row);
|
||||||
|
if ($tDo['left_time'] > 0){
|
||||||
|
array_push($emojiList,Emoji::toDto($row));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(! in_array($itemId,array_map(function ($val){
|
||||||
|
return $val['item_id'];
|
||||||
|
},$emojiList))){
|
||||||
$this->_rspErr(1, 'item_id parameter error');
|
$this->_rspErr(1, 'item_id parameter error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,17 +72,10 @@ class EmojiController extends BaseAuthedController
|
|||||||
$this->_rspErr(1, 'The emoji has been used');
|
$this->_rspErr(1, 'The emoji has been used');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($uses){
|
foreach ($uses as &$val){
|
||||||
foreach ($uses as &$val){
|
if ($val['slot_id'] == $slotId){
|
||||||
if ($val['slot_id'] == $slotId){
|
$val['item_id'] = $itemId;
|
||||||
$val['item_id'] = $itemId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
array_push($uses,array(
|
|
||||||
'item_id' => $itemId,
|
|
||||||
"slot_id" => $slotId
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Emoji::updateEmoji( json_encode($uses));
|
Emoji::updateEmoji( json_encode($uses));
|
||||||
|
@ -10,46 +10,53 @@ class Emoji extends BaseModel
|
|||||||
private static function defaultUseEmoji(){
|
private static function defaultUseEmoji(){
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'item_id' => 200001,
|
'item_id' => 0,
|
||||||
"slot_id" => 1
|
"slot_id" => 1
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'item_id' => 200002,
|
'item_id' => 0,
|
||||||
"slot_id" => 2
|
"slot_id" => 2
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'item_id' => 200003,
|
'item_id' => 0,
|
||||||
"slot_id" => 3
|
"slot_id" => 3
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'item_id' => 200004,
|
'item_id' => 0,
|
||||||
"slot_id" => 4
|
"slot_id" => 4
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'item_id' => 200005,
|
'item_id' => 0,
|
||||||
"slot_id" => 5
|
"slot_id" => 5
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'item_id' => 200006,
|
'item_id' => 0,
|
||||||
"slot_id" => 6
|
"slot_id" => 6
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function defaultEmoji(){
|
|
||||||
$default = array();
|
|
||||||
$meta = mt\Parameter::getByName('emoji_default');
|
public static function emojiList($cb){
|
||||||
if ($meta){
|
SqlHelper::ormSelect(
|
||||||
$default = explode('|',$meta['param_value']) ;
|
myself()->_getSelfMysql(),
|
||||||
}
|
't_emoji',
|
||||||
return $default;
|
array(
|
||||||
|
'account_id'=> myself()->_getAccountId(),
|
||||||
|
),
|
||||||
|
function ($row) use($cb) {
|
||||||
|
$cb($row);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function emojiList(){
|
public static function toDto($row){
|
||||||
$data = self::DefaultEmoji();
|
return array(
|
||||||
//查询用户新获得的表情(t_emoji 表)
|
'item_id' => $row['item_id'],
|
||||||
|
// 'valid_time' => $row['valid_time'],
|
||||||
return $data;
|
'left_time' => max(0,$row['valid_time'] - (myself()->_getNowTime()-$row['last_get_time']) ),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUseEmoji(){
|
public static function getUseEmoji(){
|
||||||
@ -62,9 +69,22 @@ class Emoji extends BaseModel
|
|||||||
);
|
);
|
||||||
if ($row){
|
if ($row){
|
||||||
$useEmojiList = emptyReplace(json_decode($row['used'], true), array());
|
$useEmojiList = emptyReplace(json_decode($row['used'], true), array());
|
||||||
|
$isUpdate = 0;
|
||||||
|
foreach ($useEmojiList as &$value){
|
||||||
|
$emojiDb = self::findEmoji($value['item_id']);
|
||||||
|
if ($emojiDb){
|
||||||
|
$emojiDto = self::toDto($emojiDb);
|
||||||
|
if ($emojiDto['left_time'] == 0){
|
||||||
|
$value['item_id'] = 0;
|
||||||
|
$isUpdate = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($isUpdate){
|
||||||
|
self::updateEmoji(json_encode($useEmojiList));
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$useEmojiList= self::defaultUseEmoji();
|
$useEmojiList = self::defaultUseEmoji();
|
||||||
self::updateEmoji(json_encode($useEmojiList));
|
|
||||||
}
|
}
|
||||||
return $useEmojiList;
|
return $useEmojiList;
|
||||||
}
|
}
|
||||||
@ -89,4 +109,48 @@ class Emoji extends BaseModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function findEmoji($itemId){
|
||||||
|
return SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_emoji',
|
||||||
|
array(
|
||||||
|
'account_id'=> myself()->_getAccountId(),
|
||||||
|
'item_id'=> $itemId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addEmoji($itemMeta,$time){
|
||||||
|
$row = self::findEmoji($itemMeta['id']);
|
||||||
|
if ($row){
|
||||||
|
$leftTime = max(0,$row['valid_time'] - (myself()->_getNowTime()-$row['last_get_time']) );
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_emoji',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'item_id' => $itemMeta['id'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'last_get_time' => myself()->_getNowTime(),
|
||||||
|
'valid_time' => $leftTime + $time * 86400,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_emoji',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'item_id' => $itemMeta['id'],
|
||||||
|
'last_get_time' => myself()->_getNowTime(),
|
||||||
|
'valid_time' => $time * 86400,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -111,6 +111,7 @@ class Item {
|
|||||||
const TREASURE_BOX = 30;
|
const TREASURE_BOX = 30;
|
||||||
const GOLD_SYN = 31;
|
const GOLD_SYN = 31;
|
||||||
const BATTLE_REWARD_BOX = 32;
|
const BATTLE_REWARD_BOX = 32;
|
||||||
|
const TIMING_PROP_TYPE = 33;
|
||||||
|
|
||||||
const FUNC_RENAME_CARD_SUBTYPE = 1;
|
const FUNC_RENAME_CARD_SUBTYPE = 1;
|
||||||
const FUNC_GUILD_CARD_SUBTYPE = 3;
|
const FUNC_GUILD_CARD_SUBTYPE = 3;
|
||||||
|
29
webapp/services/TimingPropService.php
Normal file
29
webapp/services/TimingPropService.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
require_once('models/Emoji.php');
|
||||||
|
|
||||||
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
|
use models\Emoji;
|
||||||
|
use mt\Item;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class TimingPropService extends BaseService
|
||||||
|
{
|
||||||
|
const EMOJI_SUB_TYPE = 1;
|
||||||
|
public function handleProp($itemMeta){
|
||||||
|
if ($itemMeta['type'] != Item::TIMING_PROP_TYPE){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch ($itemMeta['sub_type']){
|
||||||
|
case self::EMOJI_SUB_TYPE :{
|
||||||
|
$emojiMeta = Item::get($itemMeta['relationship']);
|
||||||
|
if ($emojiMeta['type'] == Item::EMOJI_TYPE){
|
||||||
|
Emoji::addEmoji($emojiMeta , $itemMeta['Item_duration']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user