Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb
This commit is contained in:
commit
34e67de8cc
@ -1444,6 +1444,7 @@ class StakingDetail(object):
|
|||||||
['order_id', '', 'order_id'],
|
['order_id', '', 'order_id'],
|
||||||
['start_time', '', '质押开始时间'],
|
['start_time', '', '质押开始时间'],
|
||||||
['stake_time', '', '质押时间'],
|
['stake_time', '', '质押时间'],
|
||||||
|
['redeem_time', '', '赎回时间'],
|
||||||
['txhash', '', 'txhash'],
|
['txhash', '', 'txhash'],
|
||||||
|
|
||||||
['item_id', 0, '道具id'],
|
['item_id', 0, '道具id'],
|
||||||
|
@ -103,8 +103,6 @@ CREATE TABLE `t_staking` (
|
|||||||
|
|
||||||
alter table t_bc_order add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name';
|
alter table t_bc_order add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name';
|
||||||
|
|
||||||
alter table t_mall add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name';
|
|
||||||
|
|
||||||
insert into version (version) values(2023081601);
|
insert into version (version) values(2023081601);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
@ -199,6 +199,7 @@ class Staking extends BaseModel {
|
|||||||
'order_id' => $row['order_id'],
|
'order_id' => $row['order_id'],
|
||||||
'start_time' => $row['start_time'],
|
'start_time' => $row['start_time'],
|
||||||
'stake_time' => $row['stake_time'],
|
'stake_time' => $row['stake_time'],
|
||||||
|
'redeem_time' => $row['redeem_time'],
|
||||||
'txhash' => $row['txhash'],
|
'txhash' => $row['txhash'],
|
||||||
|
|
||||||
'item_id' => $row['item_id'],
|
'item_id' => $row['item_id'],
|
||||||
@ -211,9 +212,18 @@ class Staking extends BaseModel {
|
|||||||
myself()->_getDaySeconds($row['start_time'])) /
|
myself()->_getDaySeconds($row['start_time'])) /
|
||||||
3600 / 24);
|
3600 / 24);
|
||||||
$saveDays = intval($row['stake_time'] / 3600 / 24);
|
$saveDays = intval($row['stake_time'] / 3600 / 24);
|
||||||
$dailyInterest = self::getDailyInterest($row['stake_time']);
|
|
||||||
$dto['stacked_days'] = max(0, $passedDays);
|
$dto['stacked_days'] = max(0, $passedDays);
|
||||||
$dto['remain_days'] = max(0, $saveDays - $dto['stacked_days']);
|
$dto['remain_days'] = max(0, $saveDays - $dto['stacked_days']);
|
||||||
|
$stakedDays = $dto['stacked_days'];
|
||||||
|
$dailyInterest = self::getDailyInterest($row['stake_time'], $dto['remain_days']);
|
||||||
|
$srcDailyInterest = $dailyInterest;
|
||||||
|
if ($saveDays >= 30 * 12 * 2) {
|
||||||
|
if ($stakedDays < 30 * 12) {
|
||||||
|
$dailyInterest *= 0.6;
|
||||||
|
} else {
|
||||||
|
$dailyInterest *= 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
$dto['daily_rewards'] = $dto['cec_value'] * $dailyInterest;
|
$dto['daily_rewards'] = $dto['cec_value'] * $dailyInterest;
|
||||||
/*
|
/*
|
||||||
error_log(json_encode(array(
|
error_log(json_encode(array(
|
||||||
@ -222,20 +232,33 @@ class Staking extends BaseModel {
|
|||||||
'daily_interest' => $dailyInterest
|
'daily_interest' => $dailyInterest
|
||||||
)));
|
)));
|
||||||
*/
|
*/
|
||||||
|
$srcDailyRewards = $dto['cec_value'] * $srcDailyInterest;
|
||||||
$dto['cec_rewards'] = 0;
|
$dto['cec_rewards'] = 0;
|
||||||
$dto['total_rewards'] = 0;
|
$dto['total_rewards'] = 0;
|
||||||
if ($dto['status'] == self::REDEEM_STATUS) {
|
if ($dto['status'] == self::REDEEM_STATUS) {
|
||||||
if ($dto['remain_days'] <= 0 ) {
|
if ($dto['remain_days'] <= 0 ) {
|
||||||
$dto['cec_rewards'] = $dto['daily_rewards'] * $saveDays;
|
$dto['cec_rewards'] = $srcDailyRewards * $saveDays;
|
||||||
} else {
|
} else {
|
||||||
$dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25;
|
if ($saveDays >= 30 * 12 * 2) {
|
||||||
|
$dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6 * 0.25;
|
||||||
|
$dto['cec_rewards'] += $srcDailyRewards * max(0, $stakedDays - 30 * 12) * 0.4 * 0.25;
|
||||||
|
} else {
|
||||||
|
$dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$dto['total_rewards'] = $dto['cec_rewards'];
|
$dto['total_rewards'] = $dto['cec_rewards'];
|
||||||
} else {
|
} else {
|
||||||
if ($dto['remain_days'] <= 0 ) {
|
if ($dto['remain_days'] <= 0 ) {
|
||||||
$dto['cec_rewards'] = $dto['daily_rewards'] * $saveDays;
|
$dto['cec_rewards'] = $srcDailyRewards * $saveDays;
|
||||||
|
} else {
|
||||||
|
if ($saveDays >= 30 * 12 * 2) {
|
||||||
|
$dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6;
|
||||||
|
$dto['cec_rewards'] += $srcDailyRewards * max(0, $stakedDays - 30 * 12) * 0.4;
|
||||||
|
} else {
|
||||||
|
$dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$dto['total_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']);
|
$dto['total_rewards'] = $dto['cec_rewards'];
|
||||||
}
|
}
|
||||||
return $dto;
|
return $dto;
|
||||||
}
|
}
|
||||||
@ -245,7 +268,7 @@ class Staking extends BaseModel {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDailyInterest($stakeTime)
|
private static function getDailyInterest($stakeTime, $remainDays)
|
||||||
{
|
{
|
||||||
$months = intval($stakeTime / 3600 / 24 / 30);
|
$months = intval($stakeTime / 3600 / 24 / 30);
|
||||||
if ($months <= 0) {
|
if ($months <= 0) {
|
||||||
|
@ -215,9 +215,15 @@ class BlockChainService {
|
|||||||
if (strlen($val) <= $decimals) {
|
if (strlen($val) <= $decimals) {
|
||||||
$floatPart = $val;
|
$floatPart = $val;
|
||||||
} else {
|
} else {
|
||||||
$intPart = substr($val, 0, $decimals);
|
$intPart = substr($val, 0, strlen($val) - $decimals);
|
||||||
$floatPart = substr($val, $decimals);
|
$floatPart = substr($val, strlen($val) - $decimals);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
error_log(json_encode(array(
|
||||||
|
'val' => $val,
|
||||||
|
'int_part' => $intPart,
|
||||||
|
'float_part' => $floatPart,
|
||||||
|
)));*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class GameItemMarketBuyOk {
|
|||||||
)),
|
)),
|
||||||
'param3' => json_encode($orderDb),
|
'param3' => json_encode($orderDb),
|
||||||
));
|
));
|
||||||
$currencyName = $orderDb['currency_name'];
|
$currencyName = $orderDb['currency'];
|
||||||
EventService::mallConsume($accountId, $currencyName, $price);
|
EventService::mallConsume($accountId, $currencyName, $price);
|
||||||
myself()->_rspOk();
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user