更新
This commit is contained in:
@@ -379,6 +379,26 @@ class OrderLogic
|
||||
if (isset($params['order_type'])) {
|
||||
$order->order_type = (int)$params['order_type'];
|
||||
}
|
||||
// 支付时间参与营业额等统计,仅已支付/已退款订单允许修正且不可清空
|
||||
if (array_key_exists('payment_time', $params)) {
|
||||
$paymentTime = trim((string)$params['payment_time']);
|
||||
if (!in_array((int)$order->status, [2, 4], true)) {
|
||||
self::setError('仅已支付或已退款订单可修改支付时间');
|
||||
return false;
|
||||
}
|
||||
if ($paymentTime === '') {
|
||||
self::setError('已支付或已退款订单的支付时间不能为空');
|
||||
return false;
|
||||
}
|
||||
$order->payment_time = $paymentTime;
|
||||
}
|
||||
if (isset($params['create_time'])) {
|
||||
$createTime = (string)$params['create_time'];
|
||||
$order->create_time = self::normalizeEditedCreateTime(
|
||||
$order->getData('create_time'),
|
||||
$createTime
|
||||
);
|
||||
}
|
||||
|
||||
$order->save();
|
||||
return true;
|
||||
@@ -388,6 +408,18 @@ class OrderLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容历史库中 create_time 为 INT 时间戳的表结构
|
||||
*/
|
||||
private static function normalizeEditedCreateTime(mixed $storedValue, string $dateTime): int|string
|
||||
{
|
||||
if (is_int($storedValue) || (is_string($storedValue) && ctype_digit($storedValue))) {
|
||||
return (int)strtotime($dateTime);
|
||||
}
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付订单
|
||||
* @param int $id
|
||||
|
||||
Reference in New Issue
Block a user