更新
This commit is contained in:
parent
48511412a8
commit
fa6fb1ed11
@ -20,7 +20,8 @@ class IndexController extends BaseApiController
|
||||
public function index()
|
||||
{
|
||||
|
||||
d(config('payment.wechat.default.mch_id'));
|
||||
$extra=$this->request->post();
|
||||
d(!empty($extra['payer']['openid']));
|
||||
$queue = 'send-mail';
|
||||
// 数据,可以直接传数组,无需序列化
|
||||
$data = ['to' => 'tom@gmail.com', 'content' => 'hello'];
|
||||
|
@ -12,6 +12,7 @@ use app\common\service\PushService;
|
||||
use app\common\service\wechat\WeChatMnpService;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
use Webman\RedisQueue\Redis;
|
||||
|
||||
/**
|
||||
* 支付成功后处理订单状态
|
||||
@ -57,10 +58,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
||||
return true;
|
||||
}
|
||||
$order->money = bcdiv($extra['amount']['payer_total'],100,2);
|
||||
$order->money = bcdiv($extra['amount']['payer_total'], 100, 2);
|
||||
$order->paid = 1;
|
||||
$order->status = 1;
|
||||
if($order->pay_type==9){
|
||||
if ($order->pay_type == 9) {
|
||||
$order->status = 2;
|
||||
}
|
||||
$order->save();
|
||||
@ -72,12 +73,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
Cart::whereIn('cart_id', $order['cart_id'])->update(['is_pay' => 1]);
|
||||
}
|
||||
}
|
||||
PushService::push('cash_register_'.$order['user_id'], $order['user_id'], '您有一笔订单已支付');
|
||||
if(isset($extra['payer']['openid']) && $order->pay_type!=9){
|
||||
(new WeChatMnpService)->delivery($orderSn,$extra['payer']['openid']);
|
||||
PushService::push('cash_register_' . $order['user_id'], $order['user_id'], '您有一笔订单已支付');
|
||||
if (!empty($extra['payer']['openid']) && $order->pay_type != 9) {
|
||||
Redis::send('push-delivery',['order_id'=>$orderSn,'openid'=>$extra['payer']['openid']],5);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
30
app/queue/redis/PushDeliverySend.php
Normal file
30
app/queue/redis/PushDeliverySend.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\service\wechat\WeChatMnpService;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
|
||||
use support\Log;
|
||||
|
||||
class PushDeliverySend implements Consumer
|
||||
{
|
||||
// 要消费的队列名
|
||||
public $queue = 'push-delivery';
|
||||
|
||||
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||
public $connection = 'default';
|
||||
|
||||
// 消费
|
||||
public function consume($data)
|
||||
{
|
||||
(new WeChatMnpService)->delivery($data['order_id'], $data['openid']);
|
||||
|
||||
}
|
||||
public function onConsumeFailure(\Throwable $e, $package)
|
||||
{
|
||||
$package['max_attempts']=0;
|
||||
Log::error('推送小程序发货通知失败:'.$package['data']['order_id']);
|
||||
return $package;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user