Memberconsult.php 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 Memberconsult extends MobileMember {
  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/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. $this->my_consult();
  59. }
  60. public function my_consult() {
  61. //实例化商品咨询模型
  62. $consult_model = model('consult');
  63. $goods_model = model('goods');
  64. $search_array = array();
  65. if (input('param.type') != '') {
  66. if (input('param.type') == 'to_reply') {
  67. $search_array[] = array('consult_reply', '=', '');
  68. }
  69. if (input('param.type') == 'replied') {
  70. $search_array[] = array('consult_reply', '<>', '');
  71. }
  72. }
  73. $search_array[] = array('member_id', '=', $this->member_info['member_id']);
  74. $list_consult = $consult_model->getConsultList($search_array);
  75. if(!empty($list_consult)){
  76. foreach($list_consult as $key => $val){
  77. $condition = array();
  78. $condition[] = array('goods_id','=',$val['goods_id']);
  79. $goodsinfo = $goods_model->getGoodsInfo($condition,'goods_image,goods_price');
  80. $list_consult[$key]['goods_image'] = goods_cthumb($goodsinfo['goods_image']);
  81. $list_consult[$key]['goods_price'] = $goodsinfo['goods_price'];
  82. }
  83. }
  84. // 咨询类型
  85. $consult_type = rkcache('consulttype', true);
  86. $result = array_merge(array('consult_list' => $list_consult, 'consult_type' => $consult_type), mobile_page($consult_model->page_info));
  87. ds_json_encode(10000, '', $result);
  88. }
  89. }