Sellerevaluate.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 店铺评论控制器
  10. */
  11. class Sellerevaluate extends MobileSeller
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize();
  16. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberevaluate.lang.php');
  17. }
  18. /**
  19. * @api {POST} api/Sellerevaluate/evaluate_list 评价列表
  20. * @apiVersion 1.0.0
  21. * @apiGroup Sellerevaluate
  22. *
  23. * @apiHeader {String} X-DS-KEY 卖家授权token
  24. *
  25. * @apiParam {String} goods_name 商品名称
  26. * @apiParam {String} member_name 会员名称
  27. * @apiParam {String} page 页码
  28. * @apiParam {String} pagesize 每页显示数量
  29. *
  30. * @apiSuccess {String} code 返回码,10000为成功
  31. * @apiSuccess {String} message 返回消息
  32. * @apiSuccess {Object} result 返回数据
  33. * @apiSuccess {Object[]} result.goodsevallist 评论列表 (返回字段参考evaluategoods表)
  34. * @apiSuccess {String} result.goodsevallist.geval_goodsimage_url 商品图片完整路径
  35. * @apiSuccess {Int} result.page_total 总页数
  36. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  37. */
  38. public function evaluate_list()
  39. {
  40. $evaluategoods_model = model('evaluategoods');
  41. $condition = array();
  42. $goods_name = input('param.goods_name');
  43. if (!empty($goods_name)) {
  44. $condition[] = array('geval_goodsname', 'like', '%' . $goods_name . '%');
  45. }
  46. $member_name = input('param.member_name');
  47. if (!empty($member_name)) {
  48. $condition[] = array('geval_frommembername', 'like', '%' . $member_name . '%');
  49. }
  50. $condition[] = array('geval_storeid', '=', $this->store_info['store_id']);
  51. $goodsevallist = $evaluategoods_model->getEvaluategoodsList($condition, 5, 'geval_id desc');
  52. foreach ($goodsevallist as $key => $val) {
  53. $goodsevallist[$key]['geval_goodsimage_url'] = goods_cthumb($val['geval_goodsimage']);
  54. }
  55. $result = array_merge(array('goodsevallist' => $goodsevallist), mobile_page($evaluategoods_model->page_info));
  56. ds_json_encode(10000, '', $result);
  57. }
  58. /**
  59. * @api {POST} api/Sellerevaluate/explain_save 解释来自买家的评价
  60. * @apiVersion 1.0.0
  61. * @apiGroup Sellerevaluate
  62. *
  63. * @apiHeader {String} X-DS-KEY 卖家授权token
  64. *
  65. * @apiParam {Int} geval_id 评论ID
  66. * @apiParam {String} geval_explain 解释
  67. *
  68. * @apiSuccess {String} code 返回码,10000为成功
  69. * @apiSuccess {String} message 返回消息
  70. * @apiSuccess {Object} result 返回数据
  71. */
  72. public function explain_save()
  73. {
  74. $geval_id = intval(input('post.geval_id'));
  75. $geval_explain = trim(input('post.geval_explain'));
  76. //验证表单
  77. if (!$geval_explain) {
  78. ds_json_encode(10001, lang('member_evaluation_explain_nullerror'));
  79. }
  80. $data = array();
  81. $data['result'] = true;
  82. $evaluategoods_model = model('evaluategoods');
  83. $evaluate_info = $evaluategoods_model->getEvaluategoodsInfoByID($geval_id, $this->store_info['store_id']);
  84. if (empty($evaluate_info)) {
  85. ds_json_encode(10001, lang('param_error'));
  86. }
  87. $update = array('geval_explain' => $geval_explain);
  88. $condition = array('geval_id' => $geval_id);
  89. $result = $evaluategoods_model->editEvaluategoods($update, $condition);
  90. if ($result) {
  91. ds_json_encode(10000, lang('ds_common_op_succ'));
  92. } else {
  93. ds_json_encode(10001, lang('ds_common_op_fail'));
  94. }
  95. }
  96. }