This commit is contained in:
Your Name
2026-06-04 09:57:14 +08:00
parent 26b2cde699
commit 32f8e19bf1
4 changed files with 15 additions and 8 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ use think\console\Output;
* 使用方法: * 使用方法:
* php think express:auto-update * php think express:auto-update
* *
* 配置 crontab(每 10 分钟):拉快递 100 + 按履约「已发货/已签收」核对释放诊单医助(与是否甘草单无关) * 配置 crontab(每 10 分钟):拉快递 100 + 按履约「已发货」核对释放诊单医助(跳过已完成/已签收业务单,与是否甘草单无关)
* 0,10,20,30,40,50 * * * * cd /path/to/server && php think express:auto-update >> /dev/null 2>&1 * 0,10,20,30,40,50 * * * * cd /path/to/server && php think express:auto-update >> /dev/null 2>&1
* *
* 已对「业务订单创建人非二中心」(或创建人为开方医生时按待释放身份判定)执行发货/签收自动释放的诊单会写入 tcm_diagnosis.shipped_non_er_assistant_cleared_at * 已对「业务订单创建人非二中心」(或创建人为开方医生时按待释放身份判定)执行发货/签收自动释放的诊单会写入 tcm_diagnosis.shipped_non_er_assistant_cleared_at
@@ -46,7 +46,7 @@ class ExpressAutoUpdate extends Command
$output->writeln("成功: {$result['success']}"); $output->writeln("成功: {$result['success']}");
$output->writeln("失败: {$result['failed']}"); $output->writeln("失败: {$result['failed']}");
$output->writeln("医助已移除(物流任务+指派日志): " . (int) ($result['assistant_cleared'] ?? 0)); $output->writeln("医助已移除(物流任务+指派日志): " . (int) ($result['assistant_cleared'] ?? 0));
$output->writeln("医助已移除(履约已发货/签收核对): " . (int) ($recon['cleared'] ?? 0) . " (扫描 " . (int) ($recon['scanned'] ?? 0) . " 单)"); $output->writeln("医助已移除(履约已发货核对): " . (int) ($recon['cleared'] ?? 0) . " (扫描 " . (int) ($recon['scanned'] ?? 0) . " 单)");
$lines = array_merge($result['assistant_lines'] ?? [], $recon['lines'] ?? []); $lines = array_merge($result['assistant_lines'] ?? [], $recon['lines'] ?? []);
if ($lines === []) { if ($lines === []) {
$output->writeln('医助明细: (无)'); $output->writeln('医助明细: (无)');
@@ -30,6 +30,7 @@ use think\console\Output;
* 建议 crontab(每 30 分钟执行一次): * 建议 crontab(每 30 分钟执行一次):
* 0,30 * * * * cd /path/to/server && php think gancao:sync-logistics --limit=200 >> runtime/log/gancao_sync.log 2>&1 * 0,30 * * * * cd /path/to/server && php think gancao:sync-logistics --limit=200 >> runtime/log/gancao_sync.log 2>&1
* *
* 跳过履约状态为已完成(3)、已签收(6) 的业务订单,不再拉取甘草路由。
* 已对「业务订单创建人非二中心」(发货/签收自动释放规则见 ExpressTrackingService)的诊单会写入 tcm_diagnosis.shipped_non_er_assistant_cleared_at * 已对「业务订单创建人非二中心」(发货/签收自动释放规则见 ExpressTrackingService)的诊单会写入 tcm_diagnosis.shipped_non_er_assistant_cleared_at
* 后续履约核对不再重复扫描(需先执行 sql/1.9.20260507/add_diagnosis_shipped_non_er_assistant_cleared_at.sql)。 * 后续履约核对不再重复扫描(需先执行 sql/1.9.20260507/add_diagnosis_shipped_non_er_assistant_cleared_at.sql)。
*/ */
@@ -123,7 +124,7 @@ class GancaoSyncLogisticsRoute extends Command
$output->writeln('成功:' . $stats['success']); $output->writeln('成功:' . $stats['success']);
$output->writeln('失败:' . $stats['failed']); $output->writeln('失败:' . $stats['failed']);
$output->writeln('医助已移除(甘草同步+指派日志):' . (int) ($stats['assistant_cleared'] ?? 0)); $output->writeln('医助已移除(甘草同步+指派日志):' . (int) ($stats['assistant_cleared'] ?? 0));
$output->writeln('医助已移除(履约已发货/签收核对):' . (int) ($stats['reconcile_cleared'] ?? 0) . '(扫描 ' . (int) ($stats['reconcile_scanned'] ?? 0) . ' 单)'); $output->writeln('医助已移除(履约已发货核对):' . (int) ($stats['reconcile_cleared'] ?? 0) . '(扫描 ' . (int) ($stats['reconcile_scanned'] ?? 0) . ' 单)');
$lines = array_merge($stats['assistant_lines'] ?? [], $stats['reconcile_lines'] ?? []); $lines = array_merge($stats['assistant_lines'] ?? [], $stats['reconcile_lines'] ?? []);
if ($lines === []) { if ($lines === []) {
$output->writeln('医助明细:(无)'); $output->writeln('医助明细:(无)');
@@ -873,7 +873,7 @@ class ExpressTrackingService
} }
/** /**
* 按处方订单履约核对:已发货(5)/已签收(6) 时符合条件的订单调用 applyAssistantReleaseForShippedPrescriptionOrder。 * 按处方订单履约核对:已发货(5) 时符合条件的订单调用 applyAssistantReleaseForShippedPrescriptionOrder(已完成/已签收不再扫描)
* 与快递 100 / 甘草来自哪个物流渠道无关;是否清空医助以该方法为准(**二中心豁免看业务单创建人**参见 apply;已 shipped 释放且 assistant_id=0 视为已处理)。 * 与快递 100 / 甘草来自哪个物流渠道无关;是否清空医助以该方法为准(**二中心豁免看业务单创建人**参见 apply;已 shipped 释放且 assistant_id=0 视为已处理)。
* *
* @return array{scanned: int, cleared: int, lines: list<string>} * @return array{scanned: int, cleared: int, lines: list<string>}
@@ -888,7 +888,7 @@ class ExpressTrackingService
->whereNull('po.delete_time') ->whereNull('po.delete_time')
->whereNull('d.delete_time') ->whereNull('d.delete_time')
->whereRaw('(IFNULL(d.shipped_non_er_assistant_cleared_at, 0) = 0 OR d.assistant_id > 0)') ->whereRaw('(IFNULL(d.shipped_non_er_assistant_cleared_at, 0) = 0 OR d.assistant_id > 0)')
->whereIn('po.fulfillment_status', [5, 6]) ->where('po.fulfillment_status', 5)
->where('po.diagnosis_id', '>', 0) ->where('po.diagnosis_id', '>', 0)
->where(function ($w) { ->where(function ($w) {
$w->where('d.assistant_id', '>', 0) $w->where('d.assistant_id', '>', 0)
@@ -435,7 +435,7 @@ final class GancaoLogisticsRouteService
} }
/** /**
* 批量同步:选取候选订单(已上传甘草、且未签收/未取消的) * 批量同步:选取候选订单(已上传甘草、且未完成/未签收/未取消的)
* *
* @return array{total:int, success:int, failed:int, skipped:int, assistant_cleared:int, assistant_skipped_assign_log:int, assistant_lines:list<string>, details:array<int, array<string,mixed>>} * @return array{total:int, success:int, failed:int, skipped:int, assistant_cleared:int, assistant_skipped_assign_log:int, assistant_lines:list<string>, details:array<int, array<string,mixed>>}
*/ */
@@ -464,8 +464,8 @@ final class GancaoLogisticsRouteService
$w->whereIn('gancao_order_state', [110, 20, 30, 90]) $w->whereIn('gancao_order_state', [110, 20, 30, 90])
->whereOr('tracking_number', '<>', ''); ->whereOr('tracking_number', '<>', '');
}); });
// 排除已取消(4)、已签收(6);已完成(3)仍跑一次以补齐路由 // 排除已完成(3)、已取消(4)、已签收(6)
$q->whereNotIn('fulfillment_status', [4, 6]); $q->whereNotIn('fulfillment_status', [3, 4, 6]);
} }
$orders = $q->order('id', 'desc')->limit($limit)->select(); $orders = $q->order('id', 'desc')->limit($limit)->select();
@@ -481,6 +481,12 @@ final class GancaoLogisticsRouteService
*/ */
private static function appendSyncOneResult(array &$stats, PrescriptionOrder $order): void private static function appendSyncOneResult(array &$stats, PrescriptionOrder $order): void
{ {
$fs = (int) ($order->fulfillment_status ?? 0);
if (in_array($fs, [3, 6], true)) {
$stats['skipped']++;
return;
}
$stats['total']++; $stats['total']++;
try { try {
$r = self::syncOne($order); $r = self::syncOne($order);