validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $query = RcCommissionLog::find()->alias('al') ->leftJoin(ReOrder::tableName() . 'o', 'o.id = al.order_id') ->where([ 'al.store_id' => get_store_id(), 'al.parent_id' => get_user_id(), ]); if ($this->type > -1 && in_array($this->type, [1, 2])) { $query->andWhere(['al.log_type' => $this->type]); } // if ($this->status > -1 ) { // $query->andWhere(['o.is_pay' => $this->status == 1 ? 1 : ($this->status == 2 ? 1 : 0)]); // } $query->andWhere(['o.is_pay' => 1]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'page' => $this->page - 1, 'pageSize' => $this->limit]); $query->select('al.*, o.pay_price'); $list = $query->limit($pagination->limit)->offset($pagination->offset)->orderBy('created_at DESC')->asArray()->all(); foreach ($list as &$value) { $value['date'] = date('Y-m-d H:i:s', $value['created_at']); $value['content'] = $value['desc']; $value['user_info'] = User::find()->alias('u') ->leftJoin(['su' => SaasUser::tableName()], 'su.mobile = u.binding') ->where(['u.id' => $value['user_id']])->select('su.name, su.avatar')->asArray()->one() ?: [ 'name' => '', 'avatar' => '' ]; } // unset($value); return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'list' => $list, 'page'=>$this->page - 1, 'pageSize'=> $this->limit, 'row_count' => $count ] ]; } }