| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace app\api\controller;
- use think\Db;
- use fast\Tree;
- use app\common\controller\Api;
- /**
- * 股份 收益 分红
- */
- class Platform extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- public function index()
- {
- $config=$this->config();
- $configs=config('site');
- $map=[];
- // $map['ishot']=2;
- // $map['endtimesjc']=['>',time()];
- // if(input('uid',0)>0){
- // $map['uid']=input('uid');
- // }
- $list = model('Platform')
- // ->with('user')
- // ->where($map)
- ->limit(10)
- ->select();
- $data=['config'=>$config,'doctor'=>$list];
- $this->success('请求成功',$data);
- }
- public function test(){
- $this->success('请求成功');
- }
- public function user_share_order(){
- $map = []; // 初始化$map数组,避免未定义时的错误
- if(input('uid', 0) > 0){
- // 明确指定uid所属的表(假设主表为video_share)
- $map['video_share.uid'] = input('uid');
- $count = $this->user_share_count($map['video_share.uid']);
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $config = $this->config();
- $list = model('VideoShare')
- ->with('videolist,user')
- ->where($map)
- ->limit($offset, $limit)
- ->select();
- $total = model('VideoShare')
- ->with('users')
- ->where($map)
- ->count();
- // var_dump(model('VideoShare')->getLastSql());die();
- $data = ['config' => $config, 'doctor' => $list,'total'=>$total,'count' => $count];
- $this->success('请求成功', $data);
- }
- public function user_share_count($uid){ // 统计用户各个短剧的版权数量
- $map = []; // 初始化$map数组,避免未定义时的错误
- $map['uid'] = $uid;
- $timestamp = strtotime("-3 years");
- $count = model('VideoShare')
- ->where($map)
- ->where('createtime','>',$timestamp)
- ->group('vid')
- ->field('vid,sum(num) as count')
- ->select();
- return $count;
- }
- // 查看各平台的收益情况
- public function platform_income(){
- $map = []; // 初始化查询条件数组
- // 修正条件:使用正确的输入参数名 platform_id
- if(input('platform_id', 0) > 0){
- $map['video_platform_record.platform_id'] = input('platform_id', 0);
- }
- // vid 条件正确,无需修改
- if(input('vid', 0) > 0){
- $map['video_platform_record.vid'] = input('vid', 0);
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $config = $this->config();
- $list = model('VideoPlatformRecord')
- ->with('platform,videolist')
- ->where($map)
- ->limit($offset, $limit)
- ->select();
- $total = model('VideoPlatformRecord')
- ->with('platform,videolist')
- ->where($map)
- ->count();
- $data = ['config' => $config, 'doctor' => $list, 'total' => $total];
- $this->success('请求成功', $data);
- }
- // 每日分配各个短剧在不同平台的收益
- public function platform_income_day(){
- // 先获取所有短剧在不同平台的收益上下限
- $list = model('VideoPlatform')->select();
- if($list) {
- foreach ($list as $k => $v) {
- $randomNumber = mt_rand($v['min'] * 100, $v['max'] * 100) / 100;
- $up = [
- 'vid' => $v['vid'],
- 'platform_id' => $v['platform_id'],
- 'num' => $randomNumber,
- 'createtime' => time(),
- ];
- $id = Db::name('VideoPlatformRecord')->insertGetId($up);
- }
- }
- $this->success('分配完成');
- }
- }
|