1、合作商余额查询

2、分油账户司机可用额度
This commit is contained in:
2026-10-20 23:21:10 +08:00
parent 45452c1799
commit fafd3e2c16
134 changed files with 2344 additions and 352 deletions
@@ -22,7 +22,7 @@ namespace app\console\command;
use app\common\lock\RedisLock;
use app\common\model\partners\Order as OrderModel;
use app\common\model\qyt\Enterprise as EnterpriseModel;
use app\common\service\PartnersBalance;
use app\common\service\MallOil;
use app\common\service\QueueService;
use app\common\service\QytOil;
use think\console\Command;
@@ -48,12 +48,13 @@ class PartnersQueue extends Command
{
$this->queueService = new QueueService();
while (true) {
$message = $this->queueService->pop('partners_queue');
// 阻塞式取队列:有单立刻开始下发,不用等轮询间隔。
// 5 秒超时只是为了让空闲时也能跑到下面的兜底巡检(内部已限频 60s)。
$message = $this->queueService->bpop('partners_queue', 5);
if ($message) {
$this->processMessage($message);
} else {
$this->reconcile();
sleep(1);
}
}
}
@@ -198,18 +199,14 @@ class PartnersQueue extends Command
}
/**
* 发放失败 -> 回补合作商余额(仅在状态跃迁胜出时调用,天然幂等)
* 发放失败 -> 原路退款(仅在状态跃迁胜出时调用,天然幂等)
* · 合作商单 -> 回补 partners.balance
* · 商城单 -> 退回下单用户余额(按实付折算),并把失败状态回写 order_goods
*/
protected function refundBalance($order)
{
PartnersBalance::refund(
(int) $order['partners_id'],
(float) $order['total_price'],
(string) $order['partners_order_no'],
(int) $order['order_id'],
(int) $order['store_id']
);
(new QytOil())->saveLog("发放失败已回补合作商余额 order={$order['order_id']} amount={$order['total_price']}");
MallOil::giveBack($order, (float) $order['total_price'], '发放失败');
MallOil::syncGoods($order);
}
/**