Forráskód Böngészése

feat: 优化支付

xiansin 2 éve
szülő
commit
841fcab9b2

+ 3 - 2
mini/components/Recharge/index.vue

xqd xqd
@@ -142,6 +142,7 @@ export default {
           },
           success: payRes => {
             if (payRes.code === 0) {
+              this.$loading('支付结果查询中...')
               this.query()
             } else {
               this.$u.toast('支付失败')
@@ -160,16 +161,16 @@ export default {
     query() {
       if (this.interval) return
       setInterval(() => {
-        this.$loading('支付结果查询中...')
         this.$api.pay.query(this.payId).then(res => {
           this.$hideLoading()
           this.$u.toast('支付成功')
+          clearInterval(this.interval)
           // 获取用户信息
           this.$api.user.info().then(res => {
             this.$store.dispatch('user/info', res.data)
           })
         }).catch(err => {
-
+          this.$hideLoading()
         })
       }, 1000)
     }

+ 2 - 1
mini/pages/member/index.vue

xqd xqd
@@ -74,6 +74,7 @@ export default {
           },
           success: payRes => {
             if (payRes.code === 0) {
+              this.$loading('支付结果查询中...')
               this.query()
             } else {
               this.$u.toast('支付失败')
@@ -91,10 +92,10 @@ export default {
     query() {
       if (this.interval) return
       setInterval(() => {
-        this.$loading('支付结果查询中...')
         this.$api.pay.query(this.payId).then(res => {
           this.$hideLoading()
           this.$u.toast('支付成功')
+          clearInterval(this.interval)
           // 获取用户信息
           this.$api.user.info().then(res => {
             this.$store.dispatch('user/info', res.data)

+ 2 - 2
server/app/Helper/Bytedance/Payment.php

xqd
@@ -54,9 +54,9 @@ class Payment
     private function getNoticeData()
     {
         $notify = \request()->all();
-        $notify = '{"msg":"{\"appid\":\"tt5b312d8cc40f46b701\",\"cp_orderno\":\"10022082800824490007\",\"cp_extra\":\"\",\"way\":\"2\",\"channel_no\":\"2022082822001477591433078541\",\"channel_gateway_no\":\"\",\"payment_order_no\":\"PCP2022082822540531221069106962\",\"out_channel_order_no\":\"2022082822001477591433078541\",\"total_amount\":1,\"status\":\"SUCCESS\",\"seller_uid\":\"71227862181355706950\",\"extra\":\"\",\"item_id\":\"\",\"paid_at\":1661698458,\"message\":\"\",\"order_id\":\"7136939355201063205\",\"trade_item_list\":null,\"ec_pay_trade_no\":\"NEP2022082822540409483061846962\"}","msg_signature":"804a60e48936b14a739230cef21fe6204427732e","nonce":"78","timestamp":"1661698459","type":"payment"}';
+        //$notify = '{"msg":"{\"appid\":\"tt5b312d8cc40f46b701\",\"cp_orderno\":\"10022082800824490007\",\"cp_extra\":\"\",\"way\":\"2\",\"channel_no\":\"2022082822001477591433078541\",\"channel_gateway_no\":\"\",\"payment_order_no\":\"PCP2022082822540531221069106962\",\"out_channel_order_no\":\"2022082822001477591433078541\",\"total_amount\":1,\"status\":\"SUCCESS\",\"seller_uid\":\"71227862181355706950\",\"extra\":\"\",\"item_id\":\"\",\"paid_at\":1661698458,\"message\":\"\",\"order_id\":\"7136939355201063205\",\"trade_item_list\":null,\"ec_pay_trade_no\":\"NEP2022082822540409483061846962\"}","msg_signature":"804a60e48936b14a739230cef21fe6204427732e","nonce":"78","timestamp":"1661698459","type":"payment"}';
         //获取订单信息
-        $notify = json_decode($notify,true);
+        //$notify = json_decode($notify,true);
         \Log::info('抖音支付回调==>'.json_encode($notify,JSON_UNESCAPED_SLASHES));
 
         if($notify['msg_signature'] !== $this->app->getNotifySign($notify)){

+ 10 - 2
server/app/Http/Controllers/V1/PayController.php

xqd xqd
@@ -3,6 +3,8 @@
 namespace App\Http\Controllers\V1;
 
 
+use App\Models\Pay;
+
 class PayController extends Controller
 {
     public function bytedance()
@@ -10,8 +12,14 @@ class PayController extends Controller
         $app = $this->getByteDanceFactory();
     }
 
-    public function query()
+    public function query($payId)
     {
-        
+        $pay = Pay::find($payId);
+        if(!$pay || $pay->status){
+            return $this->success();
+        }
+
+        return $this->error();
+
     }
 }

+ 0 - 1
server/app/Http/Controllers/V1/PayNoticeController.php

xqd
@@ -37,7 +37,6 @@ class PayNoticeController extends Controller
                     $this->buyVip($payId);
                 }
 
-
                 \DB::commit();
             } catch (\Exception $e) {
                 \DB::rollBack();