|
@@ -15,25 +15,10 @@ class Money extends Api
|
|
|
|
|
|
//配置
|
|
|
public function withdraw_config(){
|
|
|
- //部分提现,直推返佣+下单收益
|
|
|
- $map1 = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'log_type' => 3,
|
|
|
- 'withdraw_id' => 0,
|
|
|
- ];
|
|
|
- $zhitui = Db::name('user_score_log')->where($map1)->sum('change_value');
|
|
|
-
|
|
|
- $map2 = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'log_type' => 5,
|
|
|
- 'withdraw_id' => 0,
|
|
|
- ];
|
|
|
- $shouyi = Db::name('user_score_log')->where($map2)->sum('shouyi');
|
|
|
-
|
|
|
|
|
|
$data = [
|
|
|
'score' => model('wallet')->getWallet($this->auth->id,'score'),
|
|
|
- 'score_bufen' => bcadd($zhitui,$shouyi),
|
|
|
+ 'score_bufen' => model('wallet')->getWallet($this->auth->id,'shouyi'),
|
|
|
'min_withdrawal_money' => config('site.min_withdrawal_money'),
|
|
|
'max_withdrawal_money' => config('site.max_withdrawal_money'),
|
|
|
'type_1' => Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('type',1)->where('status',1)->field('realname,banknumber,bankname')->find(),
|
|
@@ -61,36 +46,18 @@ class Money extends Api
|
|
|
$this->error('目前还有兑换在审核中,请稍后在兑换');
|
|
|
}
|
|
|
|
|
|
+ //开启事务
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
//余额查询
|
|
|
if($from == 'all'){
|
|
|
$user_money = model('wallet')->getWallet($this->auth->id,'score');
|
|
|
}else{
|
|
|
-
|
|
|
- //部分提现,直推返佣+下单收益
|
|
|
- $map1 = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'log_type' => 3,
|
|
|
- 'withdraw_id' => 0,
|
|
|
- ];
|
|
|
- $zhitui = Db::name('user_score_log')->where($map1)->sum('change_value');
|
|
|
-
|
|
|
- $map2 = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'log_type' => 5,
|
|
|
- 'withdraw_id' => 0,
|
|
|
- ];
|
|
|
- $shouyi = Db::name('user_score_log')->where($map2)->sum('shouyi');
|
|
|
-
|
|
|
- $user_money = bcadd($zhitui,$shouyi);
|
|
|
-
|
|
|
- //记录id,等会修改状态
|
|
|
- $user_score_log_ids_1 = Db::name('user_score_log')->where($map1)->column('id');
|
|
|
- $user_score_log_ids_2 = Db::name('user_score_log')->where($map2)->column('id');
|
|
|
-
|
|
|
- $user_score_log_ids = array_merge($user_score_log_ids_1,$user_score_log_ids_2);
|
|
|
+ $user_money = model('wallet')->getWallet($this->auth->id,'shouyi');
|
|
|
}
|
|
|
|
|
|
if ($user_money <= 0) {
|
|
|
+ Db::rollback();
|
|
|
$this->error('积分不足');
|
|
|
}
|
|
|
|
|
@@ -107,8 +74,7 @@ class Money extends Api
|
|
|
$data['from'] = ($from == 'all') ? 1 : 2; //all=1,bufen=2
|
|
|
|
|
|
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
+
|
|
|
//添加提现记录
|
|
|
$log_id = Db::name('user_withdraw')->insertGetId($data);
|
|
|
if (!$log_id) {
|
|
@@ -116,12 +82,12 @@ class Money extends Api
|
|
|
$this->error('申请兑换失败');
|
|
|
}
|
|
|
|
|
|
- //积分日志改状态
|
|
|
+ //扣收益
|
|
|
if($from == 'bufen'){
|
|
|
- $rs_bufen = Db::name('user_score_log')->where('id','IN',$user_score_log_ids)->update(['withdraw_id'=>$log_id]);
|
|
|
- if ($rs_bufen === false) {
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'shouyi',-$data['score'],2,'积分兑换','user_withdraw',$log_id);
|
|
|
+ if ($rs_wallet['status'] == false) {
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
Db::rollback();
|
|
|
- $this->error('申请兑换失败');
|
|
|
}
|
|
|
}
|
|
|
|