/** * @brief 从银行返回的excel列表总导出支付成功和失败信息,用于后续处理,解冻,结算等。 * * @return public function * @retval * @see * @note * @author 吕宝贵 * @date 2015/12/22 18:14:17 **/ public function actionImportFromExcel() { //获取文件 $excelFile = UploadedFile::getInstanceByName('payedfile'); if (!$excelFile) { throw new Exception('获取上传文件失败'); } $excelConverter = new Excel(); $payedItems = $excelConverter->importFromFile(); //循环处理支付结果,对有问题的结果写入文件,导出给用户,一天提取的款项默认不多,因此不需要做异步处理 foreach ($payedItems as $payedItem) { if ($payedItem['status']) { $payable = Payable::findOne($payedItem['id']); $userAccount = Yii::$app->account->getUserAccount($payable->uid); $callbackFunc = [UserWithdraw::className(), 'processFinishPayNotify']; if (!$userAccount->processWithdrawPaySuccess($payable->id, $callbackFunc)) { //将错误处理的信息记录下来 } } } }
/** * 保存提现数据 * * @param int $trade_id * @param int $now * @return boolean */ public function saveWithdrawData($trade_id = 0, $now = 0) { if ($trade_id <= 0) { return false; } //保存数据 $model = new UserWithdraw(); if ($this->type == UserWithdraw::TYPE_BANK) { $model->real_name = $this->real_name; $model->bank_name = $this->bank_name; } $model->type = $this->type; $model->trade_id = $trade_id; $model->account = $this->account; $model->amount = $this->amount; $model->time_create = $now; $model->time_update = $now; if ($model->save()) { return true; } else { return false; } }