Sellerevaluate.php 4.4 KB

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