From 330e1fc9da9b424ac1b09334cb2f447066557012 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Tue, 6 Aug 2024 11:35:52 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 3 +-- webapp/models/HashRate.php | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index db7923b6..01ffb1b8 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1699,8 +1699,7 @@ CREATE TABLE `t_hash_rate` ( `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`) + PRIMARY KEY (`idx`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- diff --git a/webapp/models/HashRate.php b/webapp/models/HashRate.php index 2b782dd8..f038ae92 100644 --- a/webapp/models/HashRate.php +++ b/webapp/models/HashRate.php @@ -8,15 +8,27 @@ class HashRate extends BaseModel { public static function find($taskId,$period){ - return SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_hash_rate', +// return SqlHelper::ormSelectOne( +// myself()->_getSelfMysql(), +// 't_hash_rate', +// array( +// 'account_id' => myself()->_getAccountId(), +// 'task_id' => $taskId, +// 'period' => $period, +// ) +// ); + $row = myself()->_getSelfMysql()->execQueryOne( + 'SELECT * FROM t_hash_rate WHERE account_id=:account AND period=:period AND task_id=:task_id ORDER BY idx DESC LIMIT 1', array( - 'account_id' => myself()->_getAccountId(), - 'task_id' => $taskId, - 'period' => $period, + ':account' => myself()->_getAccountId(), + ':period' => $period, + ':task_id' => $taskId, ) ); + if (!$row){ + $row = array(); + } + return $row; } public static function getCount($period){ @@ -33,17 +45,9 @@ class HashRate extends BaseModel public static function add($taskId,$period){ - SqlHelper::upsert( + SqlHelper::insert( myself()->_getSelfMysql(), 't_hash_rate', - array( - 'account_id' => myself()->_getAccountId(), - 'period' => $period, - 'task_id' => $taskId - ), - array( - 'modifytime' => myself()->_getNowTime() - ), array( 'account_id' => myself()->_getAccountId(), 'period' => $period,