|
|
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\model\Config;
|
|
|
use app\common\model\MoneyIn;
|
|
|
+use app\common\model\MoneyOut;
|
|
|
use app\common\model\Order AS OrderModel;
|
|
|
use app\common\model\User AS UserModel;
|
|
|
use think\Db;
|
|
|
@@ -29,7 +30,7 @@ class Money extends Api
|
|
|
|
|
|
$data['amount_list'] = [100,200,500,1000,5000,10000];//快捷输入额度
|
|
|
$data['usdt'] = $data['bank'] = 1;
|
|
|
- $recharge_info = UserModel::getAgentInfoByAgentId($user['agent_id']);
|
|
|
+ $recharge_info = UserModel::getAgentRechargeInfoByAgentId($user['agent_id']);
|
|
|
if(empty($recharge_info)){
|
|
|
$this->error(__('无充值信息'));
|
|
|
}
|
|
|
@@ -60,7 +61,7 @@ class Money extends Api
|
|
|
|
|
|
$user = $this->auth->getUser();
|
|
|
|
|
|
- $recharge_info = UserModel::getAgentInfoByAgentId($user['agent_id']);
|
|
|
+ $recharge_info = UserModel::getAgentRechargeInfoByAgentId($user['agent_id']);
|
|
|
if(empty($recharge_info)){
|
|
|
$this->error(__('无充值信息'));
|
|
|
}
|
|
|
@@ -69,7 +70,7 @@ class Money extends Api
|
|
|
'order_type' => $recharge_type,
|
|
|
'user_id' => $user['id'],
|
|
|
'amount' => $amount,
|
|
|
- 'status' => 0,
|
|
|
+ 'status' => MoneyIn::Default,
|
|
|
'agent_id' => $recharge_info['agent_id']
|
|
|
];
|
|
|
|
|
|
@@ -140,16 +141,11 @@ class Money extends Api
|
|
|
$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)
|
|
|
@@ -158,7 +154,14 @@ class Money extends Api
|
|
|
$this->error(__('参数有误'));
|
|
|
}
|
|
|
|
|
|
- if ($order_info['status'] != 0) {
|
|
|
+ //上传图片
|
|
|
+ $file_info = ali_oss_upload($this->request, 'recharge', $order_no);
|
|
|
+ if($file_info['code'] == 0){
|
|
|
+ $this->error($file_info['msg']);
|
|
|
+ }
|
|
|
+ $img_url = $file_info['data']['full_url'];
|
|
|
+
|
|
|
+ if ($order_info['status'] != MoneyIn::Default) {
|
|
|
if (empty($order_info['img_url'])) {
|
|
|
(new MoneyIn())
|
|
|
->where('order_no', $order_no)
|
|
|
@@ -173,7 +176,7 @@ class Money extends Api
|
|
|
->where('order_no', $order_no)
|
|
|
->update([
|
|
|
'img_url' => $img_url,
|
|
|
- 'status' => 1,
|
|
|
+ 'status' => MoneyIn::Pending,
|
|
|
]);
|
|
|
$this->success(__('提交成功'));
|
|
|
}
|
|
|
@@ -186,18 +189,14 @@ class Money extends Api
|
|
|
{
|
|
|
$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;
|
|
|
+ $data['balance'] = $user['balance'];
|
|
|
+ $data['money_out_sum'] = MoneyOut::where('user_id', $user['id'])->where('status', MoneyOut::Success)->sum('amount');
|
|
|
+
|
|
|
+ $withdraw_info = UserModel::getAgentWithdrawInfoByAgentId($user['agent_id']);
|
|
|
+ if(empty($withdraw_info)){
|
|
|
+ $this->error(__('无提现信息'));
|
|
|
}
|
|
|
+ $data = array_merge($data, $withdraw_info);
|
|
|
|
|
|
$this->success('', $data);
|
|
|
}
|