Memberconsult.php 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 咨询控制器
  10. */
  11. class Memberconsult extends MobileMember
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize(); // TODO: Change the autogenerated stub
  16. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerconsult.lang.php');
  17. }
  18. /**
  19. * @api {POST} api/Memberconsult/index 查询买家商品咨询
  20. * @apiVersion 1.0.0
  21. * @apiGroup Memberconsult
  22. *
  23. * @apiHeader {String} X-DS-KEY 用户授权token
  24. *
  25. * @apiParam {String} type 类型 to_reply待回复 replied已回复
  26. * @apiParam {Int} per_page 每页显示数量
  27. * @apiParam {Int} page 当前页数
  28. *
  29. * @apiSuccess {String} code 返回码,10000为成功
  30. * @apiSuccess {String} message 返回消息
  31. * @apiSuccess {Object} result 返回数据
  32. * @apiSuccess {Object[]} result.consult_list 咨询列表
  33. * @apiSuccess {Int} result.consult_list.consult_addtime 咨询时间,Unix时间戳
  34. * @apiSuccess {Int} result.consult_list.consult_content 咨询内容
  35. * @apiSuccess {Int} result.consult_list.consult_id 咨询ID
  36. * @apiSuccess {Int} result.consult_list.consult_isanonymous 是否匿名,0否1是
  37. * @apiSuccess {Int} result.consult_list.consult_reply 回复内容
  38. * @apiSuccess {Int} result.consult_list.consult_replytime 回复时间
  39. * @apiSuccess {Int} result.consult_list.consulttype_id 咨询类型ID
  40. * @apiSuccess {Int} result.consult_list.goods_id 商品ID
  41. * @apiSuccess {Int} result.consult_list.goods_name 商品名称
  42. * @apiSuccess {Int} result.consult_list.member_id 用户ID
  43. * @apiSuccess {Int} result.consult_list.member_name 用户名称
  44. * @apiSuccess {Int} result.consult_list.store_id 店铺ID
  45. * @apiSuccess {Int} result.consult_list.store_name 店铺名称
  46. * @apiSuccess {Object} result.consult_type 咨询类型,键为咨询类型ID
  47. * @apiSuccess {Int} result.consult_type.consulttype_id 咨询类型ID
  48. * @apiSuccess {String} result.consult_type.consulttype_introduce 咨询类型描述
  49. * @apiSuccess {String} result.consult_type.consulttype_name 咨询类型名称
  50. * @apiSuccess {Int} result.consult_type.consulttype_sort 咨询类型排序
  51. * @apiSuccess {Int} result.page_total 总页数
  52. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  53. */
  54. public function index()
  55. {
  56. $this->my_consult();
  57. }
  58. public function my_consult()
  59. {
  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. }