Storesnstrace.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. * ============================================================================
  13. * 控制器
  14. */
  15. class Storesnstrace extends AdminControl {
  16. public function initialize() {
  17. parent::initialize(); // TODO: Change the autogenerated stub
  18. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/storesnstrace.lang.php');
  19. }
  20. /**
  21. * 动态列表
  22. */
  23. public function index() {
  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. $st_id = input('param.st_id');
  68. $st_id_array = ds_delete_param($st_id);
  69. if ($st_id_array == FALSE) {
  70. ds_json_encode('10001', lang('param_error'));
  71. }
  72. // 删除动态
  73. $rs = model('storesnstracelog')->delStoresnstracelog(array(array('stracelog_id' ,'in', $st_id_array)));
  74. if ($rs) {
  75. // 删除评论
  76. model('storesnscomment')->delStoresnscomment(array(array('stracelog_id','in', $st_id_array)));
  77. $this->log(lang('ds_del').lang('admin_snstrace_comment'), 1);
  78. ds_json_encode('10000', lang('ds_common_del_succ'));
  79. } else {
  80. ds_json_encode('10001', lang('ds_common_del_fail'));
  81. }
  82. }
  83. /**
  84. * 编辑动态
  85. */
  86. public function strace_edit() {
  87. $st_id = input('param.st_id');
  88. $st_id_array = ds_delete_param($st_id);
  89. if ($st_id_array == FALSE) {
  90. ds_json_encode('10001', lang('param_error'));
  91. }
  92. // where条件
  93. $where = array();
  94. $where[]=array('stracelog_id','in', $st_id_array);
  95. // update条件
  96. $update = array();
  97. if (input('param.type') == 'hide') {
  98. $update['stracelog_state'] = 0;
  99. }else{
  100. $update['stracelog_state'] = 1;
  101. }
  102. // 实例化模型
  103. $rs = model('storesnstracelog')->editStoresnstracelog($update, $where);
  104. if ($rs) {
  105. $this->log(lang('ds_edit').lang('admin_snstrace_comment'), 1);
  106. ds_json_encode('10000', lang('ds_common_op_succ'));
  107. } else {
  108. ds_json_encode('10001', lang('ds_common_op_fail'));
  109. }
  110. }
  111. /**
  112. * 评论列表
  113. */
  114. public function storecomment_list() {
  115. // where 条件
  116. $where = array();
  117. $st_id = intval(input('get.st_id'));
  118. if ($st_id > 0) {
  119. $where[]=array('stracelog_id','=',$st_id);
  120. }
  121. if (input('get.search_uname') != '') {
  122. $where[]=array('storesnscomm_membername','like', '%' . trim(input('get.search_uname')) . '%');
  123. }
  124. if (input('get.search_content') != '') {
  125. $where[]=array('storesnscomm_content','like', '%' . trim(input('get.search_content')) . '%');
  126. }
  127. if (input('get.search_state') != '') {
  128. $where[]=array('storesnscomm_state','=',intval(input('get.search_state')));
  129. }
  130. if (input('get.search_stime') != '') {
  131. $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
  132. $where[] = array('storesnscomm_time','>=', $s_time);
  133. }
  134. if (input('get.search_etime') != '') {
  135. $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime'))+86399) : null;
  136. $where[] = array('storesnscomm_time','<=', $e_time);
  137. }
  138. $model_storesnscomment = model('storesnscomment');
  139. $storesnscomm_list = $model_storesnscomment->getStoresnscommentList($where, '*', 'storesnscomm_id desc', 0, 20);
  140. $this->setAdminCurItem('index');
  141. View::assign('scomm_list', $storesnscomm_list);
  142. View::assign('show_page', $model_storesnscomment->page_info->render());
  143. return View::fetch();
  144. }
  145. /**
  146. * 删除评论
  147. */
  148. public function scomm_del() {
  149. $sc_id = input('param.sc_id');
  150. $sc_id_array = ds_delete_param($sc_id);
  151. if ($sc_id_array == FALSE) {
  152. ds_json_encode('10001', lang('param_error'));
  153. }
  154. // 实例化模型
  155. $rs = model('storesnscomment')->delStoresnscomment(array(array('storesnscomm_id','in', $sc_id_array)));
  156. if ($rs) {
  157. $this->log(lang('ds_del').lang('admin_snstrace_pl'), 1);
  158. ds_json_encode('10000', lang('ds_common_del_succ'));
  159. } else {
  160. ds_json_encode('10001', lang('ds_common_del_fail'));
  161. }
  162. }
  163. /**
  164. * 评论编辑
  165. */
  166. public function scomm_edit() {
  167. $sc_id = input('param.sc_id');
  168. $sc_id_array = ds_delete_param($sc_id);
  169. if ($sc_id_array == FALSE) {
  170. ds_json_encode('10001', lang('param_error'));
  171. }
  172. $storesnscomm_state = 1;
  173. if (input('get.type') == 'hide') {
  174. $storesnscomm_state = 0;
  175. }
  176. // 实例化模型
  177. $rs = model('storesnscomment')->editStoresnscomment(array('storesnscomm_state' => $storesnscomm_state), array(array('storesnscomm_id' ,'in', $sc_id_array)));
  178. if ($rs) {
  179. $this->log(lang('ds_edit').lang('admin_snstrace_pl'), 1);
  180. ds_json_encode('10000', lang('ds_common_op_succ'));
  181. } else {
  182. ds_json_encode('10001', lang('ds_common_op_fail'));
  183. }
  184. }
  185. }