Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb
This commit is contained in:
commit
505f542488
@ -377,4 +377,62 @@ class AAMarket(object):
|
||||
['!rows', [_common.ChainActivity()], '数据'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'GET',
|
||||
'name': '/api/recharge/goods',
|
||||
'desc': '充值-商品列表',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/recharge/goods',
|
||||
'is_json_params': False,
|
||||
'request_params': [
|
||||
],
|
||||
'params': [
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!rows', [_common.RechargeGoods()], '数据'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/recharge/buy',
|
||||
'desc': '充值-购买',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/recharge/buy',
|
||||
'headers': _common.JwtHeader,
|
||||
'is_json_params': True,
|
||||
'request_params': [
|
||||
],
|
||||
'params': [
|
||||
['net_id', 0, '链id'],
|
||||
['goods_id', '', '商品id'],
|
||||
['account_address', '', '钱包地址(一般为小狐狸)'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!calls', [
|
||||
['trans_id', '', '事务id'],
|
||||
['trans_req', _common.MFTransactionRequest(), '调用合约参数'],
|
||||
], '合约调用']
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/recharge/history',
|
||||
'desc': '充值-历史',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/recharge/history',
|
||||
'headers': _common.JwtHeader,
|
||||
'is_json_params': True,
|
||||
'request_params': [
|
||||
],
|
||||
'params': [
|
||||
['net_id', 0, '链id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['page', _common.StreamPage(), '分页信息'],
|
||||
['!rows', [_common.RechargeHistory()], '数据'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -5,21 +5,37 @@ class HashRate(object):
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'info',
|
||||
'name': 'taskList',
|
||||
'desc': '获取算力信息',
|
||||
'group': 'HashRate',
|
||||
'url': 'webapp/index.php?c=HashRate&a=info',
|
||||
'url': 'webapp/index.php?c=HashRate&a=taskList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['type', 0, '1:战斗任务 2:英雄任务 3:行为任务 4:充值消费任务'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!list', [HashRateList()], '行为列表'],
|
||||
['!task_list1', [HashRateList()], '任务列表1'],
|
||||
['!task_list2', [HashRateList()], '任务列表2'],
|
||||
['obtain_start_time', 0, '获得期开始时间'],
|
||||
['obtain_end_time', 0, '获得期结束时间'],
|
||||
['income_end_time', 0, '盈利期结束时间'],
|
||||
['state', 0, '0:未开始 1:获得期 2:盈利期'],
|
||||
['myHashRate', 0, '我的算力'],
|
||||
['refresh_times', 0, '今日刷新次数'],
|
||||
]
|
||||
},{
|
||||
'name': 'commitTask',
|
||||
'desc': '获取算力信息',
|
||||
'group': 'HashRate',
|
||||
'url': 'webapp/index.php?c=HashRate&a=commitTask',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['task_id', 0, '任务id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!award', [_common.AwardItem()], '奖励'],
|
||||
]
|
||||
},
|
||||
]
|
||||
@ -32,5 +48,5 @@ class HashRateList(object):
|
||||
['task_id', 0, '任务id'],
|
||||
['current', 0, '当前进度'],
|
||||
['target', 0, '目标进度'],
|
||||
['state', 0, '1:完成 0:未完成'],
|
||||
['state', 0, '2:完成(已领取) 1:完成(未领取) 0:未完成'],
|
||||
]
|
@ -1114,6 +1114,7 @@ class ChipPageSlot(object):
|
||||
['state', 0, '0:未解锁 1:已解锁'],
|
||||
['chip_id', '', '芯片唯一id'],
|
||||
['item_id', '', '芯片itemId'],
|
||||
['quality', '', '芯片品阶'],
|
||||
]
|
||||
|
||||
class HeroPreset(object):
|
||||
@ -1828,5 +1829,19 @@ class RechargeGoods(object):
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['goods_id', '', '商品id(购买时用)'],
|
||||
['goods_meta', '', '配置表信息(和excel完全一样)'],
|
||||
['diamond', 0, '充值所得钻石'],
|
||||
['currency', '', '货币地址'],
|
||||
['price', '', '价格'],
|
||||
]
|
||||
|
||||
class RechargeHistory(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['order_id', '', '订单id'],
|
||||
['txhash', '', 'txhash'],
|
||||
['net_id', 0, '链id'],
|
||||
['currency', '', '货币地址'],
|
||||
['amount', '', '货币数'],
|
||||
['createtime', 0, '成交时间'],
|
||||
]
|
||||
|
@ -1697,13 +1697,30 @@ CREATE TABLE `t_hash_rate` (
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`task_id` int(11) NOT NULL COMMENT '配置表id',
|
||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
||||
`reward` int(64) 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_period_task_id` (`account_id`,`period`, `task_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_hash_rate_reward`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_hash_rate_reward`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_hash_rate_reward` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
||||
`reward` int(64) 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_period` (`account_id`,`period`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_hash_rate_battle_data`
|
||||
--
|
||||
|
@ -15,6 +15,34 @@ CREATE TABLE `t_emoji` (
|
||||
UNIQUE KEY `account_item_id` (`account_id`, `item_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
DROP TABLE IF EXISTS `t_hash_rate`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_hash_rate` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`task_id` int(11) NOT NULL COMMENT '配置表id',
|
||||
`period` 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_period_task_id` (`account_id`,`period`, `task_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
DROP TABLE IF EXISTS `t_hash_rate_reward`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_hash_rate_reward` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
||||
`reward` int(64) 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_period` (`account_id`,`period`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
insert into version (version) values(2024052101);
|
||||
|
||||
commit;
|
||||
|
@ -88,6 +88,7 @@ define('TN_HASH_RATE_SYN_CHIP_TIMES', 50004);
|
||||
define('TN_HASH_RATE_SYN_SKIN_TIMES', 50005);
|
||||
define('TN_HASH_RATE_UP_HERO_TIMES', 50006);
|
||||
define('TN_HASH_RATE_UP_CHIP_TIMES', 50007);
|
||||
define('TN_HASH_DAILY_REFRESH_TIMES', 50008);
|
||||
|
||||
define('SHOP_BUY_MODE_NORMAL', 0);
|
||||
define('SHOP_BUY_MODE_DAILY_SELECTION', 1);
|
||||
|
@ -276,14 +276,14 @@ class BaseController {
|
||||
return $channel == "0000";
|
||||
}
|
||||
|
||||
public function callService($serviceName, $funcName)
|
||||
public function _callServiceStatic($serviceName, $funcName, ...$args)
|
||||
{
|
||||
if (!array_key_exists($serviceName, $this->serviceHash)) {
|
||||
require_once('services/' . $serviceName . '.php');
|
||||
$this->serviceHash[$serviceName] = $this->_getNowTime();
|
||||
}
|
||||
$method = new ReflectionMethod($serviceName . 'Service', $funcName);
|
||||
$ret = $method->invoke(null);
|
||||
$method = new ReflectionMethod('services\\' . $serviceName, $funcName);
|
||||
$ret = $method->invoke(null, ...$args);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
require_once('services/HashRateService.php');
|
||||
require_once('services/LootService.php');
|
||||
|
||||
require_once('mt/AchievementsPower.php');
|
||||
require_once('mt/AchievementsCycle.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('models/HashRate.php');
|
||||
|
||||
use models\HashRate;
|
||||
@ -67,14 +69,14 @@ class HashRateController extends BaseAuthedController
|
||||
$mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService);
|
||||
foreach ($mateList as $mate) {
|
||||
$taskDb = HashRate::find($mate['id'],$currentPeriod['id']);
|
||||
$temp = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
||||
array_push($taskDtoList1, $temp);
|
||||
$taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
||||
array_push($taskDtoList1, $taskDto);
|
||||
}
|
||||
$mateList2 = \mt\AchievementsPower::getListByType(0);
|
||||
foreach ($mateList2 as $mate) {
|
||||
$taskDb = HashRate::find($mate['id'],$currentPeriod['id']);
|
||||
$temp = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
||||
array_push($taskDtoList2, $temp);
|
||||
$taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb);
|
||||
array_push($taskDtoList2, $taskDto);
|
||||
}
|
||||
$obtain_start_time = strtotime($currentPeriod['obtain_start_time']);
|
||||
$obtain_end_time = strtotime($currentPeriod['obtain_end_time']);
|
||||
@ -94,16 +96,54 @@ class HashRateController extends BaseAuthedController
|
||||
'income_start_time' => $income_start_time,
|
||||
'income_end_time' => $income_end_time,
|
||||
'state' => $state,
|
||||
'refresh_times' => myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0),
|
||||
'myHashRate' => 0,
|
||||
));
|
||||
}
|
||||
|
||||
public function commitTask(){
|
||||
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||
if (! $currentPeriod){
|
||||
$this->_rspErr(1, 'Already ended');
|
||||
return;
|
||||
}
|
||||
$taskId = getReqVal('task_id', 0);
|
||||
$taskMeta = \mt\AchievementsPower::find($taskId);
|
||||
if (!$taskMeta) {
|
||||
$this->_rspErr(1, 'task_id error');
|
||||
return;
|
||||
}
|
||||
$taskDb = HashRate::find($taskMeta['id'],$currentPeriod['id']);
|
||||
$taskDto = $this->hashRateService->hashRateTaskDto($taskMeta,$taskDb);
|
||||
|
||||
if (!$taskDto) {
|
||||
$this->_rspErr(10, 'server internal error');
|
||||
return;
|
||||
}
|
||||
if ($taskDto['state'] == \services\HashRateService::RECEIVED_STATE) {
|
||||
$this->_rspErr(2, "Can't get it again");
|
||||
return;
|
||||
}
|
||||
// if ($taskDto['state'] == \services\HashRateService::NOT_FINISHED_STATE) {
|
||||
// $this->_rspErr(3, 'task not achieved');
|
||||
// return;
|
||||
// }
|
||||
$lootIndex = $taskMeta['Reward_Loot'];
|
||||
$reward = \services\LootService::dropOutItem($lootIndex);
|
||||
$rewardNum = $reward[0]['item_num'];
|
||||
HashRate::add($taskMeta['id'],$currentPeriod['id']);
|
||||
HashRate::rewardAdd($currentPeriod['id'],$rewardNum);
|
||||
//刷新任务
|
||||
$refreshTimes = myself()->_getDailyV(TN_HASH_DAILY_REFRESH_TIMES,0);
|
||||
$refreshTimesMax = \mt\Parameter::getVal('economy_account_compute_refresh_max',5);
|
||||
if ($taskMeta['is_refresh'] == \mt\AchievementsPower::REFRESH_STATE && $refreshTimes < $refreshTimesMax){
|
||||
$this->hashRateService->refreshHashRateTask($taskMeta,$currentPeriod['id']);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'award' => $reward,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ require_once('models/InGameMall.php');
|
||||
|
||||
require_once('services/MailApiService.php');
|
||||
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\InGameMall;
|
||||
|
||||
|
43
webapp/controller/UnitTestController.class.php
Normal file
43
webapp/controller/UnitTestController.class.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class UnitTestController extends BaseAuthedController {
|
||||
|
||||
public function _handlePre()
|
||||
{
|
||||
parent::_handlePre();
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
die("can't create UnitTestController");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function testNotice()
|
||||
{
|
||||
try {
|
||||
$marqueeType= getReqVal('type', 1);
|
||||
$loop = getReqVal('loop', 1);
|
||||
$interval = getReqVal('interval', 10);
|
||||
|
||||
$contents= file_get_contents('php://input');
|
||||
$postdata = json_decode($contents, true);
|
||||
|
||||
$content = '';
|
||||
if ($marqueeType == 1) {
|
||||
$elements = $postdata["elements"];
|
||||
$content = services\NoticeService::buildCustom($elements);
|
||||
} else if ($marqueeType == 2) {// deprecated
|
||||
$langKey = $postdata["lang_key"];
|
||||
$langParams = $postdata["lang_params"];
|
||||
$content = services\NoticeService::buildMulLangTemplate($langKey, $langParams);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
myself()->_callServiceStatic('NoticeService', 'send', $content, $loop, $interval);
|
||||
//services\NoticeService::send($content, $loop, $interval);
|
||||
} catch (Exception $e){
|
||||
error_log($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -85,6 +85,7 @@ class ChipPage extends BaseModel
|
||||
if ($value['chip_id']){
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
$newData[$key]['item_id'] = $chipDb['item_id'];
|
||||
$newData[$key]['quality'] = $chipDb['quality'];
|
||||
$rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
|
||||
foreach ($rand_attr as $val){
|
||||
array_push($attrs,$val);
|
||||
|
@ -47,11 +47,25 @@ class HashRate extends BaseModel
|
||||
}
|
||||
|
||||
|
||||
public static function add($fieldKv){
|
||||
SqlHelper::insert(
|
||||
public static function add($taskId,$period){
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hash_rate',
|
||||
$fieldKv
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'period' => $period,
|
||||
'task_id' => $taskId
|
||||
),
|
||||
array(
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'period' => $period,
|
||||
'task_id' => $taskId,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -91,4 +105,28 @@ class HashRate extends BaseModel
|
||||
return $totalHashRate;
|
||||
}
|
||||
|
||||
public static function rewardAdd($period,$reward){
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hash_rate_reward',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'period' => $period,
|
||||
),
|
||||
array(
|
||||
'reward' => function () use($reward) {
|
||||
return "reward + ${reward}";
|
||||
},
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'period' => $period,
|
||||
'reward' => $reward,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -198,6 +198,7 @@ class Hero extends BaseModel {
|
||||
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$row['quality']);
|
||||
$unsealTime = $row['unseal_time'] ? $row['unseal_time'] : $row['createtime'];
|
||||
$validTime = $unsealTime + 86400 * $heroAtteMeta['validTime'] ;
|
||||
$skinDb = HeroSkin::find($row['skin_id']);
|
||||
$dto = array(
|
||||
'idx' => $row['idx'],
|
||||
'token_id' => $row['token_id'],
|
||||
@ -206,6 +207,7 @@ class Hero extends BaseModel {
|
||||
'hero_lv' => $row['hero_lv'],
|
||||
'hero_tili' => $row['hero_tili'],
|
||||
'state' => $row['state'],
|
||||
'skin_id' => $skinDb?$skinDb['skin_id']:0,
|
||||
'quality' => $row['quality'],
|
||||
'skill_lv1' => $row['skill_lv1'],
|
||||
'skill_lv2' => $row['skill_lv2'],
|
||||
|
@ -11,6 +11,7 @@ require_once('models/Hero.php');
|
||||
require_once('models/HeroPreset.php');
|
||||
require_once('models/SignLog.php');
|
||||
require_once('models/UserHonor.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon;
|
||||
@ -74,6 +75,11 @@ class User extends BaseModel {
|
||||
$heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']);
|
||||
$heroUniid = $heroDb ? $row['hero_id'] : 0;
|
||||
$heroId = $heroDb ? $heroDb['hero_id'] : 0;
|
||||
$skinId = 0;
|
||||
if ($heroDb){
|
||||
$skinDb = HeroSkin::find($heroDb['skin_id']);
|
||||
$skinId = $skinDb ? $skinDb['skin_id']:0;
|
||||
}
|
||||
$honorInfo = array();
|
||||
if ($row['address']){
|
||||
$honorInfo = UserHonor::info($row['address']);
|
||||
@ -98,6 +104,7 @@ class User extends BaseModel {
|
||||
'diamond' => cecFormat($row['diamond']),
|
||||
'hero_uniid' => $heroUniid,
|
||||
'hero_id' => $heroId,
|
||||
'skin_id' => $skinId,
|
||||
'first_fight' => $row['first_fight'],
|
||||
'already_guide' => $row['already_guide'],
|
||||
'pve_instance_id' => $row['pve_instance_id'],
|
||||
@ -125,6 +132,11 @@ class User extends BaseModel {
|
||||
$heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']);
|
||||
$heroUniid = $heroDb ? $row['hero_id'] : 0;
|
||||
$heroId = $heroDb ? $heroDb['hero_id'] : 0;
|
||||
$skinId = 0;
|
||||
if ($heroDb){
|
||||
$skinDb = HeroSkin::find($heroDb['skin_id']);
|
||||
$skinId = $skinDb ? $skinDb['skin_id']:0;
|
||||
}
|
||||
$honorInfo = array();
|
||||
if ($row['address']){
|
||||
$honorInfo = UserHonor::info($row['address']);
|
||||
@ -149,6 +161,7 @@ class User extends BaseModel {
|
||||
'diamond' => cecFormat($row['diamond']),
|
||||
'hero_uniid' => $heroUniid,
|
||||
'hero_id' => $heroId,
|
||||
'skin_id' => $skinId,
|
||||
'first_fight' => $row['first_fight'],
|
||||
'already_guide' => $row['already_guide'],
|
||||
'head_list' => self::getHeadList($row),
|
||||
|
@ -37,6 +37,9 @@ class AchievementsPower {
|
||||
const TYPE3 = 3;
|
||||
const TYPE4 = 4;
|
||||
|
||||
const REFRESH_STATE = 1;
|
||||
const NOT_REFRESH_STATE = 0;
|
||||
|
||||
public static function find($id){
|
||||
return getXVal(self::getMetaList(), $id, null);
|
||||
}
|
||||
@ -55,13 +58,25 @@ class AchievementsPower {
|
||||
public static function getListByType($type){
|
||||
$mateList = array();
|
||||
foreach (self::getMetaList() as $mate){
|
||||
if ($mate['scene'] == $type){
|
||||
if ($mate['task_type'] == $type){
|
||||
array_push($mateList,$mate);
|
||||
}
|
||||
}
|
||||
return $mateList;
|
||||
}
|
||||
|
||||
public static function getAvailableTasks($type,$excludeMetas){
|
||||
$metas = array();
|
||||
foreach (self::getListByType($type) as $meta) {
|
||||
if (!array_find($excludeMetas, function($val) use($meta) {
|
||||
return $val['task_id'] == $meta['id'];
|
||||
})) {
|
||||
array_push($metas, $meta);
|
||||
}
|
||||
}
|
||||
return $metas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getMetaList()
|
||||
|
@ -105,9 +105,17 @@ class HashRateService extends BaseService
|
||||
);
|
||||
|
||||
if ($taskDb){
|
||||
$taskDto['current'] = $taskDto['target'];
|
||||
$taskDto['state'] = self::RECEIVED_STATE;
|
||||
return $taskDto;
|
||||
if ($taskMate['scene'] > 0){
|
||||
if (myself()->_getDaySeconds($taskDb['modifytime']) == myself()->_getNowDaySeconds()) {
|
||||
$taskDto['current'] = $taskDto['target'];
|
||||
$taskDto['state'] = self::RECEIVED_STATE;
|
||||
return $taskDto;
|
||||
}
|
||||
}else{
|
||||
$taskDto['current'] = $taskDto['target'];
|
||||
$taskDto['state'] = self::RECEIVED_STATE;
|
||||
return $taskDto;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($taskMate['Completion_type']){
|
||||
@ -338,6 +346,38 @@ class HashRateService extends BaseService
|
||||
json_encode($this->hashRateTask));
|
||||
}
|
||||
|
||||
public function refreshHashRateTask($taskMate,$period){
|
||||
$taskList = $this->getHashRateTasks($taskMate['task_type']);
|
||||
$metas = AchievementsPower::getAvailableTasks($taskMate['task_type'],$taskList);
|
||||
if (count($metas)<1) {
|
||||
return;
|
||||
}
|
||||
$randMetas = array();
|
||||
foreach ($metas as $meta){
|
||||
$taskDb = HashRate::find($meta['id'],$period);
|
||||
if (!$taskDb || myself()->_getDaySeconds($taskDb['modifytime']) < myself()->_getNowDaySeconds()){
|
||||
array_push($randMetas,$meta);
|
||||
}
|
||||
}
|
||||
if (count($randMetas)<1) {
|
||||
return;
|
||||
}
|
||||
$key = array_rand($randMetas,1);
|
||||
foreach ($taskList as $k=>$task){
|
||||
if ($task['task_id'] == $taskMate['id']){
|
||||
$taskList[$k] = array(
|
||||
'task_id' => $metas[$key]['id'],
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->hashRateTask['task'.$taskMate['task_type']] = $taskList;
|
||||
$this->saveHashRateTask();
|
||||
myself()->_incDailyV(TN_HASH_DAILY_REFRESH_TIMES,0,1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function serverTaskDto($taskMate){
|
||||
$taskDto = array(
|
||||
|
80
webapp/services/NoticeService.php
Normal file
80
webapp/services/NoticeService.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace services;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class NoticeService extends BaseService {
|
||||
|
||||
const ELE_TYPE_RAW_TEXT = 1;
|
||||
const ELE_TYPE_MUL_LANG = 2;
|
||||
|
||||
/*
|
||||
{
|
||||
"type": 1, //自定义
|
||||
"elements":[
|
||||
{
|
||||
"ele_type": 1, //原始文本
|
||||
"color": "#xxxxxxx", //[可选], 无则使用多语言里的颜色
|
||||
"text": "" //如果是多语言则表示多语言配置表里的key
|
||||
},
|
||||
{
|
||||
"ele_type": 2, //多语言(读取多语言表)
|
||||
"color": "#xxxxxxx", //[可选], 无则使用多语言里的颜色
|
||||
"lang_key": "",
|
||||
"lang_params":[
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
public static function buildCustom($elements)
|
||||
{
|
||||
$data = [
|
||||
"type"=>1,
|
||||
"elements"=> $elements,
|
||||
];
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
public static function send($content, $loop, $interval) {
|
||||
$appkey = "YOUME1838B3633FF1410BDC9124BBD806F245B9D2E5AC";
|
||||
$identifier="admin";
|
||||
$appsecret="q6B570yTyj/00Nk4mYZtgDwyew5v05t13V1vo4mxpEuAaWUiinAyVxG41sNu3vsFe8sipOLfKfIVYGhzpQrqzvj5sId3mrBfj/s65a2gp36yDrI/nX5BnUAJB317SEosR6xLoPuhBvHU+/1DWI7nKSKaRNxnQiC46PJKFc2kX50BAAE=";
|
||||
|
||||
$data = [
|
||||
"Notice"=>[
|
||||
"ChannelID"=>"world_room_1",//频道 ID,app 内唯一,字符串
|
||||
"NoticeType"=>1,//1 为跑马灯公告,2 为聊天框公告,3 为置顶公告,整数
|
||||
"LoopType"=>1,// 公告循环类型,1 为一次性公告,2 为周期性公告,整数
|
||||
"Title"=>"",// 公告标题,字符串
|
||||
"Content"=>$content,//"testtttttt222",// 公告内容,字符串
|
||||
"LinkKeyWords"=>"",// 链接关键字,字符串
|
||||
"LinkAddr"=>"",// 链接地址,字符串
|
||||
"Creator"=>"",// 公告添加人,字符串
|
||||
"EnableStatus"=>2,// 公告启用状态,1 为停用,2 为启用,整数
|
||||
|
||||
"SendStartTime"=>"",// 公告发送时间,格式为 HH:MM:SS,字符串
|
||||
"SendInstantly"=>1,// 是否即时发送,也属于公告 json 里的字段。1 是,0 否,不指定则不起作用
|
||||
"SendTimes"=>$loop,// 公告发送次数,整数(需要传入)
|
||||
"SendInterval"=>$interval,// 公告发送多次时,每次的间隔,单位秒,整数(需要传入)
|
||||
]
|
||||
];
|
||||
|
||||
$url = "https://sgapi.youme.im/v1/im/add_notice";
|
||||
$curtime = time();
|
||||
|
||||
$params = array(
|
||||
"appkey" => $appkey,
|
||||
"identifier"=> $appkey,
|
||||
"curtime"=> $curtime,
|
||||
"checksum"=> strtolower(sha1($appsecret.$curtime)),
|
||||
);
|
||||
|
||||
$response = '';
|
||||
phpcommon\HttpClient::postContentEx($url, $params, json_encode($data), $response, ['Content-Type: application/json']);
|
||||
|
||||
if (SERVER_ENV != _ONLINE) {
|
||||
error_log($response);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user