show->field($field, $label)->using([ 1 => '经验积分', 2 => '成就积分', 3 => '活动积分', 4 => '签到积分', 5 => '推荐积分', ]); } /** * 添加操作类型字段 * * @param string $field 字段名 * @param string $label 标签名 * @return void */ public function fieldOperateType(string $field = 'operate_type', string $label = '操作类型'): void { $this->show->field($field, $label)->using(LOG_TYPE::getAllTypes()); } /** * 添加积分余额字段 * * @param string $field 字段名 * @param string $label 标签名 * @return void */ public function fieldBalance(string $field = 'balance', string $label = '积分余额'): void { $this->show->field($field, $label)->as(function ($value) { return number_format($value); }); } /** * 添加积分数量字段 * * @param string $field 字段名 * @param string $label 标签名 * @return void */ public function fieldAmount(string $field = 'amount', string $label = '积分数量'): void { $this->show->field($field, $label)->as(function ($value) { $formattedValue = number_format(abs($value)); if ($value > 0) { return "+{$formattedValue}"; } elseif ($value < 0) { return "-{$formattedValue}"; } else { return $formattedValue; } }); } /** * 添加时间戳字段 * * @param string $field 字段名 * @param string $label 标签名 * @param string $format 日期格式 * @return void */ public function fieldTimestamp(string $field, string $label, string $format = 'Y-m-d H:i:s'): void { $this->show->field($field, $label)->as(function ($value) use ($format) { return $value ? date($format, $value) : ''; }); } /** * 添加状态字段 * * @param string $field 字段名 * @param string $label 标签名 * @return void */ public function fieldStatus(string $field = 'status', string $label = '状态'): void { $this->show->field($field, $label)->using([ 0 => '待处理', 1 => '已完成', 2 => '已失败', ]); } /** * 添加订单类型字段 * * @param string $field 字段名 * @param string $label 标签名 * @return void */ public function fieldOrderType(string $field = 'order_type', string $label = '订单类型'): void { $this->show->field($field, $label)->using([ 'exchange' => '积分兑换', 'consume' => '积分消费', 'reward' => '积分奖励', 'refund' => '积分退款', ]); } /** * 添加JSON数据字段 * * @param string $field 字段名 * @param string $label 标签名 * @return void */ public function fieldJson(string $field, string $label): void { $this->show->field($field, $label)->as(function ($value) { if (is_array($value)) { return '
' . json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . ''; } return $value; }); } /** * 添加积分流转信息字段 * * @param string $label 标签名 * @return void */ public function fieldCirculationInfo(string $label = '流转信息'): void { $this->show->field('user_id', $label)->as(function ($userId) { $fromPointId = $this->from_point_id; $toPointId = $this->to_point_id; $pointTypes = [ 1 => '经验积分', 2 => '成就积分', 3 => '活动积分', 4 => '签到积分', 5 => '推荐积分', ]; if (is_object($fromPointId)) { $fromPointId = $fromPointId->value; } if (is_object($toPointId)) { $toPointId = $toPointId->value; } $fromPointName = $pointTypes[$fromPointId] ?? "积分{$fromPointId}"; $toPointName = $pointTypes[$toPointId] ?? "积分{$toPointId}"; return "用户: {$userId}