更新系统bug
This commit is contained in:
@@ -1547,7 +1547,15 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
self::writeLog($id, $adminId, $adminInfo, 'complete', '订单完成,状态变更为「已完成」,实付金额更新为 ¥' . $linkedPayPaidTotal);
|
||||
$unassignSummary = self::clearDiagnosisAssistantOnComplete((int) $order->diagnosis_id);
|
||||
|
||||
self::writeLog(
|
||||
$id,
|
||||
$adminId,
|
||||
$adminInfo,
|
||||
'complete',
|
||||
'订单完成,状态变更为「已完成」,实付金额更新为 ¥' . $linkedPayPaidTotal . $unassignSummary
|
||||
);
|
||||
|
||||
$out = $order->toArray();
|
||||
self::maskInternalCostIfNeeded($out, $adminInfo);
|
||||
@@ -1556,6 +1564,50 @@ class PrescriptionOrderLogic
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成订单时把关联诊单的 assistant_id 清空,让患者回到「待分配」状态
|
||||
* 仅当该患者没有其它进行中的处方订单时才清空,避免误覆盖
|
||||
*
|
||||
* @return string 追加到操作日志的描述(无变更则返回空串)
|
||||
*/
|
||||
private static function clearDiagnosisAssistantOnComplete(int $diagnosisId): string
|
||||
{
|
||||
if ($diagnosisId <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
$diag = Diagnosis::where('id', $diagnosisId)->whereNull('delete_time')->find();
|
||||
if (!$diag) {
|
||||
return '';
|
||||
}
|
||||
$oldAssistant = (string) ($diag['assistant_id'] ?? '');
|
||||
if ($oldAssistant === '' || $oldAssistant === '0') {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 同一诊单下若仍有未完成/未取消的处方订单,则不清空
|
||||
$pendingCount = PrescriptionOrder::where('diagnosis_id', $diagnosisId)
|
||||
->whereNull('delete_time')
|
||||
->whereNotIn('fulfillment_status', [3, 4])
|
||||
->count();
|
||||
if ($pendingCount > 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
Diagnosis::where('id', $diagnosisId)
|
||||
->whereNull('delete_time')
|
||||
->update(['assistant_id' => '']);
|
||||
|
||||
return ';并已清空诊单医助分配(原 assistant_id=' . $oldAssistant . '),患者进入待分配状态';
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('clearDiagnosisAssistantOnComplete failed: ' . $e->getMessage(), [
|
||||
'diagnosis_id' => $diagnosisId,
|
||||
]);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表行是否展示「上传甘草药方」(需配置甘草、处方审核通过、未上传过、有权限;不要求支付审核)。
|
||||
*
|
||||
|
||||
@@ -24,5 +24,7 @@ return [
|
||||
'express:sync' => 'app\\command\\SyncTrackingNumbers',
|
||||
// 企业微信客户同步
|
||||
'qywx:sync-customer' => 'app\\command\\QywxSyncCustomer',
|
||||
// 甘草订单物流路由同步(GET_TASK_ROUTE_LIST)
|
||||
'gancao:sync-logistics' => 'app\\command\\GancaoSyncLogisticsRoute',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user