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