WIN-2308041133\Administrator 8 months ago
parent
commit
a9ed235413
1 changed files with 41 additions and 0 deletions
  1. 41 0
      application/api/controller/Platform.php

+ 41 - 0
application/api/controller/Platform.php

@@ -116,5 +116,46 @@ class Platform extends Api
         }
         $this->success('分配完成');
     }
+//    检查过期版权,并扣除贡献值
+    public function past_copyright(){
+        $list = model('VideoShare')->where('endtime','<',time())->where('type',2)->select();
+        if($list) {
+            foreach ($list as $k => $v) {
+                $video_user = model('VideoUser')->where('uid',$v['uid'])->where('vid',$v['vid'])->find();
+                if ($video_user){
+//                    要过期的版权数量也就是贡献值数量
+                    $share = $video_user['share']-$v['num']; // 扣除版权
+                    $contribution = $video_user['contribution']-$v['num']; //扣除贡献值
+                    $res1 = model('VideoUser')->where('uid',$v['uid'])->where('vid',$v['vid'])->update(['share'=>$share,'contribution'=>$contribution]);
+//                   保存扣除记录
+                    $up = [
+                        'vid' => $v['vid'],
+                        'uid' => $v['uid'],
+                        'link_id' => $v['id'],
+                        'num' => $v['num'],
+                        'after' => $contribution,
+                        'content' => '版权过期,扣除对应贡献值',
+                        'createtime' => time(),
+                        'pm' => 1,
+                    ];
+                    $id = Db::name('VideoShareRecord')->insertGetId($up);
+                    $user = model('VideoList')->where('id',$v['vid'])->find();
+                    $user_contribution = $user['share']+$v['num'];
+                    $res2 = model('VideoList')->where('id',$v['vid'])->update(['share'=>$user_contribution]);
+                }
+            }
+        }
+        $this->success('检查完成');
+    }
+//    每日分红
+    public function dividend_day(){
+//        获取所有短剧列表
+        $list = model('video_user')->where('')->select();
+//        统计该短剧的总版版权数量以及持有版权的用户列表
+
+//        获取昨天该短剧的收益数据
+
+//        给各个用户分红
+    }
 
 }