代理体现

This commit is contained in:
“wanyongkang”
2021-02-26 11:01:06 +08:00
parent ed2ec19338
commit 29ba2ddb52
3 changed files with 100 additions and 21 deletions

View File

@@ -7,6 +7,8 @@ use app\agent\model\AgentUser;
use app\agent\model\ProductUserPrice;
use app\agent\model\AgentPrice as AgentPriceModel;
use app\agent\model\User as UserModel;
use app\agent\model\AgentScore as AgentScoreModel;
use app\agent\model\CashOut as CashOutModel;
class Userinfo extends Controller
{
@@ -58,6 +60,46 @@ class Userinfo extends Controller
}
}
//提现
public function cashOut()
{
$post = json_decode(file_get_contents("php://input"), true);
$data = [];
$data['userid'] = $this->userinfo['OperaterID'];
$data['username'] = $this->userinfo['LoginName'];
$data['money'] = $post['cash_out_money'];
$data['apply_reason'] = $post['reason'];
$data['alipay_account'] = $post['alipay_account'];
$data['real_name'] = $post['real_name'];
$data['is_agent'] = 1;
$agent_user_model = new AgentUser;
$agent_info = $agent_user_model->getOne(['id'=>$data['userid']]);
$user_rest = $agent_info['account'];
$rest = $user_rest - $post['cash_out_money'];
if ($rest < 0){
echo json_encode(['Code'=>-10000,]);
die;
} else {
$agent_user_model->where(['id'=>$data['userid']])->update(['account'=>$rest]);
$cash = new CashOutModel;
$status = $cash->add($data);
$score_model = new AgentScoreModel;
$score['agent_id'] = $data['userid'];
$score['order_id'] = 0;
$score['score_type'] = 4;
$score['score_value'] = $data['money'];
$score['agent_name'] = $this->userinfo['LoginName'];
$score['op_user'] = $this->userinfo['LoginName'];
$score['rest_amount1'] = $agent_info['account'];
$score['rest_amount2'] = $rest;
$score['remark'] = '提现扣除';
$score_model->add($score);
}
echo json_encode(['Code'=>10000,]);
}
//验证是否是该代理的用户
public function verify()
{