|
@@ -845,7 +845,7 @@ class Money extends Common
|
|
|
$exchexsoundlogModel = new \app\common\model\UserExchsoundLog();
|
|
|
$detail = "声币兑换钻石";
|
|
|
// 添加钻石流水记录
|
|
|
- $res1 = $jewellogModel->addUserJewelLog($this->auth->id, $exchangeMoney, "+", $userInfo["jewel"], $detail, 4);
|
|
|
+// $res1 = $jewellogModel->addUserJewelLog($this->auth->id, $exchangeMoney, "+", $userInfo["jewel"], $detail, 4);
|
|
|
|
|
|
// 添加兑换记录
|
|
|
$res2 = $exchexsoundlogModel->addExchsoundLog($this->auth->id, $scoin, $exchangeMoney);
|
|
@@ -983,27 +983,34 @@ class Money extends Common
|
|
|
|
|
|
$userId = $this->auth->id;
|
|
|
// 查询余额
|
|
|
- $userModel = new \app\common\model\User();
|
|
|
- $userInfo = $userModel->lock('lock in share mode')->find($userId);
|
|
|
- if ($exchangeMoney > $userInfo["money"]) {
|
|
|
+ $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
|
|
|
+ if ($exchangeMoney > $userwallet["money"]) {
|
|
|
throw new Exception("余额不足!");
|
|
|
}
|
|
|
|
|
|
- $moneylogModel = new \app\common\model\UserMoneyLog();
|
|
|
- $jewellogModel = new \app\common\model\UserJewelLog();
|
|
|
- $exchangelogModel = new \app\common\model\UserExchangeLog();
|
|
|
- $detail = "余额兑换钻石";
|
|
|
- // 添加资金流水记录
|
|
|
- $res1 = $moneylogModel->addRecord($userId, $exchangeMoney, "-", $userInfo["money"], $detail,114);
|
|
|
+ //
|
|
|
+ $detail = '余额兑换钻石';
|
|
|
+
|
|
|
+ //减去用户余额
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,$exchangeMoney,'-',0,$detail,114,'money');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ Db::rollback();
|
|
|
+ }
|
|
|
+
|
|
|
+ //增加用户钻石余额
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $scoin, '+', 0, $detail, 14,'jewel');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ Db::rollback();
|
|
|
+ }
|
|
|
+
|
|
|
// 添加兑换记录
|
|
|
+ $exchangelogModel = new \app\common\model\UserExchangeLog();
|
|
|
$res2 = $exchangelogModel->addExchangeLog($userId, $scoin, $exchangeMoney);
|
|
|
- // 添加钻石流水记录
|
|
|
- $res3 = $jewellogModel->addUserJewelLog($userId, $scoin, "+", $userInfo["jewel"], $detail, 14);
|
|
|
- // 减去用户余额
|
|
|
- $res4 = $userModel->where(["id" => $userId])->setDec("money", $exchangeMoney);
|
|
|
- // 增加用户钻石余额
|
|
|
- $res5 = $userModel->where(["id" => $userId])->setInc("jewel", $scoin);
|
|
|
- if ($res1 && $res2 && $res3 && $res4 && $res5) {
|
|
|
+
|
|
|
+
|
|
|
+ if ($res2) {
|
|
|
Db::commit();
|
|
|
$this->success("兑换成功!");
|
|
|
} else {
|