mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-22 10:57:27 +08:00
bonus log add time field
This commit is contained in:
@@ -55,13 +55,15 @@ class BonusLogResource extends Resource
|
||||
,
|
||||
Tables\Columns\TextColumn::make('old_total_value')
|
||||
->label(__('bonus-log.fields.old_total_value'))
|
||||
->formatStateUsing(fn ($state) => number_format($state))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('value')
|
||||
->formatStateUsing(fn ($record) => $record->old_total_value > $record->new_total_value ? "-" . $record->value : "+" . $record->value)
|
||||
->formatStateUsing(fn ($record) => $record->old_total_value > $record->new_total_value ? "-" . number_format($record->value) : "+" . number_format($record->value))
|
||||
->label(__('bonus-log.fields.value'))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('new_total_value')
|
||||
->label(__('bonus-log.fields.new_total_value'))
|
||||
->formatStateUsing(fn ($state) => number_format($state))
|
||||
,
|
||||
Tables\Columns\TextColumn::make('comment')
|
||||
->label(__('label.comment'))
|
||||
|
||||
@@ -9,6 +9,8 @@ class BonusLogs extends NexusModel
|
||||
|
||||
protected $fillable = ['uid', 'business_type', 'old_total_value', 'value', 'new_total_value', 'comment'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
const DEFAULT_BONUS_CANCEL_ONE_HIT_AND_RUN = 10000;
|
||||
const DEFAULT_BONUS_BUY_ATTENDANCE_CARD = 1000;
|
||||
const DEFAULT_BONUS_BUY_TEMPORARY_INVITE = 500;
|
||||
|
||||
@@ -283,6 +283,7 @@ class BonusRepository extends BaseRepository
|
||||
do_log("update user seedbonus affected rows != 1, query: " . last_query(), 'error');
|
||||
throw new \RuntimeException("Update user seedbonus fail.");
|
||||
}
|
||||
$nowStr = now()->toDateTimeString();
|
||||
$bonusLog = [
|
||||
'business_type' => $logBusinessType,
|
||||
'uid' => $user->id,
|
||||
@@ -290,6 +291,8 @@ class BonusRepository extends BaseRepository
|
||||
'value' => $requireBonus,
|
||||
'new_total_value' => $newUserBonus,
|
||||
'comment' => sprintf('[%s] %s', BonusLogs::$businessTypes[$logBusinessType]['text'], $logComment),
|
||||
'created_at' => $nowStr,
|
||||
'updated_at' => $nowStr,
|
||||
];
|
||||
BonusLogs::query()->insert($bonusLog);
|
||||
do_log("bonusLog: " . nexus_json_encode($bonusLog));
|
||||
|
||||
Reference in New Issue
Block a user