Membermallconsult.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class Membermallconsult extends BaseMember
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/membermallconsult.lang.php');
  21. }
  22. /**
  23. * 平台客服咨询首页
  24. */
  25. public function index()
  26. {
  27. // 咨询列表
  28. $mallconsult_model = model('mallconsult');
  29. $consult_list = $mallconsult_model->getMallconsultList(array('member_id' => session('member_id')), '*', '10');
  30. View::assign('consult_list', $consult_list);
  31. View::assign('show_page', $mallconsult_model->page_info->render());
  32. // 回复状态
  33. $this->typeState();
  34. $this->setMemberCurMenu('member_mallconsult');
  35. $this->setMemberCurItem('consult_list');
  36. return View::fetch($this->template_dir . 'member_mallconsult_list');
  37. }
  38. /**
  39. * 平台咨询详细
  40. */
  41. public function mallconsult_info()
  42. {
  43. $id = intval(input('param.id'));
  44. if ($id <= 0) {
  45. $this->error(lang('param_error'));
  46. }
  47. // 咨询详细信息
  48. $consult_info = model('mallconsult')->getMallconsultInfo(array(
  49. 'mallconsult_id' => $id, 'member_id' => session('member_id')
  50. ));
  51. View::assign('consult_info', $consult_info);
  52. // 咨询类型列表
  53. $type_list = model('mallconsulttype')->getMallconsulttypeList(array(), 'mallconsulttype_id,mallconsulttype_name', 'mallconsulttype_id');
  54. View::assign('type_list', $type_list);
  55. // 回复状态
  56. $this->typeState();
  57. $this->setMemberCurMenu('member_mallconsult');
  58. $this->setMemberCurItem('consult_list');
  59. return View::fetch($this->template_dir . 'member_mallconsult_info');
  60. }
  61. /**
  62. * 添加平台客服咨询
  63. */
  64. public function add_mallconsult()
  65. {
  66. // 咨询类型列表
  67. $type_list = model('mallconsulttype')->getMallconsulttypeList(array());
  68. View::assign('type_list', $type_list);
  69. if (input('param.inajax')) {
  70. return View::fetch($this->template_dir . 'add_inajax');
  71. } else {
  72. $this->setMemberCurMenu('member_mallconsult');
  73. $this->setMemberCurItem('consult_list');
  74. return View::fetch($this->template_dir . 'member_mallconsult_add');
  75. }
  76. }
  77. /**
  78. * 保存平台咨询
  79. */
  80. public function save_mallconsult()
  81. {
  82. if (!request()->isPost()) {
  83. ds_json_encode(10001, lang('param_error'));
  84. }
  85. //验证表单信息
  86. $data = [
  87. 'type_id' => input('post.type_id'),
  88. 'consult_content' => input('post.consult_content')
  89. ];
  90. $mallconsult_validate = ds_validate('mallconsult');
  91. if (!$mallconsult_validate->scene('save_mallconsult')->check($data)) {
  92. ds_json_encode(10001, $mallconsult_validate->getError());
  93. }
  94. $insert = array();
  95. $insert['mallconsulttype_id'] = input('post.type_id');
  96. $insert['member_id'] = session('member_id');
  97. $insert['member_name'] = session('member_name');
  98. $insert['mallconsult_content'] = input('post.consult_content');
  99. $res = word_filter($insert['mallconsult_content']);
  100. if (!$res['code']) {
  101. ds_json_encode(10001, $res['msg']);
  102. }
  103. $insert['mallconsult_content'] = $res['data']['text'];
  104. $result = model('mallconsult')->addMallconsult($insert);
  105. if ($result) {
  106. ds_json_encode(10000, lang('ds_common_op_succ'));
  107. } else {
  108. ds_json_encode(10001, lang('ds_common_op_fail'));
  109. }
  110. }
  111. /**
  112. * 删除平台客服咨询
  113. */
  114. public function del_mallconsult()
  115. {
  116. $id = intval(input('param.id'));
  117. if ($id <= 0) {
  118. ds_json_encode(10001, lang('param_error'));
  119. }
  120. $result = model('mallconsult')->delMallconsult(array('mallconsult_id' => $id, 'member_id' => session('member_id')));
  121. if ($result) {
  122. ds_json_encode(10000, lang('ds_common_del_succ'));
  123. } else {
  124. ds_json_encode(10001, lang('ds_common_del_fail'));
  125. }
  126. }
  127. /**
  128. * 咨询的回复状态
  129. */
  130. private function typeState()
  131. {
  132. $state = array('0' => lang('did_not_return'), '1' => lang('have_to_reply'));
  133. View::assign('state', $state);
  134. }
  135. /**
  136. * 用户中心右边,小导航
  137. *
  138. * @param string $menu_key 当前导航的menu_key
  139. * @return
  140. */
  141. protected function getMemberItemList()
  142. {
  143. $menu_array = array(
  144. array(
  145. 'name' => 'consult_list', 'text' => lang('platform_customer_service_consultation_list'),
  146. 'url' => (string)url('Membermallconsult/index')
  147. ),
  148. );
  149. return $menu_array;
  150. }
  151. }