...
|
...
|
@@ -669,12 +669,42 @@ class Car extends Base |
|
|
/**
|
|
|
* 钱包金额
|
|
|
* @return void
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function mywallet(){
|
|
|
$res=Db::name("user")->where("id",$this->auth->id)->field("money")->find();
|
|
|
return $this->success("请求成功",$res);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提现接口
|
|
|
* @return void
|
|
|
*/
|
|
|
public function withdrawal(){
|
|
|
$money=$this->request->param("money");
|
|
|
$name=$this->request->param("name");
|
|
|
$bank_card=$this->request->param("bank_card");
|
|
|
$user_id=$this->auth->id;
|
|
|
$user=Db::name("user")->where("id",$user_id)->find();
|
|
|
if($user['money']<$money){
|
|
|
$this->error("金额不足");
|
|
|
}
|
|
|
//减少金额
|
|
|
$newmoney=bcsub($user['money'],$money,2);
|
|
|
$updatemoney=Db::name("user")->where("id",$user_id)->update(['money'=>$newmoney]);
|
|
|
if($updatemoney){
|
|
|
//添加提现记录
|
|
|
$data=[
|
|
|
"user_id"=>$user_id,
|
|
|
"bank_card"=>$bank_card,
|
|
|
"name"=>$name,
|
|
|
"create_time"=>time(),
|
|
|
"money"=>$money,
|
|
|
"newmoney"=>$newmoney,
|
|
|
];
|
|
|
$res=Db::name("withdrawal")->insert($data);
|
|
|
return $this->success("提现成功",$res);
|
|
|
}else{
|
|
|
return $this->error("提现失败");
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|