更新
This commit is contained in:
@@ -36,6 +36,7 @@ use app\common\service\pharmacy\LockedPharmacySnapshotMutation;
|
||||
use app\common\service\pharmacy\PharmacySubmissionClaimService;
|
||||
use app\common\service\pharmacy\PharmacySubmissionClaimWorkflow;
|
||||
use app\common\service\pharmacy\PharmacySupplyMode;
|
||||
use app\common\service\tcm\RevisitDueHook;
|
||||
use think\db\Query;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
@@ -979,7 +980,7 @@ class PrescriptionOrderLogic
|
||||
{
|
||||
self::$error = '';
|
||||
try {
|
||||
return Db::transaction(static function () use ($params, $adminId, $adminInfo) {
|
||||
$created = Db::transaction(static function () use ($params, $adminId, $adminInfo) {
|
||||
// 先锁始终存在的处方行;空订单集合也能串行化两次创建。
|
||||
// 首个一致性读发生在获得该锁后,等待者可见前一次创建提交的订单。
|
||||
$rx = Prescription::where('id', (int) ($params['prescription_id'] ?? 0))
|
||||
@@ -998,6 +999,13 @@ class PrescriptionOrderLogic
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 事务提交后刷新复诊到期快照(新订单开启新周期;钩子内部吞异常,不影响创建结果)
|
||||
if (is_array($created)) {
|
||||
RevisitDueHook::onOrderChanged((int) ($created['diagnosis_id'] ?? 0), (int) ($created['id'] ?? 0), 'create');
|
||||
}
|
||||
|
||||
return $created;
|
||||
}
|
||||
|
||||
private static function createLocked(array $params, int $adminId, array $adminInfo)
|
||||
@@ -1165,7 +1173,7 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
|
||||
try {
|
||||
return Db::transaction(static function () use ($params, $adminId, $adminInfo) {
|
||||
$edited = Db::transaction(static function () use ($params, $adminId, $adminInfo) {
|
||||
$order = PrescriptionOrder::where('id', (int) $params['id'])
|
||||
->whereNull('delete_time')->lock(true)->find();
|
||||
if (!$order) {
|
||||
@@ -1192,6 +1200,13 @@ class PrescriptionOrderLogic
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 事务提交后刷新复诊到期快照:下单时间影响锚点/诊次;返回体不含 diagnosis_id,由钩子按订单 id 反查
|
||||
if (is_array($edited)) {
|
||||
RevisitDueHook::onOrderChanged(0, (int) ($edited['id'] ?? 0), 'edit_time');
|
||||
}
|
||||
|
||||
return $edited;
|
||||
}
|
||||
|
||||
public static function detail(int $id, int $adminId, array $adminInfo): ?array
|
||||
@@ -2251,7 +2266,7 @@ class PrescriptionOrderLogic
|
||||
{
|
||||
self::setError('');
|
||||
try {
|
||||
return LockedPharmacySnapshotMutation::execute(
|
||||
$withdrawn = LockedPharmacySnapshotMutation::execute(
|
||||
$id,
|
||||
static fn () => self::withdrawLocked($id, $adminId, $adminInfo)
|
||||
);
|
||||
@@ -2261,6 +2276,13 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 事务提交后刷新复诊到期快照(撤回置 4,订单退出有效口径;钩子内部吞异常)
|
||||
if (is_array($withdrawn)) {
|
||||
RevisitDueHook::onOrderChanged((int) ($withdrawn['diagnosis_id'] ?? 0), $id, 'withdraw');
|
||||
}
|
||||
|
||||
return $withdrawn;
|
||||
}
|
||||
|
||||
private static function withdrawLocked(int $id, int $adminId, array $adminInfo)
|
||||
@@ -3303,6 +3325,9 @@ class PrescriptionOrderLogic
|
||||
$logLine
|
||||
);
|
||||
|
||||
// 刷新复诊到期快照(9/10 退出有效口径,终态可能释放医助;钩子内部吞异常)
|
||||
RevisitDueHook::onOrderChanged((int) $order->diagnosis_id, $id, 'complete:' . $targetFulfillmentStatus);
|
||||
|
||||
$out = $order->toArray();
|
||||
self::maskInternalCostIfNeeded($out, $adminInfo);
|
||||
self::maskRemarkExtraIfNeeded($out, $adminInfo);
|
||||
@@ -3478,6 +3503,9 @@ class PrescriptionOrderLogic
|
||||
|
||||
self::writeLog($id, $adminId, $adminInfo, 'refund', $logLine);
|
||||
|
||||
// 刷新复诊到期快照(全额退款置 10 退出有效口径并可能释放医助;钩子内部吞异常)
|
||||
RevisitDueHook::onOrderChanged((int) $order->diagnosis_id, $id, 'refund');
|
||||
|
||||
$out = $order->toArray();
|
||||
$out['this_refund_amount'] = $refundAmount;
|
||||
$out['refund_full'] = $isFullRefund;
|
||||
|
||||
Reference in New Issue
Block a user