钻石兑换金币
This commit is contained in:
@@ -58,7 +58,7 @@ class UserWallet extends BaseCom
|
||||
public function exchange_coin()
|
||||
{
|
||||
$key_name = 'exchange_coin_' . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
redis_lock_exit($key_name, 10, 10);
|
||||
$earnings_num = input('earnings_num', 0);
|
||||
//最少兑换钻石
|
||||
$min_earnings_num = get_system_config_value('min_earnings_num');
|
||||
|
||||
@@ -117,38 +117,44 @@ class UserWallet extends Model
|
||||
];
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
|
||||
$give_gift_id = db::name('user_exchange')->insertGetId($data);
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 2,//1金币2钻石
|
||||
'change_value' => $earnings_num,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 1,
|
||||
'change_value' => $earnings_num * $ear_exchange_coin,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$re = db::name('vs_user_money_log')->insertAll($account_log);
|
||||
$re1 = db::name('user_wallet')->where('user_id',$uid)->setDec('earnings',$earnings_num);
|
||||
$re2 = db::name('user_wallet')->where('user_id',$uid)->setInc('coin',$earnings_num * $ear_exchange_coin);
|
||||
if($re && $re1 && $re2){
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '兑换成功', 'data' => null];
|
||||
}else{
|
||||
try{
|
||||
$give_gift_id = db::name('user_exchange')->insertGetId($data);
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 2,//1金币2钻石
|
||||
'change_value' => $earnings_num,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 1,
|
||||
'change_value' => $earnings_num * $ear_exchange_coin,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$re = db::name('vs_user_money_log')->insertAll($account_log);
|
||||
$re1 = db::name('user_wallet')->where('user_id',$uid)->setDec('earnings',$earnings_num);
|
||||
$re2 = db::name('user_wallet')->where('user_id',$uid)->setInc('coin',$earnings_num * $ear_exchange_coin);
|
||||
if($re && $re1 && $re2){
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '兑换成功', 'data' => null];
|
||||
}else{
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '兑换失败', 'data' => null];
|
||||
}
|
||||
}catch (\Exception $e){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '兑换失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//转币
|
||||
|
||||
Reference in New Issue
Block a user