Extend.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Cache;
  5. class Extend extends Base {
  6. public function dataCount()
  7. {
  8. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'data_count';
  9. $data = Cache::get($key);
  10. if(empty($data)){
  11. $totay = strtotime(date('Y-m-d'));
  12. //视频
  13. $where = [];
  14. $where['vod_status'] = ['eq',1];
  15. $tmp = model('Vod')->field('type_id_1,type_id,count(vod_id) as cc')->where($where)->group('type_id_1,type_id')->select();
  16. foreach($tmp as $k=>$v){
  17. $data['vod_all'] += intval($v['cc']);
  18. $list['type_all_'.$v['type_id']] = $v->toArray();
  19. }
  20. $where['vod_time'] = ['egt',$totay];
  21. $tmp = model('Vod')->field('type_id_1,type_id,count(vod_id) as cc')->where($where)->group('type_id_1,type_id')->select();
  22. foreach($tmp as $k=>$v){
  23. $data['vod_today'] += intval($v['cc']);
  24. $list['type_today_'.$v['type_id']] = $v->toArray();
  25. }
  26. $data['vod_min'] = model('Vod')->min('vod_id');
  27. //文章
  28. $where = [];
  29. $where['art_status'] = ['eq',1];
  30. $tmp = model('Art')->field('type_id_1,type_id,count(art_id) as cc')->where($where)->group('type_id_1,type_id')->select();
  31. foreach($tmp as $k=>$v){
  32. $data['art_all'] += intval($v['cc']);
  33. $list['type_all_'.$v['type_id']] = $v->toArray();
  34. }
  35. $where['art_time'] = ['egt',$totay];
  36. $tmp = model('Art')->field('type_id_1,type_id,count(art_id) as cc')->where($where)->group('type_id_1,type_id')->select();
  37. foreach($tmp as $k=>$v){
  38. $data['art_today'] += intval($v['cc']);
  39. $list['type_today_'.$v['type_id']] = $v->toArray();
  40. }
  41. $data['art_min'] = model('Art')->min('art_id');
  42. //分类
  43. foreach($list as $k=>$v) {
  44. $data[$k]=$v['cc'];
  45. if(strpos($k,'type_all')!==false){
  46. $data['type_all_' . $v['type_id_1']] += $v['cc'];
  47. }
  48. if(strpos($k,'type_today')!==false){
  49. $data['type_today_' . $v['type_id_1']] += $v['cc'];
  50. }
  51. }
  52. //专题
  53. $where = [];
  54. $where['topic_status'] = ['eq',1];
  55. $tmp = model('Topic')->where($where)->count();
  56. $data['topic_all'] = $tmp;
  57. $where['topic_time'] = ['egt',$totay];
  58. $tmp = model('Topic')->where($where)->count();
  59. $data['topic_today'] = $tmp;
  60. $data['tpoic_min'] = model('Topic')->min('topic_id');
  61. //演员库
  62. $where = [];
  63. $where['actor_status'] = ['eq',1];
  64. $tmp = model('Actor')->where($where)->count();
  65. $data['actor_all'] = $tmp;
  66. $where['actor_time'] = ['egt',$totay];
  67. $tmp = model('Actor')->where($where)->count();
  68. $data['actor_today'] = $tmp;
  69. $data['actor_min'] = model('Actor')->min('actor_id');
  70. //角色库
  71. $where = [];
  72. $where['role_status'] = ['eq',1];
  73. $tmp = model('Role')->where($where)->count();
  74. $data['role_all'] = $tmp;
  75. $where['role_time'] = ['egt',$totay];
  76. $tmp = model('Role')->where($where)->count();
  77. $data['role_today'] = $tmp;
  78. $data['role_min'] = model('Role')->min('role_id');
  79. //网址库
  80. $where = [];
  81. $where['website_status'] = ['eq',1];
  82. $tmp = model('Website')->where($where)->count();
  83. $data['website_all'] = $tmp;
  84. $where['website_time'] = ['egt',$totay];
  85. $tmp = model('Website')->where($where)->count();
  86. $data['website_today'] = $tmp;
  87. $data['website_min'] = model('Website')->min('website_id');
  88. Cache::set($key,$data,$GLOBALS['config']['app']['cache_time']);
  89. }
  90. return $data;
  91. }
  92. public function areaData($lp)
  93. {
  94. $order = $lp['order'];
  95. $start = intval(abs($lp['start']));
  96. $num = intval(abs($lp['num']));
  97. $tid = intval($lp['tid']);
  98. $config = config('maccms.app');
  99. $data_str = $config['vod_extend_area'];
  100. if($tid>0){
  101. $type_list = model('Type')->getCache('tree_list');
  102. $type_info = $type_list[$tid];
  103. if(!empty($type_info)){
  104. $type_extend = json_decode($type_info['type_extend'],true);
  105. $data_str = $type_extend['area'];
  106. }
  107. }
  108. if(empty($num)){
  109. $num = 20;
  110. }
  111. if($start>1){
  112. $start--;
  113. }
  114. $tmp = explode(',',$data_str);
  115. if($order=='desc'){
  116. $tmp = array_reverse($tmp);
  117. }
  118. $list = [];
  119. foreach($tmp as $k=>$v){
  120. if($k>=$start && $k<$num){
  121. $list[] = ['area_name' => $v];
  122. }
  123. }
  124. $list = array_filter($list);
  125. $total = count($list);
  126. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('area_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  127. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  128. }
  129. public function langData($lp)
  130. {
  131. $order = $lp['order'];
  132. $start = intval(abs($lp['start']));
  133. $num = intval(abs($lp['num']));
  134. $tid = intval($lp['tid']);
  135. $config = config('maccms.app');
  136. $data_str = $config['vod_extend_lang'];
  137. if($tid>0){
  138. $type_list = model('Type')->getCache('tree_list');
  139. $type_info = $type_list[$tid];
  140. if(!empty($type_info)){
  141. $type_extend = json_decode($type_info['type_extend'],true);
  142. $data_str = $type_extend['lang'];
  143. }
  144. }
  145. if(empty($num)){
  146. $num = 20;
  147. }
  148. if($start>1){
  149. $start--;
  150. }
  151. $tmp = explode(',',$data_str);
  152. if($order=='desc'){
  153. $tmp = array_reverse($tmp);
  154. }
  155. $list = [];
  156. foreach($tmp as $k=>$v){
  157. if($k>=$start && $k<$num){
  158. $list[] = ['lang_name' => $v];
  159. }
  160. }
  161. $list = array_filter($list);
  162. $total = count($list);
  163. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('lang_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  164. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  165. }
  166. public function classData($lp)
  167. {
  168. $order = $lp['order'];
  169. $start = intval(abs($lp['start']));
  170. $num = intval(abs($lp['num']));
  171. $tid = intval($lp['tid']);
  172. $config = config('maccms.app');
  173. $data_str = $config['vod_extend_class'];
  174. if($tid>0){
  175. $type_list = model('Type')->getCache('tree_list');
  176. $type_info = $type_list[$tid];
  177. if(!empty($type_info)){
  178. $type_extend = json_decode($type_info['type_extend'],true);
  179. $data_str = $type_extend['class'];
  180. }
  181. }
  182. if(empty($num)){
  183. $num = 20;
  184. }
  185. if($start>1){
  186. $start--;
  187. }
  188. $tmp = explode(',',$data_str);
  189. if($order=='desc'){
  190. $tmp = array_reverse($tmp);
  191. }
  192. $list = [];
  193. foreach($tmp as $k=>$v){
  194. if($k>=$start && $k<$num){
  195. $list[] = ['class_name' => $v];
  196. }
  197. }
  198. $list = array_filter($list);
  199. $total = count($list);
  200. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('class_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  201. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  202. }
  203. public function yearData($lp)
  204. {
  205. $order = $lp['order'];
  206. $start = intval(abs($lp['start']));
  207. $num = intval(abs($lp['num']));
  208. $tid = intval($lp['tid']);
  209. $config = config('maccms.app');
  210. $data_str = $config['vod_extend_year'];
  211. if($tid>0){
  212. $type_list = model('Type')->getCache('tree_list');
  213. $type_info = $type_list[$tid];
  214. if(!empty($type_info)){
  215. $type_extend = json_decode($type_info['type_extend'],true);
  216. $data_str = $type_extend['year'];
  217. }
  218. }
  219. if(empty($num)){
  220. $num = 20;
  221. }
  222. if($start>1){
  223. $start--;
  224. }
  225. $tmp = explode(',',$data_str);
  226. if($order=='desc'){
  227. $tmp = array_reverse($tmp);
  228. }
  229. $list = [];
  230. foreach($tmp as $k=>$v){
  231. if($k>=$start && $k<$num){
  232. $list[] = ['year_name' => $v];
  233. }
  234. }
  235. $list = array_filter($list);
  236. $total = count($list);
  237. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('year_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  238. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  239. }
  240. public function versionData($lp)
  241. {
  242. $order = $lp['order'];
  243. $start = intval(abs($lp['start']));
  244. $num = intval(abs($lp['num']));
  245. $tid = intval($lp['tid']);
  246. $config = config('maccms.app');
  247. $data_str = $config['vod_extend_version'];
  248. if($tid>0){
  249. $type_list = model('Type')->getCache('tree_list');
  250. $type_info = $type_list[$tid];
  251. if(!empty($type_info)){
  252. $type_extend = json_decode($type_info['type_extend'],true);
  253. $data_str = $type_extend['version'];
  254. }
  255. }
  256. if(empty($num)){
  257. $num = 20;
  258. }
  259. if($start>1){
  260. $start--;
  261. }
  262. $tmp = explode(',',$data_str);
  263. if($order=='desc'){
  264. $tmp = array_reverse($tmp);
  265. }
  266. $list = [];
  267. foreach($tmp as $k=>$v){
  268. if($k>=$start && $k<$num){
  269. $list[] = ['version_name' => $v];
  270. }
  271. }
  272. $list = array_filter($list);
  273. $total = count($list);
  274. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('version_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  275. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  276. }
  277. public function stateData($lp)
  278. {
  279. $order = $lp['order'];
  280. $start = intval(abs($lp['start']));
  281. $num = intval(abs($lp['num']));
  282. $tid = intval($lp['tid']);
  283. $config = config('maccms.app');
  284. $data_str = $config['vod_extend_state'];
  285. if($tid>0){
  286. $type_list = model('Type')->getCache('tree_list');
  287. $type_info = $type_list[$tid];
  288. if(!empty($type_info)){
  289. $type_extend = json_decode($type_info['type_extend'],true);
  290. $data_str = $type_extend['state'];
  291. }
  292. }
  293. if (!in_array($order, ['asc', 'desc'])) {
  294. $order = 'asc';
  295. }
  296. if(empty($num)){
  297. $num = 20;
  298. }
  299. if($start>1){
  300. $start--;
  301. }
  302. $tmp = explode(',',$data_str);
  303. if($order=='desc'){
  304. $tmp = array_reverse($tmp);
  305. }
  306. $list = [];
  307. foreach($tmp as $k=>$v){
  308. if($k>=$start && $k<$num){
  309. $list[] = ['state_name' => $v];
  310. }
  311. }
  312. $list = array_filter($list);
  313. $total = count($list);
  314. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('state_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  315. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  316. }
  317. public function letterData($lp)
  318. {
  319. $data_str = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0-9';
  320. $tmp = explode(',',$data_str);
  321. $order = $lp['order'];
  322. $start = intval(abs($lp['start']));
  323. $num = intval(abs($lp['num']));
  324. $tid = intval($lp['tid']);
  325. if (!in_array($order, ['asc', 'desc'])) {
  326. $order = 'asc';
  327. }
  328. if(empty($num)){
  329. $num = 20;
  330. }
  331. if($start>1){
  332. $start--;
  333. }
  334. if($tid>0){
  335. }
  336. if($order=='desc'){
  337. $tmp = array_reverse($tmp);
  338. }
  339. $list = [];
  340. foreach($tmp as $k=>$v){
  341. if($k>=$start && $k<$num){
  342. $list[] = ['letter_name' => $v];
  343. }
  344. }
  345. $list = array_filter($list);
  346. $total = count($list);
  347. $cach_name = $GLOBALS['config']['app']['cache_flag']. '_' . md5('letter_listcache_'.join('&',$lp).'_'.$order.'_'.$num.'_'.$start);
  348. return ['code'=>1,'msg'=>lang('data_list'),'page'=>1,'limit'=>$num,'total'=>$total,'list'=>$list];
  349. }
  350. }