Membermallconsult.php 5.7 KB

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