Parcourir la source

feat: 快手相关

xiansin il y a 2 ans
Parent
commit
a1ef79267e

+ 2 - 1
mini/.eslintrc.js

xqd
@@ -13,7 +13,8 @@ module.exports = {
   globals: {
     uni: true,
     wx: true,
-    tt: true
+    tt: true,
+    ks: true
   },
   rules: {
     "vue/max-attributes-per-line": [2, {

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

xqd xqd
@@ -133,7 +133,7 @@ export default {
       this.$loading('请稍后...')
       this.$api.user.recharge.create({ id: item.id }).then(res => {
         console.log('-->data', res)
-        /* ifdef MP-TOUTIAO */
+        // #ifdef MP-TOUTIAO
         tt.pay({
           service: 5,
           orderInfo: {
@@ -148,11 +148,29 @@ export default {
               this.$u.toast('支付失败')
             }
           },
-          fail(res) {
+          fail: err => {
+            console.log('-->data', err)
             // 调起收银台失败处理逻辑
           }
         })
-        /* endif */
+        // #endif
+        // #ifdef MP-KUAISHOU
+        ks.pay({
+          serviceId: '1',
+          orderInfo: {
+            order_no: res.data.order_id,
+            order_info_token: res.data.order_token
+          },
+          success: payRes => {
+            this.$loading('支付结果查询中...')
+            this.query()
+          },
+          fail: err => {
+            console.log('-->data', err)
+            // 调起收银台失败处理逻辑
+          }
+        })
+        // #endif
         this.$hideLoading()
       }).catch(() => {
         this.$hideLoading()

+ 2 - 1
mini/setting.js

xqd
@@ -1,8 +1,9 @@
 /**
  * Created by JianJia.Zhou<jianjia.zhou> on 2022/3/18.
  */
-const IS_DEV = process.env.NODE_ENV === 'development'
+// const IS_DEV = process.env.NODE_ENV === 'development'
 
+const IS_DEV = false
 module.exports = {
   // 版本
   VERSION: '0.0.1',

+ 1 - 0
server/app/Helper/ByteDance.php

xqd
@@ -85,6 +85,7 @@ class ByteDance extends BaseUniPlatform
      */
     public function getSign(array $data)
     {
+        $rList = [];
         foreach ($data as $k => $v) {
             if ($k == "other_settle_params" || $k == "app_id" || $k == "sign" || $k == "thirdparty_id")
                 continue;

+ 8 - 2
server/app/Helper/Kuaishou.php

xqd xqd
@@ -59,11 +59,16 @@ class Kuaishou extends BaseUniPlatform
                 'app_id' => $this->appId,
                 'access_token' =>  $this->accessToken,
             ]);
-        return $this->post(
+        $res  = $this->post(
             $url,
             $data,
             'json'
         );
+
+        return  [
+            'order_id' => $res['order_info']['order_no'],
+            'order_token' => $res['order_info']['order_info_token']
+        ];
     }
 
 
@@ -126,7 +131,8 @@ class Kuaishou extends BaseUniPlatform
 
     public function getNotifySign(array $data)
     {
-        $str = json_encode($data,JSON_UNESCAPED_UNICODE).$this->secret;
+        $req = file_get_contents('php://input');
+        $str = $req.$this->secret;
         return md5($str);
     }
 

+ 2 - 1
server/app/Helper/UniPlatform/Kuaishou/Payment.php

xqd
@@ -60,9 +60,10 @@ class Payment
 
         $this->messageId = $notify['message_id'];
         //获取订单信息
+        $notify = array_merge($notify,['kwaisign' => $kwaisign]);
         \Log::info('快手支付回调==>'.json_encode($notify,JSON_UNESCAPED_SLASHES));
         if($kwaisign !== $this->app->getNotifySign($notify)){
-            //throw new \Exception('签名验证错误');
+            throw new \Exception('签名验证错误');
         }
 
         return $notify['data'];

+ 3 - 3
server/app/Http/Controllers/V1/PayNoticeController.php

xqd xqd
@@ -29,7 +29,7 @@ class PayNoticeController extends Controller
                 $pay->pay_type = $data['way'];
                 $pay->serial_number = $data['channel_no'];
                 $pay->status = $data['status'] == 'SUCCESS';
-                $pay->pay_dt = Carbon::now()->toDateString();
+                $pay->pay_dt = Carbon::now()->toDateTimeString();
                 $pay->save();
                 // 处理
                 if ($pay->source == Pay::SOURCE_RECHARGE) {
@@ -66,10 +66,10 @@ class PayNoticeController extends Controller
                 if($data['channel'] == 'ALIPAY'){
                     $payType = 2;
                 }
-                $pay->pay_type = $data['channel'];
+                $pay->pay_type = $payType;
                 $pay->serial_number = $data['trade_no'];
                 $pay->status = $data['status'] == 'SUCCESS';
-                $pay->pay_dt = Carbon::now()->toDateString();
+                $pay->pay_dt = Carbon::now()->toDateTimeString();
                 $pay->save();
                 // 处理
                 if ($pay->source == Pay::SOURCE_RECHARGE) {

+ 0 - 1
server/app/Models/Pay.php

xqd
@@ -78,7 +78,6 @@ class Pay extends Model
         $payId = SerialNumber::createOrderId(\user()->id);
         // 字节跳动下单
         $res = $byteDance->createOrder($payId, $price, \user()->open_id);
-        dd($res);
         $res['pay_id'] = $payId;
 
         $pay = new Pay();