feat: 添加了新的条码支付订单通知功能,优化了支付逻辑,提高了支付成功率

This commit is contained in:
mkm 2024-08-07 21:26:13 +08:00
parent 0375951b3f
commit d7f03993bf
2 changed files with 36 additions and 8 deletions
app/api/controller

@ -16,6 +16,9 @@ use app\common\model\store_order\StoreOrder;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
use app\common\service\Curl;
use Exception;
use support\Log;
use think\facade\Db;
use Webman\RedisQueue\Redis;
@ -184,6 +187,14 @@ class OrderController extends BaseApiController
} 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']]);
try{
$arr = ["msgtype" => "markdown", "markdown" => ["content" => "有新的条码支付订单"]];
$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b538e44b-940b-445f-afe0-97320942d959';
(new Curl())->postJson($url, json_encode($arr));
}catch(Exception $e){
Log::error('推送订单失败');
}
return $this->success('用户支付中');
}
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
@ -294,6 +305,13 @@ class OrderController extends BaseApiController
} 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']]);
try{
$arr = ["msgtype" => "markdown", "markdown" => ["content" => "有新的条码支付订单"]];
$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b538e44b-940b-445f-afe0-97320942d959';
(new Curl())->postJson($url, json_encode($arr));
}catch(Exception $e){
Log::error('推送订单失败');
}
return $this->success('用户支付中');
}
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);

@ -17,7 +17,10 @@ use app\common\model\user\User;
use app\common\model\user\UserAddress;
use app\common\model\user_create_log\UserCreateLog;
use app\common\model\user_recharge\UserRecharge;
use app\common\service\Curl;
use Exception;
use support\Cache;
use support\Log;
use Webman\RedisQueue\Redis;
class StoreController extends BaseApiController
@ -149,6 +152,13 @@ class StoreController extends BaseApiController
PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result);
} else {
Redis::send('send-code-pay', ['order_id' => $order['order_id'],'pay_type'=>'recharge']);
try{
$arr = ["msgtype" => "markdown", "markdown" => ["content" => "有新的条码支付充值订单"]];
$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b538e44b-940b-445f-afe0-97320942d959';
(new Curl())->postJson($url, json_encode($arr));
}catch(Exception $e){
Log::error('推送订单失败');
}
return $this->success('用户支付中');
}
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);