|
@@ -130,8 +130,9 @@ class Noble extends Api
|
|
|
$where = [];
|
|
|
$where["id"] = $this->auth->id;
|
|
|
$userInfo = $userModel->where($where)->find();
|
|
|
+ $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
|
|
|
// 判断用户余额
|
|
|
- if($userInfo["jewel"]-$money < 0) {
|
|
|
+ if($userwallet["jewel"]-$money < 0) {
|
|
|
$this->error("您的钻石余额不足,请先充值");
|
|
|
}
|
|
|
|
|
@@ -155,14 +156,21 @@ class Noble extends Api
|
|
|
$data = [];
|
|
|
$data["noble"] = $level_id;
|
|
|
$data["noble_duetime"] = $duetime;
|
|
|
- $submoney = bcsub($userInfo["jewel"],$money);
|
|
|
// 开通返现
|
|
|
$return = $nldlCount>0?$noblelevelInfo["give"]:$noblelevelInfo["firstgive"];
|
|
|
- $data["jewel"] = bcadd($submoney,$return);
|
|
|
|
|
|
$res1 = $userModel->update($data,$where);
|
|
|
// 添加当前用户钻石流水记录
|
|
|
- $res2 = $userjewellogModel->addUserJewelLog($this->auth->id, $money, "-", $userInfo["jewel"], "开通贵族:'" . $noblelevelInfo["name"] . "',扣除" . $money . "钻石!", 5);
|
|
|
+ $res2 = true;
|
|
|
+
|
|
|
+ //扣除用户钻石余额
|
|
|
+ if($money > 0){
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $money, "-", 0, "开通贵族:'" . $noblelevelInfo["name"] . "',扣除" . $money . "钻石!", 5,'jewel');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 添加贵族等级开通明细
|
|
|
$data = [];
|
|
@@ -173,7 +181,14 @@ class Noble extends Api
|
|
|
$res3 = $nldlModel->insertGetId($data);
|
|
|
|
|
|
// 添加当前用户钻石流水记录
|
|
|
- $res4 = $userjewellogModel->addUserJewelLog($this->auth->id, $return, "+", $userInfo["jewel"] - $money, "开通贵族:'" . $noblelevelInfo["name"] . "',赠送" . $return . "钻石!", 15);
|
|
|
+ $res4 = true;
|
|
|
+ if($return > 0){
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $return, "+", 0, "开通贵族:'" . $noblelevelInfo["name"] . "',赠送" . $return . "钻石!", 15,'jewel');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if($res1 && $res2 && $res3 && $res4) {
|