更新保证金回调

This commit is contained in:
yaooo 2023-09-25 10:47:52 +08:00
parent c41c29b64b
commit 4d86cf292d
2 changed files with 20 additions and 12 deletions

View File

@ -116,7 +116,7 @@ class MerchantIntentionRepository extends BaseRepository
$margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']);
$data['is_margin'] = $margin['is_margin'] ?? -1;
$data['margin'] = $margin['margin'] ?? 0;
$data['margin'] = 0;
$merData = [];
if ($create) {
$password = substr($intention['phone'], -6);
@ -137,7 +137,10 @@ class MerchantIntentionRepository extends BaseRepository
'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1,
'mer_password' => $password,
'is_margin' => $margin['is_margin'] ?? -1,
'margin' => $margin['margin'] ?? 0,
// 用户需缴纳保证金
'recharge_margin' => $margin['margin'] ?? 0,
// 用户已缴纳保证金
'margin' => 0,
'uid' => $intention['uid'],
'reg_admin_id' => $autoCreate ? 0: request()->adminId(),
'mer_intention_id' => $id

View File

@ -14,17 +14,22 @@ class paySuccessMargin
public function handle($event)
{
Log::info('微信支付保证金成功回调' . json_encode($event));
$this->event = $event;
$order_sn = $event['order_sn'] ?? '';
$marginInfo = Db::name('margin_order')->where('order_sn', $order_sn)->find();
Db::name('margin_order')->where('order_sn', $order_sn)->update([
'paid' => 1,
'pay_time' => date('Y-m-d H:i:s')
]);
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([
'is_margin' => 10
]);
Db::transaction(function () use ($event) {
$order_sn = $event['order_sn'] ?? '';
$marginInfo = Db::name('margin_order')->where('order_sn', $order_sn)->find();
Db::name('margin_order')->where('order_sn', $order_sn)->update([
'paid' => 1,
'pay_time' => date('Y-m-d H:i:s')
]);
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->inc('margin',$marginInfo['total_price']);
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->dec('recharge_margin',$marginInfo['total_price']);
$merchantInfo = Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->find();
if ($merchantInfo['recharge_margin'] <= 0) {
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([
'is_margin' => 10
]);
}
});
}
}