/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PayableProcessBatch::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'admin_uid' => $this->admin_uid, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'admin_username', $this->admin_username]);
     return $dataProvider;
 }
 /**
  * @brief 产生Excel文件
  *
  * @return  protected function 
  * @retval   
  * @see 
  * @note 
  * @author 吕宝贵
  * @date 2016/01/11 14:34:57
  **/
 protected function generateDatas($payables, $processBatch = null)
 {
     if (empty($payables)) {
         throw new Exception('没有可供下载的记录');
     }
     $meta = ['filename' => '付款明细' . date('Y-m-d-H'), 'author' => 'Mr-Hug', 'modify_user' => 'Mr-Hug', 'title' => 'Mr-Hug付款明细', 'subject' => 'Mr-Hug付款明细', 'description' => 'Mr-Hug应付账款明细,用户提现明细', 'keywords' => 'Mr-Hug, 付款,银行转账', 'category' => '银行转账'];
     $headerLables = ['企业参考号', '收款人编号', '收款人账号', '收款人名称', '收方开户支行', '收款人所在省', '收款人所在市', '收方邮件地址', '收方移动电话', '币种', '付款分行', '结算方式', '业务种类', '付方账号', '期往日', '期望时间', '用途', '金额', '收方行号', '收方开户银行', '业务摘要'];
     $datas = [];
     //第一行为title信息
     $datas[] = $headerLables;
     $totalMoney = 0;
     $payableCount = 0;
     $payableIds = [];
     foreach ($payables as $payable) {
         $totalMoney += $payable->money;
         $payableCount += 1;
         $data = [$payable->id, $payable->receive_uid, $payable->receiverBankAccount->account_no, $payable->receiverBankAccount->account_name, '', $payable->receiverBankAccount->province, $payable->receiverBankAccount->city, '', '', '', '', '普通', '', '', date('Ymd', $payable->updated_at + 86400 * 2), '', 'Mr-Hug服务费', $payable->money, '', $payable->receiverBankAccount->bank_name, $payable->memo];
         if (!$processBatch) {
             $callbackFunc = [UserWithdraw::className(), 'processPayingNotify'];
             if (!Yii::$app->account->processWithdrawPaying($payable, $callbackFunc)) {
                 return false;
             }
         }
         $datas[] = $data;
         $payableIds[] = $payable->id;
     }
     if (!$processBatch) {
         $processBatch = new PayableProcessBatch();
         $processBatch->total_money = $totalMoney;
         $processBatch->count = $payableCount;
         $processBatch->download_time = time();
         if (!$processBatch->save()) {
             return false;
         }
     }
     //处理相关的应付记录状态
     if (!Yii::$app->db->createCommand()->update(Payable::tableName(), ['process_batch_no' => $processBatch->id], ['id' => $payableIds])->execute()) {
         return false;
     }
     return ['datas' => $datas, 'meta' => $meta];
 }