mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-08-07 22:29:44 +08:00
修改模板文件
This commit is contained in:
parent
a82e41b1ea
commit
e8d9ec1d9e
@ -55,22 +55,31 @@ class BalancePyamentService extends PaymentService
|
|||||||
if ($order['status'] !== 2) throw new Exception("不可发起支付");
|
if ($order['status'] !== 2) throw new Exception("不可发起支付");
|
||||||
// 创建支付行为
|
// 创建支付行为
|
||||||
$this->createPaymentAction($orderNo, $paymentTitle, $paymentAmount);
|
$this->createPaymentAction($orderNo, $paymentTitle, $paymentAmount);
|
||||||
// 扣减用户余额
|
// 检查能否支付
|
||||||
[$total, $count] = UserBalanceService::instance()->amount($order['uid'], [$orderNo]);
|
[$total, $count] = UserBalanceService::instance()->amount($order['uid'], [$orderNo]);
|
||||||
if ($paymentAmount > $total - $count) throw new Exception("可抵扣余额不足");
|
if ($paymentAmount > $total - $count) throw new Exception("可抵扣余额不足");
|
||||||
$this->app->db->name('ShopOrder')->where(['order_no' => $orderNo])->update(['payment_balance' => $paymentAmount]);
|
try {
|
||||||
// 扣除余额金额
|
// 扣减用户余额
|
||||||
data_save('DataUserBalance', [
|
$this->app->db->transaction(function () use ($order, $paymentAmount) {
|
||||||
'uid' => $order['uid'],
|
$this->app->db->name('ShopOrder')->where(['order_no' => $order['order_no']])->update([
|
||||||
'code' => $order['order_no'],
|
'payment_balance' => $paymentAmount,
|
||||||
'name' => "账户余额支付",
|
]);
|
||||||
'remark' => "使用余额支付订单{$order['order_no']}金额{$paymentAmount}元",
|
// 扣除余额金额
|
||||||
'amount' => -$paymentAmount,
|
data_save('DataUserBalance', [
|
||||||
], 'code', ['name' => '账户余额支付']);
|
'uid' => $order['uid'],
|
||||||
// 更新支付行为
|
'code' => $order['order_no'],
|
||||||
$this->updatePaymentAction($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '账户余额支付');
|
'name' => "账户余额支付",
|
||||||
// 刷新用户余额
|
'remark' => "使用余额支付订单{$order['order_no']}金额{$paymentAmount}元",
|
||||||
UserBalanceService::instance()->amount($order['uid']);
|
'amount' => -$paymentAmount,
|
||||||
return ['info' => '余额支付完成'];
|
], 'code', ['name' => '账户余额支付']);
|
||||||
|
// 更新支付行为
|
||||||
|
$this->updatePaymentAction($order['order_no'], CodeExtend::uniqidDate(20), $paymentAmount, '账户余额支付');
|
||||||
|
});
|
||||||
|
// 刷新用户余额
|
||||||
|
UserBalanceService::instance()->amount($order['uid']);
|
||||||
|
return ['code' => 1, 'info' => '余额支付完成'];
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return ['code' => 0, 'info' => $exception->getMessage()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -57,6 +57,6 @@ class EmptyPaymentService extends PaymentService
|
|||||||
$this->createPaymentAction($orderNo, $paymentTitle, $paymentAmount);
|
$this->createPaymentAction($orderNo, $paymentTitle, $paymentAmount);
|
||||||
// 更新支付行为
|
// 更新支付行为
|
||||||
$this->updatePaymentAction($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '无需支付');
|
$this->updatePaymentAction($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '无需支付');
|
||||||
return ['info' => '无需支付', 'status' => 1];
|
return ['code' => 1, 'info' => '无需支付'];
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user