/** * 获取订单列表信息 */ public function actionList() { $this->layout = 'main'; //判断用户是否登录 if (!UserBaseInfo::isLogin()) { return $this->redirect(Url::toRoute('user/login')); } //从session或cookie中获取open_id $openId = UserBaseInfo::getOpenId(); $data['open_id'] = $openId; $data['status'] = Order::ORDER_USABLE_STATUS; $params = Yii::$app->request->get(); $startTime = false; $endTime = false; $time = Yii::$app->util->loadConfig('user-order-time', '/platform_i/config/'); if ($params) { if (isset($params['startTime']) && isset($params['endTime'])) { $data['startTime'] = strtotime($params['startTime'] . ' 00:00:00'); $data['endTime'] = strtotime($params['endTime'] . ' 23:59:59'); $checkTime = $this->checkTime($params['startTime'], $params['endTime']); if ($checkTime['startTime'] && $checkTime['endTime']) { $data['startTime'] = strtotime($checkTime['startTime'] . ' 00:00:00'); $data['endTime'] = strtotime($checkTime['endTime'] . '23:59:59'); $params['startTime'] = $checkTime['startTime']; $params['endTime'] = $checkTime['endTime']; } if ($data['startTime'] > $data['endTime']) { $tmpParam = $params['startTime']; $params['startTime'] = $params['endTime']; $params['endTime'] = $tmpParam; $tmpData = $data['startTime']; $data['startTime'] = $data['endTime']; $data['endTime'] = $tmpData; } $timeInterval = $params['startTime'] . '_' . $params['endTime']; foreach ($time as $key => &$value) { if ($timeInterval == $value['timeInterval']) { $value['class'] = true; } } } else { if (isset($params['timeRange'])) { if (in_array($params['timeRange'], array_keys($time))) { $time[$params['timeRange']]['class'] = true; } else { $time[1]['class'] = true; } } else { //默认为今天 $time[1]['class'] = true; $params['timeRange'] = 1; } $data['endTime'] = strtotime(date('Y-m-d 23:59:59')); $data['startTime'] = $this->getTime($params['timeRange']); } if (isset($params['payStatus'])) { if ($params['payStatus'] != 0 && $params['payStatus'] != 1 && $params['payStatus'] != 5) { unset($params['payStatus']); } else { $data['pay_status'] = $params['payStatus']; } } } else { $params['timeRange'] = 1; $data['endTime'] = strtotime(date('Y-m-d 23:59:59')); $data['startTime'] = $this->getTime($params['timeRange']); $time[1]['class'] = true; } $result = Order::getData($data, $startTime, $endTime); $pages = new Pagination(['totalCount' => $result->count(), 'pageSize' => '10']); $result = $result->offset($pages->offset)->limit($pages->limit)->asArray()->all(); //从缓存中取出应用配置信息 $appConfig = AppConfig::getConfigUrl(); if (is_array($appConfig)) { foreach ($result as $key => &$value) { $value['config_urls'] = $appConfig[$value['app_id']]; } } return $this->render('list', ['result' => $result, 'pages' => $pages, 'time' => $time]); }
/** * 关联cp_config_url */ public function getConfigUrl() { return $this->hasOne(AppConfig::className(), ['app_id' => 'app_id']); }