Storesnstrace.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Storesnstrace extends AdminControl {
  18. public function initialize() {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/storesnstrace.lang.php');
  21. }
  22. /**
  23. * 动态列表
  24. */
  25. public function index() {
  26. // where条件
  27. $where = array();
  28. if (input('get.search_sname') != '') {
  29. $where[]=array('stracelog_storename','like', '%' . trim(input('get.search_sname')) . '%');
  30. }
  31. if (input('get.search_stitle') != '') {
  32. $where[]=array('stracelog_title','like', '%' . trim(input('get.search_stitle')) . '%');
  33. }
  34. if (input('get.search_scontent') != '') {
  35. $where[]=array('stracelog_content','like', '%' . trim(input('get.search_scontent')) . '%');
  36. }
  37. if (input('get.search_type') != '') {
  38. $where[]=array('stracelog_type','=',trim(input('get.search_type')));
  39. }
  40. if (input('get.search_stime') != '') {
  41. $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
  42. $where[] = array('stracelog_time','>=', $s_time);
  43. }
  44. if (input('get.search_etime') != '') {
  45. $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime'))+86399) : null;
  46. $where[] = array('stracelog_time','<=', $e_time);
  47. }
  48. // 实例化模型
  49. $storesnstracelog_model = model('storesnstracelog');
  50. $storetrace_list = $storesnstracelog_model->getStoresnstracelogList($where, '*', 'stracelog_id desc', 0, 10);
  51. if (!empty($storetrace_list) && is_array($storetrace_list)) {
  52. foreach ($storetrace_list as $key => $val) {
  53. if ($val['stracelog_content'] == '') {
  54. $data = json_decode(stripslashes($val['stracelog_goodsdata']), true);
  55. $content = $storesnstracelog_model->spellingStyle($val['stracelog_type'], $data);
  56. $storetrace_list[$key]['stracelog_content'] = str_replace("%siteurl%", HOME_SITE_URL . DIRECTORY_SEPARATOR, $content);
  57. }
  58. }
  59. }
  60. $this->setAdminCurItem('index');
  61. View::assign('storetrace_list', $storetrace_list);
  62. View::assign('show_page', $storesnstracelog_model->page_info->render());
  63. return View::fetch();
  64. }
  65. /**
  66. * 删除动态
  67. */
  68. public function strace_del() {
  69. $st_id = input('param.st_id');
  70. $st_id_array = ds_delete_param($st_id);
  71. if ($st_id_array == FALSE) {
  72. ds_json_encode('10001', lang('param_error'));
  73. }
  74. // 删除动态
  75. $rs = model('storesnstracelog')->delStoresnstracelog(array(array('stracelog_id' ,'in', $st_id_array)));
  76. if ($rs) {
  77. // 删除评论
  78. model('storesnscomment')->delStoresnscomment(array(array('stracelog_id','in', $st_id_array)));
  79. $this->log(lang('ds_del').lang('admin_snstrace_comment'), 1);
  80. ds_json_encode('10000', lang('ds_common_del_succ'));
  81. } else {
  82. ds_json_encode('10001', lang('ds_common_del_fail'));
  83. }
  84. }
  85. /**
  86. * 编辑动态
  87. */
  88. public function strace_edit() {
  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. $update[]=array('stracelog_state','=',1);
  100. if (input('param.type') == 'hide') {
  101. $update['stracelog_state'] = 0;
  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. ?>