Memberconsult.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 咨询控制器
  14. */
  15. class Memberconsult extends MobileMember {
  16. public function initialize() {
  17. parent::initialize(); // TODO: Change the autogenerated stub
  18. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerconsult.lang.php');
  19. }
  20. /**
  21. * @api {POST} api/Memberconsult/index 查询买家商品咨询
  22. * @apiVersion 1.0.0
  23. * @apiGroup Memberconsult
  24. *
  25. * @apiHeader {String} X-DS-KEY 用户授权token
  26. *
  27. * @apiParam {String} type 类型 to_reply待回复 replied已回复
  28. * @apiParam {Int} per_page 每页显示数量
  29. * @apiParam {Int} page 当前页数
  30. *
  31. * @apiSuccess {String} code 返回码,10000为成功
  32. * @apiSuccess {String} message 返回消息
  33. * @apiSuccess {Object} result 返回数据
  34. * @apiSuccess {Object[]} result.consult_list 咨询列表
  35. * @apiSuccess {Int} result.consult_list.consult_addtime 咨询时间,Unix时间戳
  36. * @apiSuccess {Int} result.consult_list.consult_content 咨询内容
  37. * @apiSuccess {Int} result.consult_list.consult_id 咨询ID
  38. * @apiSuccess {Int} result.consult_list.consult_isanonymous 是否匿名,0否1是
  39. * @apiSuccess {Int} result.consult_list.consult_reply 回复内容
  40. * @apiSuccess {Int} result.consult_list.consult_replytime 回复时间
  41. * @apiSuccess {Int} result.consult_list.consulttype_id 咨询类型ID
  42. * @apiSuccess {Int} result.consult_list.goods_id 商品ID
  43. * @apiSuccess {Int} result.consult_list.goods_name 商品名称
  44. * @apiSuccess {Int} result.consult_list.member_id 用户ID
  45. * @apiSuccess {Int} result.consult_list.member_name 用户名称
  46. * @apiSuccess {Int} result.consult_list.store_id 店铺ID
  47. * @apiSuccess {Int} result.consult_list.store_name 店铺名称
  48. * @apiSuccess {Object} result.consult_type 咨询类型,键为咨询类型ID
  49. * @apiSuccess {Int} result.consult_type.consulttype_id 咨询类型ID
  50. * @apiSuccess {String} result.consult_type.consulttype_introduce 咨询类型描述
  51. * @apiSuccess {String} result.consult_type.consulttype_name 咨询类型名称
  52. * @apiSuccess {Int} result.consult_type.consulttype_sort 咨询类型排序
  53. * @apiSuccess {Int} result.page_total 总页数
  54. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  55. */
  56. public function index() {
  57. $this->my_consult();
  58. }
  59. public function my_consult() {
  60. //实例化商品咨询模型
  61. $consult_model = model('consult');
  62. $goods_model = model('goods');
  63. $search_array = array();
  64. if (input('param.type') != '') {
  65. if (input('param.type') == 'to_reply') {
  66. $search_array[] = array('consult_reply', '=', '');
  67. }
  68. if (input('param.type') == 'replied') {
  69. $search_array[] = array('consult_reply', '<>', '');
  70. }
  71. }
  72. $search_array[] = array('member_id', '=', $this->member_info['member_id']);
  73. $list_consult = $consult_model->getConsultList($search_array);
  74. if(!empty($list_consult)){
  75. foreach($list_consult as $key => $val){
  76. $condition = array();
  77. $condition[] = array('goods_id','=',$val['goods_id']);
  78. $goodsinfo = $goods_model->getGoodsInfo($condition,'goods_image,goods_price');
  79. $list_consult[$key]['goods_image'] = goods_cthumb($goodsinfo['goods_image']);
  80. $list_consult[$key]['goods_price'] = $goodsinfo['goods_price'];
  81. }
  82. }
  83. // 咨询类型
  84. $consult_type = rkcache('consulttype', true);
  85. $result = array_merge(array('consult_list' => $list_consult, 'consult_type' => $consult_type), mobile_page($consult_model->page_info));
  86. ds_json_encode(10000, '', $result);
  87. }
  88. }