['text' => 'Cancel H&R'], self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'], self::BUSINESS_TYPE_BUY_ATTENDANCE_CARD => ['text' => 'Buy attendance card'], self::BUSINESS_TYPE_STICKY_PROMOTION => ['text' => 'Buy torrent sticky promotion'], self::BUSINESS_TYPE_POST_REWARD => ['text' => 'Reward post'], self::BUSINESS_TYPE_EXCHANGE_UPLOAD => ['text' => 'Exchange upload'], self::BUSINESS_TYPE_EXCHANGE_INVITE => ['text' => 'Exchange invite'], self::BUSINESS_TYPE_CUSTOM_TITLE => ['text' => 'Custom title'], self::BUSINESS_TYPE_BUY_VIP => ['text' => 'Buy VIP'], self::BUSINESS_TYPE_GIFT_TO_SOMEONE => ['text' => 'Gift to someone'], self::BUSINESS_TYPE_NO_AD => ['text' => 'No ad'], self::BUSINESS_TYPE_GIFT_TO_LOW_SHARE_RATIO => ['text' => 'Gift to low share ratio'], self::BUSINESS_TYPE_LUCKY_DRAW => ['text' => 'Lucky draw'], self::BUSINESS_TYPE_EXCHANGE_DOWNLOAD => ['text' => 'Exchange download'], self::BUSINESS_TYPE_BUY_TEMPORARY_INVITE => ['text' => 'Buy temporary invite'], self::BUSINESS_TYPE_BUY_RAINBOW_ID => ['text' => 'Buy rainbow ID'], self::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => ['text' => 'Buy change username card'], self::BUSINESS_TYPE_GIFT_MEDAL => ['text' => 'Gift medal to someone'], self::BUSINESS_TYPE_BUY_TORRENT => ['text' => 'Buy torrent'], self::BUSINESS_TYPE_ROLE_WORK_SALARY => ['text' => 'Role work salary'], self::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => ['text' => 'Torrent be downloaded'], self::BUSINESS_TYPE_RECEIVE_REWARD => ['text' => 'Receive reward'], ]; public function getBusinessTypeTextAttribute() { return nexus_trans('bonus-log.business_types.' . $this->business_type); } public static function getBonusForCancelHitAndRun() { $result = Setting::get('bonus.cancel_hr'); return $result ?? self::DEFAULT_BONUS_CANCEL_ONE_HIT_AND_RUN; } public static function getBonusForBuyAttendanceCard() { $result = Setting::get('bonus.attendance_card'); return $result ?? self::DEFAULT_BONUS_BUY_ATTENDANCE_CARD; } public static function getBonusForBuyTemporaryInvite() { $result = Setting::get('bonus.one_tmp_invite'); return $result ?? self::DEFAULT_BONUS_BUY_TEMPORARY_INVITE; } public static function getBonusForBuyRainbowId() { $result = Setting::get('bonus.rainbow_id'); return $result ?? self::DEFAULT_BONUS_BUY_RAINBOW_ID; } public static function getBonusForBuyChangeUsernameCard() { $result = Setting::get('bonus.change_username_card'); return $result ?? self::DEFAULT_BONUS_BUY_CHANGE_USERNAME_CARD; } public static function add(int $userId, float $old, float $delta, float $new, string $comment, int $businessType) { if (!isset(self::$businessTypes[$businessType])) { throw new \InvalidArgumentException("Invalid business type: $businessType"); } $nowStr = Carbon::now()->toDateTimeString(); return self::query()->create([ 'business_type' => $businessType, 'uid' => $userId, 'old_total_value' => $old, 'value' => $delta, 'new_total_value' => $new, 'comment' => sprintf("[%s] %s", self::$businessTypes[$businessType]['text'], $comment), 'created_at' => $nowStr, 'updated_at' => $nowStr, ]); } }