Sellerconsult.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * 咨询管理
  4. * Date: 2017/6/28
  5. * Time: 12:32
  6. */
  7. namespace app\home\controller;
  8. use think\facade\View;
  9. use think\facade\Lang;
  10. /**
  11. *
  12. *
  13. * ----------------------------------------------------------------------------
  14. *
  15. * 控制器
  16. */
  17. class Sellerconsult extends BaseSeller
  18. {
  19. public function initialize()
  20. {
  21. parent::initialize(); // TODO: Change the autogenerated stub
  22. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerconsult.lang.php');
  23. }
  24. /**
  25. * 商品咨询列表页
  26. */
  27. public function index()
  28. {
  29. $consult_model = model('consult');
  30. $list_consult = array();
  31. $where = array();
  32. if (trim(input('param.type')) == 'to_reply') {
  33. $where[] = array('consult_reply', '=', '');
  34. } elseif (trim(input('param.type')) == 'replied') {
  35. $where[] = array('consult_reply', '<>', '');
  36. }
  37. if (intval(input('param.ctid')) > 0) {
  38. $where[] = array('consulttype_id', '=', intval(input('param.ctid')));
  39. }
  40. $where[] = array('store_id', '=', session('store_id'));
  41. $list_consult = $consult_model->getConsultList($where, '*', 10);
  42. View::assign('show_page', $consult_model->page_info->render());
  43. View::assign('list_consult', $list_consult);
  44. // 咨询类型
  45. $consult_type = rkcache('consulttype', true);
  46. View::assign('consult_type', $consult_type);
  47. $type = (input('param.type')) ? input('param.type') : 'index';
  48. /* 设置卖家当前菜单 */
  49. $this->setSellerCurMenu('seller_consult');
  50. /* 设置卖家当前栏目 */
  51. $this->setSellerCurItem($type);
  52. return View::fetch($this->template_dir . 'consult_list');
  53. }
  54. /**
  55. * 商品咨询删除处理
  56. */
  57. public function drop_consult()
  58. {
  59. $ids = trim(input('param.id'));
  60. if ($ids < 0) {
  61. ds_json_encode(10001, lang('param_error'));
  62. }
  63. $consult_model = model('consult');
  64. $id_array = explode(',', $ids);
  65. $where = array();
  66. $where[] = array('store_id', '=', session('store_id'));
  67. $where[] = array('consult_id', 'in', $id_array);
  68. $state = $consult_model->delConsult($where);
  69. if ($state) {
  70. ds_json_encode(10000, lang('store_consult_drop_success'));
  71. } else {
  72. ds_json_encode(10001, lang('store_consult_drop_fail'));
  73. }
  74. }
  75. /**
  76. * 回复商品咨询表单页
  77. */
  78. public function reply_consult()
  79. {
  80. $consult_model = model('consult');
  81. $search_array = array();
  82. $search_array['consult_id'] = intval(input('param.id'));
  83. $search_array['store_id'] = session('store_id');
  84. $consult_info = $consult_model->getConsultInfo($search_array);
  85. View::assign('consult', $consult_info);
  86. return View::fetch($this->template_dir . 'consult_reply');
  87. }
  88. /**
  89. * 商品咨询回复内容的保存处理
  90. */
  91. public function reply_save()
  92. {
  93. $consult_id = intval(input('consult_id'));
  94. if ($consult_id <= 0) {
  95. ds_json_encode(10001, lang('param_error'));
  96. }
  97. $consult_model = model('consult');
  98. $update = array();
  99. $update['consult_reply'] = input('post.content');
  100. $condition = array();
  101. $condition[] = array('store_id', '=', session('store_id'));
  102. $condition[] = array('consult_id', '=', $consult_id);
  103. $state = $consult_model->editConsult($condition, $update);
  104. if ($state) {
  105. $consult_info = $consult_model->getConsultInfo(array('consult_id' => $consult_id));
  106. // 发送用户消息
  107. $param = array();
  108. $param['code'] = 'consult_goods_reply';
  109. $param['member_id'] = $consult_info['member_id'];
  110. $param['ali_param'] = array(
  111. 'goods_name' => $consult_info['goods_name']
  112. );
  113. $param['ten_param'] = array(
  114. $consult_info['goods_name']
  115. );
  116. $param['param'] = array_merge($param['ali_param'], array(
  117. 'consult_url' => HOME_SITE_URL . '/Memberconsult/my_consult'
  118. ));
  119. //微信模板消息
  120. $param['weixin_param'] = array(
  121. 'url' => config('ds_config.h5_site_url') . '/pages/member/consult/ConsultList',
  122. 'data' => array(
  123. "keyword1" => array(
  124. "value" => $consult_info['consult_id'],
  125. "color" => "#333"
  126. ),
  127. "keyword2" => array(
  128. "value" => $consult_info['goods_name'],
  129. "color" => "#333"
  130. ),
  131. "keyword3" => array(
  132. "value" => $consult_info['consult_content'],
  133. "color" => "#333"
  134. )
  135. ),
  136. );
  137. model('cron')->addCron(array('cron_exetime' => TIMESTAMP, 'cron_type' => 'sendMemberMsg', 'cron_value' => serialize($param)));
  138. ds_json_encode(10000, lang('ds_common_op_succ'));
  139. } else {
  140. ds_json_encode(10001, lang('ds_common_op_fail'));
  141. }
  142. }
  143. /**
  144. * 用户中心右边,小导航
  145. *
  146. * @param string $menu_type 导航类型
  147. * @param string $menu_key 当前导航的menu_key
  148. * @param array $array 附加菜单
  149. * @return
  150. */
  151. protected function getSellerItemList()
  152. {
  153. $menu_array = array(
  154. array(
  155. 'name' => 'index', 'text' => lang('store_consult_all_consulting'), 'url' => (string)url('Sellerconsult/index')
  156. ), array(
  157. 'name' => 'to_reply', 'text' => lang('store_consult_no_reply'), 'url' => (string)url('Sellerconsult/index', ['type' => 'to_reply'])
  158. ), array(
  159. 'name' => 'replied', 'text' => lang('store_consult_consultation'), 'url' => (string)url('Sellerconsult/index', ['type' => 'replied'])
  160. )
  161. );
  162. return $menu_array;
  163. }
  164. }