255], [['keyword'], 'trim'], [['type'], 'required'] ]; } public function search() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0] ]; } $query = SharingReceiver::find()->where(['is_delete' => 0]); if ($this->type == self::CALL_TYPE_STORE) { $query->andWhere(['store_id' => $this->store_id]); } if (!empty($this->keyword)) { // 订单号 if ($this->search_type == 1) { $query->andWhere(['like', 'order_no', $this->keyword]); } // 名称 if ($this->search_type == 2) { $query->andWhere(['like', 'name', $this->keyword]); } } if (!empty($this->dateStart)) { $query->andWhere(['>=', 'created_at', strtotime($this->dateStart)]); } if (!empty($this->dateEnd)) { $query->andWhere(['<=', 'created_at', strtotime($this->dateEnd)]); } if (($this->status && in_array($this->status, [0, 1, 2])) || $this->status == 0) { $query->andWhere(['is_pay' => $this->status]); } // 0: 店铺分销, 1:平台分销, 2:平台推荐, 3:服务商分账, 4:商城间分销, 5:消费返利 // if (($this->from && in_array($this->from, [0, 1, 2, 3, 4])) || $this->from == 0) { // $query->andWhere(['from' => $this->from]); // } if ((isset($this->from)) && intval($this->from) !== -1) { $query->andWhere(['from' => $this->from]); } else { $query->andWhere(['from' => SharingReceiver::FROM_ARR]); } if ($this->from == 5) { $query->andWhere(['from' => 1]); $query->andWhere(['like', 'remark', '自购返利']); } $query->orderBy('id DESC') ->select('*'); $list = pagination_make($query); foreach ($list['list'] as &$val) { $val['rate'] = $val['rate'] . "%"; $val['created_at'] = date('Y-m-d H:i:s', $val['created_at']); $val['updated_at'] = date('Y-m-d H:i:s', $val['updated_at']); } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $list['list'], 'pageNo' => $list['pageNo'], 'totalCount' => $list['totalCount'], ] ]; } }