From 15ba2b0107261e0c1605b74f2c44dc94d6069ac4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 10 Oct 2024 14:50:07 +0800 Subject: [PATCH] 1 --- webapp/models/HashRateShopBuyRecord.php | 57 +------------------------ 1 file changed, 2 insertions(+), 55 deletions(-) diff --git a/webapp/models/HashRateShopBuyRecord.php b/webapp/models/HashRateShopBuyRecord.php index 488c738d..b2942791 100644 --- a/webapp/models/HashRateShopBuyRecord.php +++ b/webapp/models/HashRateShopBuyRecord.php @@ -53,11 +53,11 @@ class HashRateShopBuyRecord extends BaseModel return $buyRecordHash; } - public static function add($itemId, $itemNum) + public static function add($goodsId, $goodsNum) { SqlHelper::upsert( myself()->_getSelfMysql(), - 't_shop_buy_record', + 't_hashrate_shop_buy_record', array( 'account_id' => myself()->_getAccountId(), 'item_id' => $itemId, @@ -92,57 +92,4 @@ class HashRateShopBuyRecord extends BaseModel ); } - public static function addWithAddress($address, $itemId, $itemNum) - { - $account_id = ShopBuyRecord::getAccountId($address); - SqlHelper::upsert( - myself()->_getMysql($address), - 't_shop_buy_record', - array( - 'account_id' => $account_id, - 'item_id' => $itemId, - ), - array( - 'this_day_buy_times' => function () { - $nowDaySeconds = myself()->_getNowDaySeconds(); - $cond = " last_buy_time>=${nowDaySeconds} AND last_buy_time<=${nowDaySeconds} + 3600 * 24 "; - return "CASE WHEN (${cond}) THEN this_day_buy_times + 1 ELSE 0 END"; - }, - 'this_week_buy_times' => function () { - $mondaySeconds = myself()->_getMondaySeconds(); - $cond = " last_buy_time>=${mondaySeconds} AND last_buy_time<=${mondaySeconds} + 3600 * 24 * 7 "; - return "CASE WHEN (${cond}) THEN this_week_buy_times + 1 ELSE 0 END"; - }, - 'total_buy_times' => function () { - return 'total_buy_times + 1'; - }, - 'last_buy_time' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ), - array( - 'account_id' => $account_id, - 'item_id' => $itemId, - 'this_day_buy_times' => 1, - 'this_week_buy_times' => 1, - 'total_buy_times' => 1, - 'last_buy_time' => myself()->_getNowTime(), - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ) - ); - } - - private static function getAccountId($address) - { - $row = SqlHelper::ormSelectOne( - myself()->_getMysql($address), - 't_user', - array( - 'address' => $address - ) - ); - - return $row['account_id']; - } - }