lizhen_gitee пре 1 година
родитељ
комит
8bc76e7422

+ 15 - 0
application/api/controller/Notify.php

@@ -162,14 +162,29 @@ class Notify extends Api
         if($user_info['vip_endtime'] < time()){
             //过期了
             $vip_endtime = time() + (intval($args['days']) * 86400);
+            $vip_type = 1;
         }else{
             //追加vip
             $vip_endtime = $user_info['vip_endtime'] + (intval($args['days']) * 86400);
+            $vip_type = 2;
         }
         $update_data = [
             'vip_endtime'=>$vip_endtime,
         ];
         $result = Db::name('user_wallet')->where('user_id',$orderInfo['user_id'])->update($update_data);
+
+        //记录日志
+        $log_data = [
+            'user_id' => $orderInfo['user_id'],
+            'before'  => $user_info['vip_endtime'],
+            'change_value'  => intval($args['days']) * 86400,
+            'remain'  => $vip_endtime,
+            'remark'  => '安卓购买vip',
+            'createtime'  => time(),
+            'vip_type'  => $vip_type,
+        ];
+        Db::name('user_vip_log')->insertGetId($log_data);
+
         if($result === false)
         {
             Db::rollback();

+ 28 - 0
application/api/controller/Payios.php

@@ -257,9 +257,11 @@ class Payios extends Api
         if($user_info['vip_endtime'] < time()){
             //过期了
             $vip_endtime = time() + (intval($order_info['days']) * 86400);
+            $vip_type = 1;
         }else{
             //追加vip
             $vip_endtime = $user_info['vip_endtime'] + (intval($order_info['days']) * 86400);
+            $vip_type = 2;
         }
         $update_data = [
             'vip_endtime'=>$vip_endtime,
@@ -271,6 +273,17 @@ class Payios extends Api
             Db::rollback();
             $this->error('充值失败');
         }
+        //记录日志
+        $log_data = [
+            'user_id' => $order_info['user_id'],
+            'before'  => $user_info['vip_endtime'],
+            'change_value'  => intval($order_info['days']) * 86400,
+            'remain'  => $vip_endtime,
+            'remark'  => 'ios续费vip',
+            'createtime'  => time(),
+            'vip_type'  => $vip_type,
+        ];
+        Db::name('user_vip_log')->insertGetId($log_data);
         //逻辑结束
 
         //添加新的一个task
@@ -334,6 +347,7 @@ class Payios extends Api
         $order_map = [
 //            'user_id' => $this->auth->id,
             'out_trade_no' => $out_trade_no,
+            //'original_transaction_id' => $transaction_id,
         ];
         $order_info = Db::name('pay_order')->where($order_map)->lock(true)->find();
         if (!$order_info) {
@@ -390,9 +404,11 @@ class Payios extends Api
             if($user_info['vip_endtime'] < time()){
                 //过期了
                 $vip_endtime = time() + (intval($args['days']) * 86400);
+                $vip_type = 1;
             }else{
                 //追加vip
                 $vip_endtime = $user_info['vip_endtime'] + (intval($args['days']) * 86400);
+                $vip_type = 2;
             }
             $update_data = [
                 'vip_endtime'=>$vip_endtime,
@@ -404,6 +420,18 @@ class Payios extends Api
                 Db::rollback();
                 $this->error('充值失败');
             }
+            //记录日志
+            $log_data = [
+                'user_id' => $order_info['user_id'],
+                'before'  => $user_info['vip_endtime'],
+                'change_value'  => intval($args['days']) * 86400,
+                'remain'  => $vip_endtime,
+                'remark'  => 'ios购买vip',
+                'createtime'  => time(),
+                'vip_type'  => $vip_type,
+            ];
+            Db::name('user_vip_log')->insertGetId($log_data);
+
             //订阅vip需要多加的逻辑
             if($order_info['is_lianxu'] == 1){
                 $task_data = [

+ 14 - 0
application/api/controller/Usersign.php

@@ -134,11 +134,25 @@ class Usersign extends Api
             $vip_endtime = model('wallet')->getWallet($this->auth->id,'vip_endtime');
             if($vip_endtime <= time()){
                 $new_vip_endtime = time() + $add_time;
+                $vip_type = 1;
             }else{
                 $new_vip_endtime = $vip_endtime + $add_time;
+                $vip_type = 2;
             }
             $rs = Db::name('user_wallet')->where('user_id',$this->auth->id)->update(['vip_endtime'=>$new_vip_endtime]);
 
+            //记录日志
+            $log_data = [
+                'user_id' => $this->auth->id,
+                'before'  => $vip_endtime,
+                'change_value'  => $add_time,
+                'remain'  => $new_vip_endtime,
+                'remark'  => '签到送vip',
+                'createtime'  => time(),
+                'vip_type'  => $vip_type,
+            ];
+            Db::name('user_vip_log')->insertGetId($log_data);
+
             if($rs === false){
                 Db::rollback();
                 $this->error('连续签到赠送vip失败');