1、合作商余额查询
2、分油账户司机可用额度
This commit is contained in:
@@ -13,7 +13,7 @@ declare (strict_types=1);
|
||||
|
||||
namespace app\store\controller\partners;
|
||||
|
||||
use app\common\service\PartnersBalance;
|
||||
use app\common\service\MallOil;
|
||||
use app\common\service\QueueService;
|
||||
use app\common\model\qyt\Enterprise as EnterpriseModel;
|
||||
use app\common\service\QytInvoice;
|
||||
@@ -119,16 +119,10 @@ class Order extends Controller
|
||||
if ($order['use_status'] != 0) {
|
||||
return $this->renderError('该单已加油核销,不可重发');
|
||||
}
|
||||
// 发放失败时余额已回补,重发需重新扣减合作商余额
|
||||
$logId = PartnersBalance::deduct(
|
||||
(int) $order['partners_id'],
|
||||
(float) $order['total_price'],
|
||||
(string) $order['partners_order_no'],
|
||||
$orderId,
|
||||
(int) $order['store_id']
|
||||
);
|
||||
if ($logId === false) {
|
||||
return $this->renderError('合作商余额不足,请先充值后再重发');
|
||||
// 发放失败时额度已原路退回,重发需重新扣减:
|
||||
// 合作商单扣合作商余额,小程序单扣下单用户余额
|
||||
if (!MallOil::take($order, (float) $order['total_price'])) {
|
||||
return $this->renderError(MallOil::notEnoughText($order));
|
||||
}
|
||||
// 仅允许从「发放失败(3)」重置为「未提交(0)」,避免与「发放中(1)」的单冲突。
|
||||
// 同时清空编号并把重发次数 +1:企油通按 batch_no 幂等,沿用老批次的话
|
||||
@@ -148,17 +142,13 @@ class Order extends Controller
|
||||
'update_time' => time(),
|
||||
]);
|
||||
if (!$reset) {
|
||||
// 状态已被其它进程改变 -> 回补刚扣的余额
|
||||
PartnersBalance::refund(
|
||||
(int) $order['partners_id'],
|
||||
(float) $order['total_price'],
|
||||
(string) $order['partners_order_no'],
|
||||
$orderId,
|
||||
(int) $order['store_id']
|
||||
);
|
||||
// 状态已被其它进程改变 -> 回补刚扣的额度
|
||||
MallOil::giveBack($order, (float) $order['total_price'], '重发撤销');
|
||||
return $this->renderError('当前状态不允许重发(仅「发放失败」的订单可重发)');
|
||||
}
|
||||
(new QueueService())->push('partners_queue', json_encode(['order_id' => $orderId], 320));
|
||||
// 小程序单把「重新发放」状态同步回订单商品行,用户端立刻能看到
|
||||
MallOil::syncGoods($order);
|
||||
return $this->renderSuccess('已提交重新发放,请稍后刷新查看结果');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user