更新
This commit is contained in:
@@ -9,6 +9,7 @@ use app\common\model\ExpressStateLog;
|
||||
use app\common\model\ExpressTrace;
|
||||
use app\common\model\ExpressTracking;
|
||||
use app\common\model\tcm\PrescriptionOrder;
|
||||
use app\common\service\ExpressTrackingService;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ final class GancaoLogisticsRouteService
|
||||
* 拉取并落库单个订单的物流路由
|
||||
*
|
||||
* @param PrescriptionOrder $order
|
||||
* @return array{success:bool, message:string, traces_count:int, state:string, raw?:array}
|
||||
* @return array{success:bool, message:string, traces_count:int, state:string, raw?:array, assistant_sync?:array|null}
|
||||
*/
|
||||
public static function syncOne(PrescriptionOrder $order): array
|
||||
{
|
||||
@@ -118,12 +119,18 @@ final class GancaoLogisticsRouteService
|
||||
|
||||
self::logQuery($order, $trackingNumber, 'auto', true, $resp['runtime_ms'], '', count($routeList));
|
||||
|
||||
$assistantSync = ExpressTrackingService::applyAssistantReleaseForShippedPrescriptionOrder($order, [
|
||||
'tracking_number' => $trackingNumber,
|
||||
'source' => 'gancao_route_sync',
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'ok',
|
||||
'traces_count' => $tracesCount,
|
||||
'state' => $newState,
|
||||
'raw' => $result,
|
||||
'assistant_sync' => $assistantSync,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -423,11 +430,20 @@ final class GancaoLogisticsRouteService
|
||||
/**
|
||||
* 批量同步:选取候选订单(已上传甘草、且未签收/未取消的)
|
||||
*
|
||||
* @return array{total:int, success:int, failed:int, skipped:int, 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>>}
|
||||
*/
|
||||
public static function syncBatch(int $limit = 100, ?int $onlyOrderId = null): array
|
||||
{
|
||||
$stats = ['total' => 0, 'success' => 0, 'failed' => 0, 'skipped' => 0, 'details' => []];
|
||||
$stats = [
|
||||
'total' => 0,
|
||||
'success' => 0,
|
||||
'failed' => 0,
|
||||
'skipped' => 0,
|
||||
'assistant_cleared' => 0,
|
||||
'assistant_skipped_assign_log' => 0,
|
||||
'assistant_lines' => [],
|
||||
'details' => [],
|
||||
];
|
||||
|
||||
$q = PrescriptionOrder::whereNull('delete_time')
|
||||
->where('gancao_reciperl_order_no', '<>', '');
|
||||
@@ -462,6 +478,32 @@ final class GancaoLogisticsRouteService
|
||||
];
|
||||
if ($r['success']) {
|
||||
$stats['success']++;
|
||||
if (!empty($r['assistant_sync']) && is_array($r['assistant_sync'])) {
|
||||
$sync = $r['assistant_sync'];
|
||||
$act = (string) ($sync['action'] ?? '');
|
||||
if ($act === 'cleared') {
|
||||
$stats['assistant_cleared']++;
|
||||
$stats['assistant_lines'][] = sprintf(
|
||||
'[移除医助][甘草路由] 诊单=%d 业务订单=%d 运单=%s 原医助ID=%s 履约状态=%d',
|
||||
(int) ($sync['diagnosis_id'] ?? 0),
|
||||
(int) ($sync['prescription_order_id'] ?? 0),
|
||||
(string) ($sync['tracking_number'] ?? ''),
|
||||
(string) ($sync['former_assistant_id'] ?? ''),
|
||||
(int) ($sync['fulfillment_status'] ?? 0)
|
||||
);
|
||||
} elseif ($act === 'skipped_assign_log') {
|
||||
$stats['assistant_skipped_assign_log']++;
|
||||
$stats['assistant_lines'][] = sprintf(
|
||||
'[保留医助][甘草路由] 诊单=%d 业务订单=%d 运单=%s 医助ID=%s 指派记录=%d条 履约状态=%d',
|
||||
(int) ($sync['diagnosis_id'] ?? 0),
|
||||
(int) ($sync['prescription_order_id'] ?? 0),
|
||||
(string) ($sync['tracking_number'] ?? ''),
|
||||
(string) ($sync['assistant_id'] ?? ''),
|
||||
(int) ($sync['assign_log_count'] ?? 0),
|
||||
(int) ($sync['fulfillment_status'] ?? 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$stats['failed']++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user