Manage.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. public function showOrderStatus($id)
  29. {
  30. $info = Dever::db('journal/order')->one($id);
  31. if ($info) {
  32. if ($info['status'] == 1) {
  33. #return '*已支付';
  34. return '待支付';
  35. } elseif ($info['status'] == 2) {
  36. return '已支付';
  37. } elseif ($info['status'] == 3) {
  38. return '支付失败';
  39. } elseif ($info['status'] == 5) {
  40. $table['状态'] = '已退款';
  41. $manage = Dever::db('manage/admin')->one($info['tk_admin']);
  42. $table['备注'] = $info['tk_desc'];
  43. $table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
  44. $table['操作人'] = $manage['username'];
  45. return Dever::table($table);
  46. }
  47. }
  48. }
  49. private function search($table = 'content/article')
  50. {
  51. $keyword = Dever::input('keyword');
  52. $yes = Dever::input('yes');
  53. $where = array();
  54. if ($yes) {
  55. $yes = Dever::db($table)->search(array('ids' => $yes));
  56. }
  57. if (!$keyword) {
  58. $where['limit'] = '0,50';
  59. $data = Dever::db($table)->search($where);
  60. } else {
  61. $where['name'] = $keyword;
  62. $data = Dever::db($table)->search($where);
  63. }
  64. $result = array();
  65. if ($yes) {
  66. foreach ($yes as $k => $v) {
  67. if (isset($data[$k])) {
  68. unset($data[$k]);
  69. }
  70. $yes[$k]['selected'] = 'selected';
  71. }
  72. $data = $yes + $data;
  73. $data = array_merge($data, array());
  74. } else {
  75. $data = array_merge($data, array());
  76. }
  77. if (!$data) {
  78. Dever::alert('暂无数据');
  79. }
  80. return $data;
  81. }
  82. # 搜索文章
  83. public function search_article_api()
  84. {
  85. return $this->search('content/article');
  86. }
  87. # 搜索视频
  88. public function search_vod_api()
  89. {
  90. return $this->search('video/vod');
  91. }
  92. # 搜索直播
  93. public function search_live_api()
  94. {
  95. return $this->search('video/live');
  96. }
  97. # 搜索小刊
  98. public function search_journal_api()
  99. {
  100. return $this->search('journal/info');
  101. }
  102. # 显示杂志内页
  103. public function journalContent()
  104. {
  105. $where['info_id'] = Dever::input('search_option_info_id');
  106. $where['state'] = Dever::input('search_option_state');
  107. $data = Dever::db('journal/content')->all($where);
  108. $database = Dever::load('manage/database');
  109. $type = Dever::db('journal/content')->config['gettype'];
  110. if ($data) {
  111. foreach ($data as $k => $v) {
  112. $data[$k]['height'] = 'height: 154px;';
  113. $data[$k]['info_height'] = 'height: auto;';
  114. if ($v['type'] > 2) {
  115. $data[$k]['height'] = 'height: 104px;';
  116. $data[$k]['info_height'] = 'height: 47px;';
  117. }
  118. if ($v['type'] <= 2) {
  119. $data[$k]['name'] = '';
  120. } elseif ($v['type'] == 3) {
  121. $data[$k]['pic'] = $v['focus'];
  122. }
  123. if ($v['type'] == 11) {
  124. # 图文
  125. $info = Dever::load('content/lib/article')->get($v['article_id']);
  126. if ($info) {
  127. $data[$k]['pic'] = $info['pic_cover'];
  128. $data[$k]['name'] = $info['name'];
  129. }
  130. } elseif ($v['type'] == 12) {
  131. # 视频
  132. $info = Dever::load('video/lib/vod')->get($v['vod_id']);
  133. if ($info) {
  134. $data[$k]['pic'] = $info['pic_cover'];
  135. $data[$k]['name'] = $info['name'];
  136. }
  137. } elseif ($v['type'] == 13) {
  138. # 直播
  139. $info = Dever::load('video/lib/live')->get($v['live_id']);
  140. if ($info) {
  141. $data[$k]['pic'] = $info['pic_cover'];
  142. $data[$k]['name'] = $info['name'];
  143. }
  144. }
  145. $data[$k]['typename'] = $type[$v['type']];
  146. /*
  147. if ($v['type'] == 1) {
  148. $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
  149. } else {
  150. $data[$k]['text'] = '';
  151. }
  152. */
  153. $data[$k]['text'] = '';
  154. $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
  155. $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
  156. $data[$k]['editurl'] = $link;
  157. $data[$k]['delete'] = $database->url('delete', $v['id']);
  158. }
  159. }
  160. return $data;
  161. }
  162. private function text_name($link, $content_id, $info_id, $location, $name)
  163. {
  164. $where['info_id'] = $info_id;
  165. $where['content_id'] = $content_id;
  166. $where['location'] = $location;
  167. $info = Dever::db('journal/content_text')->one($where);
  168. $link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
  169. if ($info) {
  170. $link .= '&where_id=' . $info['id'];
  171. }
  172. $html = '<a style="cursor:pointer;" href="javascript:;" onclick="fastEdit($(this), \''.$link.'\', \'编辑'.$name.'文字\', \'\')">'.$name.'</a>';
  173. return $html;
  174. }
  175. public function text($database, $content_id, $info_id)
  176. {
  177. $link = $database->url('edit');
  178. $location = Dever::db('journal/content_text')->config['location'];
  179. $html = '<table class="layui-table"><tbody><tr>';
  180. $i = 0;
  181. foreach ($location as $k => $v) {
  182. $name = $this->text_name($link, $content_id, $info_id, $k, $v);
  183. $html .= '<td>'.$name.'</td>';
  184. if ($i == 2 || $i == 5) {
  185. $html .= '</tr><tr>';
  186. }
  187. $i++;
  188. }
  189. $html .= '</tr></tbody></table>';
  190. return $html;
  191. }
  192. public function updateJournalContent_api()
  193. {
  194. $data = Dever::input('data');
  195. if ($data) {
  196. $data = explode(',', str_replace('data-', '', $data));
  197. foreach ($data as $k => $v) {
  198. $k = $k + 1;
  199. $where['where_id'] = $v;
  200. $where['reorder'] = $k;
  201. Dever::db('journal/content')->update($where);
  202. }
  203. }
  204. return $data;
  205. }
  206. public function addContent($id, $name, $data)
  207. {
  208. # 获取最新的reorder
  209. $info_id = Dever::param('info_id', $data);
  210. $data = Dever::db('journal/content')->getAllByReorder(array('info_id' => $info_id));
  211. if ($data) {
  212. $update['where_id'] = $id;
  213. $update['reorder'] = $data['reorder'] + 1;
  214. Dever::db('journal/content')->update($update);
  215. }
  216. }
  217. public function getName($id)
  218. {
  219. $info = Dever::db('journal/buy_num')->one($id);
  220. if ($info && $info['name']) {
  221. return $info['name'];
  222. } else {
  223. return '购买' . $info['num'] . '本';
  224. }
  225. }
  226. public function getPrice($id)
  227. {
  228. $info = Dever::db('journal/buy_num')->one($id);
  229. $journal = Dever::db('journal/info')->one($info['info_id']);
  230. if ($info && $info['price']) {
  231. return $info['price'];
  232. } else {
  233. return $info['num'] * $journal['cash'] . '元';
  234. }
  235. }
  236. }