kevin_zhangl 3 лет назад
Родитель
Сommit
8ed58b896b

+ 13 - 0
common/helpers/Tool.php

@@ -9,6 +9,7 @@
 namespace common\helpers;
 
 
+use common\models\ApproachOrderCall;
 use Faker\Provider\Uuid;
 use yii\base\Exception;
 use yii\helpers\Url;
@@ -489,4 +490,16 @@ class Tool {
         $uuid = !$upper ? Uuid::uuid() : strtoupper(Uuid::uuid());
         return str_replace('-', $symbol, $uuid);
     }
+
+    /**
+     * PayStack订单写入MongoDB.
+     * @param $call
+     * @return void
+     */
+    public static function approachOrderCall($call)
+    {
+        $model = new ApproachOrderCall();
+        $model->load($call);
+        $model->save();
+    }
 }

+ 95 - 0
common/models/ApproachOrderCall.php

@@ -0,0 +1,95 @@
+<?php
+
+namespace common\models;
+
+use common\components\MongoActiveRecord;
+use Yii;
+
+/**
+ * This is the model class for collection "ar_approach_order_call".
+ *
+ * @property \MongoDB\BSON\ObjectID|string $_id
+ * @property mixed $user_name
+ * @property mixed $opt_type
+ * @property mixed $return_result
+ * @property mixed $success_times
+ * @property mixed $fail_times
+ * @property mixed $device
+ * @property mixed $request_route
+ * @property mixed $ip
+ * @property mixed $created_at
+ * @property mixed $user_agent
+ * @property mixed $period_num
+ */
+class ApproachOrderCall extends MongoActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function collectionName()
+    {
+        return 'ar_approach_order_call';
+    }
+
+    /**
+     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
+     */
+    public static function getDb()
+    {
+        return Yii::$app->get('dbLog');
+    }
+
+    /**
+     * 获取id
+     * @return string
+     */
+    public function getId() {
+        return (string) $this->_id;
+    }
+    /**
+     * {@inheritdoc}
+     */
+    public function attributes()
+    {
+        return [
+            'id',
+            'domain',
+            'status',
+            'reference',
+            'amount',
+            'created_at',
+            'paid_at',
+            'channel',
+            'currency',
+            'ip_address',
+            'metadata',
+            'return_result',
+            'customer',
+            'email',
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'PayID',
+            'domain' => 'domain',
+            'status' => 'status',
+            'reference' => 'reference',
+            'amount' => 'amount(kobo)',
+            'created_at' => 'created_at',
+            'paid_at' => 'paid_at',
+            'channel' => 'channel',
+            'currency' => 'currency',
+            'ip_address' => 'ip_address',
+            'metadata' => 'metadata',
+            'return_result' => 'return_result',
+            'customer' => 'customer',
+            'email' => 'email',
+        ];
+    }
+
+}

+ 1 - 0
frontendApi/modules/v1/controllers/ShopController.php

@@ -197,6 +197,7 @@ class ShopController extends BaseController {
             $request = \Yii::$app->request->post();
             // TODO:支付webhook回调日志
             LoggerTool::info($request);
+            Tool::approachOrderCall($request);
             $data = $request['data'];
             $status = $request['data']['status'] ?? 'false';
             // 订单状态

+ 2 - 2
frontendEle/src/views/user/upgrade.vue

@@ -128,8 +128,8 @@
                             <div class="white-box-footer flex">
                                 <el-button @click="getSum()">Total calculation<!-- 计算合计 --></el-button>
                                 <div class='flex data' style="flex:1;justify-content: flex-end;">
-                                    <div style="margin-right:2rem"><!-- 商品价格 -->product price:{{sell_price_sum}}</div>
-                                    <div><!-- 商品PV -->product BV:{{price_pv_sum}}</div>
+                                    <div style="margin-right:2rem"><!-- 商品价格 -->product price:{{sell_price_sum}}</div>
+                                    <div><!-- 商品PV -->product BV:{{price_pv_sum}}</div>
                                 </div>
                             </div>
                         </el-tab-pane>