第二次更新

This commit is contained in:
2026-09-10 20:56:46 +08:00
parent 4d6a7e7aac
commit caeb4d6760
310 changed files with 2427 additions and 382 deletions
@@ -15,6 +15,7 @@ namespace app\store\controller\partners;
use app\common\service\PartnersBalance;
use app\common\service\QueueService;
use app\common\model\qyt\Enterprise as EnterpriseModel;
use app\common\service\QytOil;
use app\store\controller\Controller;
use app\store\model\order\QrCode as QrCodeModel;
@@ -71,7 +72,15 @@ class Order extends Controller
if ($order['oil_status'] != 1) {
return $this->renderError('该单尚未发放成功,无法获取加油地址');
}
$h5Url = (new QytOil())->h5Url((string) $order['mobile']);
// 免登链接要带本单企业的 creditcode(营业执照号),把登录固定到该企业
$enterprise = EnterpriseModel::detail((int) $order['qyt_enterprise_id']);
if (!$enterprise) {
return $this->renderError('本单绑定的企油通企业不存在,无法生成加油地址');
}
if ($enterprise['status'] !== 'approved') {
return $this->renderError('企业「' . $enterprise['company_name'] . '」尚未通过企油通审核,无法生成加油地址');
}
$h5Url = QytOil::forEnterprise($enterprise)->h5Url((string) $order['mobile']);
if (!$h5Url) {
return $this->renderError('生成加油地址失败,请检查企油通配置');
}
@@ -115,11 +124,23 @@ class Order extends Controller
if ($logId === false) {
return $this->renderError('合作商余额不足,请先充值后再重发');
}
// 仅允许从「发放失败(3)」重置为「未提交(0)」,避免与正在处理的单冲突
// 仅允许从「发放失败(3)」重置为「未提交(0)」,避免与「发放中(1)」的单冲突。
// 同时清空编号并把重发次数 +1:企油通按 batch_no 幂等,沿用老批次的话
// 7.8 会一直返回那条旧的失败记录,重发永远不可能成功。
$reset = Db::name('partners_order')->where('order_id', $orderId)
->where('oil_status', 0)
->where('oil_status_zsy', 3)
->update(['oil_status_zsy' => 0, 'oil_text' => '后台重新发放', 'update_time' => time()]);
->update([
'oil_status_zsy' => 0,
'batch_no' => '',
'waybill_no' => '',
'waybill_no_code' => '',
'qyt_retry_num' => Db::raw('qyt_retry_num + 1'),
'qyt_query_time' => 0,
'qyt_query_num' => 0,
'oil_text' => '后台重新发放',
'update_time' => time(),
]);
if (!$reset) {
// 状态已被其它进程改变 -> 回补刚扣的余额
PartnersBalance::refund(