Storesnstrace.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Storesnstrace extends AdminControl
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/storesnstrace.lang.php');
  18. }
  19. /**
  20. * 动态列表
  21. */
  22. public function index()
  23. {
  24. // where条件
  25. $where = array();
  26. if (input('get.search_sname') != '') {
  27. $where[] = array('stracelog_storename', 'like', '%' . trim(input('get.search_sname')) . '%');
  28. }
  29. if (input('get.search_stitle') != '') {
  30. $where[] = array('stracelog_title', 'like', '%' . trim(input('get.search_stitle')) . '%');
  31. }
  32. if (input('get.search_scontent') != '') {
  33. $where[] = array('stracelog_content', 'like', '%' . trim(input('get.search_scontent')) . '%');
  34. }
  35. if (input('get.search_type') != '') {
  36. $where[] = array('stracelog_type', '=', trim(input('get.search_type')));
  37. }
  38. if (input('get.search_stime') != '') {
  39. $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
  40. $where[] = array('stracelog_time', '>=', $s_time);
  41. }
  42. if (input('get.search_etime') != '') {
  43. $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime')) + 86399) : null;
  44. $where[] = array('stracelog_time', '<=', $e_time);
  45. }
  46. // 实例化模型
  47. $storesnstracelog_model = model('storesnstracelog');
  48. $storetrace_list = $storesnstracelog_model->getStoresnstracelogList($where, '*', 'stracelog_id desc', 0, 10);
  49. if (!empty($storetrace_list) && is_array($storetrace_list)) {
  50. foreach ($storetrace_list as $key => $val) {
  51. if ($val['stracelog_content'] == '') {
  52. $data = json_decode(stripslashes($val['stracelog_goodsdata']), true);
  53. $content = $storesnstracelog_model->spellingStyle($val['stracelog_type'], $data);
  54. $storetrace_list[$key]['stracelog_content'] = str_replace("%siteurl%", HOME_SITE_URL . DIRECTORY_SEPARATOR, $content);
  55. }
  56. }
  57. }
  58. $this->setAdminCurItem('index');
  59. View::assign('storetrace_list', $storetrace_list);
  60. View::assign('show_page', $storesnstracelog_model->page_info->render());
  61. return View::fetch();
  62. }
  63. /**
  64. * 删除动态
  65. */
  66. public function strace_del()
  67. {
  68. $st_id = input('param.st_id');
  69. $st_id_array = ds_delete_param($st_id);
  70. if ($st_id_array == FALSE) {
  71. ds_json_encode('10001', lang('param_error'));
  72. }
  73. // 删除动态
  74. $rs = model('storesnstracelog')->delStoresnstracelog(array(array('stracelog_id', 'in', $st_id_array)));
  75. if ($rs) {
  76. // 删除评论
  77. model('storesnscomment')->delStoresnscomment(array(array('stracelog_id', 'in', $st_id_array)));
  78. $this->log(lang('ds_del') . lang('admin_snstrace_comment'), 1);
  79. ds_json_encode('10000', lang('ds_common_del_succ'));
  80. } else {
  81. ds_json_encode('10001', lang('ds_common_del_fail'));
  82. }
  83. }
  84. /**
  85. * 编辑动态
  86. */
  87. public function strace_edit()
  88. {
  89. $st_id = input('param.st_id');
  90. $st_id_array = ds_delete_param($st_id);
  91. if ($st_id_array == FALSE) {
  92. ds_json_encode('10001', lang('param_error'));
  93. }
  94. // where条件
  95. $where = array();
  96. $where[] = array('stracelog_id', 'in', $st_id_array);
  97. // update条件
  98. $update = array();
  99. if (input('param.type') == 'hide') {
  100. $update['stracelog_state'] = 0;
  101. } else {
  102. $update['stracelog_state'] = 1;
  103. }
  104. // 实例化模型
  105. $rs = model('storesnstracelog')->editStoresnstracelog($update, $where);
  106. if ($rs) {
  107. $this->log(lang('ds_edit') . lang('admin_snstrace_comment'), 1);
  108. ds_json_encode('10000', lang('ds_common_op_succ'));
  109. } else {
  110. ds_json_encode('10001', lang('ds_common_op_fail'));
  111. }
  112. }
  113. /**
  114. * 评论列表
  115. */
  116. public function storecomment_list()
  117. {
  118. // where 条件
  119. $where = array();
  120. $st_id = intval(input('get.st_id'));
  121. if ($st_id > 0) {
  122. $where[] = array('stracelog_id', '=', $st_id);
  123. }
  124. if (input('get.search_uname') != '') {
  125. $where[] = array('storesnscomm_membername', 'like', '%' . trim(input('get.search_uname')) . '%');
  126. }
  127. if (input('get.search_content') != '') {
  128. $where[] = array('storesnscomm_content', 'like', '%' . trim(input('get.search_content')) . '%');
  129. }
  130. if (input('get.search_state') != '') {
  131. $where[] = array('storesnscomm_state', '=', intval(input('get.search_state')));
  132. }
  133. if (input('get.search_stime') != '') {
  134. $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
  135. $where[] = array('storesnscomm_time', '>=', $s_time);
  136. }
  137. if (input('get.search_etime') != '') {
  138. $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime')) + 86399) : null;
  139. $where[] = array('storesnscomm_time', '<=', $e_time);
  140. }
  141. $model_storesnscomment = model('storesnscomment');
  142. $storesnscomm_list = $model_storesnscomment->getStoresnscommentList($where, '*', 'storesnscomm_id desc', 0, 20);
  143. $this->setAdminCurItem('index');
  144. View::assign('scomm_list', $storesnscomm_list);
  145. View::assign('show_page', $model_storesnscomment->page_info->render());
  146. return View::fetch();
  147. }
  148. /**
  149. * 删除评论
  150. */
  151. public function scomm_del()
  152. {
  153. $sc_id = input('param.sc_id');
  154. $sc_id_array = ds_delete_param($sc_id);
  155. if ($sc_id_array == FALSE) {
  156. ds_json_encode('10001', lang('param_error'));
  157. }
  158. // 实例化模型
  159. $rs = model('storesnscomment')->delStoresnscomment(array(array('storesnscomm_id', 'in', $sc_id_array)));
  160. if ($rs) {
  161. $this->log(lang('ds_del') . lang('admin_snstrace_pl'), 1);
  162. ds_json_encode('10000', lang('ds_common_del_succ'));
  163. } else {
  164. ds_json_encode('10001', lang('ds_common_del_fail'));
  165. }
  166. }
  167. /**
  168. * 评论编辑
  169. */
  170. public function scomm_edit()
  171. {
  172. $sc_id = input('param.sc_id');
  173. $sc_id_array = ds_delete_param($sc_id);
  174. if ($sc_id_array == FALSE) {
  175. ds_json_encode('10001', lang('param_error'));
  176. }
  177. $storesnscomm_state = 1;
  178. if (input('get.type') == 'hide') {
  179. $storesnscomm_state = 0;
  180. }
  181. // 实例化模型
  182. $rs = model('storesnscomment')->editStoresnscomment(array('storesnscomm_state' => $storesnscomm_state), array(array('storesnscomm_id', 'in', $sc_id_array)));
  183. if ($rs) {
  184. $this->log(lang('ds_edit') . lang('admin_snstrace_pl'), 1);
  185. ds_json_encode('10000', lang('ds_common_op_succ'));
  186. } else {
  187. ds_json_encode('10001', lang('ds_common_op_fail'));
  188. }
  189. }
  190. }