feat: 增加微信支付码支付功能
This commit is contained in:
parent
4bc8092931
commit
27a71efb07
@ -292,6 +292,7 @@ class OrderController extends BaseApiController
|
|||||||
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||||
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
||||||
} else {
|
} else {
|
||||||
|
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||||
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
|
@ -280,6 +280,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
||||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
||||||
}
|
}
|
||||||
|
if($order['pay_type']==9){
|
||||||
|
Db::name('wechat_micropay')->where(['order_id'=>$order['order_id']])->delete();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,12 +464,12 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$uid = $order['other_uid'];
|
$uid = $order['other_uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||||
if (!empty($extra['payer']['openid'])) {
|
if (!empty($extra['payer']['openid'])) {
|
||||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
|
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
|
||||||
}
|
}
|
||||||
|
Db::name('wechat_micropay')->where(['order_id'=>$order['order_id']])->delete();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ use app\store\validate\store_order\StoreOrderValidate;
|
|||||||
use support\Cache;
|
use support\Cache;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
|
use think\facade\Db;
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,6 +247,7 @@ class StoreOrderController extends BaseAdminController
|
|||||||
Log::error(json_encode($result));
|
Log::error(json_encode($result));
|
||||||
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
||||||
} else {
|
} else {
|
||||||
|
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||||
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
@ -318,6 +320,7 @@ class StoreOrderController extends BaseAdminController
|
|||||||
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
||||||
} else {
|
} else {
|
||||||
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
||||||
|
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]);
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]);
|
||||||
|
@ -63,27 +63,27 @@ class Task
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//每10秒执行一次
|
//每10秒执行一次
|
||||||
// new Crontab('*/10 * * * * *', function () {
|
new Crontab('*/10 * * * * *', function () {
|
||||||
// $select=Db::name('wechat_micropay')->limit(100)->select();
|
$select=Db::name('wechat_micropay')->limit(100)->select();
|
||||||
// $pay = new PayService();
|
$pay = new PayService();
|
||||||
// foreach ($select as $k=>$v) {
|
foreach ($select as $k=>$v) {
|
||||||
// $time = time();
|
$time = time();
|
||||||
// if ($time - $v['create_time'] > 60){
|
if ($time - $v['create_time'] > 60){
|
||||||
// Db::name('wechat_micropay')->where('id',$v['id'])->delete();
|
Db::name('wechat_micropay')->where('id',$v['id'])->delete();
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// $order = [
|
$order = [
|
||||||
// 'out_trade_no' => $v['order_id'],
|
'out_trade_no' => $v['order_id'],
|
||||||
// ];
|
];
|
||||||
// $res = $pay->wechat->query($order);
|
$res = $pay->wechat->query($order);
|
||||||
// if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
||||||
// if(isset($data['pay_type']) && $data['pay_type']=='recharge'){
|
if(isset($data['pay_type']) && $data['pay_type']=='recharge'){
|
||||||
// PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
||||||
// }else{
|
}else{
|
||||||
// PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user