更新
This commit is contained in:
@@ -8,6 +8,7 @@ use app\adminapi\logic\auth\AuthLogic;
|
||||
use app\adminapi\logic\order\OrderLogic;
|
||||
use app\common\model\Order;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\model\tcm\DiagnosisAssignLog;
|
||||
use app\common\model\tcm\Prescription;
|
||||
use app\common\model\tcm\PrescriptionOrder;
|
||||
use app\common\model\tcm\PrescriptionOrderLog;
|
||||
@@ -117,12 +118,8 @@ class PrescriptionOrderLogic
|
||||
if (self::canSeeAllPrescriptionOrders($adminInfo)) {
|
||||
return true;
|
||||
}
|
||||
if ((int) $row->creator_id === $adminId) {
|
||||
return true;
|
||||
}
|
||||
$aid = (int) Diagnosis::where('id', (int) $row->diagnosis_id)->whereNull('delete_time')->value('assistant_id');
|
||||
|
||||
return $aid === $adminId;
|
||||
return (int) $row->creator_id === $adminId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -948,7 +945,7 @@ class PrescriptionOrderLogic
|
||||
*
|
||||
* @return array<string,mixed>|false
|
||||
*/
|
||||
public static function ship(int $id, string $expressCompany, string $trackingNumber, int $adminId, array $adminInfo)
|
||||
public static function ship(int $id, string $expressCompany, string $trackingNumber, string $shipMode, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
|
||||
@@ -976,6 +973,9 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
$shipMode = self::normalizeShipMode($shipMode);
|
||||
$shipModeText = $shipMode === 'direct' ? '药房直发' : '甘草药方发';
|
||||
|
||||
$order->express_company = self::normalizeExpressCompany($expressCompany);
|
||||
$order->tracking_number = $trackingNumber;
|
||||
// 仅履约中(2)时才推进到已发货(5),已发货(5)则只更新快递信息保持状态
|
||||
@@ -994,9 +994,21 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
|
||||
if ($isFirstShip) {
|
||||
self::writeLog((int) $order->id, $adminId, $adminInfo, 'ship', '确认发货,运单:' . $trackingNumber . '(' . $expressCompany . ')');
|
||||
self::writeLog(
|
||||
(int) $order->id,
|
||||
$adminId,
|
||||
$adminInfo,
|
||||
'ship',
|
||||
'确认发货(' . $shipModeText . '),运单:' . $trackingNumber . '(' . $expressCompany . ')'
|
||||
);
|
||||
} else {
|
||||
self::writeLog((int) $order->id, $adminId, $adminInfo, 'fill_tracking', '更新发货信息,运单:' . $trackingNumber . '(' . $expressCompany . ')');
|
||||
self::writeLog(
|
||||
(int) $order->id,
|
||||
$adminId,
|
||||
$adminInfo,
|
||||
'fill_tracking',
|
||||
'更新发货信息(' . $shipModeText . '),运单:' . $trackingNumber . '(' . $expressCompany . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$out = $order->toArray();
|
||||
@@ -1006,6 +1018,16 @@ class PrescriptionOrderLogic
|
||||
return $out;
|
||||
}
|
||||
|
||||
private static function normalizeShipMode(string $shipMode): string
|
||||
{
|
||||
$s = strtolower(trim($shipMode));
|
||||
if ($s === 'direct') {
|
||||
return 'direct';
|
||||
}
|
||||
|
||||
return 'gancao';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>|false
|
||||
*/
|
||||
@@ -1771,7 +1793,7 @@ class PrescriptionOrderLogic
|
||||
|
||||
/**
|
||||
* 完成订单时把关联诊单的 assistant_id 清空,让患者回到「待分配」状态
|
||||
* 仅当该患者没有其它进行中的处方订单时才清空,避免误覆盖
|
||||
* 仅当该患者没有其它进行中的处方订单且无指派日志时才清空,避免误覆盖
|
||||
*
|
||||
* @return string 追加到操作日志的描述(无变更则返回空串)
|
||||
*/
|
||||
@@ -1791,6 +1813,14 @@ class PrescriptionOrderLogic
|
||||
return '';
|
||||
}
|
||||
|
||||
// 存在医助指派日志时,保留当前医助分配,不自动清空
|
||||
$assignLogCount = DiagnosisAssignLog::where('diagnosis_id', $diagnosisId)
|
||||
->whereNull('delete_time')
|
||||
->count();
|
||||
if ($assignLogCount > 0) {
|
||||
return ';检测到该患者已有医助指派记录,保留当前医助分配(assistant_id=' . $oldAssistant . ')';
|
||||
}
|
||||
|
||||
// 同一诊单下若仍有未完成/未取消的处方订单,则不清空
|
||||
$pendingCount = PrescriptionOrder::where('diagnosis_id', $diagnosisId)
|
||||
->whereNull('delete_time')
|
||||
|
||||
Reference in New Issue
Block a user