123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?php
- namespace app\admin\controller;
- use think\facade\View;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 控制器
- */
- class Storesnstrace extends AdminControl
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/storesnstrace.lang.php');
- }
- /**
- * 动态列表
- */
- public function index()
- {
- // where条件
- $where = array();
- if (input('get.search_sname') != '') {
- $where[] = array('stracelog_storename', 'like', '%' . trim(input('get.search_sname')) . '%');
- }
- if (input('get.search_stitle') != '') {
- $where[] = array('stracelog_title', 'like', '%' . trim(input('get.search_stitle')) . '%');
- }
- if (input('get.search_scontent') != '') {
- $where[] = array('stracelog_content', 'like', '%' . trim(input('get.search_scontent')) . '%');
- }
- if (input('get.search_type') != '') {
- $where[] = array('stracelog_type', '=', trim(input('get.search_type')));
- }
- if (input('get.search_stime') != '') {
- $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
- $where[] = array('stracelog_time', '>=', $s_time);
- }
- if (input('get.search_etime') != '') {
- $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime')) + 86399) : null;
- $where[] = array('stracelog_time', '<=', $e_time);
- }
- // 实例化模型
- $storesnstracelog_model = model('storesnstracelog');
- $storetrace_list = $storesnstracelog_model->getStoresnstracelogList($where, '*', 'stracelog_id desc', 0, 10);
- if (!empty($storetrace_list) && is_array($storetrace_list)) {
- foreach ($storetrace_list as $key => $val) {
- if ($val['stracelog_content'] == '') {
- $data = json_decode(stripslashes($val['stracelog_goodsdata']), true);
- $content = $storesnstracelog_model->spellingStyle($val['stracelog_type'], $data);
- $storetrace_list[$key]['stracelog_content'] = str_replace("%siteurl%", HOME_SITE_URL . DIRECTORY_SEPARATOR, $content);
- }
- }
- }
- $this->setAdminCurItem('index');
- View::assign('storetrace_list', $storetrace_list);
- View::assign('show_page', $storesnstracelog_model->page_info->render());
- return View::fetch();
- }
- /**
- * 删除动态
- */
- public function strace_del()
- {
- $st_id = input('param.st_id');
- $st_id_array = ds_delete_param($st_id);
- if ($st_id_array == FALSE) {
- ds_json_encode('10001', lang('param_error'));
- }
- // 删除动态
- $rs = model('storesnstracelog')->delStoresnstracelog(array(array('stracelog_id', 'in', $st_id_array)));
- if ($rs) {
- // 删除评论
- model('storesnscomment')->delStoresnscomment(array(array('stracelog_id', 'in', $st_id_array)));
- $this->log(lang('ds_del') . lang('admin_snstrace_comment'), 1);
- ds_json_encode('10000', lang('ds_common_del_succ'));
- } else {
- ds_json_encode('10001', lang('ds_common_del_fail'));
- }
- }
- /**
- * 编辑动态
- */
- public function strace_edit()
- {
- $st_id = input('param.st_id');
- $st_id_array = ds_delete_param($st_id);
- if ($st_id_array == FALSE) {
- ds_json_encode('10001', lang('param_error'));
- }
- // where条件
- $where = array();
- $where[] = array('stracelog_id', 'in', $st_id_array);
- // update条件
- $update = array();
- if (input('param.type') == 'hide') {
- $update['stracelog_state'] = 0;
- } else {
- $update['stracelog_state'] = 1;
- }
- // 实例化模型
- $rs = model('storesnstracelog')->editStoresnstracelog($update, $where);
- if ($rs) {
- $this->log(lang('ds_edit') . lang('admin_snstrace_comment'), 1);
- ds_json_encode('10000', lang('ds_common_op_succ'));
- } else {
- ds_json_encode('10001', lang('ds_common_op_fail'));
- }
- }
- /**
- * 评论列表
- */
- public function storecomment_list()
- {
- // where 条件
- $where = array();
- $st_id = intval(input('get.st_id'));
- if ($st_id > 0) {
- $where[] = array('stracelog_id', '=', $st_id);
- }
- if (input('get.search_uname') != '') {
- $where[] = array('storesnscomm_membername', 'like', '%' . trim(input('get.search_uname')) . '%');
- }
- if (input('get.search_content') != '') {
- $where[] = array('storesnscomm_content', 'like', '%' . trim(input('get.search_content')) . '%');
- }
- if (input('get.search_state') != '') {
- $where[] = array('storesnscomm_state', '=', intval(input('get.search_state')));
- }
- if (input('get.search_stime') != '') {
- $s_time = input('get.search_stime') != '' ? strtotime(input('get.search_stime')) : null;
- $where[] = array('storesnscomm_time', '>=', $s_time);
- }
- if (input('get.search_etime') != '') {
- $e_time = input('get.search_etime') != '' ? (strtotime(input('get.search_etime')) + 86399) : null;
- $where[] = array('storesnscomm_time', '<=', $e_time);
- }
- $model_storesnscomment = model('storesnscomment');
- $storesnscomm_list = $model_storesnscomment->getStoresnscommentList($where, '*', 'storesnscomm_id desc', 0, 20);
- $this->setAdminCurItem('index');
- View::assign('scomm_list', $storesnscomm_list);
- View::assign('show_page', $model_storesnscomment->page_info->render());
- return View::fetch();
- }
- /**
- * 删除评论
- */
- public function scomm_del()
- {
- $sc_id = input('param.sc_id');
- $sc_id_array = ds_delete_param($sc_id);
- if ($sc_id_array == FALSE) {
- ds_json_encode('10001', lang('param_error'));
- }
- // 实例化模型
- $rs = model('storesnscomment')->delStoresnscomment(array(array('storesnscomm_id', 'in', $sc_id_array)));
- if ($rs) {
- $this->log(lang('ds_del') . lang('admin_snstrace_pl'), 1);
- ds_json_encode('10000', lang('ds_common_del_succ'));
- } else {
- ds_json_encode('10001', lang('ds_common_del_fail'));
- }
- }
- /**
- * 评论编辑
- */
- public function scomm_edit()
- {
- $sc_id = input('param.sc_id');
- $sc_id_array = ds_delete_param($sc_id);
- if ($sc_id_array == FALSE) {
- ds_json_encode('10001', lang('param_error'));
- }
- $storesnscomm_state = 1;
- if (input('get.type') == 'hide') {
- $storesnscomm_state = 0;
- }
- // 实例化模型
- $rs = model('storesnscomment')->editStoresnscomment(array('storesnscomm_state' => $storesnscomm_state), array(array('storesnscomm_id', 'in', $sc_id_array)));
- if ($rs) {
- $this->log(lang('ds_edit') . lang('admin_snstrace_pl'), 1);
- ds_json_encode('10000', lang('ds_common_op_succ'));
- } else {
- ds_json_encode('10001', lang('ds_common_op_fail'));
- }
- }
- }
|