Sellerconsult.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 卖家咨询控制器
  15. */
  16. class Sellerconsult extends MobileSeller {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerconsult.lang.php');
  20. }
  21. /**
  22. * @api {POST} api/Sellerconsult/index 商品咨询列表页
  23. * @apiVersion 1.0.0
  24. * @apiGroup Sellerconsult
  25. *
  26. * @apiHeader {String} X-DS-KEY 卖家授权token
  27. *
  28. * @apiParam {String} type 回复状态 to_reply待回复 replied已回复
  29. * @apiParam {Int} ctid 咨询类型
  30. * @apiParam {String} page 页码
  31. * @apiParam {String} pagesize 每页显示数量
  32. *
  33. * @apiSuccess {String} code 返回码,10000为成功
  34. * @apiSuccess {String} message 返回消息
  35. * @apiSuccess {Object} result 返回数据
  36. * @apiSuccess {Object[]} result.consult_list 咨询列表 (参考字段参考consult表)
  37. * @apiSuccess {Object} result.consult_type 咨询类型,键为咨询类型ID
  38. * @apiSuccess {Int} result.consult_type.consulttype_id 咨询类型ID
  39. * @apiSuccess {String} result.consult_type.consulttype_introduce 咨询类型描述
  40. * @apiSuccess {String} result.consult_type.consulttype_name 咨询类型名称
  41. * @apiSuccess {Int} result.consult_type.consulttype_sort 咨询类型排序
  42. * @apiSuccess {Int} result.page_total 总页数
  43. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  44. */
  45. public function index() {
  46. $consult_model = model('consult');
  47. $list_consult = array();
  48. $where = array();
  49. if (trim(input('param.type')) == 'to_reply') {
  50. $where[] = array('consult_reply', '=', '');
  51. } elseif (trim(input('param.type')) == 'replied') {
  52. $where[] = array('consult_reply', '<>', '');
  53. }
  54. if (intval(input('param.ctid')) > 0) {
  55. $where[] = array('consulttype_id', '=', intval(input('param.ctid')));
  56. }
  57. $where[] = array('store_id', '=', $this->store_info['store_id']);
  58. $list_consult = $consult_model->getConsultList($where, '*', 10);
  59. // 咨询类型
  60. $consult_type = rkcache('consulttype', true);
  61. $result = array_merge(array('consult_list' => $list_consult, 'consult_type' => $consult_type), mobile_page($consult_model->page_info));
  62. ds_json_encode(10000, '', $result);
  63. }
  64. /**
  65. * @api {POST} api/Sellerconsult/drop_consult 商品咨询删除处理
  66. * @apiVersion 1.0.0
  67. * @apiGroup Sellerconsult
  68. *
  69. * @apiHeader {String} X-DS-KEY 卖家授权token
  70. *
  71. * @apiParam {Int} id 咨询ID
  72. *
  73. * @apiSuccess {String} code 返回码,10000为成功
  74. * @apiSuccess {String} message 返回消息
  75. * @apiSuccess {Object} result 返回数据
  76. */
  77. public function drop_consult() {
  78. $ids = trim(input('param.id'));
  79. if ($ids < 0) {
  80. ds_json_encode(10001, lang('param_error'));
  81. }
  82. $consult_model = model('consult');
  83. $id_array = explode(',', $ids);
  84. $where = array();
  85. $where[] = array('store_id', '=', $this->store_info['store_id']);
  86. $where[] = array('consult_id', 'in', $id_array);
  87. $state = $consult_model->delConsult($where);
  88. if ($state) {
  89. ds_json_encode(10000, lang('store_consult_drop_success'));
  90. } else {
  91. ds_json_encode(10001, lang('store_consult_drop_fail'));
  92. }
  93. }
  94. /**
  95. * @api {POST} api/Sellerconsult/reply_save 商品咨询回复内容的保存处理
  96. * @apiVersion 1.0.0
  97. * @apiGroup Sellerconsult
  98. *
  99. * @apiHeader {String} X-DS-KEY 卖家授权token
  100. *
  101. * @apiParam {Int} consult_id 咨询ID
  102. * @apiHeader {String} content 回复内容
  103. *
  104. * @apiSuccess {String} code 返回码,10000为成功
  105. * @apiSuccess {String} message 返回消息
  106. * @apiSuccess {Object} result 返回数据
  107. */
  108. public function reply_save() {
  109. $consult_id = intval(input('consult_id'));
  110. if ($consult_id <= 0) {
  111. ds_json_encode(10001, lang('param_error'));
  112. }
  113. $consult_model = model('consult');
  114. $update = array();
  115. $update['consult_reply'] = input('post.content');
  116. $condition = array();
  117. $condition[] = array('store_id','=',$this->store_info['store_id']);
  118. $condition[] = array('consult_id','=',$consult_id);
  119. $state = $consult_model->editConsult($condition, $update);
  120. if ($state) {
  121. $consult_info = $consult_model->getConsultInfo(array('consult_id' => $consult_id));
  122. // 发送用户消息
  123. $param = array();
  124. $param['code'] = 'consult_goods_reply';
  125. $param['member_id'] = $consult_info['member_id'];
  126. //阿里短信参数
  127. $param['ali_param'] = array(
  128. 'goods_name' => $consult_info['goods_name']
  129. );
  130. $param['ten_param'] = array(
  131. $consult_info['goods_name']
  132. );
  133. $param['param'] = array_merge($param['ali_param'], array(
  134. 'consult_url' => HOME_SITE_URL .'/Memberconsult/my_consult'
  135. ));
  136. //微信模板消息
  137. $param['weixin_param'] = array(
  138. 'url' => config('ds_config.h5_site_url') . '/member/consult_list',
  139. 'data' => array(
  140. "keyword1" => array(
  141. "value" => $consult_info['consult_id'],
  142. "color" => "#333"
  143. ),
  144. "keyword2" => array(
  145. "value" => $consult_info['goods_name'],
  146. "color" => "#333"
  147. ),
  148. "keyword3" => array(
  149. "value" => $consult_info['consult_content'],
  150. "color" => "#333"
  151. )
  152. ),
  153. );
  154. \mall\queue\QueueClient::push('sendMemberMsg', $param);
  155. ds_json_encode(10000, lang('ds_common_op_succ'));
  156. } else {
  157. ds_json_encode(10001, lang('ds_common_op_fail'));
  158. }
  159. }
  160. }