Inform.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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 Inform 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') . '/inform.lang.php');
  21. }
  22. /*
  23. * 未处理的举报列表
  24. */
  25. public function inform_list() {
  26. $this->get_inform_list(1, 'inform_list');
  27. return View::fetch();
  28. }
  29. /*
  30. * 已处理的举报列表
  31. */
  32. public function inform_handled_list() {
  33. $this->get_inform_list(2, 'inform_handled_list');
  34. return View::fetch();
  35. }
  36. /*
  37. * 获取举报列表
  38. */
  39. private function get_inform_list($type, $action) {
  40. //获得举报列表
  41. $inform_model = model('inform');
  42. //搜索条件
  43. $condition = array();
  44. if ((input('param.input_inform_goods_name'))) {
  45. $condition[] = array('inform.inform_goods_name', 'like', "%" . input('param.input_inform_goods_name') . "%");
  46. }
  47. if ((input('param.input_inform_member_name'))) {
  48. $condition[] = array('inform.inform_member_name', 'like', "%" . input('param.input_inform_member_name') . "%");
  49. }
  50. if ((input('param.input_inform_type'))) {
  51. $condition[] = array('inform_subject.informsubject_type_name', 'like', "%" . input('param.input_inform_type') . "%");
  52. }
  53. if ((input('param.input_inform_subject'))) {
  54. $condition[] = array('inform_subject.informsubject_content', 'like', "%" . input('param.input_inform_subject') . "%");
  55. }
  56. $stime = input('param.input_inform_datetime_start') ? strtotime(input('param.input_inform_datetime_start')) : 0;
  57. $etime = input('param.input_inform_datetime_end') ? strtotime(input('param.input_inform_datetime_end')) : 0;
  58. if ($stime > 0) {
  59. $condition[] = array('inform.inform_datetime', '>=', $stime);
  60. }
  61. if ($etime > 0) {
  62. $etime=$etime+86399;
  63. $condition[] = array('inform.inform_datetime', '<=', $etime);
  64. }
  65. if ($type === 1) {
  66. $order = 'inform_id asc';
  67. } else {
  68. $order = 'inform_id desc';
  69. }
  70. $condition[] = array('inform.inform_state', '=', $type);
  71. $inform_list = $inform_model->getInformList($condition, 10, $order);
  72. $this->setAdminCurItem($action);
  73. View::assign('inform_list', $inform_list);
  74. View::assign('show_page', $inform_model->page_info->render());
  75. }
  76. /*
  77. * 举报类型列表
  78. */
  79. public function inform_subject_type_list() {
  80. //获得有效举报类型列表
  81. $informsubjecttype_model = model('informsubjecttype');
  82. $informsubjecttype_list = $informsubjecttype_model->getActiveInformsubjecttypeList(10);
  83. $this->setAdminCurItem('inform_subject_type_list');
  84. View::assign('informsubjecttype_list', $informsubjecttype_list);
  85. View::assign('show_page', $informsubjecttype_model->page_info->render());
  86. return View::fetch();
  87. }
  88. /*
  89. * 举报主题列表
  90. */
  91. public function inform_subject_list() {
  92. //获得举报主题列表
  93. $informsubject_model = model('informsubject');
  94. //搜索条件
  95. $condition = array();
  96. $informsubject_type_id = intval(input('param.informsubject_type_id'));
  97. if ($informsubject_type_id > 0) {
  98. $condition[] = array('informsubject_type_id', '=', $informsubject_type_id);
  99. }
  100. $condition[] = array('informsubject_state', '=', 1);
  101. $informsubject_list = $informsubject_model->getInformsubjectList($condition, 10);
  102. //获取有效举报类型
  103. $informsubjecttype_model = model('informsubjecttype');
  104. $type_list = $informsubjecttype_model->getActiveInformsubjecttypeList();
  105. $this->setAdminCurItem('inform_subject_list');
  106. View::assign('informsubject_list', $informsubject_list);
  107. View::assign('type_list', $type_list);
  108. View::assign('show_page', $informsubject_model->page_info->render());
  109. return View::fetch();
  110. }
  111. /*
  112. * 添加举报类型页面
  113. */
  114. public function inform_subject_type_add() {
  115. if (!request()->isPost()) {
  116. return View::fetch();
  117. } else {
  118. //获取提交的内容
  119. $input['informtype_name'] = trim(input('post.informtype_name'));
  120. $input['informtype_desc'] = trim(input('post.informtype_desc'));
  121. //验证提交的内容
  122. $data = [
  123. 'informtype_name' => $input['informtype_name'],
  124. 'informtype_desc' => $input['informtype_desc'],
  125. ];
  126. $inform_validate = ds_validate('inform');
  127. if (!$inform_validate->scene('inform_subject_type_save')->check($data)) {
  128. $this->error($inform_validate->getError());
  129. } else {
  130. //验证成功保存
  131. $input['informtype_state'] = 1;
  132. $informsubjecttype_model = model('informsubjecttype');
  133. $informsubjecttype_model->addInformsubjecttype($input);
  134. $this->log(lang('ds_add') . lang('inform_type') . '[' . input('post.informtype_name') . ']', 1);
  135. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  136. }
  137. }
  138. }
  139. /*
  140. * 添加举报类型页面
  141. */
  142. public function inform_subject_type_edit() {
  143. $informtype_id = input('param.informtype_id');
  144. if (!request()->isPost()) {
  145. $informsubjecttype_model = model('informsubjecttype');
  146. $condition = array();
  147. $condition[] = ['informtype_id','=',$informtype_id];
  148. $informsubjecttype_info = $informsubjecttype_model->getInformsubjecttypeInfo($condition);
  149. View::assign('informsubjecttype_info', $informsubjecttype_info);
  150. return View::fetch();
  151. } else {
  152. //获取提交的内容
  153. $condition = array();
  154. $condition[] = ['informtype_id','=',$informtype_id];
  155. $input['informtype_name'] = trim(input('post.informtype_name'));
  156. $input['informtype_desc'] = trim(input('post.informtype_desc'));
  157. //验证提交的内容
  158. $data = [
  159. 'informtype_name' => $input['informtype_name'],
  160. 'informtype_desc' => $input['informtype_desc'],
  161. ];
  162. $inform_validate = ds_validate('inform');
  163. if (!$inform_validate->scene('inform_subject_type_save')->check($data)) {
  164. $this->error($inform_validate->getError());
  165. } else {
  166. //验证成功保存
  167. $input['informtype_state'] = 1;
  168. $informsubjecttype_model = model('informsubjecttype');
  169. $informsubjecttype_model->editInformsubjecttype($input,$condition);
  170. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  171. }
  172. }
  173. }
  174. /*
  175. * 删除举报类型,伪删除只是修改标记
  176. */
  177. public function inform_subject_type_drop() {
  178. $informtype_id = trim(input('param.informtype_id'));
  179. $informrtype_id_array = ds_delete_param($informtype_id);
  180. if ($informrtype_id_array == FALSE) {
  181. ds_json_encode(10001, lang('param_error'));
  182. }
  183. //删除分类
  184. $informsubjecttype_model = model('informsubjecttype');
  185. $update_array = array();
  186. $update_array['informtype_state'] = 2;
  187. $where_array = array();
  188. $where_array[] = array('informtype_id', 'in', $informrtype_id_array);
  189. $informsubjecttype_model->editInformsubjecttype($update_array, $where_array);
  190. //删除分类下边的主题
  191. $informsubject_model = model('informsubject');
  192. $update_subject_array = array();
  193. $update_subject_array['informsubject_state'] = 2;
  194. $where_subject_array = array();
  195. $where_subject_array[] = array('informsubject_type_id', 'in', $informrtype_id_array);
  196. $informsubject_model->editInformsubject($update_subject_array, $where_subject_array);
  197. $this->log(lang('ds_del') . lang('inform_type') . '[ID:' . input('post.informtype_id') . ']', 1);
  198. ds_json_encode(10000, lang('ds_common_del_succ'));
  199. }
  200. /*
  201. * 添加举报主题页面
  202. */
  203. public function inform_subject_add() {
  204. if (!request()->isPost()) {
  205. //获得可用举报类型列表
  206. $informsubjecttype_model = model('informsubjecttype');
  207. $informsubjecttype_list = $informsubjecttype_model->getActiveInformsubjecttypeList();
  208. if (empty($informsubjecttype_list)) {
  209. $this->error(lang('inform_type_error'));
  210. }
  211. View::assign('informsubjecttype_list', $informsubjecttype_list);
  212. return View::fetch();
  213. } else {
  214. //获取提交的内容
  215. list($input['informsubject_type_id'], $input['informsubject_type_name']) = explode(',', trim(input('post.inform_subject_type')));
  216. $input['informsubject_content'] = trim(input('post.informsubject_content'));
  217. //验证提交的内容
  218. $data = [
  219. 'informsubject_type_name' => $input['informsubject_type_name'],
  220. 'informsubject_content' => $input['informsubject_content'],
  221. 'informsubject_type_id' => $input['informsubject_type_id']
  222. ];
  223. $inform_validate = ds_validate('inform');
  224. if (!$inform_validate->scene('inform_subject_save')->check($data)) {
  225. $this->error($inform_validate->getError());
  226. } else {
  227. //验证成功保存
  228. $input['informsubject_state'] = 1;
  229. $informsubject_model = model('informsubject');
  230. $informsubject_model->addInformsubject($input);
  231. $this->log('添加' . lang('inform_subject') . '[' . $input['informsubject_type_name'] . ']', 1);
  232. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  233. }
  234. }
  235. }
  236. /*
  237. * 删除举报主题,伪删除只是修改标记
  238. */
  239. public function inform_subject_drop() {
  240. $informsubject_id = trim(input('param.informsubject_id'));
  241. $informsubject_id_array = ds_delete_param($informsubject_id);
  242. if ($informsubject_id_array == FALSE) {
  243. ds_json_encode('10001', lang('param_error'));
  244. }
  245. $informsubject_model = model('informsubject');
  246. $update_array = array();
  247. $update_array['informsubject_state'] = 2;
  248. $where_array = array();
  249. $where_array[] = array('informsubject_id', 'in', $informsubject_id_array);
  250. $informsubject_model->editInformsubject($update_array, $where_array);
  251. $this->log(lang('ds_del') . lang('inform_subject') . '[' . input('post.informsubject_id') . ']', 1);
  252. ds_json_encode(10000, lang('ds_common_del_succ'));
  253. }
  254. /*
  255. * 显示处理举报
  256. */
  257. public function show_handle_page() {
  258. $inform_id = intval(input('param.inform_id'));
  259. $inform_goods_name = urldecode(input('param.inform_goods_name'));
  260. View::assign('inform_id', $inform_id);
  261. View::assign('inform_goods_name', $inform_goods_name);
  262. return View::fetch('inform_handle');
  263. }
  264. /*
  265. * 处理举报
  266. */
  267. public function inform_handle() {
  268. $inform_id = intval(input('post.inform_id'));
  269. $inform_handle_type = intval(input('post.inform_handle_type'));
  270. $inform_handle_message = trim(input('post.inform_handle_message'));
  271. if (empty($inform_id) || empty($inform_handle_type)) {
  272. $this->error(lang('param_error'));
  273. }
  274. //验证输入的数据
  275. $data = [
  276. "inform_handle_message" => $inform_handle_message,
  277. ];
  278. $inform_validate = ds_validate('inform');
  279. if (!$inform_validate->scene('inform_handle')->check($data)) {
  280. $this->error($inform_validate->getError());
  281. }
  282. $inform_model = model('inform');
  283. $inform_info = $inform_model->getOneInform(array('inform_id' => $inform_id));
  284. if (empty($inform_info) || intval($inform_info['inform_state']) === 2) {
  285. $this->error(lang('param_error'));
  286. }
  287. $update_array = array();
  288. $where_array = array();
  289. //根据选择处理
  290. switch ($inform_handle_type) {
  291. case 1:
  292. $where_array[] = array('inform_id', '=', $inform_id);
  293. break;
  294. case 2:
  295. //恶意举报,清理所有该用户的举报,设置该用户禁止举报
  296. $where_array[] = array('inform_member_id', '=', $inform_info['inform_member_id']);
  297. $this->denyMemberInform($inform_info['inform_member_id']);
  298. break;
  299. case 3:
  300. //有效举报,商品禁售
  301. $where_array[] = array('inform_id', '=', $inform_id);
  302. $this->denyGoods($inform_info['inform_goods_id']);
  303. break;
  304. default:
  305. $this->error(lang('param_error'));
  306. }
  307. $update_array['inform_state'] = 2;
  308. $update_array['inform_handle_type'] = $inform_handle_type;
  309. $update_array['inform_handle_message'] = $inform_handle_message;
  310. $update_array['inform_handle_datetime'] = TIMESTAMP;
  311. $admin_info = $this->getAdminInfo();
  312. $update_array['inform_handle_member_id'] = $admin_info['admin_id'];
  313. $where_array[] = array('inform_state', '=', 1);
  314. if ($inform_model->editInform($update_array, $where_array)) {
  315. $this->log(lang('inform_text_handle') . lang('inform') . '[ID:' . $inform_id . ']', 1);
  316. dsLayerOpenSuccess(lang('ds_common_op_succ'));
  317. } else {
  318. $this->error(lang('ds_common_op_fail'));
  319. }
  320. }
  321. /*
  322. * 禁止该用户举报
  323. */
  324. private function denyMemberInform($member_id) {
  325. $member_model = model('member');
  326. $param = array();
  327. $param['inform_allow'] = 2;
  328. return $member_model->editMember(array('member_id' => $member_id), $param, $member_id);
  329. }
  330. /*
  331. * 禁止商品销售
  332. */
  333. private function denyGoods($goods_id) {
  334. //修改商品状态
  335. $goods_model = model('goods');
  336. $goods_info = $goods_model->getGoodsInfoByID($goods_id);
  337. if (empty($goods_info)) {
  338. return true;
  339. }
  340. return $goods_model->editProducesLockUp(array('goods_stateremark' => lang('goods_be_informed')), array('goods_commonid' => $goods_info['goods_commonid']));
  341. }
  342. /**
  343. * 获取卖家栏目列表,针对控制器下的栏目
  344. */
  345. protected function getAdminItemList() {
  346. $menu_array = array(
  347. array(
  348. 'name' => 'inform_list',
  349. 'text' => lang('inform_state_unhandle'),
  350. 'url' => (string) url('Inform/inform_list')
  351. ),
  352. array(
  353. 'name' => 'inform_handled_list',
  354. 'text' => lang('inform_state_handled'),
  355. 'url' => (string) url('Inform/inform_handled_list')
  356. ),
  357. array(
  358. 'name' => 'inform_subject_type_list',
  359. 'text' => lang('inform_type'),
  360. 'url' => (string) url('Inform/inform_subject_type_list')
  361. ),
  362. array(
  363. 'name' => 'inform_subject_type_add',
  364. 'text' => lang('inform_type_add'),
  365. 'url' => "javascript:dsLayerOpen('" . (string) url('Inform/inform_subject_type_add') . "','" . lang('inform_type_add') . "')"
  366. ),
  367. array(
  368. 'name' => 'inform_subject_list',
  369. 'text' => lang('inform_subject'),
  370. 'url' => (string) url('Inform/inform_subject_list')
  371. ),
  372. array(
  373. 'name' => 'inform_subject_add',
  374. 'text' => lang('inform_subject_add'),
  375. 'url' => "javascript:dsLayerOpen('" . (string) url('Inform/inform_subject_add') . "','" . lang('inform_subject_add') . "')"
  376. ),
  377. );
  378. return $menu_array;
  379. }
  380. }