mall_consult.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /**
  3. * 平台客观咨询管理
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class mall_consultControl extends SystemControl{
  7. public function __construct(){
  8. parent::__construct();
  9. }
  10. /**
  11. * 咨询管理
  12. */
  13. public function indexOp(){
  14. $condition = array();
  15. if(chksubmit()){
  16. $member_name = trim($_GET['member_name']);
  17. if($member_name != ''){
  18. $condition['member_name'] = array('like', '%' . $member_name . '%');
  19. Tpl::output('member_name', $member_name);
  20. }
  21. $mct_id = intval($_GET['mctid']);
  22. if ($mct_id > 0) {
  23. $condition['mct_id'] = $mct_id;
  24. Tpl::output('mctid', $mct_id);
  25. }
  26. }
  27. $model_mallconsult = Model('mall_consult');
  28. $consult_list = $model_mallconsult->getMallConsultList($condition,'*', 10);
  29. Tpl::output('show_page',$model_mallconsult->showpage());
  30. Tpl::output('consult_list',$consult_list);
  31. // 咨询类型列表
  32. $type_list = Model('mall_consult_type')->getMallConsultTypeList(array(), 'mct_id,mct_name', 'mct_id');
  33. Tpl::output('type_list', $type_list);
  34. // 回复状态
  35. $state = array('0'=>'未回复', '1'=>'已回复');
  36. Tpl::output('state', $state);
  37. Tpl::showpage('mall_consult.index');
  38. }
  39. /**
  40. * 回复咨询
  41. */
  42. public function consult_replyOp() {
  43. $model_mallconsult = Model('mall_consult');
  44. if (chksubmit()) {
  45. $mc_id = intval($_POST['mc_id']);
  46. $reply_content = trim($_POST['reply_content']);
  47. if ($mc_id <= 0 || $reply_content == '') {
  48. showMessage(L('param_error'));
  49. }
  50. $update['is_reply'] = 1;
  51. $update['mc_reply'] = $reply_content;
  52. $update['mc_reply_time'] = time();
  53. $update['admin_id'] = $this->admin_info['id'];
  54. $update['admin_name'] = $this->admin_info['name'];
  55. $result = $model_mallconsult->editMallConsult(array('mc_id' => $mc_id), $update);
  56. if ($result) {
  57. $consult_info = $model_mallconsult->getMallConsultInfo(array('mc_id' => $mc_id));
  58. // 发送用户消息
  59. $param = array();
  60. $param['code'] = 'consult_mall_reply';
  61. $param['member_id'] = $consult_info['member_id'];
  62. $param['param'] = array(
  63. 'consult_url' => urlShop('member_mallconsult', 'mallconsult_info', array('id' => $mc_id))
  64. );
  65. QueueClient::push('sendMemberMsg', $param);
  66. showMessage('回复成功', urlAdmin('mall_consult', 'index'));
  67. } else {
  68. showMessage('回复失败');
  69. }
  70. }
  71. $id = intval($_GET['id']);
  72. if ($id <= 0) {
  73. showMessage(L('param_error'));
  74. }
  75. $consult_info = $model_mallconsult->getMallConsultDetail($id);
  76. Tpl::output('consult_info', $consult_info);
  77. Tpl::showpage('mall_consult.reply');
  78. }
  79. /**
  80. * 删除平台客服咨询
  81. */
  82. public function del_consultOp(){
  83. $id = $_GET['id'];
  84. if($id <= 0){
  85. showMessage(Language::get('nc_common_del_fail'));
  86. }
  87. $result = Model('mall_consult')->delMallConsult(array('mc_id' => $id));
  88. if($result){
  89. $this->log('删除平台客服咨询'.'[ID:'.$id.']',null);
  90. showMessage(Language::get('nc_common_del_succ'));
  91. }else{
  92. showMessage(Language::get('nc_common_del_fail'));
  93. }
  94. }
  95. /**
  96. * 批量删除平台客服咨询
  97. */
  98. public function del_consult_batchOp(){
  99. $ids = $_POST['id'];
  100. if(empty($ids)){
  101. showMessage(Language::get('nc_common_del_fail'));
  102. }
  103. $result = Model('mall_consult')->delMallConsult(array('mc_id' => array('in', $ids)));
  104. if($result){
  105. $this->log('删除平台客服咨询'.'[ID:'.implode(',', $ids).']',null);
  106. showMessage(Language::get('nc_common_del_succ'));
  107. }else{
  108. showMessage(Language::get('nc_common_del_fail'));
  109. }
  110. }
  111. /**
  112. * 咨询类型列表
  113. */
  114. public function type_listOp() {
  115. $model_mct = Model('mall_consult_type');
  116. if (chksubmit()) {
  117. $mctid_array = $_POST['del_id'];
  118. if (!is_array($mctid_array)) {
  119. showMessage(L('param_error'));
  120. }
  121. foreach ($mctid_array as $val){
  122. if (!is_numeric($val)) {
  123. showMessage(L('param_error'));
  124. }
  125. }
  126. $result = $model_mct->delMallConsultType(array('mct_id' => array('in', $mctid_array)));
  127. if ($result) {
  128. $this->log('删除平台客服咨询类型 ID:'.implode(',', $mctid_array), 1);
  129. showMessage(L('nc_common_del_succ'));
  130. } else {
  131. $this->log('删除平台客服咨询类型 ID:'.implode(',', $mctid_array), 0);
  132. showMessage(L('nc_common_del_fail'));
  133. }
  134. }
  135. $type_list = $model_mct->getMallConsultTypeList(array(), 'mct_id,mct_name,mct_sort');
  136. Tpl::output('type_list', $type_list);
  137. Tpl::showpage('mall_consult.type_list');
  138. }
  139. /**
  140. * 新增咨询类型
  141. */
  142. public function type_addOp() {
  143. if (chksubmit()) {
  144. // 验证
  145. $obj_validate = new Validator();
  146. $obj_validate->validateparam = array(
  147. array("input"=>$_POST["mct_name"], "require"=>"true", "message"=>'请填写咨询类型名称'),
  148. array("input"=>$_POST["mct_sort"], "require"=>"true", 'validator'=>'Number', "message"=>'请正确填写咨询类型排序'),
  149. );
  150. $error = $obj_validate->validate();
  151. if ($error != ''){
  152. showMessage(Language::get('error').$error,'','','error');
  153. }
  154. $insert = array();
  155. $insert['mct_name'] = trim($_POST['mct_name']);
  156. $insert['mct_introduce'] = $_POST['mct_introduce'];
  157. $insert['mct_sort'] = intval($_POST['mct_sort']);
  158. $result = Model('mall_consult_type')->addMallConsultType($insert);
  159. if ($result){
  160. $this->log('新增咨询类型',1);
  161. showMessage(L('nc_common_save_succ'), urlAdmin('mall_consult', 'type_list'));
  162. }else {
  163. $this->log('新增咨询类型',0);
  164. showMessage(L('nc_common_save_fail'));
  165. }
  166. }
  167. Tpl::showpage('mall_consult.type_add');
  168. }
  169. /**
  170. * 编辑咨询类型
  171. */
  172. public function type_editOp() {
  173. $model_mct = Model('mall_consult_type');
  174. if (chksubmit()) {
  175. // 验证
  176. $obj_validate = new Validator();
  177. $obj_validate->validateparam = array(
  178. array("input"=>$_POST["mct_name"], "require"=>"true", "message"=>'请填写咨询类型名称'),
  179. array("input"=>$_POST["mct_sort"], "require"=>"true", 'validator'=>'Number', "message"=>'请正确填写咨询类型排序'),
  180. );
  181. $error = $obj_validate->validate();
  182. if ($error != ''){
  183. showMessage(Language::get('error').$error,'','','error');
  184. }
  185. $where = array();
  186. $where['mct_id'] = intval($_POST['mct_id']);
  187. $update = array();
  188. $update['mct_name'] = trim($_POST['mct_name']);
  189. $update['mct_introduce'] = $_POST['mct_introduce'];
  190. $update['mct_sort'] = intval($_POST['mct_sort']);
  191. $result = $model_mct->editMallConsultType($where, $update);
  192. if ($result){
  193. $this->log('编辑平台客服咨询类型 ID:'.$where['mct_id'],1);
  194. showMessage(L('nc_common_op_succ'), urlAdmin('mall_consult', 'type_list'));
  195. }else {
  196. $this->log('编辑平台客服咨询类型 ID:'.$where['mct_id'],0);
  197. showMessage(L('nc_common_op_fail'));
  198. }
  199. }
  200. $mct_id = intval($_GET['mct_id']);
  201. if ($mct_id <= 0) {
  202. showMessage(L('param_error'));
  203. }
  204. $mct_info = $model_mct->getMallConsultTypeInfo(array('mct_id' => $mct_id));
  205. Tpl::output('mct_info', $mct_info);
  206. Tpl::showpage('mall_consult.type_edit');
  207. }
  208. /**
  209. * 删除咨询类型
  210. */
  211. public function type_delOp() {
  212. $mct_id = intval($_GET['mct_id']);
  213. if ($mct_id <= 0) {
  214. showMessage(L('param_error'));
  215. }
  216. $result = Model('mall_consult_type')->delMallConsultType(array('mct_id' => $mct_id));
  217. if ($result) {
  218. $this->log('删除平台客服咨询类型 ID:'.$mct_id, 1);
  219. showMessage(L('nc_common_del_succ'));
  220. } else {
  221. $this->log('删除平台客服咨询类型 ID:'.$mct_id, 0);
  222. showMessage(L('nc_common_del_fail'));
  223. }
  224. }
  225. }