|
|
@@ -71,6 +71,7 @@ class Money extends Api
|
|
|
'user_id' => $user['id'],
|
|
|
'amount' => $amount,
|
|
|
'status' => MoneyIn::Default,
|
|
|
+ 'user_type' => $user['user_type'],
|
|
|
'agent_id' => $recharge_info['agent_id']
|
|
|
];
|
|
|
|
|
|
@@ -200,4 +201,129 @@ class Money extends Api
|
|
|
|
|
|
$this->success('', $data);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交提现信息
|
|
|
+ * @return void
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function withdraw_submit()
|
|
|
+ {
|
|
|
+ $type = $this->request->post('type');
|
|
|
+ $amount = $this->request->post('amount');
|
|
|
+ if(!in_array($type, [1,2])){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+ if(!($amount > 0)){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $user = $this->auth->getUser();
|
|
|
+ if($amount > $user['balance']){
|
|
|
+ $this->error(__('余额不足'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $withdraw_info = UserModel::getAgentWithdrawInfoByAgentId($user['agent_id']);
|
|
|
+ if(empty($withdraw_info)){
|
|
|
+ $this->error(__('无提现信息'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $insert_data = [
|
|
|
+ 'order_type' => $type,
|
|
|
+ 'user_id' => $user['id'],
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'status' => MoneyOut::Default,
|
|
|
+ 'agent_id' => $withdraw_info['agent_id'],
|
|
|
+ 'user_type' => $user['user_type'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ //USDT充值
|
|
|
+ if($type == 1){
|
|
|
+ if(empty($withdraw_info['usdt'])){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+ $usdt_address = $this->request->post('usdt');
|
|
|
+ if(empty($usdt_address)){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $insert_data['order_no'] = 'U' . time() . $user['id'];
|
|
|
+ $insert_data['usdt_address'] = $usdt_address;
|
|
|
+ }else{
|
|
|
+ if(empty($withdraw_info['bank'])){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+ $insert_data['bank_name'] = $this->request->post('bank_name');
|
|
|
+ $insert_data['bank_card'] = $this->request->post('bank_card');
|
|
|
+ $insert_data['account_name']= $this->request->post('account_name');
|
|
|
+ if(empty($insert_data['bank_name']) || empty($insert_data['bank_card']) || empty($insert_data['account_name'])){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+ $insert_data['order_no'] = 'B' . time() . $user['id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $fund_pwd = $this->request->post('fund_pwd');
|
|
|
+ if(empty($fund_pwd)){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+ if($user['fund_pwd'] != md5($fund_pwd)){
|
|
|
+ $this->error(__('资金密码有误'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //写入
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ (new MoneyOut())->save($insert_data);
|
|
|
+ Db::commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ $this->success('');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 充值提现列表
|
|
|
+ * @return void
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function money_list()
|
|
|
+ {
|
|
|
+ $type = $this->request->post('type');
|
|
|
+ if(empty($type)){
|
|
|
+ $type = 1;
|
|
|
+ }
|
|
|
+ if(!in_array($type, [1,2])){
|
|
|
+ $this->error(__('参数有误'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $user = $this->auth->getUser();
|
|
|
+ $res_data = [];
|
|
|
+
|
|
|
+ if($type == 1){
|
|
|
+ //充值列表
|
|
|
+ $info_list = MoneyIn::where('user_id', $user['id'])
|
|
|
+ ->field('order_no,order_type,amount,status,create_time')
|
|
|
+ ->order('id DESC')
|
|
|
+ ->paginate($this->pageSize);
|
|
|
+ foreach ($info_list as $k => $v) {
|
|
|
+ $info_list[$k]['status_name'] = (new MoneyIn())->getStatusNames($v['status']);
|
|
|
+ }
|
|
|
+ $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
|
|
|
+ }else{
|
|
|
+ //提现列表
|
|
|
+ $info_list = MoneyOut::where('user_id', $user['id'])
|
|
|
+ ->field('order_no,order_type,amount,status,create_time')
|
|
|
+ ->order('id DESC')
|
|
|
+ ->paginate($this->pageSize);
|
|
|
+ foreach ($info_list as $k => $v) {
|
|
|
+ $info_list[$k]['status_name'] = (new MoneyOut())->getStatusNames($v['status']);
|
|
|
+ }
|
|
|
+ $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $res_data['money_in_sum'] = MoneyIn::where('user_id', $user['id'])->where('status', MoneyIn::Success)->sum('amount');
|
|
|
+ $res_data['money_out_sum'] = MoneyOut::where('user_id', $user['id'])->where('status', MoneyOut::Success)->sum('amount');
|
|
|
+ $this->success('', $res_data);
|
|
|
+ }
|
|
|
}
|