Manage.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. namespace Journal\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function showOrderUser($id)
  7. {
  8. $info = Dever::db('journal/order')->one($id);
  9. $table = array();
  10. $user = Dever::db('passport/user')->one($info['uid']);
  11. $table['用户名'] = $user['username'];
  12. $table['手机号'] = $user['mobile'];
  13. //$table['产品名'] = $info['name'];
  14. if ($info['type'] == 1) {
  15. $table['支付方式'] = '购买';
  16. $table['支付金额'] = $info['cash'];
  17. } else {
  18. $table['支付方式'] = '兑换';
  19. $table['兑换码'] = $info['code'];
  20. }
  21. //$table['购买数量'] = $info['num'];
  22. if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
  23. $user = Dever::db('passport/user')->one($info['source_uid']);
  24. $table['邀请人'] = $user['username'];
  25. }
  26. return Dever::table($table);
  27. }
  28. private function search($table = 'content/article')
  29. {
  30. $keyword = Dever::input('keyword');
  31. $yes = Dever::input('yes');
  32. $where = array();
  33. if ($yes) {
  34. $yes = Dever::db($table)->search(array('ids' => $yes));
  35. }
  36. if (!$keyword) {
  37. $where['limit'] = '0,50';
  38. $data = Dever::db($table)->search($where);
  39. } else {
  40. $where['name'] = $keyword;
  41. $data = Dever::db($table)->search($where);
  42. }
  43. $result = array();
  44. if ($yes) {
  45. foreach ($yes as $k => $v) {
  46. if (isset($data[$k])) {
  47. unset($data[$k]);
  48. }
  49. $yes[$k]['selected'] = 'selected';
  50. }
  51. $data = $yes + $data;
  52. $data = array_merge($data, array());
  53. } else {
  54. $data = array_merge($data, array());
  55. }
  56. if (!$data) {
  57. Dever::alert('暂无数据');
  58. }
  59. return $data;
  60. }
  61. # 搜索文章
  62. public function search_article_api()
  63. {
  64. return $this->search('content/article');
  65. }
  66. # 搜索视频
  67. public function search_vod_api()
  68. {
  69. return $this->search('video/vod');
  70. }
  71. # 搜索直播
  72. public function search_live_api()
  73. {
  74. return $this->search('video/live');
  75. }
  76. # 搜索小刊
  77. public function search_journal_api()
  78. {
  79. return $this->search('journal/info');
  80. }
  81. # 显示杂志内页
  82. public function journalContent()
  83. {
  84. $where['info_id'] = Dever::input('search_option_info_id');
  85. $where['state'] = Dever::input('search_option_state');
  86. $data = Dever::db('journal/content')->all($where);
  87. $database = Dever::load('manage/database');
  88. $type = Dever::db('journal/content')->config['gettype'];
  89. if ($data) {
  90. foreach ($data as $k => $v) {
  91. $data[$k]['height'] = 'height: 154px;';
  92. $data[$k]['info_height'] = 'height: auto;';
  93. if ($v['type'] > 2) {
  94. $data[$k]['height'] = 'height: 104px;';
  95. $data[$k]['info_height'] = 'height: 47px;';
  96. }
  97. if ($v['type'] <= 2) {
  98. $data[$k]['name'] = '';
  99. } elseif ($v['type'] == 3) {
  100. $data[$k]['pic'] = $v['focus'];
  101. }
  102. if ($v['type'] == 11) {
  103. # 图文
  104. $info = Dever::load('content/lib/article')->get($v['article_id']);
  105. if ($info) {
  106. $data[$k]['pic'] = $info['pic_cover'];
  107. $data[$k]['name'] = $info['name'];
  108. }
  109. } elseif ($v['type'] == 12) {
  110. # 视频
  111. $info = Dever::load('video/lib/vod')->get($v['vod_id']);
  112. if ($info) {
  113. $data[$k]['pic'] = $info['pic_cover'];
  114. $data[$k]['name'] = $info['name'];
  115. }
  116. } elseif ($v['type'] == 13) {
  117. # 直播
  118. $info = Dever::load('video/lib/live')->get($v['live_id']);
  119. if ($info) {
  120. $data[$k]['pic'] = $info['pic_cover'];
  121. $data[$k]['name'] = $info['name'];
  122. }
  123. }
  124. $data[$k]['typename'] = $type[$v['type']];
  125. /*
  126. if ($v['type'] == 1) {
  127. $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
  128. } else {
  129. $data[$k]['text'] = '';
  130. }
  131. */
  132. $data[$k]['text'] = '';
  133. $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
  134. $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
  135. $data[$k]['editurl'] = $link;
  136. $data[$k]['delete'] = $database->url('delete', $v['id']);
  137. }
  138. }
  139. return $data;
  140. }
  141. private function text_name($link, $content_id, $info_id, $location, $name)
  142. {
  143. $where['info_id'] = $info_id;
  144. $where['content_id'] = $content_id;
  145. $where['location'] = $location;
  146. $info = Dever::db('journal/content_text')->one($where);
  147. $link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
  148. if ($info) {
  149. $link .= '&where_id=' . $info['id'];
  150. }
  151. $html = '<a style="cursor:pointer;" href="javascript:;" onclick="fastEdit($(this), \''.$link.'\', \'编辑'.$name.'文字\', \'\')">'.$name.'</a>';
  152. return $html;
  153. }
  154. public function text($database, $content_id, $info_id)
  155. {
  156. $link = $database->url('edit');
  157. $location = Dever::db('journal/content_text')->config['location'];
  158. $html = '<table class="layui-table"><tbody><tr>';
  159. $i = 0;
  160. foreach ($location as $k => $v) {
  161. $name = $this->text_name($link, $content_id, $info_id, $k, $v);
  162. $html .= '<td>'.$name.'</td>';
  163. if ($i == 2 || $i == 5) {
  164. $html .= '</tr><tr>';
  165. }
  166. $i++;
  167. }
  168. $html .= '</tr></tbody></table>';
  169. return $html;
  170. }
  171. public function updateJournalContent_api()
  172. {
  173. $data = Dever::input('data');
  174. if ($data) {
  175. $data = explode(',', str_replace('data-', '', $data));
  176. foreach ($data as $k => $v) {
  177. $k = $k + 1;
  178. $where['where_id'] = $v;
  179. $where['reorder'] = $k;
  180. Dever::db('journal/content')->update($where);
  181. }
  182. }
  183. return $data;
  184. }
  185. }