public function index() { $per = C('DB_PREFIX'); $Bconfig = (require C("APP_ROOT") . "Conf/borrow_config.php"); //网站公告 $parm['type_id'] = 26; $parm['limit'] = 4; $this->assign("noticeList", getArticleList($parm)); //网站公告 $a = loan_total_info(); //var_dump($a); $d['a1'] = M('members m')->where($map)->count('m.id'); //假的 $d['a2'] = $a['ordinary_total']; $d['a3'] = $a['num_total']; $d['a4'] = $a['has_also']; $d['a5'] = $a['arrears']; //var_dump($d); $this->assign("a1", $d); //正在进行的贷款 $searchMap = array(); $searchMap['b.borrow_status'] = array("in", '2,4,6,7'); //$searchMap['b.is_tuijian']=array("in",'0,1'); //$searchMap['b.borrow_btype']=1; $parm = array(); $parm['map'] = $searchMap; $parm['limit'] = 6; $parm['orderby'] = "b.borrow_status ASC,b.id DESC"; $listBorrow = getBorrowList($parm); //var_dump($listBorrow); $this->assign("listBorrow", $listBorrow); $searchMap = array(); $searchMap['b.borrow_status'] = array("in", '2,4,6,7'); $searchMap['_string'] = "b.is_tuijian = 1"; $parm = array(); $parm['map'] = $searchMap; $parm['limit'] = 2; $parm['_string'] = "b.is_tuijian = 1"; $parm['orderby'] = "b.borrow_status ASC,b.id DESC"; $listBorrow1 = getBorrowList($parm); $this->assign("listBorrow1", $listBorrow1); //测试时间获取函数开始 //$date = date("Y-m-d",time()); //$ret = get_date($date,'m'); //dump($ret);exit; //测试时间获取函数结束 //////////////////////调取数据//////////// $money_log = get_money_log(0); $borrowOutNum = M("borrow_info")->where("borrow_status in(6,7,8,9)")->count("id"); $transferBorrowOutNum = M("transfer_borrow_info")->count("id"); $mborrowOutNum = $borrowOutNum + $transferBorrowOutNum; $shouyi = M('borrow_info')->sum('borrow_interest'); $this->assign("shouyi", $shouyi); $this->assign("mcount", M("members")->count("id")); $this->assign("mborrowOut", $money_log['17']['money']); $this->assign("mborrowOutNum", $mborrowOutNum); //////////////////////调取数据//////////// //正在进行的贷款 ///////////////省心宝列表开始 fan 2013-10-21////////////// $parm = array(); $searchMap = array(); //$searchMap['borrow_status']=2; //$searchMap['b.on_off']=1; //$searchMap['b.is_jijin']=0; //$searchMap['b.is_show'] = array('in','0,1'); $searchMap['b.borrow_status'] = array('neq', '3'); //$searchMap['b.online_time']=array("lt",time()); $parm['map'] = $searchMap; $parm['limit'] = 3; //$parm['orderby'] = "b.is_show desc,b.progress asc"; $listTBorrow = getTBorrowList($parm); $this->assign("listTBorrow", $listTBorrow); ///////////////省心宝列表结束 fan 2013-10-21////////////// ///////////////省心宝列表开始 fan 2014-06-13////////////// /* hycd $parm = array(); $searchMap = array(); //$searchMap['borrow_status']=2; //$searchMap['is_tuijian']=0; $searchMap['on_off']=1; $searchMap['is_jijin']=1; $searchMap['b.online_time']=array("lt",time()+300); $parm['map'] = $searchMap; $parm['limit'] = 2; $parm['orderby'] = "b.is_show desc,b.borrow_status ASC,b.borrow_duration ASC,b.online_time desc"; $listFBorrow = getTBorrowList($parm); $this->assign("listFBorrow",$listFBorrow); $this->assign('Bconfig',$Bconfig);*/ $searchMap = array(); $searchMap['b.borrow_status'] = array("in", '2,4,6,7'); $searchMap['b.is_tuijian'] = array("in", '0,1'); //$searchMap['b.borrow_btype']=2; $parm = array(); $parm['map'] = $searchMap; $parm['limit'] = 2; $parm['orderby'] = "b.borrow_status ASC,b.id DESC"; $listFBorrow = getTBorrowList($parm); //var_dump($listBorrow); $this->assign("listFBorrow", $listFBorrow); ///////////////省心宝列表结束 fan 2014-06-13/////////////// $this->display(); /****************************募集期内标未满,自动流标 新增 2013-03-13****************************/ //流标返回 $mapT = array(); $mapT['collect_time'] = array("lt", time()); $mapT['borrow_status'] = 2; $tlist = M("borrow_info")->field("id,borrow_uid,borrow_type,borrow_money,first_verify_time,borrow_interest_rate,borrow_duration,repayment_type,collect_day,collect_time")->where($mapT)->select(); if (empty($tlist)) { exit; } foreach ($tlist as $key => $vbx) { $borrow_id = $vbx['id']; //流标 $done = false; $borrowInvestor = D('borrow_investor'); $binfo = M("borrow_info")->field("borrow_type,borrow_money,borrow_uid,borrow_duration,repayment_type")->find($borrow_id); $investorList = $borrowInvestor->field('id,investor_uid,investor_capital')->where("borrow_id={$borrow_id}")->select(); M('investor_detail')->where("borrow_id={$borrow_id}")->delete(); if ($binfo['borrow_type'] == 1) { $limit_credit = memberLimitLog($binfo['borrow_uid'], 12, $binfo['borrow_money'], $info = "{$binfo['id']}号标流标"); } //返回额度 $borrowInvestor->startTrans(); $bstatus = 3; $upborrow_info = M('borrow_info')->where("id={$borrow_id}")->setField("borrow_status", $bstatus); //处理借款概要 $buname = M('members')->getFieldById($binfo['borrow_uid'], 'user_name'); //处理借款概要 if (is_array($investorList)) { $upsummary_res = M('borrow_investor')->where("borrow_id={$borrow_id}")->setField("status", $type); foreach ($investorList as $v) { MTip('chk15', $v['investor_uid']); //sss $accountMoney_investor = M("member_money")->field(true)->find($v['investor_uid']); $datamoney_x['uid'] = $v['investor_uid']; $datamoney_x['type'] = $type == 3 ? 16 : 8; $datamoney_x['affect_money'] = $v['investor_capital']; $datamoney_x['account_money'] = $accountMoney_investor['account_money'] + $datamoney_x['affect_money']; //投标不成功返回充值资金池 $datamoney_x['collect_money'] = $accountMoney_investor['money_collect']; $datamoney_x['freeze_money'] = $accountMoney_investor['money_freeze'] - $datamoney_x['affect_money']; $datamoney_x['back_money'] = $accountMoney_investor['back_money']; //会员帐户 $mmoney_x['money_freeze'] = $datamoney_x['freeze_money']; $mmoney_x['money_collect'] = $datamoney_x['collect_money']; $mmoney_x['account_money'] = $datamoney_x['account_money']; $mmoney_x['back_money'] = $datamoney_x['back_money']; //会员帐户 $_xstr = $type == 3 ? "复审未通过" : "募集期内标未满,流标"; $datamoney_x['info'] = "第{$borrow_id}号标" . $_xstr . ",返回冻结资金"; $datamoney_x['add_time'] = time(); $datamoney_x['add_ip'] = get_client_ip(); $datamoney_x['target_uid'] = $binfo['borrow_uid']; $datamoney_x['target_uname'] = $buname; $moneynewid_x = M('member_moneylog')->add($datamoney_x); if ($moneynewid_x) { $bxid = M('member_money')->where("uid={$datamoney_x['uid']}")->save($mmoney_x); } } } else { $moneynewid_x = true; $bxid = true; $upsummary_res = true; } if ($moneynewid_x && $upsummary_res && $bxid && $upborrow_info) { $done = true; $borrowInvestor->commit(); } else { $borrowInvestor->rollback(); } if (!$done) { continue; } MTip('chk11', $vbx['borrow_uid'], $borrow_id); $verify_info['borrow_id'] = $borrow_id; $verify_info['deal_info_2'] = text($_POST['deal_info_2']); $verify_info['deal_user_2'] = 0; $verify_info['deal_time_2'] = time(); $verify_info['deal_status_2'] = 3; if ($vbx['first_verify_time'] > 0) { M('borrow_verify')->save($verify_info); } else { M('borrow_verify')->add($verify_info); } $vss = M("members")->field("user_phone,user_name")->where("id = {$vbx['borrow_uid']}")->find(); SMStip("refuse", $vss['user_phone'], array("#USERANEM#", "ID"), array($vss['user_name'], $verify_info['borrow_id'])); //@SMStip("refuse",$vss['user_phone'],array("#USERANEM#","ID"),array($vss['user_name'],$verify_info['borrow_id'])); //updateBinfo $newBinfo = array(); $newBinfo['id'] = $borrow_id; $newBinfo['borrow_status'] = 3; $newBinfo['second_verify_time'] = time(); $x = M("borrow_info")->save($newBinfo); } /****************************募集期内标未满,自动流标 新增 2013-03-13****************************/ }
/** * 用户借款支出汇总 * 、支付投标奖励、支付利息、提现手续费、借款管理费、会员及认证费用、逾期及催收费用 、 支出总和、待付利息总额 * * @param mixed $uid //用户id */ function get_personal_out($uid) { $log = get_money_log($uid); $out['borrow_manage'] = $log['18']['money']; //借款管理费 $out['pay_tender'] = $log['21']['money'] + $log['42']['money']; //支付投标奖励 $out['overdue'] = $log['30']['money'] + $log['31']['money']; //逾期催收 $out['authenticate'] = $log['14']['money'] + $log['22']['money'] + $log['25']['money'] + $log['26']['money']; // 认证费用 //withdraw_fee $interest = M("investor_detail")->field('sum(receive_capital) as capital, sum(interest) as interest')->where("borrow_uid={$uid} and status in (1,2,3,4,5)")->find(); $out['interest'] = $interest['interest']; //支付利息 $out['capital'] = $interest['capital']; // 已还本金 //待付利息\本金 $interest_pay = M('investor_detail')->field('sum(interest) as interest, sum(capital) as capital')->where("borrow_uid={$uid} and status in (6,7)")->find(); //echo M()->getlastsql();exit; $out['interest_pay'] = $interest_pay['interest']; //待还利息 $out['capital_pay'] = $interest_pay['capital']; //待还金额 $czfee = M('member_payonline')->where("uid={$uid} AND status=1")->sum('fee'); //在线充值手续费 $out['czfee'] = $czfee; //print_r($out); $withdraw = M('member_withdrawlog')->field('sum(feeamt) as fee, sum(transamt) as withdraw_money')->where("uid={$uid} and status=1")->find(); $servfee = M("member_withdrawlog")->field('sum(servfee) as servfee')->where("uid={$uid} and status=1")->find(); $out['withdraw_fee'] = $withdraw['fee'] + $servfee['servfee']; //提现手续费 $out['withdraw_money'] = $withdraw['withdraw_money']; //提现金额 $db_money = M("member_moneylog")->where("uid=" . $uid . " AND type=104")->sum("affect_money"); //查询会员的担保费总额 $out['danbao'] = abs($db_money); $out['total'] = $out['borrow_manage'] + $out['pay_tender'] + $out['overdue'] + $out['authenticate'] + $out['interest'] + $out['withdraw_fee'] - $db_money; //echo "<pre>";print_r($out);echo "</pre>";exit; return $out; }
/** +---------------------------------------------------------- * 默认操作 +---------------------------------------------------------- */ public function index() { $map = array(); if ($_REQUEST['uname']) { $map['m.user_name'] = array("like", urldecode($_REQUEST['uname']) . "%"); $search['uname'] = urldecode($_REQUEST['uname']); } if ($_REQUEST['realname']) { $map['mi.real_name'] = urldecode($_REQUEST['realname']); $search['realname'] = $map['mi.real_name']; } if (!empty($_REQUEST['bj']) && !empty($_REQUEST['lx']) && !empty($_REQUEST['money'])) { if ($_REQUEST['lx'] == 'allmoney') { if ($_REQUEST['bj'] == 'gt') { $bj = '>'; } else { if ($_REQUEST['bj'] == 'lt') { $bj = '<'; } else { if ($_REQUEST['bj'] == 'eq') { $bj = '='; } } } $map['_string'] = "(mm.account_money+mm.back_money) " . $bj . $_REQUEST['money']; } else { $map[$_REQUEST['lx']] = array($_REQUEST['bj'], $_REQUEST['money']); } $search['bj'] = $_REQUEST['bj']; $search['lx'] = $_REQUEST['lx']; $search['money'] = $_REQUEST['money']; } //分页处理 import("ORG.Util.Page"); $count = M('members m')->join("{$this->pre}member_money mm ON mm.uid=m.id")->join("{$this->pre}member_info mi ON mi.uid=m.id")->where($map)->count('m.id'); $p = new Page($count, C('ADMIN_PAGE_SIZE')); $page = $p->show(); $Lsql = "{$p->firstRow},{$p->listRows}"; //分页处理 $pre = $this->pre; $field = 'm.id,m.reg_time,m.user_name,mi.real_name,mm.money_freeze,mm.money_collect,(mm.account_money+mm.back_money) total_money,mm.account_money,mm.back_money'; $list = M('members m')->field($field)->join("{$this->pre}member_money mm ON mm.uid=m.id")->join("{$this->pre}member_info mi ON mi.uid=m.id")->where($map)->limit($Lsql)->order("m.id DESC")->select(); foreach ($list as $key => $v) { $uid = $v['id']; $list[$key]['benefit'] = get_personal_benefit($uid); $list[$key]['out'] = get_personal_out($uid); $list[$key]['count'] = get_personal_count($uid); $money_log = get_money_log($uid); $list[$key]['glycz'] = $money_log['17']['money']; $withdraw0 = M('member_withdraw')->where("uid={$uid} AND withdraw_status=0")->sum('withdraw_money'); //待提现 $withdraw1 = M('member_withdraw')->where("uid={$uid} AND withdraw_status=1")->sum('withdraw_money'); //提现处理中 $withdraw3 = M('member_withdraw')->where("uid={$uid} AND withdraw_status=0")->sum('second_fee'); //待提现手续费 $withdraw4 = M('member_withdraw')->where("uid={$uid} AND withdraw_status=1")->sum('second_fee'); //处理中提现手续费 $list[$key]['dshtx'] = $withdraw0 + $withdraw3; $list[$key]['chulizhong'] = $withdraw1 + $withdraw4; } $this->assign("bj", array("gt" => '大于', "eq" => '等于', "lt" => '小于')); $this->assign("lx", array("allmoney" => '可用余额', "mm.money_freeze" => '冻结金额', "mm.money_collect" => '待收金额')); $this->assign("list", $list); $this->assign("pagebar", $page); $this->assign("search", $search); $this->assign("query", http_build_query($search)); $this->display(); }
/** * 用户借款支出汇总 * 、支付投标奖励、支付利息、提现手续费、借款管理费、会员及认证费用、逾期及催收费用 、 支出总和、待付利息总额 * * @param mixed $uid //用户id */ function get_personal_out($uid) { $log = get_money_log($uid); $out['borrow_manage'] = $log['18']['money']; //借款管理费 $out['pay_tender'] = $log['21']['money'] + $log['42']['money']; //支付投标奖励 $out['overdue'] = $log['30']['money'] + $log['31']['money']; //逾期催收 $out['authenticate'] = $log['14']['money'] + $log['22']['money'] + $log['25']['money'] + $log['26']['money']; // 认证费用 $interest = M("investor_detail")->field('sum(receive_capital) as capital, sum(receive_interest) as interest')->where("borrow_uid={$uid} and status in (1,2,3,4,5)")->find(); $out['interest'] = $interest['interest']; //支付利息 $out['capital'] = $interest['capital']; // 已还本金 //待付利息\本金 $interest_pay = M('investor_detail')->field('sum(interest) as interest, sum(capital) as capital')->where("borrow_uid={$uid} and status in (6,7)")->find(); $out['interest_pay'] = $interest_pay['interest']; //待还利息 $out['capital_pay'] = $interest_pay['capital']; //待还金额 $czfee = M('member_payonline')->where("uid={$uid} AND status=1")->sum('fee'); //在线充值手续费 $out['czfee'] = $czfee; //print_r($out); $withdraw = M('member_withdraw')->field('sum(second_fee) as fee, sum(withdraw_money) as withdraw_money')->where("uid={$uid} and withdraw_status=2")->find(); $out['withdraw_fee'] = $withdraw['fee']; //提现手续费 $out['withdraw_money'] = $withdraw['withdraw_money']; //提现金额 $out['total'] = $out['borrow_manage'] + $out['pay_tender'] + $out['overdue'] + $out['authenticate'] + $out['interest'] + $out['withdraw_fee']; return $out; }