更新
This commit is contained in:
@@ -924,9 +924,47 @@ class OrderLogic
|
||||
return count(array_intersect($myRoles, $supervisorRoles)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务订单可关联支付单列表:仅展示创建时间在此日 0 点及之后的支付单(编辑时当前单已关联的旧单仍保留在列表中)
|
||||
*/
|
||||
private static function payOrderLinkableMinCreateTs(): int
|
||||
{
|
||||
return strtotime('2026-04-20 00:00:00');
|
||||
}
|
||||
|
||||
/**
|
||||
* zyt_order.create_time 可能为 int 时间戳或 datetime 字符串,不可直接 (int) 强转(字符串会得到 0)
|
||||
*/
|
||||
private static function orderCreateTimeToUnix(mixed $value): int
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return 0;
|
||||
}
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return $value->getTimestamp();
|
||||
}
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_float($value)) {
|
||||
return (int) $value;
|
||||
}
|
||||
if (is_string($value)) {
|
||||
if (is_numeric($value) && strlen($value) <= 12) {
|
||||
return (int) $value;
|
||||
}
|
||||
$ts = strtotime($value);
|
||||
|
||||
return $ts !== false ? $ts : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 某诊单下可关联的支付单(待支付/已支付),供关联业务订单多选(主管/诊单医助看该诊单全部;否则仅本人创建)
|
||||
* 已占用(关联到未撤回/未取消的业务订单)的支付单会排除;编辑某业务订单时传 $exceptPrescriptionOrderId 以保留当前单已选中的项
|
||||
* 列表仅含 2026-04-20 及之后创建的支付单(已关联到当前编辑业务订单的除外)
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
@@ -974,6 +1012,7 @@ class OrderLogic
|
||||
);
|
||||
}
|
||||
|
||||
$minCreateTs = self::payOrderLinkableMinCreateTs();
|
||||
$out = [];
|
||||
foreach ($rows as $row) {
|
||||
$oid = (int) ($row['id'] ?? 0);
|
||||
@@ -985,6 +1024,10 @@ class OrderLogic
|
||||
if ($busy && ! $allowed) {
|
||||
continue;
|
||||
}
|
||||
$ct = self::orderCreateTimeToUnix($row['create_time'] ?? null);
|
||||
if ($ct < $minCreateTs && ! $allowed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$out[] = $row;
|
||||
}
|
||||
@@ -994,11 +1037,17 @@ class OrderLogic
|
||||
|
||||
/**
|
||||
* 校验支付单均可关联到指定诊单(已支付、归属与权限)
|
||||
* 默认仅允许关联 2026-04-20 及之后创建的支付单;编辑业务订单时传入 $prescriptionOrderIdForDateGrace,已关联到该业务订单的旧单除外
|
||||
*
|
||||
* @param int[] $ids zyt_order.id
|
||||
*/
|
||||
public static function assertPayOrdersLinkable(array $ids, int $diagnosisId, int $adminId, array $adminInfo): ?string
|
||||
{
|
||||
public static function assertPayOrdersLinkable(
|
||||
array $ids,
|
||||
int $diagnosisId,
|
||||
int $adminId,
|
||||
array $adminInfo,
|
||||
?int $prescriptionOrderIdForDateGrace = null
|
||||
): ?string {
|
||||
$ids = array_values(array_unique(array_filter(array_map('intval', $ids), static fn(int $v): bool => $v > 0)));
|
||||
if ($diagnosisId <= 0) {
|
||||
return '诊单无效';
|
||||
@@ -1021,6 +1070,7 @@ class OrderLogic
|
||||
return '部分支付单不存在或已删除';
|
||||
}
|
||||
|
||||
$minTs = self::payOrderLinkableMinCreateTs();
|
||||
foreach ($orders as $o) {
|
||||
if ((int) $o->patient_id !== $diagnosisId) {
|
||||
return '支付单与诊单不匹配';
|
||||
@@ -1031,6 +1081,18 @@ class OrderLogic
|
||||
if (! $supervisor && ! $isDiagAssistant && (int) $o->creator_id !== $adminId) {
|
||||
return '无权限关联所选支付单';
|
||||
}
|
||||
$ct = self::orderCreateTimeToUnix($o->create_time ?? null);
|
||||
if ($ct < $minTs) {
|
||||
$grace = false;
|
||||
if ($prescriptionOrderIdForDateGrace !== null && $prescriptionOrderIdForDateGrace > 0) {
|
||||
$grace = PrescriptionOrderPayOrder::where('prescription_order_id', $prescriptionOrderIdForDateGrace)
|
||||
->where('pay_order_id', (int) $o->id)
|
||||
->count() > 0;
|
||||
}
|
||||
if (! $grace) {
|
||||
return '仅可关联 2026年4月20日及之后创建的支付单';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user