Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb

This commit is contained in:
hujiabin 2023-08-29 17:27:40 +08:00
commit 34e67de8cc
5 changed files with 39 additions and 11 deletions

View File

@ -1444,6 +1444,7 @@ class StakingDetail(object):
['order_id', '', 'order_id'],
['start_time', '', '质押开始时间'],
['stake_time', '', '质押时间'],
['redeem_time', '', '赎回时间'],
['txhash', '', 'txhash'],
['item_id', 0, '道具id'],

View File

@ -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_mall add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name';
insert into version (version) values(2023081601);
commit;

View File

@ -199,6 +199,7 @@ class Staking extends BaseModel {
'order_id' => $row['order_id'],
'start_time' => $row['start_time'],
'stake_time' => $row['stake_time'],
'redeem_time' => $row['redeem_time'],
'txhash' => $row['txhash'],
'item_id' => $row['item_id'],
@ -211,9 +212,18 @@ class Staking extends BaseModel {
myself()->_getDaySeconds($row['start_time'])) /
3600 / 24);
$saveDays = intval($row['stake_time'] / 3600 / 24);
$dailyInterest = self::getDailyInterest($row['stake_time']);
$dto['stacked_days'] = max(0, $passedDays);
$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;
/*
error_log(json_encode(array(
@ -222,20 +232,33 @@ class Staking extends BaseModel {
'daily_interest' => $dailyInterest
)));
*/
$srcDailyRewards = $dto['cec_value'] * $srcDailyInterest;
$dto['cec_rewards'] = 0;
$dto['total_rewards'] = 0;
if ($dto['status'] == self::REDEEM_STATUS) {
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 * 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'];
} else {
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;
}
@ -245,7 +268,7 @@ class Staking extends BaseModel {
return 1;
}
public static function getDailyInterest($stakeTime)
private static function getDailyInterest($stakeTime, $remainDays)
{
$months = intval($stakeTime / 3600 / 24 / 30);
if ($months <= 0) {

View File

@ -215,9 +215,15 @@ class BlockChainService {
if (strlen($val) <= $decimals) {
$floatPart = $val;
} else {
$intPart = substr($val, 0, $decimals);
$floatPart = substr($val, $decimals);
$intPart = substr($val, 0, strlen($val) - $decimals);
$floatPart = substr($val, strlen($val) - $decimals);
}
/*
error_log(json_encode(array(
'val' => $val,
'int_part' => $intPart,
'float_part' => $floatPart,
)));*/
return true;
}

View File

@ -83,7 +83,7 @@ class GameItemMarketBuyOk {
)),
'param3' => json_encode($orderDb),
));
$currencyName = $orderDb['currency_name'];
$currencyName = $orderDb['currency'];
EventService::mallConsume($accountId, $currencyName, $price);
myself()->_rspOk();
}