更新
This commit is contained in:
@@ -102,6 +102,24 @@ class PrescriptionOrderController extends BaseAdminController
|
||||
return $this->success('', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接调用京东官方物流接口刷新轨迹并落库(绕过快递100缓存)
|
||||
*/
|
||||
public function logisticsJdUpdate()
|
||||
{
|
||||
$params = (new PrescriptionOrderValidate())->post()->goCheck('logisticsJdUpdate');
|
||||
$data = PrescriptionOrderLogic::logisticsJdUpdate(
|
||||
(int) $params['id'],
|
||||
$this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if ($data === null) {
|
||||
return $this->fail(PrescriptionOrderLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success((string) ($data['message'] ?? '京东物流轨迹已更新'), $data);
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$params = (new PrescriptionOrderValidate())->post()->goCheck('edit');
|
||||
|
||||
@@ -126,6 +126,12 @@ class AuthMiddleware
|
||||
return true;
|
||||
}
|
||||
|
||||
// 京东物流接口刷新:与「物流轨迹」同一数据域,复用 logisticsTrace 权限
|
||||
if ($accessUri === 'tcm.prescriptionorder/logisticsjdupdate'
|
||||
&& in_array('tcm.prescriptionorder/logisticstrace', $adminUris, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 挂号列表批量改渠道:与单条编辑同一数据域,复用 doctor.appointment/edit
|
||||
if ($accessUri === 'doctor.appointment/batcheditchannel'
|
||||
&& in_array('doctor.appointment/edit', $adminUris, true)) {
|
||||
|
||||
@@ -1525,6 +1525,48 @@ class PrescriptionOrderLogic
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接调用京东官方物流接口刷新轨迹并落库(后台「京东接口更新」按钮)。
|
||||
*
|
||||
* @return array{success:bool, message:string, traces_count:int, state:string}|null
|
||||
*/
|
||||
public static function logisticsJdUpdate(int $id, int $adminId, array $adminInfo): ?array
|
||||
{
|
||||
self::$error = '';
|
||||
$row = PrescriptionOrder::where('id', $id)->whereNull('delete_time')->find();
|
||||
if (!$row) {
|
||||
self::$error = '订单不存在';
|
||||
|
||||
return null;
|
||||
}
|
||||
if (!self::canAccessOrder($row, $adminId, $adminInfo)) {
|
||||
self::$error = '无权限操作';
|
||||
|
||||
return null;
|
||||
}
|
||||
$num = trim((string) ($row->tracking_number ?? ''));
|
||||
if ($num === '') {
|
||||
self::$error = '未填写快递单号';
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$ret = \app\common\service\ExpressTrackingService::queryJdOfficialAndUpdate($num);
|
||||
|
||||
if (empty($ret['success'])) {
|
||||
self::$error = (string) ($ret['message'] ?? '京东物流更新失败');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => (string) ($ret['message'] ?? '京东物流轨迹已更新'),
|
||||
'traces_count' => (int) ($ret['traces_count'] ?? 0),
|
||||
'state' => (string) ($ret['state'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $params
|
||||
* @return array<string,mixed>|false
|
||||
|
||||
@@ -68,6 +68,7 @@ class PrescriptionOrderValidate extends BaseValidate
|
||||
'tracking_number', 'express_company', 'fee_type', 'amount', 'remark_extra', 'remark_assistant', 'pay_order_ids',
|
||||
],
|
||||
'logisticsTrace' => ['id', 'phone_tail'],
|
||||
'logisticsJdUpdate' => ['id'],
|
||||
'auditPrescription' => ['id', 'action', 'remark'],
|
||||
'auditPayment' => ['id', 'action', 'remark'],
|
||||
'withdraw' => ['id'],
|
||||
|
||||
Reference in New Issue
Block a user