Sellerconsult.php 6.6 KB

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