--- a/application/p/logic/MealOrder.php +++ b/application/p/logic/MealOrder.php @@ -1670,6 +1670,8 @@ ->toArray(); if (!empty($data['data'])) { foreach ($data['data'] as $key => $item) { + $item = $this->normalizeConsumerOrderListRow($item); + $data['data'][$key] = $item; $data['data'][$key]['nickname'] = $item['user']['name'] ?? ''; $data['data'][$key]['equipment_name'] = $item['equipment']['name'] ?? ''; if ($item['pay_status'] == PayStatusEnum::PENDING) { @@ -1691,6 +1693,30 @@ $data['refund_amount'] = $this->model->where($where)->sum('refund_amount'); $data['pay_amount'] = helper::bcsub($data['pay_price'], $data['refund_amount']); return $data; + } + + /** Only the proven DECIMAL(10,2) and DATETIME(0) consumer-list projection. */ + private function normalizeConsumerOrderListRow(array $row): array + { + if (ltrim((string)\think\Config::get('database.type'), '\\') !== \app\cores\database\Dm::class) { + return $row; + } + foreach (['total_price', 'pay_price', 'cash_payment', 'subsidy_payment', 'gift_payment', + 'refund_amount', 'cash_refund_amount', 'subsidy_refund_amount', 'gift_refund_amount', 'remain_balance'] as $field) { + if (isset($row[$field]) && (is_int($row[$field]) || is_float($row[$field])) + && is_finite((float)$row[$field]) && abs($row[$field]) <= 99999999.99) { + $row[$field] = number_format((float)$row[$field], 2, '.', ''); + } + } + foreach (['bind_time', 'pay_time'] as $field) { + if (isset($row[$field]) && is_string($row[$field]) + && preg_match('/^((\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}))\.0{1,6}$/D', $row[$field], $match) + && (int)$match[2] >= 1000 && checkdate((int)$match[3], (int)$match[4], (int)$match[2]) + && (int)$match[5] <= 23 && (int)$match[6] <= 59 && (int)$match[7] <= 59) { + $row[$field] = $match[1]; + } + } + return $row; } /** --- a/application/p/logic/Api.php +++ b/application/p/logic/Api.php @@ -3331,11 +3331,24 @@ else $tmp['imageUrl'] = config('domain_name_oss').$hardImg[0]['head_img_url']; if ($type == 1) - $tmp['createTime'] = $hardImg[0]['create_time']; + $tmp['createTime'] = $this->normalizeFaceDataCreateTime($hardImg[0]['create_time']); } $data['data'][] = $tmp; } return array("code" => 0, "message" => "获取成功", "data" => $data); + } + + /** hardware_img.create_time is MySQL TIMESTAMP(0); no nonzero fractions are discarded. */ + private function normalizeFaceDataCreateTime($value) + { + if (ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class + && is_string($value) + && preg_match('/^((\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}))\.0{1,6}$/D', $value, $match) + && (int)$match[2] >= 1000 && checkdate((int)$match[3], (int)$match[4], (int)$match[2]) + && (int)$match[5] <= 23 && (int)$match[6] <= 59 && (int)$match[7] <= 59) { + return $match[1]; + } + return $value; } /**