Inform.php 17 KB

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