auth->getUser(); $data['amount_list'] = [100,200,500,1000,5000,10000];//快捷输入额度 $data['usdt'] = $data['bank'] = 1; $recharge_info = UserModel::getAgentInfoByAgentId($user['agent_id']); if(empty($recharge_info)){ $this->error(__('无充值信息')); } if(empty($recharge_info['usdt'])){ $data['usdt'] = 0; } if(empty($recharge_info['bank'])){ $data['bank'] = 0; } $this->success('', $data); } /** * 创建充值订单 * @return void */ public function recharge_create() { $recharge_type = $this->request->post('type'); $amount = $this->request->post('amount'); if(!in_array($recharge_type, [1,2])){ $this->error(__('参数有误')); } if(!($amount > 0)){ $this->error(__('参数有误')); } $user = $this->auth->getUser(); $recharge_info = UserModel::getAgentInfoByAgentId($user['agent_id']); if(empty($recharge_info)){ $this->error(__('无充值信息')); } $insert_data = [ 'order_type' => $recharge_type, 'user_id' => $user['id'], 'amount' => $amount, 'status' => 0, 'agent_id' => $recharge_info['agent_id'] ]; //USDT充值 if($recharge_type == 1){ if(empty($recharge_info['usdt'])){ $this->error(__('参数有误')); } $insert_data['order_no'] = 'U' . time() . $user['id']; $insert_data['address'] = $recharge_info['usdt']; }else{ if(empty($recharge_info['bank'])){ $this->error(__('参数有误')); } $insert_data['order_no'] = 'B' . time() . $user['id']; $insert_data['bank_name'] = $recharge_info['bank']['bank_name']; $insert_data['bank_card'] = $recharge_info['bank']['bank_card']; $insert_data['account_name']= $recharge_info['bank']['account_name']; } //写入 Db::startTrans(); try { (new MoneyIn())->save($insert_data); Db::commit(); } catch (Exception $e) { $this->error($e->getMessage()); } $this->success('', $insert_data); } /** * 上传图片 * @return void * @throws \think\exception\DbException */ public function recharge_upload() { $user = $this->auth->getUser(); $order_no = $this->request->post('order_no'); if (empty($order_no)) { $this->error(__('参数有误')); } $order_info = (new MoneyIn()) ->where('user_id', $user['id']) ->where('order_no', $order_no) ->find(); if (empty($order_no)) { $this->error(__('参数有误')); } $file_info = ali_oss_upload($this->request, 'recharge', $order_no); if($file_info['code'] == 0){ $this->error($file_info['msg']); } $this->success('', $file_info['data']); } /** * 提交充值信息 * @return void * @throws \think\exception\DbException */ public function recharge_submit() { $user = $this->auth->getUser(); $order_no = $this->request->post('order_no'); $img_url = $this->request->post('img_url'); if (empty($order_no)) { $this->error(__('参数有误')); } if (empty($img_url)) { $this->error(__('参数有误')); } $order_info = (new MoneyIn()) ->where('user_id', $user['id']) ->where('order_no', $order_no) ->find(); if (empty($order_info)) { $this->error(__('参数有误')); } if ($order_info['status'] != 0) { if (empty($order_info['img_url'])) { (new MoneyIn()) ->where('order_no', $order_no) ->update([ 'img_url' => $img_url ]); } $this->success(__('提交成功')); } (new MoneyIn()) ->where('order_no', $order_no) ->update([ 'img_url' => $img_url, 'status' => 1, ]); $this->success(__('提交成功')); } /** * 提现 * @return void */ public function withdraw() { $user = $this->auth->getUser(); $data['balance'] = $user['balance']; $data['usdt'] = $data['bank'] = 1; $recharge_info = UserModel::getAgentInfoByAgentId($user['agent_id']); if(empty($recharge_info)){ $this->error(__('无充值信息')); } if(empty($recharge_info['usdt'])){ $data['usdt'] = 0; } if(empty($recharge_info['bank'])){ $data['bank'] = 0; } $this->success('', $data); } }