[], 'attempts' => [], 'needs_review' => 0]; foreach ($records as $record) { $status = (string)($record['status'] ?? ''); if (in_array($status, ['paid', 'refunding', 'refunded', 'refund_failed'], true)) { $groups['settled'][] = $record; } else { $groups['attempts'][] = $record; if (!in_array($status, ['closed', 'pay_failed'], true)) $groups['needs_review']++; } } return $groups; } public static function paymentRecordType(array $record) { $openid = trim((string)($record['openid'] ?? '')); $number = (string)($record['out_trade_no'] ?? ''); if ($openid === 'BALANCE' || strpos($number, 'BAL') === 0) return '余额支付'; if ($openid !== '') return '微信支付'; return '未记录'; } public static function paymentType($value) { $value = trim((string)$value); $labels = ['wechat' => '微信支付', 'balance' => '余额支付', 'coupon' => '优惠券支付']; return $value === '' ? '未记录' : ($labels[$value] ?? ('其他(' . $value . ')')); } public static function operator($value) { $labels = ['user' => '用户', 'admin' => '管理员', 'master' => '师傅', 'merchant' => '商家', 'system' => '系统']; return $labels[(string)$value] ?? '未知'; } public static function amountLabel(array $order) { $status = (int)($order['pay_status'] ?? 0); if ($status === 1 || $status === 2) { return $status === 2 || (float)($order['refund_amount'] ?? 0) > 0 ? '已付金额(退款前)' : '已付金额'; } return (int)($order['status'] ?? 0) === 0 ? '订单应付金额' : '订单金额'; } public static function services($value, array $snapshot) { $value = trim((string)$value); if ($value === '') $value = '[]'; if ($value[0] !== '[' && $value[0] !== '{') return $value; $items = json_decode($value, true); if (!is_array($items) || json_last_error() !== JSON_ERROR_NONE) return ''; $parts = []; $name = trim((string)($snapshot['service_type_name'] ?? '')); $num = $snapshot['num'] ?? ($snapshot['goods_num'] ?? null); if ($name !== '' && is_numeric($num) && $num > 0) $parts[] = $name . 'x' . $num; foreach ($items as $item) { if (!is_array($item) || empty($item['name'])) continue; $count = $item['num'] ?? ($item['count'] ?? null); if ($count !== null && (!is_numeric($count) || $count <= 0)) continue; $parts[] = trim((string)$item['name']) . ($count === null ? '' : 'x' . $count); } return implode(';', $parts); } public static function quoteStatus($value) { $labels = ['wait' => '待确认', 'selected' => '已选定', 'accept' => '已选定', 'reject' => '未选定', 'expired' => '已过期']; return $labels[(string)$value] ?? '未知状态'; } }