Storesnstrace.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. 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. // where 条件
  118. $where = array();
  119. $st_id = intval(input('get.st_id'));
  120. if ($st_id > 0) {
  121. $where[]=array('stracelog_id','=',$st_id);
  122. }
  123. if (input('get.search_uname') != '') {
  124. $where[]=array('storesnscomm_membername','like', '%' . trim(input('get.search_uname')) . '%');
  125. }
  126. if (input('get.search_content') != '') {
  127. $where[]=array('storesnscomm_content','like', '%' . trim(input('get.search_content')) . '%');
  128. }
  129. if (input('get.search_state') != '') {
  130. $where[]=array('storesnscomm_state','=',intval(input('get.search_state')));
  131. }
  132. if (input('get.search_stime') != '') {
  133. $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
  134. $where[] = array('storesnscomm_time','>=', $s_time);
  135. }
  136. if (input('get.search_etime') != '') {
  137. $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime'))+86399) : null;
  138. $where[] = array('storesnscomm_time','<=', $e_time);
  139. }
  140. $model_storesnscomment = model('storesnscomment');
  141. $storesnscomm_list = $model_storesnscomment->getStoresnscommentList($where, '*', 'storesnscomm_id desc', 0, 20);
  142. $this->setAdminCurItem('index');
  143. View::assign('scomm_list', $storesnscomm_list);
  144. View::assign('show_page', $model_storesnscomment->page_info->render());
  145. return View::fetch();
  146. }
  147. /**
  148. * 删除评论
  149. */
  150. public function scomm_del() {
  151. $sc_id = input('param.sc_id');
  152. $sc_id_array = ds_delete_param($sc_id);
  153. if ($sc_id_array == FALSE) {
  154. ds_json_encode('10001', lang('param_error'));
  155. }
  156. // 实例化模型
  157. $rs = model('storesnscomment')->delStoresnscomment(array(array('storesnscomm_id','in', $sc_id_array)));
  158. if ($rs) {
  159. $this->log(lang('ds_del').lang('admin_snstrace_pl'), 1);
  160. ds_json_encode('10000', lang('ds_common_del_succ'));
  161. } else {
  162. ds_json_encode('10001', lang('ds_common_del_fail'));
  163. }
  164. }
  165. /**
  166. * 评论编辑
  167. */
  168. public function scomm_edit() {
  169. $sc_id = input('param.sc_id');
  170. $sc_id_array = ds_delete_param($sc_id);
  171. if ($sc_id_array == FALSE) {
  172. ds_json_encode('10001', lang('param_error'));
  173. }
  174. $storesnscomm_state = 1;
  175. if (input('get.type') == 'hide') {
  176. $storesnscomm_state = 0;
  177. }
  178. // 实例化模型
  179. $rs = model('storesnscomment')->editStoresnscomment(array('storesnscomm_state' => $storesnscomm_state), array(array('storesnscomm_id' ,'in', $sc_id_array)));
  180. if ($rs) {
  181. $this->log(lang('ds_edit').lang('admin_snstrace_pl'), 1);
  182. ds_json_encode('10000', lang('ds_common_op_succ'));
  183. } else {
  184. ds_json_encode('10001', lang('ds_common_op_fail'));
  185. }
  186. }
  187. }
  188. ?>