'申请', self::STATUS_AGREE => '同意', self::STATUS_ALREADY_TRANS => '已打款', self::STATUS_ALREADY_REJECT => '驳回', self::STATUS_FAIL => '失败', self::STATUS_WAIT => '打款中' ]; //打款类型 public static $type_msg = [ 'auto' => '自动打款', 'wechat' => '微信', 'alipay' => '支付宝', 'bank' => '银行转账', 'balance' => '打款到余额' ]; /** * @var float|int|mixed|null */ /** * {@inheritdoc} */ public static function tableName() { return '{{%addons_higo_withdraw_log}}'; } /** * {@inheritdoc} */ public function rules() { return [ [['mall_id', 'user_id', 'num', 'actual_num', 'extra', 'content', 'from', 'type'], 'required'], [['id', 'mall_id', 'user_id', 'from', 'status', 'created_at', 'updated_at'], 'integer'], [['num', 'actual_num', 'poundage_num', 'poundage_ratio',], 'number'], [['extra', 'content', 'transfer'], 'string'], [['order_no'], 'string', 'max' => 255], [['type'], 'string', 'max' => 45], [['from'], 'in', 'range' => [1, 2]], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'order_no' => 'Order No', 'num' => 'Num', 'actual_num' => 'Actual Num', 'poundage_num' => 'Poundage Num', 'poundage_ratio' => 'Poundage Ratio', 'from' => 'From', 'type' => 'Type', 'extra' => 'Extra', 'content' => 'Content', 'status' => 'Status', 'transfer' => 'Transfer', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function fieldsList($field = null) { $fields = [ 'user_id' => '会员ID', // 'user_info' => '基本信息', 'username' => '会员编号', 'nickname' => '会员昵称', 'user_mobile' => '手机号码', 'from' => '提现类型', // 'type' => '账户信息', 'alipay_name' => '支付宝姓名', 'mobile' => '支付宝账号', 'bank_account_type' => '账户类型', 'name' => '持卡/开户人', 'bank_name' => '开户行', 'bank_account' => '银行卡号', 'num' => '提现金额', 'actual_num' => '实际到账金额', 'poundage_num' => '手续费', 'status' => '状态', 'updated_at' => '时间', 'remark' => '备注', ]; if ($field === null) return $fields; $temp = []; foreach ($field as $val) { if (isset($fields[$val])) $temp[$val] = $fields[$val]; } return $temp; } public function saveRecord($params) { if ($params['price'] <= 0) { return [ 'state' => false, 'msg' => '提现金额必须大于0!' ]; } $exists = self::find()->where([ 'mall_id' => $params['mall_id'], 'status' => 0, 'user_id' => $params['user_id'], 'from' => $params['from'] ])->asArray()->one(); if ($exists) { return [ 'state' => false, 'msg' => '尚有未审核的提现申请!' ]; } $higo_wallet = HigoWallet::getOne([['user_id' => $params['user_id']], ['status' => StatusEnum::ENABLED], ['mall_id' => $params['mall_id']]], true, [], false, 'hi_bei'); $hi_bei = $higo_wallet['hi_bei'] ?? 0; if ($hi_bei < $params['price']) { return [ 'state' => false, 'msg' => '提现金额超出可提现金额!' ]; } $withdraw = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'withdraw'); $cash_status = $withdraw['cash_status'] ? json_decode($withdraw['cash_status'], true) : 0; $cash_status = is_array($cash_status) ? $cash_status['value'] : $cash_status; if (!$cash_status) { return [ 'state' => false, 'msg' => '暂未开启提现功能!' ]; } $cash_service_fee = $withdraw['cash_service_fee'] ? json_decode($withdraw['cash_service_fee'], true) : 0; $poundage_ratio = is_array($cash_service_fee) ? $cash_service_fee['value'] : $cash_service_fee; $wallet_type = HiGoEnum::WALLET_TYPE_HI_BEI; $balance_config = \Yii::$app->services->setting->mall->get($params['mall_id'], 'pay.balance'); if ($balance_config) { $balance_config = Json::decode((string)$balance_config); if ($balance_config['pay_password_status'] == 1) { $transactionPassword = $params['transaction_password']; $password = User::getOne([['id' => $params['user_id']]], true, '', '', 'transaction_password'); if (!$params['transaction_password']) { return [ 'state' => false, 'msg' => '请输入支付密码!' ]; } if (empty($password['transaction_password'])) { return [ 'state' => false, 'msg' => '您未设置支付密码!' ]; } if (empty($transactionPassword)) { return [ 'state' => false, 'msg' => '请输入交易密码!' ]; } if (!\Yii::$app->getSecurity()->validatePassword(trim($transactionPassword), $password['transaction_password'])) { return [ 'state' => false, 'msg' => '支付密码错误!' ]; } } } if (!$params['type']) { return [ 'state' => false, 'msg' => '请选择提现方式!' ]; } if ($params['type'] == 'wechat') { if (!isset($params['wechat_qrcode'])) { return [ 'state' => false, 'msg' => '请上传微信收款码!' ]; } } if ($params['type'] == 'alipay') { if (!$params['mobile']) { return [ 'state' => false, 'msg' => '请填写支付宝账号!' ]; } if (!$params['name']) { return [ 'state' => false, 'msg' => '请填写支付宝姓名!' ]; } } if ($params['type'] == 'third_party_address') { if (!$params['address']) { return [ 'state' => false, 'msg' => '请填写第三地址提现地址' ]; } } if ($params['type'] == 'paid') { //代付银行卡 if (!$params['name']) { return [ 'state' => false, 'msg' => '请填写持卡人!' ]; } if (!$params['bank_account']) { return [ 'state' => false, 'msg' => '请填写银行卡号!' ]; } } if ($params['type'] == 'alipay_tax') { if (!$params['mobile']) { return [ 'state' => false, 'msg' => '请填写支付宝账号(手机号)' ]; } if (!$params['name']) { return [ 'state' => false, 'msg' => '请填写支付宝姓名' ]; } if (!$params['id_card']) { return [ 'state' => false, 'msg' => '请填写身份证信息' ]; } $service = new \addons\AvoidTax\common\service\UserService(['mall_id' => $this->mall_id]); $res = $service->checkSign($this->user_id); if ($res === false) { $res = $service->goToSing($this->user_id, $params['mobile'], $params['id_card'], $params['name']); if (!$res) { return [ 'state' => false, 'msg' => $service->error ]; } // 跳转url签约 return [ 'state' => true, 'data' => $res ]; } } $hi_bei_now_price = HiBeiLogic::getNowPrice($params['mall_id']); $cash = new self(); $cash->mall_id = $params['mall_id']; $cash->user_id = $params['user_id']; $cash->num = $params['price']; $cash->actual_num = $params['price']; $cash->content = Json::encode(['user_content' => $params['content']]); $cash->from = $params['from']; $cash->type = $params['type']; $cash->extra = Json::encode([ 'name' => $params['name'], 'mobile' => $params['mobile'], 'bank_name' => $params['bank_name'], 'bank_account' => (string)$params['bank_account'], 'bank_account_type' => $params['bank_account_type'], 'wechat_qrcode' => $params['wechat_qrcode'], 'third_party_address' => $params['address'], 'now_price' => $hi_bei_now_price ], JSON_UNESCAPED_UNICODE); if ($poundage_ratio < 0 || $poundage_ratio > 100) { return [ 'state' => false, 'msg' => '手续费设置不正确!' ]; } //手续费 $poundage = 0; if ($poundage_ratio > 0 && $poundage_ratio < 100) { //手续费:取小数点2位,截断 $poundage = bcmul($poundage_ratio / 100, $params['price'], 4); // 四舍五入,保留2位 $poundage = number_format($poundage, 2, '.', ''); $cash->actual_num = bcsub($params['price'], $poundage, 2); $cash->poundage_num = $poundage; $cash->poundage_ratio = $poundage_ratio; } if (intval(bcmul($cash->actual_num, 100)) < 1) { return [ 'state' => false, 'msg' => '提现金额扣除费用后金额不足!' ]; } //计算当前价格 $cash->actual_num = bcmul($cash->actual_num,$hi_bei_now_price,2); $t = \Yii::$app->db->beginTransaction(); $basic = HiGoEnum::getHigoWalletText($params['mall_id']); $hi_bei_name = $basic[HiGoEnum::WALLET_TYPE_HI_BEI]; try { $cash->order_no = $this->getCashOrder($params['mall_id']); $desc = $hi_bei_name . '提现'; $desc .= $cash->num; if ($poundage > 0) { $desc .= ':手续费¥' . $poundage; } if (!$cash->save()) { throw new Exception($cash->getErrorMessage()); } $res_data = [ 'state' => true, 'data' => ['cash_id' => $cash->id], 'msg' => '' ]; $t->commit(); $wallet_log = [ 'mall_id' => $params['mall_id'], 'user_id' => $params['user_id'], 'change_num' => bcmul($params['price'], -1, 20), 'desc' => $desc, 'source_table' => self::tableName(), 'source_table_id' => $cash->id, 'from_type' => HiGoEnum::FROM_TYPE_WITHDRAW_HI_BEI, 'wallet_type' => $wallet_type, 'is_send' => false ]; $result = WalletLogic::handleInQueue($wallet_log); if (!$result) { $cash->status = 4; $cash->save(); return [ 'state' => false, 'msg' => '提现失败,系统繁忙!' ]; } } catch (Exception $e) { $t->rollBack(); \Yii::error($e->getMessage()); return [ 'state' => false, 'msg' => '提现失败!' . $e->getMessage() ]; } return $res_data; } private function getCashOrder($mall_id): string { $order_no = null; while (true) { $order_no = 'HG' . date('YmdHis') . rand(10000, 99999); $exist = self::find()->where(['mall_id' => $mall_id, 'order_no' => $order_no,])->asArray()->one(); if (!$exist) { break; } } return $order_no; } public function searchLogList($get): array { $mall_id = $get['mall_id']; $params['alias'] = 'b'; $params['joinWith'] = ['user']; if ($get['status'] && $get['status'] >= 0) { $params['where'][] = ['=', 'b.status', $get['status']]; } if ($get['status'] == 0) { $params['where'][] = ['=', 'b.status', $get['status']]; } if (!empty($get['keyword'])) { $params['where'] = [[ 'or', ['like', 'nickname', $get['keyword']], ['like', 'mobile', $get['keyword']] ]]; } if (!empty($get['user_id'])) { $params['where'][] = ['=', 'user_id', $get['user_id']]; } if (!empty($get['withdraw_type'])) { $params['where'][] = ['=', 'b.type', $get['withdraw_type']]; } if (!empty($get['withdraw_from'])) { $params['where'][] = ['=', 'b.from', $get['withdraw_from']]; } if (!empty($get['start_date']) && !empty($get['end_date'])) { $get['start_date'] = str_replace('+', ' ', $get['start_date']); $get['end_date'] = str_replace('+', ' ', $get['end_date']); $params['where'][] = ['>=', 'b.created_at', strtotime($get['start_date'])]; $params['where'][] = ['<=', 'b.created_at', strtotime($get['end_date'])]; } $params['where'][] = ['=', 'b.mall_id', $mall_id]; $params['order'] = ['status' => SORT_ASC, 'updated_at' => SORT_DESC]; $params['limit'] = 10; $list = self::listPage($params, false, false); $newList = []; foreach ($list['list'] as $item) { $serviceCharge = $item->poundage_num; $fact_price = $item->actual_num; $extra = $item->extra ? json_decode($item->extra, true) : []; if (!empty($extra)) $extra['bank_account'] = (string)$extra['bank_account']; if ($item->type == 'paid' || $item->type == 'joinpay') { //汇聚代付 $pay_log = PaidSinglePayLog::getOne([['mall_id' => $item->mall_id, 'order_no' => $item->order_no]]); if ($pay_log) { if ($pay_log->status == PaidSinglePayLog::STATUS_SUCCESS) { $joinpay_msg = '打款成功'; } else { $joinpay_msg = $pay_log->error_msg ?: '打款中'; } } } $total_num = bcsub($item->num,$serviceCharge,2); $now_price = bcdiv($fact_price,$total_num,2); $newItem = [ 'id' => $item->id, 'from' => $item->from, 'order_no' => $item->order_no, 'type' => $item->type, 'status' => $item->status, 'extra' => $extra, 'created_at' => $item->created_at, 'updated_at' => $item->updated_at, 'content' => $item->content ? Json::decode($item->content) : [], 'user' => [ 'avatar' => isset($item->user->avatar_url) ? $item->user->avatar_url : '', 'nickname' => isset($item->user->nickname) ? $item->user->nickname : '', 'id' => isset($item->user->id) ? $item->user->id : '', 'mobile' => isset($item->user->mobile) ? $item->user->mobile : '', ], 'cash' => [ 'price' => round($item->num, 2), 'service_fee_rate' => bcadd($serviceCharge,0,2), 'fact_price' => bcadd($fact_price,0,2), 'now_price' => $now_price ], 'joinpay_msg' => $joinpay_msg ]; $newList[] = $newItem; } $export_list = self::fieldsList(); return [ 'code' => 0, 'data' => [ 'list' => $newList, 'export_list' => $export_list, 'pagination' => $list['pagination'], ] ]; } /** * @throws Exception */ public function updateLog(): bool { $where = [['id' => $this->id]]; $cash = self::getOne($where); if (!$cash) { throw new \Exception('提现记录不存在'); } if ($cash->status == 2) { throw new \Exception('提现已打款'); } if ($cash->status == 3) { throw new \Exception('提现已被驳回'); } if ($this->status <= $cash->status) { throw new \Exception('状态错误, 请刷新重试'); } $lock_key = RedisKeyEnum::suffix(RedisKeyEnum::LOCK_USER_CASH, $cash->user_id); $identification = uniqid(); if (!LockHelper::lock($lock_key, $identification, 100, 100)) { \Yii::error('cashForm 获取锁(' . $lock_key . ')失败阻塞,提现打款:cash,操作:save,金额:' . $cash->actual_num); return false; } $t = \Yii::$app->db->beginTransaction(); try { switch ($this->status) { case 1: $this->validateCash($cash); break; case 2: $this->remit($cash); break; case 3: $this->reject($cash); break; default: throw new \Exception('错误的提现类型'); } $t->commit(); LockHelper::uLock($lock_key, $identification); } catch (\Exception $exception) { $t->rollBack(); LockHelper::uLock($lock_key, $identification); \Yii::error("finance cashForm error=" . $exception->getFile() . ";line:" . $exception->getLine() . ";message:" . $exception->getMessage()); throw new \Exception($exception->getMessage()); } return true; } /** * 申请 * @param $cash * @return bool * @throws Exception */ private function validateCash($cash): bool { if (!$cash->content) { $content = []; } else { $content = Json::decode($cash->content); } $cash->status = 1; $content['validate_content'] = $this->content ?: '审核通过'; $cash->content = Json::encode($content); if (!$cash->save()) { throw new \Exception('失败'); } return true; } /** * @Author: 广东七件事 ganxiaohao * @Date: 2020-05-30 * @Time: 11:22 * @Note:拒绝 * @param $cash * @return void * @throws \Exception */ private function reject($cash): void { if (!$this->content) { throw new \Exception('请填写备注'); } if (!$cash->content) { $content = []; } else { $content = Json::decode($cash->content); } $cash->status = 3; $content['reject_content'] = $this->content; $cash->content = Json::encode($content); if (!$cash->save()) { throw new \Exception('失败'); } $wallet_type = HiGoEnum::WALLET_TYPE_HI_BEI; $basic = HiGoEnum::getHigoWalletText($cash->mall_id); $hi_bei_name = $basic[HiGoEnum::WALLET_TYPE_HI_BEI]; $desc = $hi_bei_name."提现申请被驳回,驳回原因:" . $this->content ?? ''; $wallet_log = [ 'mall_id' => $cash->mall_id, 'user_id' => $cash->user_id, 'change_num' => abs($cash->num), 'desc' => $desc, 'source_table' => self::tableName(), 'source_table_id' => $cash->id, 'from_type' => HiGoEnum::FROM_TYPE_WITHDRAW_REFUSE_HI_BEI, 'wallet_type' => $wallet_type, 'is_send' => false ]; $result = WalletLogic::handleInQueue($wallet_log); if ($result === false) { throw new Exception('系统繁忙,请稍后再试'); } } public function getUser(): \yii\db\ActiveQuery { return $this->hasOne(User::class, ['id' => 'user_id']); } /** * @throws Exception */ private function remit($cash): void { $res = false; if ($cash->type === 'auto') { //todo 待测试联调 /** * @var UserInfo $userInfo ; */ $userInfo = UserInfo::getOne([["user_id" => $cash->user_id, "platform" => [User::PLATFORM_WECHAT, User::PLATFORM_MP_WX], "status" => StatusEnum::ENABLED]]); if (empty($userInfo)) { throw new \Exception('该用户不存在微信相关信息!'); } // $wechatPaySetting = OptionLogic::get(Option::NAME_PAYMENT, \Yii::$app->mall->id, Option::GROUP_APP); // if (!$wechatPaySetting) { // throw new \Exception('系统未开启微信支付!'); // } // if (!$wechatPaySetting['wechat_status']) { // throw new \Exception('系统未开启微信支付!'); // } try { $payment = new PayService(); $paymentTransfer = new PaymentTransfer(); $paymentTransfer->orderNo = PaymentTransfer::generate_order_no("TR"); $paymentTransfer->user = $userInfo; $paymentTransfer->title = "收益提现"; $paymentTransfer->amount = $cash->actual_num; $paymentTransfer->transferType = PayTypeEnum::WECHAT; // $paymentTransfer->transferType = PaymentTransfer::TRANSFER_TYPE_WECHAT; $paymentTransfer->cashInfo = $cash; $res = $payment->transfer($paymentTransfer); } catch (Exception $e) { throw new \Exception($e->getMessage()); } } else if ($cash->type === 'balance') { $userInfo = User::getOne([['id' => $cash->user_id, 'status' => StatusEnum::ENABLED]]); if (!$userInfo) { throw new \Exception('该用户不存在!'); } $desc = "用户收益提现到余额:" . $cash->actual_num . "元"; $data = [ 'message_id' => 0, 'mall_id' => $cash->mall_id, 'user_id' => $cash->user_id, 'wallet_type' => UserWalletService::WALLET_TYPE_BALANCE, 'is_frozen' => false, 'unfrozen' => false, 'money' => abs($cash->actual_num), 'desc' => $desc, 'source_table' => AssetsType::CASH_OUT, 'source_table_id' => $cash->id, 'from_type' => UserWalletEnum::RECHARGE, 'capital_type' => UserWalletEnum::RECHARGE_COMMISSION, ]; $res = UserWalletService::handle(0, $data); //免审核,免打款 $withdraw_config = \Yii::$app->services->setting->mall->get($cash->mall_id, 'withdraw_income'); if (isset($withdraw_config['is_examine']) && $withdraw_config['is_examine']) { $cash->content = Json::encode(['validate_content' => '提现免审核,免打款']); } } elseif ($cash->type === 'paid' || $cash->type === 'joinpay') { //代付 $res = GlobalInvoke::exec(GlobalInvoke::INVOKE_WITHDRAW_EXTENSION_PAY, $cash->mall_id, ['cash' => $cash]); if ($res) { // 提交成功 self::remit_wait($cash, "提交成功"); return; } else { // 提交失败 $msg = '代付打款失败'; throw new \Exception($msg); } } else if ($cash->type == 'alipay' || $cash->type == 'wechat' || $cash->type == 'bank' || $cash->type == 'third_party_address') { //线下转账 $res = true; } if ($res) { self::remit_success($cash); } else { $msg = '打款失败'; throw new \Exception($msg); } } /** * 明确打款成功 * * @param HigoWithdrawLog $cash * @param string $msg * @return void */ public static function remit_success(HigoWithdrawLog $cash, $msg = '打款成功') { // 保存提现信息 if ($cash->content) { $content = Json::decode($cash->content); } else { $content = []; } $cash->status = 2; $content['remit_at'] = date('Y-m-d H:i:s', time()); $content['remit_content'] = $msg; $cash->content = Json::encode($content); if (!$cash->save()) { throw new \Exception(); } return true; } /** * 打款失败,变成已同意状态,让客户自己去驳回 * * @param HigoWithdrawLog $cash * @param string $msg * @return void */ public static function remit_fail(HigoWithdrawLog $cash, $msg) { $content = empty($cash->content) ? [] : Json::decode($cash->content); $content['remit_content'] = $msg; $res = HigoWithdrawLog::updateAll([ 'status' => 1, 'content' => Json::encode($content), 'updated_at' => time() ], ['id' => $cash->id]); } /** * 打款中 * * @param [type] $cash * @param [type] $msg * @return void */ public static function remit_wait(HigoWithdrawLog $cash, $msg) { $content = empty($cash['content']) ? [] : Json::decode($cash['content']); $content['remit_content'] = $msg; $res = self::updateAll(['content' => Json::encode($content), 'status' => 5], ['id' => $cash['id']]); } public static function exportHandle(array $data) { $download_id = $data['download_id'] ?? 0; $download = Download::findOne(['id' => $download_id]); if ($download) { try { $params = json_decode($download->params, true); $filename = $download->name; $type = $download->type; $user_withdrawlog_model = HigoWithdrawLog::find(); $user_withdrawlog_model->where(['mall_id' => $params['mall_id']]); if (!empty($params['keyword'])) { $user = User::find()->where([ 'OR', ['like', 'nickname', $params['keyword'] . '%', false], ['like', 'mobile', $params['keyword'] . '%', false], ])->all(); $where[] = ['in', 'user_id', array_column($user, 'id')]; $user_withdrawlog_model->andWhere(['in', 'user_id', array_column($user, 'id')]); } if (!empty($params['user_id'])) $user_withdrawlog_model->andWhere(['=', 'user_id', $params['user_id']]); if (!empty($params['type'])) $user_withdrawlog_model->andWhere(['=', 'type', $params['withdraw_type']]); if (!empty($params['withdraw_from'])) $user_withdrawlog_model->andWhere(['=', 'from', $params['withdraw_from']]); if (!empty($params['start_date'])) $user_withdrawlog_model->andWhere(['>=', 'created_at', strtotime($params['start_date'])]); if (!empty($params['end_date'])) $user_withdrawlog_model->andWhere(['<=', 'created_at', strtotime($params['end_date'])]); if (isset($params['status'])) { $user_withdrawlog_model->andWhere(['=', 'status', $params['status']]); } else { $user_withdrawlog_model->andWhere(['>=', 'status', StatusEnum::DISABLED]); } $fields = $params['fields']; $fields_arr = self::fieldsList(); $have_select_field_arr = []; foreach ($fields as $value) { $have_select_field_arr[] = $fields_arr[$value]; } $csv = new CsvTool(); $csv->filename = $filename; $csv->file_dirname = DownloadEnum::getTypeStorageDirMap($type); $csv->export_mode = CsvTool::EXPORT_MODE_ASYNC; $csv->header = $have_select_field_arr; $user_withdrawlog_model->with(['user' => function ($query) { $query->select('id,nickname,username,avatar_url,mobile'); }]); $user_withdrawlog_model->orderBy('status asc,created_at desc'); foreach ($user_withdrawlog_model->batch() as $withdrawlog) { $csv->data = array_map(function ($withdrawlog) use ($fields) { $row = []; $extra = json_decode($withdrawlog['extra'], true) ?: []; foreach ($fields as $field) { switch (true) { case (in_array($field, ['updated_at'])): $row[] = !empty($withdrawlog[$field]) ? date('Y-m-d H:i:s', $withdrawlog[$field]) : ''; break; case ($field == 'username'): $row[] = $withdrawlog['user']['username'] ?: ''; break; case ($field == 'nickname'): $row[] = $withdrawlog['user']['nickname'] ?: ''; break; case ($field == 'user_mobile'): $row[] = $withdrawlog['user']['mobile'] ?: ''; break; case ($field == 'from'): $row[] = $withdrawlog[$field] == 1 ? '佣金收益提现' : '余额提现'; break; case ($field == 'alipay_name'): $row[] = $extra['name'] ?: ''; break; case ($field == 'mobile'): $row[] = empty($extra['mobile']) ? '' : $extra['mobile'] . "\t"; break; case ($field == 'bank_account_type'): $row[] = $extra['bank_account_type'] == 1 ? '对私账户' : ($extra['bank_account_type'] == 2 ? '对公账号' : ''); break; case ($field == 'name'): $row[] = $extra['name'] ?: ''; break; case ($field == 'bank_name'): $row[] = $extra['bank_name'] ?: ''; break; case ($field == 'bank_account'): $row[] = empty($extra['bank_account']) ? '' : $extra['bank_account'] . "\t"; break; case ($field == 'wechat_qrcode'): $row[] = $extra['wechat_qrcode'] ?: ''; break; case ($field == 'third_party_address'): $row[] = $extra['third_party_address'] ?: ''; break; case ($field == 'status'): $str = ''; switch ($withdrawlog[$field]) { case 0: $str = '待审核'; break; case 1: $str = '待打款'; break; case 2: $str = '已打款'; break; case 5: $str = '打款中'; break; case 3: $str = '已驳回'; break; } $row[] = $str; break; case ($field == 'remark'): $withdrawlog['content'] = json_decode($withdrawlog['content'], true); $str = ''; if (!empty($withdrawlog['content']['reject_content'])) $str .= '驳回备注:' . $withdrawlog['content']['reject_content']; if (!empty($withdrawlog['content']['validate_content']) && in_array($withdrawlog['status'], [1, 2])) $str .= ';审核备注:' . $withdrawlog['content']['validate_content']; if (!empty($withdrawlog['content']['remit_content']) && in_array($withdrawlog['status'], [1, 2])) $str .= ';打款备注:' . $withdrawlog['content']['remit_content']; if (!empty($withdrawlog['content']['joinpay_msg'])) $str .= ';汇聚备注:' . $withdrawlog['content']['joinpay_msg']; $row[] = $str; break; default: $row[] = !empty($withdrawlog[$field]) ? $withdrawlog[$field] : ''; } } return $row; }, $withdrawlog); $csv->export(); } $csv->updateDown($download, $params['mall_id']); return true; } catch (\Exception $e) { $download->status = 3; $res = $download->save(); self::setStaticError($e->getMessage()); return $e->getMessage(); } } } }