存钱罐
This commit is contained in:
parent
c1d1458166
commit
a561a449d2
@ -35,10 +35,10 @@ class Activity(object):
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'getBindReward',
|
||||
'name': 'getBindRewardS',
|
||||
'desc': '领取绑定奖励',
|
||||
'group': 'Activity',
|
||||
'url': 'webapp/index.php?c=Activity&a=getBindReward',
|
||||
'surl': 'webapp/index.php?c=Activity&a=getBindRewardS',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
@ -60,10 +60,10 @@ class Activity(object):
|
||||
['!task_list',[_common.Mission()], '奖励信息'],
|
||||
]
|
||||
},{
|
||||
'name': 'commitInvitationTask',
|
||||
'name': 'commitInvitationTaskS',
|
||||
'desc': '提交任务(领取奖励)',
|
||||
'group': 'Activity',
|
||||
'url': 'webapp/index.php?c=Activity&a=commitInvitationTask',
|
||||
'surl': 'webapp/index.php?c=Activity&a=commitInvitationTaskS',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['mission_id', 0, '任务id'],
|
||||
|
17
doc/Bag.py
17
doc/Bag.py
@ -26,7 +26,7 @@ class Bag(object):
|
||||
'surl': 'webapp/index.php?c=Bag&a=useItemS',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['item_uniid', 0, '道具唯一id'],
|
||||
['item_id', 0, '道具唯一id'],
|
||||
['item_num', 0, '道具数量'],
|
||||
['param1', '', '参数1(当使用的是改名卡时param1=新的角色名)'],
|
||||
['param2', '', '参数2(当使用的是改名卡时param2=签名)'],
|
||||
@ -37,6 +37,21 @@ class Bag(object):
|
||||
['award', _common.Award(), '奖励信息'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},{
|
||||
'name': 'openBoxByBindGoldS',
|
||||
'desc': '绑币开宝箱',
|
||||
'group': 'Bag',
|
||||
'surl': 'webapp/index.php?c=Bag&a=openBoxByBindGoldS',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['item_id', 0, '道具唯一id'],
|
||||
['item_num', 0, '道具数量'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['award', _common.Award(), '奖励信息'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'rename',
|
||||
|
73
doc/SavingPot.py
Normal file
73
doc/SavingPot.py
Normal file
@ -0,0 +1,73 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import _common
|
||||
|
||||
class SavingPot(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'info',
|
||||
'desc': '存钱罐信息',
|
||||
'group': 'SavingPot',
|
||||
'url': 'webapp/index.php?c=SavingPot&a=info',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [Info()], '存钱罐信息'],
|
||||
]
|
||||
},{
|
||||
'name': 'smashOpenS',
|
||||
'desc': '砸开',
|
||||
'group': 'SavingPot',
|
||||
'surl': 'webapp/index.php?c=SavingPot&a=smashOpenS',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['award', _common.AwardItem(), '奖励'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},{
|
||||
'name': 'drawGoldS',
|
||||
'desc': '取出',
|
||||
'group': 'SavingPot',
|
||||
'surl': 'webapp/index.php?c=SavingPot&a=drawGoldS',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['award', _common.AwardItem(), '奖励'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},{
|
||||
'name': 'getRecord',
|
||||
'desc': '获取记录',
|
||||
'group': 'SavingPot',
|
||||
'url': 'webapp/index.php?c=SavingPot&a=getRecord',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', 0, '第几页数据'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['pagination', _common.Pagination(), '分页信息'],
|
||||
['!rows', [_common.InGameMallGoods()], '记录列表']
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
|
||||
class Info(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['bind_gold', 0, '绑定金币数'],
|
||||
['draw_state', 0, '1:今日已领取或砸开 0:反之'],
|
||||
['up_times', 0, '今日升阶次数'],
|
||||
]
|
@ -2117,3 +2117,21 @@ CREATE TABLE `t_user_invitation_code_bind` (
|
||||
UNIQUE KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_user_bind_gold_record`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_user_bind_gold_record`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_user_bind_gold_record` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`way` int(11) NOT NULL DEFAULT '0' COMMENT '1:draw 2:open',
|
||||
`amount` 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`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
@ -3,6 +3,17 @@ begin;
|
||||
alter table t_hero add column `gold_times` int(11) NOT NULL DEFAULT '0' COMMENT '打金次数';
|
||||
alter table t_hero add column `gold_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '打金时间';
|
||||
|
||||
|
||||
CREATE TABLE `t_user_bind_gold_record` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`way` int(11) NOT NULL DEFAULT '0' COMMENT '1:draw 2:open',
|
||||
`amount` 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`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
insert into version (version) values(2024092401);
|
||||
|
||||
commit;
|
||||
|
@ -68,6 +68,8 @@ define('TN_DAILY_REFRESH_MISSION_TIMES', 9020);
|
||||
define('TN_DAILY_GOLD_MODE_BATTLE_TIMES', 9021);
|
||||
define('TN_DAILY_GATHER_GOLD', 9022);
|
||||
define('TN_DAILY_BIND_GOLD', 9023);
|
||||
define('TN_DAILY_DRAW_BIND_GOLD_STATE', 9024);
|
||||
define('TN_DAILY_TIER_N_HERO_TIMES', 9025);
|
||||
|
||||
define('TN_WEEKLY_BEGIN', 10001);
|
||||
define('TN_WEEKLY_ACTIVE', 10002);
|
||||
|
@ -69,7 +69,7 @@ class ActivityController extends BaseAuthedController {
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function getBindReward(){
|
||||
public function getBindRewardS(){
|
||||
if (!UserInvitationCode::verifyAccountBind()){
|
||||
$this->_rspErr(1, "Unbound user");
|
||||
return;
|
||||
@ -114,7 +114,7 @@ class ActivityController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function commitInvitationTask(){
|
||||
public function commitInvitationTaskS(){
|
||||
$missionId = getReqVal('mission_id', 0);
|
||||
$missionMeta = mt\Task::get($missionId);
|
||||
if (!$missionMeta) {
|
||||
|
@ -146,7 +146,20 @@ class BagController extends BaseAuthedController {
|
||||
$this->openTreasureBox($itemDb, $itemMeta, $itemNum);
|
||||
} else if ($itemMeta['type'] == mt\Item::BATTLE_REWARD_BOX) {
|
||||
myself()->_verifySwitch('bigEventBoxOpen');
|
||||
$this->openBattleBox($itemDb, $itemMeta, $itemNum);
|
||||
$costItems = mt\Item::getUseCostItems($itemMeta);
|
||||
if (count($costItems) > 0){
|
||||
foreach ($costItems as &$costItem){
|
||||
$costItem['item_num'] *= $itemNum;
|
||||
}
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
|
||||
}
|
||||
$this->openBattleBox($itemDb, $itemMeta, $itemNum,$costItems);
|
||||
} else {
|
||||
$this->_rspErr(4, 'The prop function has not been realized yet');
|
||||
}
|
||||
@ -385,18 +398,55 @@ class BagController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
private function openBattleBox($itemDb,$itemMeta,$itemNum){
|
||||
$costItems = mt\Item::getUseCostItems($itemMeta);
|
||||
if (count($costItems) > 0){
|
||||
foreach ($costItems as &$costItem){
|
||||
$costItem['item_num'] *= $itemNum;
|
||||
}
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
public function openBoxByBindGoldS(){
|
||||
$itemId = getReqVal('item_id', 0);
|
||||
$itemNum = getReqVal('item_num', 0);
|
||||
|
||||
if ($itemNum < 0) {
|
||||
$this->_rspErr(1, 'item_num must be greater than 0');
|
||||
return;
|
||||
}
|
||||
$itemDb = Bag::find($itemId);
|
||||
if (!isset($itemDb) || $itemDb['item_num'] <= 0 || $itemDb['item_num']< $itemNum) {
|
||||
$this->_rspErr(1, 'Not enough item');
|
||||
return;
|
||||
}
|
||||
$itemMeta = mt\Item::get($itemId);
|
||||
if (!$itemMeta) {
|
||||
$this->_rspErr(2, 'config error');
|
||||
return;
|
||||
}
|
||||
if ( $itemMeta['type'] != mt\Item::BATTLE_REWARD_BOX){
|
||||
$this->_rspErr(2, 'item error');
|
||||
return;
|
||||
}
|
||||
$costItems = mt\Item::getUseCostItems($itemMeta);
|
||||
$bindGold = 0;
|
||||
$normal = \mt\Parameter::getVal('bind_to_normal',0);
|
||||
if (count($costItems) > 0){
|
||||
foreach ($costItems as $costItem){
|
||||
$bindGold = $costItem['item_num'] / $normal;
|
||||
}
|
||||
}
|
||||
|
||||
$totalBindGold = $bindGold * $itemNum;
|
||||
$myBindGold = $this->_getDailyV(TN_DAILY_BIND_GOLD, 0);
|
||||
if ($totalBindGold > $myBindGold){
|
||||
$this->_rspErr(3, 'piggy bank Not enough');
|
||||
return;
|
||||
}
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_BIND_GOLD,
|
||||
'item_num' => $totalBindGold
|
||||
)
|
||||
);
|
||||
$this->_decItems($costItems);
|
||||
$this->openBattleBox($itemDb,$itemMeta,$itemNum,$costItems);
|
||||
}
|
||||
|
||||
private function openBattleBox($itemDb,$itemMeta,$itemNum,$costItems){
|
||||
|
||||
if ($itemMeta['quality'] > 3){
|
||||
$maxCec = \mt\Parameter::getVal('CEC_ServerDailyLootMax_Special',1500);
|
||||
$nameIndex = RealtimeData::CEC_NAME_INDEX2;
|
||||
@ -429,9 +479,6 @@ class BagController extends BaseAuthedController {
|
||||
$hashItems[$item['item_id']] = $item;
|
||||
}
|
||||
}
|
||||
if (count($costItems) > 0){
|
||||
$this->_decItems($costItems);
|
||||
}
|
||||
$this->_decItems(array(
|
||||
array(
|
||||
'item_id' => $itemMeta['id'],
|
||||
|
@ -500,6 +500,11 @@ class BaseAuthedController extends BaseController {
|
||||
));
|
||||
}
|
||||
break;
|
||||
case V_ITEM_BIND_GOLD:
|
||||
{
|
||||
$this->_decDailyV(TN_DAILY_BIND_GOLD, 0,$itemNum);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
|
@ -225,6 +225,9 @@ class HeroController extends BaseAuthedController {
|
||||
'unseal_time' => $unseal_time_new,
|
||||
'wealth_attr' => json_encode($attribute),
|
||||
);
|
||||
if ($heroDb['quality'] == 1){
|
||||
$this->_incDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0,1);
|
||||
}
|
||||
if ($heroDb['quality'] + 1 > 4){
|
||||
$randAttr = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
$basicMeta = mt\BattleBasicAttribute::get($heroDb['hero_id']);
|
||||
|
@ -1,19 +1,137 @@
|
||||
<?php
|
||||
require_once('services/HashRateService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/AwardService.php');
|
||||
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
require_once('mt/Parameter.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
|
||||
|
||||
|
||||
use models\Hero;
|
||||
use phpcommon\SqlHelper;
|
||||
class SavingPotController extends BaseAuthedController {
|
||||
|
||||
public function test(){
|
||||
// $times = Hero::getDailyV(10049);
|
||||
// echo $times;
|
||||
Hero::incDailyV(10049,1);
|
||||
public function info(){
|
||||
|
||||
$info = array(
|
||||
'bind_gold' => $this->_getDailyV(TN_DAILY_BIND_GOLD, 0),
|
||||
'draw_state' => $this->_getDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0),
|
||||
'up_times' => $this->_getDailyV(TN_DAILY_TIER_N_HERO_TIMES, 0),
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'data' => $info
|
||||
));
|
||||
}
|
||||
|
||||
public function smashOpenS(){
|
||||
$state = $this->_getDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0);
|
||||
if ($state > 0){
|
||||
$this->_rspErr(1, "Run out today");
|
||||
return;
|
||||
}
|
||||
$bindGold = $this->_getDailyV(TN_DAILY_BIND_GOLD, 0);
|
||||
if ($bindGold <= 0){
|
||||
$this->_rspErr(1, "piggy bank empty");
|
||||
return;
|
||||
}
|
||||
$rateRange = \mt\Parameter::getListValue('saving_withdraw_rate_range',0);
|
||||
$rate = rand($rateRange[0]*100,$rateRange[1]*100)/100;
|
||||
$normal = \mt\Parameter::getVal('bind_to_normal',0);
|
||||
$gold = max(1,floor($bindGold * $rate * $normal));
|
||||
$items = array(
|
||||
array(
|
||||
"item_id" => V_ITEM_GOLD,
|
||||
"item_num" => $gold,
|
||||
)
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
$this->_addItems($items, $awardService,$propertyChgService);
|
||||
$this->_setDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0,1);
|
||||
SqlHelper::insert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_user_bind_gold_record',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'way' => 2,
|
||||
'amount' => $gold,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
public function drawGoldS(){
|
||||
$state = $this->_getDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0);
|
||||
if ($state > 0){
|
||||
$this->_rspErr(1, "Run out today");
|
||||
return;
|
||||
}
|
||||
$bindGold = $this->_getDailyV(TN_DAILY_BIND_GOLD, 0);
|
||||
if ($bindGold <= 0){
|
||||
$this->_rspErr(1, "piggy bank empty");
|
||||
return;
|
||||
}
|
||||
$upTimes = $this->_getDailyV(TN_DAILY_TIER_N_HERO_TIMES, 0);
|
||||
if ($upTimes < 1){
|
||||
$this->_rspErr(1, "No completion condition");
|
||||
return;
|
||||
}
|
||||
$normal = \mt\Parameter::getVal('bind_to_normal',0);
|
||||
$gold = max(1,floor($bindGold * $normal));
|
||||
$items = array(
|
||||
array(
|
||||
"item_id" => V_ITEM_GOLD,
|
||||
"item_num" => $gold,
|
||||
)
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
$this->_addItems($items, $awardService,$propertyChgService);
|
||||
$this->_setDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0,1);
|
||||
SqlHelper::insert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_user_bind_gold_record',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'way' => 1,
|
||||
'amount' => $gold,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
public function getRecord(){
|
||||
$page = getReqVal('page', 0);
|
||||
$out = array(
|
||||
'pagination' => array(),
|
||||
'rows' => array()
|
||||
);
|
||||
SqlHelper::rawQueryPage(
|
||||
myself()->_getSelfMysql(),
|
||||
'SELECT * FROM t_user_bind_gold_record ',
|
||||
array(),
|
||||
array(
|
||||
'page' => $page,
|
||||
'perPage' => 8,
|
||||
'orderBy' => "ORDER BY createtime DESC",
|
||||
'handle' => function ($row) use(&$out) {
|
||||
array_push($out['rows'], $row);
|
||||
}
|
||||
),
|
||||
$out['pagination']
|
||||
);
|
||||
myself()->_rspData($out);
|
||||
}
|
||||
}
|
@ -221,7 +221,7 @@ class Hero extends BaseModel {
|
||||
'valid_time' => max(0,
|
||||
86400 * $heroAtteMeta['validTime']),
|
||||
'is_old' => $row['is_old'],
|
||||
"current_times" => myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$row['idx']),
|
||||
"current_times" => self::getDailyV($row['idx']),
|
||||
"total_times" => $heroAtteMeta['roundPerDay'],
|
||||
'activate' => $row['activate'],
|
||||
);
|
||||
@ -322,7 +322,7 @@ class Hero extends BaseModel {
|
||||
'valid_time' => max(0,
|
||||
86400 * $heroAtteMeta['validTime']),
|
||||
'is_old' => $row['is_old'],
|
||||
"current_times" => myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$row['idx']),
|
||||
"current_times" => self::getDailyV($row['idx']),
|
||||
"total_times" => $heroAtteMeta['roundPerDay'],
|
||||
'activate' => $row['activate'],
|
||||
);
|
||||
@ -368,7 +368,7 @@ class Hero extends BaseModel {
|
||||
'ability' => self::abilityInfo($row),
|
||||
'valid_time' => max(0,
|
||||
86400 * $heroAtteMeta['validTime']),
|
||||
"current_times" => myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$row['idx']),
|
||||
"current_times" => self::getDailyV($row['idx']),
|
||||
"total_times" => $heroAtteMeta['roundPerDay'],
|
||||
);
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class RoomBattleDataService extends BaseService {
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if ($heroTimes < 3 && $goldModeTimes < $rewardsMaxTimes){
|
||||
if ($heroTimes < $heroTimesMax && $goldModeTimes < $rewardsMaxTimes){
|
||||
$items = LootService::dropOutItem($rewardMeta['boundGoldLoot']);
|
||||
foreach ($items as $item){
|
||||
if ($item['item_id'] = V_ITEM_BIND_GOLD){
|
||||
|
Loading…
x
Reference in New Issue
Block a user