This commit is contained in:
mkm 2024-05-14 18:30:09 +08:00
parent 48511412a8
commit fa6fb1ed11
3 changed files with 38 additions and 8 deletions

View File

@ -20,7 +20,8 @@ class IndexController extends BaseApiController
public function index() public function index()
{ {
d(config('payment.wechat.default.mch_id')); $extra=$this->request->post();
d(!empty($extra['payer']['openid']));
$queue = 'send-mail'; $queue = 'send-mail';
// 数据,可以直接传数组,无需序列化 // 数据,可以直接传数组,无需序列化
$data = ['to' => 'tom@gmail.com', 'content' => 'hello']; $data = ['to' => 'tom@gmail.com', 'content' => 'hello'];

View File

@ -12,6 +12,7 @@ use app\common\service\PushService;
use app\common\service\wechat\WeChatMnpService; use app\common\service\wechat\WeChatMnpService;
use support\Log; use support\Log;
use think\facade\Db; use think\facade\Db;
use Webman\RedisQueue\Redis;
/** /**
* 支付成功后处理订单状态 * 支付成功后处理订单状态
@ -73,11 +74,9 @@ class PayNotifyLogic extends BaseLogic
} }
} }
PushService::push('cash_register_' . $order['user_id'], $order['user_id'], '您有一笔订单已支付'); PushService::push('cash_register_' . $order['user_id'], $order['user_id'], '您有一笔订单已支付');
if(isset($extra['payer']['openid']) && $order->pay_type!=9){ if (!empty($extra['payer']['openid']) && $order->pay_type != 9) {
(new WeChatMnpService)->delivery($orderSn,$extra['payer']['openid']); Redis::send('push-delivery',['order_id'=>$orderSn,'openid'=>$extra['payer']['openid']],5);
} }
return true; return true;
} }
} }

View 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;
}
}