first(); if ($param['mold'] == 1) { if (empty($system->is_money)) { throw new \Exception('提现功能暂未开放!'); } if ($system->min_money > $param['money']) { throw new \Exception('最小提现金额:' . $system->min_money . '元'); } } elseif ($param['mold'] == 2) { if (empty($system->is_money_one)) { throw new \Exception('提现功能暂未开放!'); } if ($system->min_money_one > $param['money']) { throw new \Exception('最小提现金额:' . $system->min_money_one . '元'); } } elseif ($param['mold'] == 5) { if (empty($system->is_money_five)) { throw new \Exception('提现功能暂未开放!'); } if ($system->min_money_five > $param['money']) { throw new \Exception('最小提现金额:' . $system->min_money_five . '元'); } } else { throw new \Exception('提现功能暂未开放!'); } /** @var $bankCard 银行卡 */ $bankCard = Db::table('wa_bank_card')->where('uid', $param['user_data']['id'])->first(); if (empty($bankCard)) { throw new \Exception('请绑定银行卡!'); } /** @var $userIdentity 实名信息 */ $userIdentity = Db::table('wa_user_identity')->where('uid', $param['user_data']['id'])->first(); if (empty($userIdentity)) { throw new \Exception('请实名后,在提现!'); } if ($param['mold'] == 1) { $hasWithdraw = Db::table('wa_withdraw') ->where('type', $param['mold']) ->where('binding_type', $param['binding_type']) ->where('user_id', $param['user_data']['id']) ->whereBetween('created_at', [date('Y-m-d') . ' 00:00:00', date('Y-m-d') . ' 23:59:59'])->exists(); if ($hasWithdraw) { throw new \Exception('今日已提现,请次日在来提现!'); } }else{ $hasWithdraw = Db::table('wa_withdraw')->where('type', $param['mold'])->where('user_id', $param['user_data']['id']) ->whereBetween('created_at', [date('Y-m-d') . ' 00:00:00', date('Y-m-d') . ' 23:59:59'])->exists(); if ($hasWithdraw) { throw new \Exception('今日已提现,请次日在来提现!'); } } $withdrawId = Db::table('wa_withdraw')->insertGetId([ 'order_no' => date('YmdHis') . mt_rand(10000, 99999), 'user_id' => $param['user_data']['id'], 'money' => $param['money'], 'type' => $param['mold'], 'affiliated_bank' => $bankCard->affiliated_bank, 'account_holder' => $bankCard->account_holder, 'card_number' => $bankCard->card_number, 'name' => Arr::get($param, 'name', ''), 'identity' => Arr::get($param, 'identity', ''), 'binding_type' => Arr::get($param, 'binding_type', 0), 'img' => !empty(Arr::get($param, 'img', '')) ? implode(',', Arr::get($param, 'img', '')) : '', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'), ]); StreamBusiness::delStream($param['user_data']['id'], $param['money'], streamType4, $param['mold'], moldTypefild($param['mold']), $withdrawId); } catch (\Throwable $exception) { throw new \Exception($exception->getMessage()); } return true; } /** 提现流水 * @param array $param * @return void */ static public function stream(array $param) { try { $data = Db::table('wa_withdraw') ->where(function ($query) use ($param) { if (!empty(Arr::get($param, 'mold'))) { $query->where('type', $param['mold']); } if (!empty(Arr::get($param, 'type'))) { if($param['type']==1){ $query->where('type', 1); }elseif ($param['type']==2){ $query->where('type', 1); $query->where('binding_type', 1); }elseif ($param['type']==3){ $query->where('type', 1); $query->where('binding_type', 2); }elseif ($param['type']==4){ $query->whereIn('type', [2,5]); } } }) ->where('user_id', $param['user_data']['id']) ->orderByDesc('id') ->paginate(Arr::get($param, 'limit', 10), ['*'], 'page', Arr::get($param, 'page')) ->toArray(); foreach ($data['data'] as $k => $v) { $data['data'][$k]->mold_name = moldType($v->type); } } catch (\Throwable $exception) { throw new \Exception($exception->getMessage()); } return $data; } /** 转账至五行银行卡 * @param array $param * @return void */ static public function transfer_accounts(array $param) { try { $system = Db::table('wa_system')->first(); if ($param['mold'] != 2) { throw new \Exception('转账至五行银行卡暂未开放!'); } $param['mold'] = 5; /** @var $bankCard 银行卡 */ $bankCard = Db::table('wa_user_social_cark')->where('user_id', $param['user_data']['id'])->first(); if (empty($bankCard)) { throw new \Exception('请先领取五行银行卡!'); } /** @var $userIdentity 实名信息 */ $userIdentity = Db::table('wa_user_identity')->where('uid', $param['user_data']['id'])->first(); if (empty($userIdentity)) { throw new \Exception('请实名后,在转入!'); } if (empty($system->conversion_value_cost)) { throw new \Exception('暂时不能转入!'); } //五行银行卡余额变更 $money = bcmul($param['money'], $system->conversion_value_cost, 2); Db::table('wa_user_social_cark')->where('user_id', $param['user_data']['id'])->increment('money', $money); //转账到五行银行卡余额 StreamBusiness::addStream($param['user_data']['id'], $money, streamType14, moldType4, moldTypefild4); //减少股票账户 StreamBusiness::delStream($param['user_data']['id'], $param['money'], streamType14, $param['mold'], moldTypefild($param['mold']), $param['user_data']['id']); } catch (\Throwable $exception) { throw new \Exception($exception->getMessage()); } return true; } }