Sellerevaluate.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 Sellerevaluate extends MobileSeller {
  16. public function initialize() {
  17. parent::initialize();
  18. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberevaluate.lang.php');
  19. }
  20. /**
  21. * @api {POST} api/Sellerevaluate/evaluate_list 评价列表
  22. * @apiVersion 1.0.0
  23. * @apiGroup Sellerevaluate
  24. *
  25. * @apiHeader {String} X-DS-KEY 卖家授权token
  26. *
  27. * @apiParam {String} goods_name 商品名称
  28. * @apiParam {String} member_name 会员名称
  29. * @apiParam {String} page 页码
  30. * @apiParam {String} pagesize 每页显示数量
  31. *
  32. * @apiSuccess {String} code 返回码,10000为成功
  33. * @apiSuccess {String} message 返回消息
  34. * @apiSuccess {Object} result 返回数据
  35. * @apiSuccess {Object[]} result.goodsevallist 评论列表 (返回字段参考evaluategoods表)
  36. * @apiSuccess {String} result.goodsevallist.geval_goodsimage_url 商品图片完整路径
  37. * @apiSuccess {Int} result.page_total 总页数
  38. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  39. */
  40. public function evaluate_list() {
  41. $evaluategoods_model = model('evaluategoods');
  42. $condition = array();
  43. $goods_name = input('param.goods_name');
  44. if (!empty($goods_name)) {
  45. $condition[] = array('geval_goodsname', 'like', '%' . $goods_name . '%');
  46. }
  47. $member_name = input('param.member_name');
  48. if (!empty($member_name)) {
  49. $condition[] = array('geval_frommembername', 'like', '%' . $member_name . '%');
  50. }
  51. $condition[] = array('geval_storeid', '=', $this->store_info['store_id']);
  52. $goodsevallist = $evaluategoods_model->getEvaluategoodsList($condition, 5, 'geval_id desc');
  53. foreach ($goodsevallist as $key => $val) {
  54. $goodsevallist[$key]['geval_goodsimage_url'] = goods_cthumb($val['geval_goodsimage']);
  55. }
  56. $result = array_merge(array('goodsevallist' => $goodsevallist), mobile_page($evaluategoods_model->page_info));
  57. ds_json_encode(10000, '', $result);
  58. }
  59. /**
  60. * @api {POST} api/Sellerevaluate/explain_save 解释来自买家的评价
  61. * @apiVersion 1.0.0
  62. * @apiGroup Sellerevaluate
  63. *
  64. * @apiHeader {String} X-DS-KEY 卖家授权token
  65. *
  66. * @apiParam {Int} geval_id 评论ID
  67. * @apiParam {String} geval_explain 解释
  68. *
  69. * @apiSuccess {String} code 返回码,10000为成功
  70. * @apiSuccess {String} message 返回消息
  71. * @apiSuccess {Object} result 返回数据
  72. */
  73. public function explain_save() {
  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. }
  97. ?>