Manage.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace Journal\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. /**
  7. * 显示用户信息
  8. *
  9. * @return mixed
  10. */
  11. public function showUserInfo($uid, $ldate = false)
  12. {
  13. if ($uid) {
  14. $user = Dever::db('passport/user')->one($uid);
  15. if ($user) {
  16. $table = array();
  17. $table['用户名'] = $user['username'];
  18. $table['手机号'] = $user['mobile'];
  19. $table['领取时间'] = date('Y-m-d H:i:s', $ldate);
  20. return Dever::table($table);
  21. }
  22. } else {
  23. return '';
  24. }
  25. }
  26. /**
  27. * 创建兑换码
  28. *
  29. * @return mixed
  30. */
  31. public function create($id, $name, $data)
  32. {
  33. $code = Dever::param('code', $data);
  34. $type = Dever::param('type', $data);
  35. $product_id = Dever::param('product_id', $data);
  36. //$product_id = $id;
  37. if (!in_array(2, $type)) {
  38. return;
  39. }
  40. $total = Dever::db('journal/code')->total(array('product_id' => $product_id,'product_price_id' => $id, 'type' => 1));
  41. if ($code > 0 && $code > $total) {
  42. $num = $code - $total;
  43. for ($i = 0; $i < $num; $i++) {
  44. $this->createCode($product_id, $id);
  45. }
  46. }
  47. }
  48. private function createCode($product_id, $id)
  49. {
  50. $code = Dever::rand(8, 0);
  51. $data['product_id'] = $product_id;
  52. $data['product_price_id'] = $id;
  53. $data['code'] = $code;
  54. $total = Dever::db('journal/code')->total($data);
  55. if ($total > 0) {
  56. return $this->createCode($product_id, $id);
  57. }
  58. $data['type'] = 1;
  59. Dever::db('code/info')->insert($data);
  60. return $code;
  61. }
  62. /**
  63. * 资料审核
  64. *
  65. * @return mixed
  66. */
  67. public function info_audit($id, $name, $data)
  68. {
  69. $info = Dever::db('task/user_info')->one($id);
  70. $status = Dever::param('status', $data);
  71. $desc = Dever::param('status_desc', $data);
  72. if ($info && $status == 3) {
  73. $uid = $info['uid'];
  74. $name = '用户认证未通过';
  75. $content = '原因:' . $desc;
  76. Dever::load('message/lib/data.push', -1, $uid, $name, $content, 11);
  77. }
  78. }
  79. private function search($table = 'content/article')
  80. {
  81. $keyword = Dever::input('keyword');
  82. $yes = Dever::input('yes');
  83. $where = array();
  84. if ($yes) {
  85. $yes = Dever::db($table)->search(array('ids' => $yes));
  86. }
  87. if (!$keyword) {
  88. $where['limit'] = '0,50';
  89. $data = Dever::db($table)->search($where);
  90. } else {
  91. $where['name'] = $keyword;
  92. $data = Dever::db($table)->search($where);
  93. }
  94. $result = array();
  95. if ($yes) {
  96. foreach ($yes as $k => $v) {
  97. if (isset($data[$k])) {
  98. unset($data[$k]);
  99. }
  100. $yes[$k]['selected'] = 'selected';
  101. }
  102. $data = $yes + $data;
  103. $data = array_merge($data, array());
  104. }
  105. return $data;
  106. }
  107. # 搜索文章
  108. public function search_article_api()
  109. {
  110. return $this->search('content/article');
  111. }
  112. # 搜索视频
  113. public function search_vod_api()
  114. {
  115. return $this->search('video/vod');
  116. }
  117. # 搜索直播
  118. public function search_live_api()
  119. {
  120. return $this->search('video/live');
  121. }
  122. }