Platform.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\api\controller;
  3. use think\Db;
  4. use fast\Tree;
  5. use app\common\controller\Api;
  6. /**
  7. * 股份 收益 分红
  8. */
  9. class Platform extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. public function index()
  14. {
  15. $config=$this->config();
  16. $configs=config('site');
  17. $map=[];
  18. // $map['ishot']=2;
  19. // $map['endtimesjc']=['>',time()];
  20. // if(input('uid',0)>0){
  21. // $map['uid']=input('uid');
  22. // }
  23. $list = model('Platform')
  24. // ->with('user')
  25. // ->where($map)
  26. ->limit(10)
  27. ->select();
  28. $data=['config'=>$config,'doctor'=>$list];
  29. $this->success('请求成功',$data);
  30. }
  31. public function test(){
  32. $this->success('请求成功');
  33. }
  34. public function user_share_order(){
  35. $map = []; // 初始化$map数组,避免未定义时的错误
  36. if(input('uid', 0) > 0){
  37. // 明确指定uid所属的表(假设主表为video_share)
  38. $map['video_share.uid'] = input('uid');
  39. $count = $this->user_share_count($map['video_share.uid']);
  40. }
  41. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  42. $config = $this->config();
  43. $list = model('VideoShare')
  44. ->with('videolist,user')
  45. ->where($map)
  46. ->limit($offset, $limit)
  47. ->select();
  48. $total = model('VideoShare')
  49. ->with('users')
  50. ->where($map)
  51. ->count();
  52. // var_dump(model('VideoShare')->getLastSql());die();
  53. $data = ['config' => $config, 'doctor' => $list,'total'=>$total,'count' => $count];
  54. $this->success('请求成功', $data);
  55. }
  56. public function user_share_count($uid){ // 统计用户各个短剧的版权数量
  57. $map = []; // 初始化$map数组,避免未定义时的错误
  58. $map['uid'] = $uid;
  59. $count = model('VideoShare')
  60. ->where($map)
  61. ->group('vid')
  62. ->field('vid,sum(num) as count')
  63. ->select();
  64. return $count;
  65. }
  66. // 查看各平台的收益情况
  67. public function platform_income(){
  68. $map = []; // 初始化$map数组,避免未定义时的错误
  69. if(input('uid', 0) > 0){
  70. // 明确指定uid所属的表(假设主表为video_share)
  71. $map['video_share.uid'] = input('uid');
  72. }
  73. if(input('vid', 0) > 0){
  74. // 明确指定uid所属的表(假设主表为video_share)
  75. $map['video_share.vid'] = input('vid');
  76. }
  77. }
  78. // 每日分配各个短剧在不同平台的收益
  79. public function platform_income_day(){
  80. // 先获取所有短剧在不同平台的收益上下限
  81. $list = model('VideoPlatform')->select();
  82. var_dump($list);die();
  83. foreach ($list as $k => $v){
  84. $randomNumber = mt_rand($v['min'] * 100, $v['max'] * 100) / 100;
  85. $up=[
  86. 'vid'=>$v['vid'],
  87. 'platform_id'=>$v['platform_id'],
  88. 'num'=>$randomNumber,
  89. 'createtime'=>time(),
  90. ];
  91. $id=Db::name('task')->insertGetId($up);
  92. }
  93. $this->success('分配完成');
  94. }
  95. }