调试信用购订单支付回调
This commit is contained in:
parent
10e2ca5d06
commit
c0e1a39c1e
@ -66,7 +66,7 @@ class PresellOrder extends BaseModel
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCombinePayParams()
|
public function getCombinePayParams($attach = 'presell')
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'order_sn' => $this->presell_order_sn,
|
'order_sn' => $this->presell_order_sn,
|
||||||
@ -77,7 +77,7 @@ class PresellOrder extends BaseModel
|
|||||||
'sub_mchid' => $this->merchant->sub_mchid,
|
'sub_mchid' => $this->merchant->sub_mchid,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'attach' => 'presell',
|
'attach' => $attach,
|
||||||
'body' => '尾款支付',
|
'body' => '尾款支付',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -76,12 +76,12 @@ class StoreGroupOrder extends BaseModel
|
|||||||
return $value ? implode(',', $value) : '';
|
return $value ? implode(',', $value) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCombinePayParams()
|
public function getCombinePayParams($attach = 'order')
|
||||||
{
|
{
|
||||||
$params = [
|
$params = [
|
||||||
'order_sn' => $this->group_order_sn,
|
'order_sn' => $this->group_order_sn,
|
||||||
'sub_orders' => [],
|
'sub_orders' => [],
|
||||||
'attach' => 'order',
|
'attach' => $attach,
|
||||||
'body' => '订单支付',
|
'body' => '订单支付',
|
||||||
];
|
];
|
||||||
foreach ($this->orderList as $order) {
|
foreach ($this->orderList as $order) {
|
||||||
|
@ -2459,7 +2459,7 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
if ($payMoney > 0) {
|
if ($payMoney > 0) {
|
||||||
if (!in_array($type, ['balance', 'scrcu'])) {
|
if (!in_array($type, ['balance', 'scrcu'])) {
|
||||||
if (systemConfig('open_wx_combine')) {
|
if (systemConfig('open_wx_combine')) {
|
||||||
$service = new CombinePayService($type, $groupOrder->getCombinePayParams());
|
$service = new CombinePayService($type, $groupOrder->getCombinePayParams('order_settle'));
|
||||||
} else {
|
} else {
|
||||||
$service = new PayService($type, $groupOrder->getPayParams($type === 'alipay' ? request()->param('return_url') : ''));
|
$service = new PayService($type, $groupOrder->getPayParams($type === 'alipay' ? request()->param('return_url') : ''));
|
||||||
}
|
}
|
||||||
@ -2471,12 +2471,11 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
$result = $payTool->pay($groupOrder);
|
$result = $payTool->pay($groupOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$groupOrder->interest->interest = $interest;
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
app()->make(MerchantRepository::class)->computedLockMoney($groupOrder->order);
|
app()->make(MerchantRepository::class)->computedLockMoney($groupOrder->order);
|
||||||
$groupOrder->interest->status = StoreOrderInterest::STATUS_SETTLED;
|
$groupOrder->interest->status = StoreOrderInterest::STATUS_SETTLED;
|
||||||
$groupOrder->interest->settle_time = date('Y-m-d H:i:s');
|
$groupOrder->interest->settle_time = date('Y-m-d H:i:s');
|
||||||
$groupOrder->interest->interest = $interest;
|
|
||||||
$groupOrder->interest->save();
|
|
||||||
|
|
||||||
/** @var UserBillRepository $userBillRepository */
|
/** @var UserBillRepository $userBillRepository */
|
||||||
$userBillRepository = app()->make(UserBillRepository::class);
|
$userBillRepository = app()->make(UserBillRepository::class);
|
||||||
@ -2495,6 +2494,7 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
|
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$groupOrder->interest->save();
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $data;
|
return $data;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -60,6 +60,7 @@ return [
|
|||||||
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
||||||
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
||||||
'pay_success_order' => [\crmeb\listens\pay\OrderPaySuccessListen::class],
|
'pay_success_order' => [\crmeb\listens\pay\OrderPaySuccessListen::class],
|
||||||
|
'pay_success_order_settle' => [\crmeb\listens\pay\OrderSettlePaySuccessListen::class],
|
||||||
'pay_success_micro_pay' => [\crmeb\listens\pay\OrderMicroPaySuccessListen::class],
|
'pay_success_micro_pay' => [\crmeb\listens\pay\OrderMicroPaySuccessListen::class],
|
||||||
'pay_success_presell' => [\crmeb\listens\pay\PresellPaySuccessListen::class],
|
'pay_success_presell' => [\crmeb\listens\pay\PresellPaySuccessListen::class],
|
||||||
'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class],
|
'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class],
|
||||||
|
54
crmeb/listens/pay/OrderSettlePaySuccessListen.php
Normal file
54
crmeb/listens/pay/OrderSettlePaySuccessListen.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace crmeb\listens\pay;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\store\order\StoreOrderInterest;
|
||||||
|
use app\common\repositories\store\order\StoreGroupOrderRepository;
|
||||||
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
|
use crmeb\interfaces\ListenerInterface;
|
||||||
|
use crmeb\utils\DingTalk;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Log;
|
||||||
|
|
||||||
|
class OrderSettlePaySuccessListen implements ListenerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($data): void
|
||||||
|
{
|
||||||
|
$orderSn = $data['order_sn'];
|
||||||
|
$groupOrder = app()->make(StoreGroupOrderRepository::class)->getWhere(['group_order_sn' => $orderSn]);
|
||||||
|
if (!$groupOrder || $groupOrder->paid == 1) return;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
app()->make(MerchantRepository::class)->computedLockMoney($groupOrder->order);
|
||||||
|
$groupOrder->interest->status = StoreOrderInterest::STATUS_SETTLED;
|
||||||
|
$groupOrder->interest->settle_time = date('Y-m-d H:i:s');
|
||||||
|
if (!$groupOrder->interest->save()) {
|
||||||
|
throw new \Exception('订单结算信息保存失败');
|
||||||
|
}
|
||||||
|
$unSettleCount = StoreOrderInterest::where('mer_id', $groupOrder->interest->mer_id)->where('status', 0)->count();
|
||||||
|
if ($unSettleCount === 0) {
|
||||||
|
/** @var MerchantRepository $merchantRepo */
|
||||||
|
$merchantRepo = app()->make(MerchantRepository::class);
|
||||||
|
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
Log::error($e->getMessage(), $data);
|
||||||
|
DingTalk::exception($e, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user