|
@@ -15,8 +15,17 @@ class Money extends Api
|
|
|
|
|
|
//配置
|
|
|
public function withdraw_config(){
|
|
|
+ //部分提现,下单收益+直推返佣
|
|
|
+ $map = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'log_type' => ['IN',[3,5]],
|
|
|
+ 'withdraw_id' => 0,
|
|
|
+ ];
|
|
|
+ $score = Db::name('user_score_log')->where($map)->sum('change_value');
|
|
|
+
|
|
|
$data = [
|
|
|
'score' => model('wallet')->getWallet($this->auth->id,'score'),
|
|
|
+ 'score_bufen' => $score,
|
|
|
'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(),
|
|
@@ -91,6 +100,70 @@ class Money extends Api
|
|
|
Db::commit();
|
|
|
$this->success('申请兑换成功,请等待审核');
|
|
|
}
|
|
|
+ //废弃的提现
|
|
|
+ public function old_scorewithdraw() {
|
|
|
+ $type = input('type', 0, 'intval'); //类型:1=支付宝,2=微信,3=银行
|
|
|
+ /*$money = input('score', '', 'intval');
|
|
|
+
|
|
|
+ if ($money <= 0) {
|
|
|
+ $this->error('请输入正确兑换积分');
|
|
|
+ }*/
|
|
|
+
|
|
|
+ $check = Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('status',0)->find();
|
|
|
+ if($check){
|
|
|
+ $this->error('目前还有兑换在审核中,请稍后在兑换');
|
|
|
+ }
|
|
|
+
|
|
|
+ //余额查询
|
|
|
+ $user_money = model('wallet')->getWallet($this->auth->id,'score');
|
|
|
+ /*if ($user_money < $money) {
|
|
|
+ $this->error('余额不足');
|
|
|
+ }*/
|
|
|
+ if ($user_money <= 0) {
|
|
|
+ $this->error('积分不足');
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询最低最高提现金额
|
|
|
+ /*$min_withdrawal_money = config('site.min_withdrawal_money') ? config('site.min_withdrawal_money') : 1;
|
|
|
+ $max_withdrawal_money = config('site.max_withdrawal_money') ? config('site.max_withdrawal_money') : 50000;
|
|
|
+ if ($money < $min_withdrawal_money) {
|
|
|
+ $this->error('最低提现金额' . $min_withdrawal_money . '元');
|
|
|
+ }
|
|
|
+ if ($money > $max_withdrawal_money) {
|
|
|
+ $this->error('最高提现金额' . $max_withdrawal_money . '元');
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ $data['order_no'] = createUniqueNo('T',$this->auth->id);
|
|
|
+ $data['user_id'] = $this->auth->id;
|
|
|
+// $data['score'] = $money;
|
|
|
+ $data['score'] = $user_money;
|
|
|
+ $data['type'] = $type;
|
|
|
+ $data['realname'] = input('realname','');
|
|
|
+ $data['banknumber'] = input('banknumber','');
|
|
|
+ $data['bankname'] = input('bankname','');
|
|
|
+ $data['createtime'] = time();
|
|
|
+ $data['status'] = 0;
|
|
|
+
|
|
|
+
|
|
|
+ //开启事务
|
|
|
+ Db::startTrans();
|
|
|
+ //添加提现记录
|
|
|
+ $log_id = Db::name('user_withdraw')->insertGetId($data);
|
|
|
+ if (!$log_id) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('申请兑换失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'score',-$data['score'],2,'积分兑换','user_withdraw',$log_id);
|
|
|
+ if ($rs_wallet['status'] == false) {
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ Db::rollback();
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ $this->success('申请兑换成功,请等待审核');
|
|
|
+ }
|
|
|
|
|
|
//用户钱包流水
|
|
|
public function scorelog(){
|