MyCommentController.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/4/20
  6. * Time: 下午6:05
  7. */
  8. namespace app\frontend\modules\order\controllers;
  9. use app\common\components\ApiController;
  10. use app\common\models\comment\CommentConfig;
  11. use app\frontend\models\Order;
  12. use app\frontend\models\OrderGoods;
  13. class MyCommentController extends ApiController
  14. {
  15. public function index()
  16. {
  17. $list = Order::getMyCommentList( \YunShop::request()->status)->toArray();
  18. if(!is_null($event_arr = \app\common\modules\shop\ShopConfig::current()->get('form_comment_list'))){
  19. foreach ($event_arr as $v){
  20. $class = array_get($v, 'class');
  21. $function = array_get($v, 'function');
  22. if ($res = $class::$function(['data'=>$list])){
  23. $list = $res['data'];
  24. }
  25. }
  26. }
  27. return $this->successJson('成功', [
  28. 'list' => $list
  29. ]);
  30. }
  31. public function paging()
  32. {
  33. $page = \YunShop::request()->page?:1;
  34. // $page = ($page - 1) ? ($page - 1) *15 : 1;
  35. $list = Order::getMyCommentListPaginate( \YunShop::request()->status,$page,15)->toArray();
  36. $config = CommentConfig::getSetConfig();
  37. //todo 临时处理
  38. foreach ($list['data'] as &$item) {
  39. foreach ($item['has_many_order_goods'] as $key => &$item2) {
  40. unset($item2['buttons']);
  41. if ($item2['comment_status'] == 1) {
  42. $item2['buttons'][] = [
  43. 'name' => '查看评价',
  44. 'api' => '',
  45. 'value' => '2'
  46. ];
  47. //开启追评
  48. if ($config->is_additional_comment) {
  49. $appendButtons = [
  50. 'name' => '追评',
  51. 'api' => '',
  52. 'value' => '1'
  53. ];
  54. array_push($item2['buttons'],$appendButtons);
  55. }
  56. }
  57. }
  58. }
  59. if(!is_null($event_arr = \app\common\modules\shop\ShopConfig::current()->get('form_comment_list'))){
  60. foreach ($event_arr as $v){
  61. $class = array_get($v, 'class');
  62. $function = array_get($v, 'function');
  63. $list = $class::$function($list) ? : $list;
  64. }
  65. }
  66. return $this->successJson('成功', [
  67. 'list' => $list
  68. ]);
  69. }
  70. public function goods()
  71. {
  72. $list = OrderGoods::getMyCommentList(1);
  73. return $this->successJson('成功', [
  74. 'list' => $list->toArray()
  75. ]);
  76. }
  77. }