优化积分修改时的备注写入适配多语言
This commit is contained in:
@@ -15,7 +15,7 @@ class PointsLog extends Backend
|
||||
protected ?object $model = null;
|
||||
|
||||
protected array $withJoinTable = ['userAsset', 'admin'];
|
||||
protected array|string $preExcludeFields = ['id', 'before', 'after', 'memo', 'admin_id', 'create_time'];
|
||||
protected array|string $preExcludeFields = ['id', 'before', 'after', 'admin_id', 'create_time'];
|
||||
protected array|string $quickSearchField = [
|
||||
'userAsset.playx_user_id',
|
||||
'userAsset.username',
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'User asset' => 'User asset',
|
||||
'Points adjustment' => 'Points adjustment',
|
||||
'User asset not found' => 'User asset not found',
|
||||
'Points adjustment must be a non-zero integer' => 'Points adjustment must be a non-zero integer',
|
||||
'Insufficient available points' => 'Insufficient available points',
|
||||
'Administrator added %s points' => 'Administrator added %s points',
|
||||
'Administrator deducted %s points' => 'Administrator deducted %s points',
|
||||
'Points log cannot be modified' => 'Points log cannot be modified',
|
||||
'Points log cannot be deleted' => 'Points log cannot be deleted',
|
||||
];
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'User asset' => '用户资产',
|
||||
'Points adjustment' => '调整积分',
|
||||
'User asset not found' => '用户资产不存在',
|
||||
'Points adjustment must be a non-zero integer' => '调整积分必须为非零整数',
|
||||
'Insufficient available points' => '可用积分不足',
|
||||
'Administrator added %s points' => '管理员增加积分 %s',
|
||||
'Administrator deducted %s points' => '管理员扣除积分 %s',
|
||||
'Points log cannot be modified' => '积分流水不允许修改',
|
||||
'Points log cannot be deleted' => '积分流水不允许删除',
|
||||
];
|
||||
@@ -37,9 +37,19 @@ class MallPointsLog extends \app\common\model\MallPointsLog
|
||||
$model->before = $before;
|
||||
$model->after = $after;
|
||||
$pointsAbs = abs($scoreValue);
|
||||
$model->memo = $scoreValue > 0
|
||||
? sprintf(__('Administrator added %s points'), $pointsAbs)
|
||||
: sprintf(__('Administrator deducted %s points'), $pointsAbs);
|
||||
$memo = trim(strval($model->getData('memo') ?? ''));
|
||||
if ($memo === '') {
|
||||
$memo = $scoreValue > 0
|
||||
? sprintf(__('Administrator added %s points'), $pointsAbs)
|
||||
: sprintf(__('Administrator deducted %s points'), $pointsAbs);
|
||||
} else {
|
||||
if (function_exists('mb_substr')) {
|
||||
$memo = mb_substr($memo, 0, 255);
|
||||
} else {
|
||||
$memo = substr($memo, 0, 255);
|
||||
}
|
||||
}
|
||||
$model->memo = $memo;
|
||||
|
||||
$userAsset->available_points = $after;
|
||||
$userAsset->save();
|
||||
|
||||
Reference in New Issue
Block a user