Manage.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. # 显示杂志内页
  123. public function journalContent()
  124. {
  125. $where['info_id'] = Dever::input('search_option_info_id');
  126. $where['state'] = Dever::input('search_option_state');
  127. $data = Dever::db('journal/content')->all($where);
  128. $database = Dever::load('manage/database');
  129. if ($data) {
  130. foreach ($data as $k => $v) {
  131. if ($v['type'] <= 2) {
  132. $data[$k]['name'] = '';
  133. } elseif ($v['type'] == 3) {
  134. $data[$k]['pic'] = $v['focus'];
  135. }
  136. if ($v['type'] == 2) {
  137. $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
  138. } else {
  139. $data[$k]['text'] = '';
  140. }
  141. $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
  142. $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
  143. $data[$k]['delete'] = $database->url('delete', $v['id']);
  144. }
  145. }
  146. return $data;
  147. }
  148. public function text($database, $content_id, $info_id)
  149. {
  150. $id = 1;
  151. $link = $database->url('edit') . '&search_option_info_id=' . $info_id . '&search_option_content_id=' . $content_id . '&table=content_text&where_id=' . $id;
  152. $edit =
  153. $html = '<table class="layui-table">
  154. <tbody>
  155. <tr>
  156. <td><a href="javascript:;" onclick="fastEdit($(this), \''.$link . '&search_option_location=1'.'\', \'编辑上左文字\', \'\')">上左</a></td>
  157. <td>上中</td>
  158. <td>上右</td>
  159. </tr>
  160. <tr>
  161. <td>中左</td>
  162. <td>正中</td>
  163. <td>中右</td>
  164. </tr>
  165. <tr>
  166. <td>下左</td>
  167. <td>下中</td>
  168. <td>下右</td>
  169. </tr>
  170. </tbody>
  171. </table>';
  172. return $html;
  173. }
  174. public function updateJournalContent_api()
  175. {
  176. $data = Dever::input('data');
  177. if ($data) {
  178. $data = explode(',', str_replace('data-', '', $data));
  179. foreach ($data as $k => $v) {
  180. $k = $k + 1;
  181. $where['where_id'] = $v;
  182. $where['reorder'] = $k;
  183. Dever::db('journal/content')->update($where);
  184. }
  185. }
  186. return $data;
  187. }
  188. }