This commit is contained in:
aozhiwei 2024-10-10 14:50:07 +08:00
parent b4d0c8f9db
commit 15ba2b0107

View File

@ -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'];
}
}