feat: 添加了新的条码支付订单通知功能,优化了支付逻辑,提高了支付成功率
This commit is contained in:
parent
0375951b3f
commit
d7f03993bf
@ -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;
|
||||
|
||||
@ -182,8 +185,16 @@ class OrderController extends BaseApiController
|
||||
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
||||
} 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']]);
|
||||
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']]);
|
||||
@ -292,8 +303,15 @@ class OrderController extends BaseApiController
|
||||
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
||||
} else {
|
||||
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||
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']]);
|
||||
@ -459,11 +477,11 @@ class OrderController extends BaseApiController
|
||||
$params = (new OrderValidate())->post()->goCheck('add');
|
||||
$uid = $this->userId;
|
||||
//拆单逻辑
|
||||
$res=OrderLogic::dealRefund($uid, $params);
|
||||
$detail = StoreOrder::where('id', $params['id'])->where('refund_type',1)->find();
|
||||
if($detail && $res!=2){
|
||||
$res=StoreOrderLogic::refund($detail,['order_id'=>$detail['order_id']]);
|
||||
if($res!=false){
|
||||
$res = OrderLogic::dealRefund($uid, $params);
|
||||
$detail = StoreOrder::where('id', $params['id'])->where('refund_type', 1)->find();
|
||||
if ($detail && $res != 2) {
|
||||
$res = StoreOrderLogic::refund($detail, ['order_id' => $detail['order_id']]);
|
||||
if ($res != false) {
|
||||
return $this->success($res);
|
||||
}
|
||||
}
|
||||
|
@ -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']]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user