1、合作商余额查询
2、分油账户司机可用额度
This commit is contained in:
@@ -8,6 +8,8 @@ use think\console\Input;
|
||||
use think\console\Output;
|
||||
use app\store\model\order\Record as RecordModel;
|
||||
use app\common\service\SybOil;
|
||||
use app\common\service\QytWaybill;
|
||||
use app\common\lock\RedisLock;
|
||||
use think\facade\Db;
|
||||
|
||||
class CallbackQueue extends Command
|
||||
@@ -427,6 +429,58 @@ class CallbackQueue extends Command
|
||||
$SybOil->saveLogStore('企油通消费回调处理成功:' . json_encode($c, 320));
|
||||
}
|
||||
break;
|
||||
case "qyt_waybill_result":
|
||||
// 企油通 3.10「发放结果通知」:一个批次一条,整批明细都在 res.list 里。
|
||||
// 判定与状态跃迁跟 7.8 轮询共用 QytWaybill,保证两条路结论一致、互相幂等。
|
||||
$batchNo = (string)($res['batch_no'] ?? '');
|
||||
$batchStatus = (int)($res['status'] ?? 0);
|
||||
$notifyTime = !empty($res['notify_time']) ? (strtotime((string)$res['notify_time']) ?: time()) : time();
|
||||
$list = (array)($res['list'] ?? []);
|
||||
$stat = ['success' => 0, 'failed' => 0, 'pending' => 0, 'skipped' => 0, 'conflict' => 0, 'miss' => 0];
|
||||
|
||||
foreach ($list as $row) {
|
||||
$code = trim((string)($row['waybill_no_code'] ?? ''));
|
||||
if ($code === '') {
|
||||
$stat['miss']++;
|
||||
continue;
|
||||
}
|
||||
$order = Db::name('partners_order')->where('waybill_no_code', $code)->find();
|
||||
if (!$order) {
|
||||
// 同一个 appId 下可能还挂着别的接入系统提交的批次,匹配不到不算异常
|
||||
$stat['miss']++;
|
||||
continue;
|
||||
}
|
||||
// 留痕:这一单到底收没收到过推送、收了几次
|
||||
QytWaybill::touchNotify((int)$order['order_id'], $notifyTime);
|
||||
|
||||
// 每单串行,避免与 qyt:status 轮询同时跃迁
|
||||
$lock = new RedisLock('qyt:status:' . $order['order_id'], 60);
|
||||
if (!$lock->acquireLock()) {
|
||||
// 轮询正在处理这一单,跳过即可:两条路的结论一样
|
||||
$stat['skipped']++;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// 锁内重读,拿到最新状态
|
||||
$fresh = Db::name('partners_order')->where('order_id', $order['order_id'])->find();
|
||||
$judged = QytWaybill::judge($batchStatus, [
|
||||
'handle_status' => (int)($row['handle_status'] ?? 0),
|
||||
'error_msg' => (string)($row['error_msg'] ?? ''),
|
||||
'remark' => (string)($row['remark'] ?? ''),
|
||||
]);
|
||||
$stat[QytWaybill::apply($fresh ?: $order, $judged, '3.10 通知')]++;
|
||||
} finally {
|
||||
$lock->releaseLock();
|
||||
}
|
||||
}
|
||||
|
||||
$SybOil->saveLogStore('3.10 发放结果通知处理完成 batch_no=' . $batchNo
|
||||
. ' 批次状态=' . $batchStatus . ' 明细=' . count($list)
|
||||
. ' 成功=' . $stat['success'] . ' 失败=' . $stat['failed']
|
||||
. ' 待处理=' . $stat['pending'] . ' 已是终态=' . $stat['skipped']
|
||||
. ' 未匹配=' . $stat['miss']
|
||||
. ($stat['conflict'] ? ' 【冲突=' . $stat['conflict'] . ',需人工核对】' : ''));
|
||||
break;
|
||||
default:
|
||||
$SybOil->saveLogStore('队列数据处理异常,未知:【'.$message.'】');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user