PlatformOrderController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace backend\modules\admin\controllers;
  3. use backend\controllers\AdminController;
  4. use common\enums\platform\PlatformEnum;
  5. use common\enums\StatusEnum;
  6. use common\models\addons\AddonsOrder;
  7. use common\models\backend\Admin;
  8. use common\models\common\PlatformSetting;
  9. use common\models\mall\Mall;
  10. use common\models\platform\PlatformOrder;
  11. use common\models\platform\PlatformOrderStatisticsDay;
  12. use Yii;
  13. /**
  14. * 商城控制器
  15. *
  16. * @Author ltm
  17. * @DateTime 2021-08-13 15:29:41
  18. * @copyright: Copyright (c) 2020 广东七件事集团
  19. */
  20. class PlatformOrderController extends AdminController
  21. {
  22. public function actionIndex($keyword = null, $is_recycle = 0)
  23. {
  24. $retuest = Yii::$app->request;
  25. if ($retuest->isAjax) {
  26. if ($retuest->isPost) {
  27. $post = Yii::$app->request->post();
  28. // 检查提交的参数
  29. $res = Yii::$app->services->validate->validate($post,[
  30. [['id','level'], 'integer'],
  31. [['title','consumer_name','order_status','date_end','date_start'], 'safe'],
  32. [['limit'],'default','value' => '15'],
  33. ]);
  34. if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  35. $post = PlatformOrder::exceptNullVal($post);
  36. if($post['date_start'] && $post['date_end']) $where[] = ['between', 'created_at', strtotime($post['date_start']),strtotime($post['date_end'])];
  37. if($post['title']) $where[] = ['like', 'title', $post['title']];
  38. if($post['consumer_name']) $where[] = ['like', 'consumer_name', $post['consumer_name']];
  39. if(isset($post['order_status']) && $post['order_status'] !== '') $where[] = ['=', 'order_status', $post['order_status']];
  40. $where[] = ['=','status',StatusEnum::ENABLED];
  41. $order = 'id desc';
  42. $params = array('where' => $where, 'order'=>$order, 'limit' => $post['limit']);
  43. $list = PlatformOrder::listPage($params);
  44. $select = 'sum(order_num) as order_num,sum(pay_num) as pay_num,sum(cancel_order_num) as cancel_order_num';
  45. $statics = PlatformOrderStatisticsDay::getOne('',true,'','id desc',$select);
  46. $list['statistics'] = $statics;
  47. $list['consumer_type'] = PlatformEnum::getConsumerTypeMap();
  48. $list['from_type'] = PlatformEnum::getFromTypeMap();
  49. $this->success('获取成功', $list);
  50. }
  51. } else {
  52. return $this->render($this->action->id);
  53. }
  54. }
  55. }