DelayLogController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace addons\Agent\backend\controllers;
  3. use addons\Agent\common\models\AgentDelayLog;
  4. use common\models\common\CapitalLog;
  5. use Yii;
  6. class DelayLogController extends BaseController
  7. {
  8. public function actionIndex() {
  9. $request = Yii::$app->request;
  10. if ($request->isAjax) {
  11. $search = $request->get();
  12. // 检查提交的参数
  13. if (!Yii::$app->services->validate->validate($search, [
  14. [['keyword', 'order_no', 'date_start', 'date_end'], 'string'],
  15. [['status'], 'safe'],
  16. [['user_id', 'page', 'limit'], 'integer'],
  17. ])) {
  18. return $this->error(Yii::$app->services->validate->getErrorMessage());
  19. }
  20. $where = [['=', 'mall_id', $this->mall_id], ['status' => [CapitalLog::STATUS_WAIT_SEND, CapitalLog::STATUS_SEND]]];
  21. !empty($search['keyword']) && $where[] = ['or', ['like', 'wallet_desc', $search['keyword']], ['like', 'contributor_name', $search['keyword']]];
  22. !empty($search['user_id']) && $where[] = ['user_id' => $search['user_id']];
  23. !empty($search['order_no']) && $where[] = ['order_no' => $search['order_no']];
  24. isset($search['status']) && $search['status'] != '' && $where[] = ['status' => $search['status']];
  25. !empty($search['date_start']) && $where[] = ['>=', 'created_at', strtotime($search['date_start'])];
  26. !empty($search['date_end']) && $where[] = ['<=', 'created_at', strtotime($search['date_end'])];
  27. $result = AgentDelayLog::listPage(['where' => $where, 'page' => $search['page'], 'with' => ['user'], 'limit' => $this->pageSize, 'order' => 'id desc']);
  28. if (!$result) return $this->error(AgentDelayLog::getStaticError());
  29. $result['wallet_types'] = AgentDelayLog::WALLET_TYPES;
  30. return $this->success('获取延时结算列表成功', $result);
  31. }
  32. return $this->render('index');
  33. }
  34. }