Sellerconsult.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. $goods_model = model('goods');
  48. $list_consult = array();
  49. $where = array();
  50. if (trim(input('param.type')) == 'to_reply') {
  51. $where[] = array('consult_reply', '=', '');
  52. } elseif (trim(input('param.type')) == 'replied') {
  53. $where[] = array('consult_reply', '<>', '');
  54. }
  55. if (intval(input('param.ctid')) > 0) {
  56. $where[] = array('consulttype_id', '=', intval(input('param.ctid')));
  57. }
  58. $where[] = array('store_id', '=', $this->store_info['store_id']);
  59. $list_consult = $consult_model->getConsultList($where, '*', 10);
  60. if(!empty($list_consult)){
  61. foreach($list_consult as $key => $val){
  62. $condition = array();
  63. $condition[] = array('goods_id','=',$val['goods_id']);
  64. $goodsinfo = $goods_model->getGoodsInfo($condition,'goods_image,goods_price');
  65. $list_consult[$key]['goods_image'] = goods_cthumb($goodsinfo['goods_image']);
  66. $list_consult[$key]['goods_price'] = $goodsinfo['goods_price'];
  67. }
  68. }
  69. // 咨询类型
  70. $consult_type = rkcache('consulttype', true);
  71. $result = array_merge(array('consult_list' => $list_consult, 'consult_type' => $consult_type), mobile_page($consult_model->page_info));
  72. ds_json_encode(10000, '', $result);
  73. }
  74. /**
  75. * @api {POST} api/Sellerconsult/drop_consult 商品咨询删除处理
  76. * @apiVersion 1.0.0
  77. * @apiGroup Sellerconsult
  78. *
  79. * @apiHeader {String} X-DS-KEY 卖家授权token
  80. *
  81. * @apiParam {Int} id 咨询ID
  82. *
  83. * @apiSuccess {String} code 返回码,10000为成功
  84. * @apiSuccess {String} message 返回消息
  85. * @apiSuccess {Object} result 返回数据
  86. */
  87. public function drop_consult() {
  88. $ids = trim(input('param.id'));
  89. if ($ids < 0) {
  90. ds_json_encode(10001, lang('param_error'));
  91. }
  92. $consult_model = model('consult');
  93. $id_array = explode(',', $ids);
  94. $where = array();
  95. $where[] = array('store_id', '=', $this->store_info['store_id']);
  96. $where[] = array('consult_id', 'in', $id_array);
  97. $state = $consult_model->delConsult($where);
  98. if ($state) {
  99. ds_json_encode(10000, lang('store_consult_drop_success'));
  100. } else {
  101. ds_json_encode(10001, lang('store_consult_drop_fail'));
  102. }
  103. }
  104. /**
  105. * @api {POST} api/Sellerconsult/reply_save 商品咨询回复内容的保存处理
  106. * @apiVersion 1.0.0
  107. * @apiGroup Sellerconsult
  108. *
  109. * @apiHeader {String} X-DS-KEY 卖家授权token
  110. *
  111. * @apiParam {Int} consult_id 咨询ID
  112. * @apiHeader {String} content 回复内容
  113. *
  114. * @apiSuccess {String} code 返回码,10000为成功
  115. * @apiSuccess {String} message 返回消息
  116. * @apiSuccess {Object} result 返回数据
  117. */
  118. public function reply_save() {
  119. $consult_id = intval(input('consult_id'));
  120. if ($consult_id <= 0) {
  121. ds_json_encode(10001, lang('param_error'));
  122. }
  123. $consult_model = model('consult');
  124. $update = array();
  125. $update['consult_reply'] = input('post.content');
  126. $condition = array();
  127. $condition[] = array('store_id','=',$this->store_info['store_id']);
  128. $condition[] = array('consult_id','=',$consult_id);
  129. $state = $consult_model->editConsult($condition, $update);
  130. if ($state) {
  131. $consult_info = $consult_model->getConsultInfo(array('consult_id' => $consult_id));
  132. // 发送用户消息
  133. $param = array();
  134. $param['code'] = 'consult_goods_reply';
  135. $param['member_id'] = $consult_info['member_id'];
  136. //阿里短信参数
  137. $param['ali_param'] = array(
  138. 'goods_name' => $consult_info['goods_name']
  139. );
  140. $param['ten_param'] = array(
  141. $consult_info['goods_name']
  142. );
  143. $param['param'] = array_merge($param['ali_param'], array(
  144. 'consult_url' => HOME_SITE_URL .'/Memberconsult/my_consult'
  145. ));
  146. //微信模板消息
  147. $param['weixin_param'] = array(
  148. 'url' => config('ds_config.h5_site_url') . '/pages/member/consult/ConsultList',
  149. 'data' => array(
  150. "keyword1" => array(
  151. "value" => $consult_info['consult_id'],
  152. "color" => "#333"
  153. ),
  154. "keyword2" => array(
  155. "value" => $consult_info['goods_name'],
  156. "color" => "#333"
  157. ),
  158. "keyword3" => array(
  159. "value" => $consult_info['consult_content'],
  160. "color" => "#333"
  161. )
  162. ),
  163. );
  164. model('cron')->addCron(array('cron_exetime'=>TIMESTAMP,'cron_type'=>'sendMemberMsg','cron_value'=>serialize($param)));
  165. ds_json_encode(10000, lang('ds_common_op_succ'));
  166. } else {
  167. ds_json_encode(10001, lang('ds_common_op_fail'));
  168. }
  169. }
  170. }