Memberconsult.php 4.3 KB

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