业务订单已发货后不能再修改服用天数
- 已发货判定:履约状态已发货/已签收/已完成,或已填快递单号,或药房回传已发货(洛阳 SHIPPED/COMPLETED、甘草 20/30) - 已发货后「修改服用参数」与订单编辑中的主方/辅方开立天数、订单服用天数不可修改(服务端拦截);次数、袋数仍可改; 订单未单独设置天数时以处方开立天数为准,不会误判为修改 - 订单详情返回 days_locked,详情抽屉、订单列表(含 H5)编辑时禁用天数输入并提示 - 重新构建管理后台 Co-Authored-By: Claude Opus 5 <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
b675822377
commit
18a0989c00
@@ -1484,6 +1484,8 @@ class PrescriptionOrderLogic
|
||||
$adminInfo,
|
||||
$diagIdForMeta > 0 ? [$diagIdForMeta => (int) ($arr['assistant_id'] ?? 0)] : []
|
||||
);
|
||||
// 已发货后服用天数锁定(前端据此禁用天数输入,服务端同样拦截)。
|
||||
$arr['days_locked'] = self::isOrderShipped($row->toArray());
|
||||
|
||||
return $arr;
|
||||
}
|
||||
@@ -2035,6 +2037,12 @@ class PrescriptionOrderLogic
|
||||
|
||||
$medDays = $params['medication_days'] ?? null;
|
||||
$medDays = $medDays === '' || $medDays === null ? null : (int) $medDays;
|
||||
if (self::isOrderShipped($order->toArray())
|
||||
&& (int) ($medDays ?? 0) !== (int) ($order->medication_days ?? 0)) {
|
||||
self::$error = self::SHIPPED_DAYS_LOCKED;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$order->recipient_name = (string) $params['recipient_name'];
|
||||
$order->recipient_phone = (string) $params['recipient_phone'];
|
||||
@@ -5969,6 +5977,17 @@ class PrescriptionOrderLogic
|
||||
return null;
|
||||
}
|
||||
|
||||
public const SHIPPED_DAYS_LOCKED = '订单已发货,不能再修改服用天数';
|
||||
|
||||
/** 已发货:履约已完成/已发货/已签收,或已填快递单号,或药房回传已发货(洛阳 SHIPPED/COMPLETED,甘草 20/30)。 */
|
||||
public static function isOrderShipped(array $order): bool
|
||||
{
|
||||
return in_array((int) ($order['fulfillment_status'] ?? 0), [3, 5, 6], true)
|
||||
|| trim((string) ($order['tracking_number'] ?? '')) !== ''
|
||||
|| in_array(strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))), ['SHIPPED', 'COMPLETED'], true)
|
||||
|| in_array((int) ($order['gancao_order_state'] ?? 0), [20, 30], true);
|
||||
}
|
||||
|
||||
/** 处方作废时可随重新开方迁移的订单状态:待审核(1)、履约中(2);已发货/已完成的订单按原处方留档。 */
|
||||
private const REISSUE_FOLLOW_STATUSES = [1, 2];
|
||||
|
||||
@@ -6193,6 +6212,19 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
}
|
||||
|
||||
// 已发货后天数随药品已定,不可再改;次数、袋数等仍可修正。
|
||||
if (self::isOrderShipped($order->toArray())) {
|
||||
$oldUsage = is_array($rx->aux_usage) ? $rx->aux_usage : (json_decode((string) $rx->aux_usage, true) ?: []);
|
||||
// 订单未单独设置天数时,以处方开立天数为准(弹窗会用它预填)。
|
||||
$effectiveMedDays = (int) ($order->medication_days ?? 0) ?: (int) ($rx->usage_days ?? 0);
|
||||
if ($usageDays !== (int) ($rx->usage_days ?? 0) || $medDays !== $effectiveMedDays
|
||||
|| ($hasAux && $auxUsageDays !== (int) ($oldUsage['usage_days'] ?? 0))) {
|
||||
self::setError(self::SHIPPED_DAYS_LOCKED);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$oldTimes = (int) ($rx->times_per_day ?? 0);
|
||||
$oldUsageDays = (int) ($rx->usage_days ?? 0);
|
||||
$oldDosageBagCount = max(1, (int) ($rx->dosage_bag_count ?? 1));
|
||||
|
||||
Reference in New Issue
Block a user