Storesnstrace.php 7.8 KB

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