diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 387e07fd..ec521724 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -88,6 +88,16 @@ class BaseController { return phpcommon\getMondaySeconds($time, $this->timeZone); } + public function _getMonthFirstDaySeconds() + { + return phpcommon\getThisMonthFirstDaySeconds($this->_getNowTime(), $this->timeZone); + } + + public function _getMonthFirstDaySecondsByTime($time) + { + return phpcommon\getThisMonthFirstDaySeconds($time, $this->timeZone); + } + public function _inTimeRangeStr($beginTimeStr, $endTimeStr) { $beginTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $beginTimeStr)); diff --git a/webapp/models/HashRateShopBuyRecord.php b/webapp/models/HashRateShopBuyRecord.php index b7bbdacd..5e4ad9b0 100644 --- a/webapp/models/HashRateShopBuyRecord.php +++ b/webapp/models/HashRateShopBuyRecord.php @@ -74,6 +74,11 @@ class HashRateShopBuyRecord extends BaseModel $cond = " last_buy_time>=${mondaySeconds} AND last_buy_time<=${mondaySeconds} + 3600 * 24 * 7 "; return "CASE WHEN (${cond}) THEN this_week_buy_times + ${goodsNum} ELSE 0 END"; }, + 'this_month_buy_times' => function () use($goodsNum) { + $mondaySeconds = myself()->_getMondaySeconds(); + $cond = " last_buy_time>=${mondaySeconds} AND last_buy_time<=${mondaySeconds} + 3600 * 24 * 7 "; + return "CASE WHEN (${cond}) THEN this_month_buy_times + ${goodsNum} ELSE 0 END"; + }, 'total_buy_times' => function () use($goodsNum) { return 'total_buy_times + ${goodsNum}'; }, @@ -86,6 +91,7 @@ class HashRateShopBuyRecord extends BaseModel 'item_id' => $itemId, 'this_day_buy_times' => $goodsNum, 'this_week_buy_times' => $goodsNum, + 'this_month_buy_times' => $goodsNum, 'total_buy_times' => $goodsNum, 'last_buy_time' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),