StoreProductReply.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\controller\store;
  12. use app\admin\controller\AuthController;
  13. use traits\CurdControllerTrait;
  14. use service\JsonService as Json;
  15. use service\UploadService as Upload;
  16. use think\Request;
  17. use app\admin\model\store\StoreProductReply as ProductReplyModel;
  18. use think\Url;
  19. /**
  20. * 评论管理 控制器
  21. * Class StoreProductReply
  22. * @package app\admin\controller\store
  23. */
  24. class StoreProductReply extends AuthController
  25. {
  26. use CurdControllerTrait;
  27. /**
  28. * 显示资源列表
  29. *
  30. * @return \think\Response
  31. */
  32. public function index()
  33. {
  34. $where = parent::getMore([
  35. ['is_reply', ''],
  36. ['comment', ''],
  37. ], $this->request);
  38. $product_id = input('product_id', 0);
  39. if ($product_id)
  40. $where['product_id'] = $product_id;
  41. else
  42. $where['product_id'] = 0;
  43. $this->assign('where', $where);
  44. $this->assign(ProductReplyModel::systemPage($where));
  45. return $this->fetch();
  46. }
  47. /**
  48. * @param $id
  49. * @return \think\response\Json|void
  50. */
  51. public function delete($id)
  52. {
  53. if (!$id) return $this->failed('数据不存在');
  54. $data['is_del'] = 1;
  55. if (!ProductReplyModel::edit($data, $id))
  56. return Json::fail(ProductReplyModel::getErrorInfo('删除失败,请稍候再试!'));
  57. else
  58. return Json::successful('删除成功!');
  59. }
  60. public function set_reply(Request $request)
  61. {
  62. $data = parent::postMore([
  63. 'id',
  64. 'content',
  65. ], $request);
  66. if (!$data['id']) return Json::fail('参数错误');
  67. if ($data['content'] == '') return Json::fail('请输入回复内容');
  68. $save['merchant_reply_content'] = $data['content'];
  69. $save['merchant_reply_time'] = time();
  70. $save['is_reply'] = 2;
  71. $res = ProductReplyModel::edit($save, $data['id']);
  72. if (!$res)
  73. return Json::fail(ProductReplyModel::getErrorInfo('回复失败,请稍候再试!'));
  74. else
  75. return Json::successful('回复成功!');
  76. }
  77. public function edit_reply(Request $request)
  78. {
  79. $data = parent::postMore([
  80. 'id',
  81. 'content',
  82. ], $request);
  83. if (!$data['id']) return Json::fail('参数错误');
  84. if ($data['content'] == '') return Json::fail('请输入回复内容');
  85. $save['merchant_reply_content'] = $data['content'];
  86. $save['merchant_reply_time'] = time();
  87. $save['is_reply'] = 2;
  88. $res = ProductReplyModel::edit($save, $data['id']);
  89. if (!$res)
  90. return Json::fail(ProductReplyModel::getErrorInfo('回复失败,请稍候再试!'));
  91. else
  92. return Json::successful('回复成功!');
  93. }
  94. }