Sellerconsult.php 6.8 KB

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