window.location.href='./login.php';"); $title='申请提现'; include './head.php'; ?> getColumn("SELECT SUM(realmoney) from pre_order where uid={$uid} and status=1 and endtime>='$today'"); if(!$order_today) $order_today = 0; $enable_money=round($userrow['money']-$order_today,2); if($enable_money<0)$enable_money=0; }else{ $enable_money=$userrow['money']; } if(isset($_GET['act']) && $_GET['act']=='do'){ if($_POST['submit']=='申请提现'){ if(!checkRefererHost())exit(); $money=daddslashes(strip_tags($_POST['money'])); if(!is_numeric($money) || !preg_match('/^[0-9.]+$/', $money) || $money<=0)exit(""); if($enable_money<$conf['settle_money']){ exit(""); } if($money>$enable_money){ exit(""); } if($money<$conf['settle_money']){ exit(""); } if($userrow['settle']==0){ exit(""); } if($conf['settle_maxlimit']>0){ $a_count = $DB->getColumn('SELECT count(*) FROM pre_settle WHERE uid=:uid AND addtime>=:addtime', [':uid'=>$uid, ':addtime'=>date('Y-m-d').' 00:00:00']); if($a_count >= $conf['settle_maxlimit']){ exit(""); } } if($conf['settle_rate']>0){ $fee=round($money*$conf['settle_rate']/100,2); if(!empty($conf['settle_fee_min']) && $fee<$conf['settle_fee_min'])$fee=$conf['settle_fee_min']; if(!empty($conf['settle_fee_max']) && $fee>$conf['settle_fee_max'])$fee=$conf['settle_fee_max']; $realmoney=round($money-$fee, 2); }else{ $realmoney=round($money, 2); } $data = ['uid'=>$uid, 'type'=>$userrow['settle_id'], 'account'=>$userrow['account'], 'username'=>$userrow['username'], 'money'=>$money, 'realmoney'=>$realmoney, 'addtime'=>'NOW()', 'status'=>0]; if($DB->insert('settle', $data)){ $settleid=$DB->lastInsertId(); changeUserMoney($uid, $money, false, '手动提现'); if($conf['settle_transfer']==1 && $conf['settle_transfermax']>0 && $money>$conf['settle_transfermax']) $conf['settle_transfer']=0; $app = convert_type($userrow['settle_id']); $channelid = $conf['transfer_'.$app]; if($conf['settle_transfer']==1 && $channelid > 0){ $out_biz_no = date("YmdHis").rand(11111,99999); $channel = \lib\Channel::get($channelid); $result = \lib\Transfer::submit($app, $channel, $out_biz_no, $userrow['account'], $userrow['username'], $realmoney); if($result['code']==0){ $update = ['status'=>1, 'endtime'=>'NOW()', 'transfer_no'=>$out_biz_no, 'transfer_channel'=>$channelid, 'transfer_status'=>1, 'transfer_result'=>$result["orderid"], 'transfer_date'=>$result["paydate"]]; if(isset($result['wxpackage'])) $update['transfer_ext'] = $result['wxpackage']; $DB->update('settle', $update, ['id'=>$settleid]); if($result['status'] == 1){ $msg = '提现成功,资金已到账!'; }elseif(isset($result['wxpackage'])){ if(checkwechat()){ $jumpurl = $siteurl.'paypage/wxtrans.php?id='.$out_biz_no.'&type=transfer'; exit(""); } $msg = '提现成功!请在结算记录页面扫描二维码确认收款,1天内未确认,将退还给商家。'; }else{ $msg = '提现成功,资金稍后到账!'; } exit(""); }else{ $message='转账失败 '.$result['msg']; $DB->update('settle', ['status'=>3, 'result'=>$result["msg"], 'transfer_status'=>2, 'transfer_result'=>$message], ['id'=>$settleid]); \lib\MsgNotice::send('apply', 0, ['uid'=>$uid, 'money'=>$money, 'realmoney'=>$realmoney, 'type'=>display_type($userrow['settle_id']), 'account'=>$userrow['account'], 'username'=>$userrow['username']]); exit(""); } }else{ \lib\MsgNotice::send('apply', 0, ['uid'=>$uid, 'money'=>$money, 'realmoney'=>$realmoney, 'type'=>display_type($userrow['settle_id']), 'account'=>$userrow['account'], 'username'=>$userrow['username']]); } } exit(""); } } ?>