/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SinaInvest::find()->orderBy('id DESC'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'uid' => $this->uid, 'status' => $this->status, 'create_at' => $this->create_at, 'update_at' => $this->update_at]); $query->andFilterWhere(['like', 'identity_id', $this->identity_id])->andFilterWhere(['like', 'out_trade_no', $this->out_trade_no])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'trade_close_time', $this->trade_close_time])->andFilterWhere(['like', 'payer_ip', $this->payer_ip])->andFilterWhere(['like', 'pay_type', $this->pay_type])->andFilterWhere(['like', 'account_type', $this->account_type])->andFilterWhere(['like', 'goods_id', $this->goods_id])->andFilterWhere(['like', 'money', $this->money])->andFilterWhere(['like', 'msg', $this->msg])->andFilterWhere(['like', 'payee_out_trade_no', $this->payee_out_trade_no])->andFilterWhere(['like', 'payee_identity_id', $this->payee_identity_id])->andFilterWhere(['like', 'payee_account_type', $this->payee_account_type])->andFilterWhere(['like', 'payee_amount', $this->payee_amount])->andFilterWhere(['like', 'payee_summary', $this->payee_summary]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel common\models\sinapay\SinaInvestSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', '新浪投资记录'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="sina-invest-index"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'uid', 'identity_id', 'summary', 'money', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) { if ($model->status === 3) { $class = 'label-success'; } elseif ($model->status === 1) { $class = 'label-success'; } elseif ($model->status === 2) { $class = 'label-warning'; } else { $class = 'label-danger'; } return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>'; }, 'filter' => Html::activeDropDownList($searchModel, 'status', \common\models\sinapay\SinaInvest::labels(), ['class' => 'form-control', 'prompt' => '请筛选'])], 'msg', 'payee_amount', 'payee_summary', 'refund_amount', 'refund_summary', ['attribute' => 'create_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'headerOptions' => ['width' => '100']]]]); ?> </div>
/** * 投资数据记录 * @param $uid * @param $identity_id * @param $out_trade_no * @param $summary * @param $trade_close_time * @param $payer_ip * @param $pay_type * @param $account_type * @param $goods_id * @param $money * @param $status * @param $msg * @return bool */ private static function investLog($uid, $identity_id, $out_trade_no, $summary, $trade_close_time, $payer_ip, $pay_type, $account_type, $goods_id, $money, $status, $msg) { $log = new SinaInvest(); $log->uid = $uid; $log->identity_id = $identity_id; $log->out_trade_no = $out_trade_no; $log->summary = $summary; $log->trade_close_time = $trade_close_time; $log->payer_ip = $payer_ip; $log->pay_type = $pay_type; $log->account_type = $account_type; $log->goods_id = $goods_id; $log->money = $money; $log->status = $status; $log->msg = $msg; return $log->save(); }
/** * Finds the SinaInvest model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SinaInvest the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SinaInvest::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }