Exemplo n.º 1
0
 public function invest()
 {
     if (!$this->uid) {
         if ($this->isAjax()) {
             die("请先登录后投资");
         } else {
             $this->redirect('M/pub/login');
         }
     }
     if ($this->isAjax()) {
         $borrow_id = intval($this->_get('bid'));
         $tnum = intval($_POST['cnum']);
         $pre = c("DB_PREFIX");
         $m = M("member_money")->field('account_money,back_money,money_collect')->find($this->uid);
         $amoney = $m['account_money'] + $m['back_money'];
         $uname = session("u_user_name");
         $binfo = M("transfer_borrow_info")->field("borrow_uid,borrow_interest_rate,transfer_out,transfer_back,transfer_total,\n                                per_transfer,is_show,deadline,min_month,increase_rate,reward_rate,borrow_duration")->find($borrow_id);
         if ($this->uid == $binfo['borrow_uid']) {
             ajaxmsg("不能去投自己的标", 0);
         }
         $month = $binfo['borrow_duration'];
         //手机版默认投资最大期限
         $max_num = $binfo['transfer_total'] - $binfo['transfer_out'];
         if ($max_num < $tnum) {
             die("本标还能认购最大份数为" . $max_num . "份,请重新输入认购份数");
         }
         $money = $binfo['per_transfer'] * $tnum;
         if ($amoney < $money) {
             die("尊敬的{$uname},您准备认购{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再认购");
         }
         $vm = getMinfo($this->uid, "m.pin_pass,mm.invest_vouch_cuse,mm.money_collect");
         $pin_pass = $vm['pin_pass'];
         $pin = md5($_POST['paypass']);
         // if ($pin != $pin_pass){
         //     die( "支付密码错误,请重试" );
         // }
         $tinvest_id = TinvestMoney($this->uid, $borrow_id, $tnum, $month);
         //投企业直投
         if ($tinvest_id) {
             //die('TRUE');
             $loanconfig = FS("Webconfig/loanconfig");
             $orders = 'T' . date("YmdHi") . $tinvest_id;
             // 发送到乾多多
             $invest_qdd = M("escrow_account")->field('*')->where("uid={$this->uid}")->find();
             $borrow_qdd = M("escrow_account")->field('*')->where("uid={$binfo['borrow_uid']}")->find();
             $invest_info = M("transfer_borrow_investor")->field("reward_money, borrow_fee")->where("id={$tinvest_id}")->find();
             $secodary = '';
             import("ORG.Loan.Escrow");
             $loan = new Escrow();
             if ($invest_info['reward_money'] > 0.0) {
                 // 投标奖励
                 $secodary[] = $loan->secondaryJsonList($invest_qdd['qdd_marked'], $invest_info['reward_money'], '二次分配', '投标奖励');
             }
             if ($invest_info['borrow_fee'] > 0.0) {
                 // 借款管理费
                 $secodary[] = $loan->secondaryJsonList($loanconfig['pfmmm'], $invest_info['borrow_fee'], '二次分配', '借款管理费');
             }
             $secodary && ($secodary = json_encode($secodary));
             $loanList = $loan->loanJsonList($invest_qdd['qdd_marked'], $borrow_qdd['qdd_marked'], $orders, 'T_' . $borrow_id, $money, $binfo['borrow_money'], '投标', "对{$borrow_id}号企业直投进行投标", $secodary);
             $loanJsonList = json_encode($loanList);
             $returnURL = C('WEB_URL') . U("tinvest/wapinvestReturn");
             $notifyURL = C('WEB_URL') . U("tinvest/notify");
             $data = $loan->transfer($loanJsonList, $returnURL, $notifyURL, 1, 1, 2, 1);
             // 自动到帐
             $form = $loan->setForm($data, 'transfer');
             // echo "aaaaaa";die();
             echo $form . "正在跳转至乾多多。。。";
             exit;
         } else {
             die("很遗憾,认购失败,请重试!");
         }
     } else {
         $borrow_id = $this->_get('bid');
         $pre = C('DB_PREFIX');
         $borrowinfo = M("transfer_borrow_info b")->join("{$pre}transfer_detail d ON d.borrow_id=b.id")->field(true)->find($borrow_id);
         $borrowinfo['progress'] = getfloatvalue($borrowinfo['transfer_out'] / $borrowinfo['transfer_total'] * 100, 2);
         $borrowinfo['need'] = getfloatvalue(($borrowinfo['transfer_total'] - $borrowinfo['transfer_out']) * $borrowinfo['per_transfer'], 2);
         $borrowinfo['updata'] = unserialize($borrowinfo['updata']);
         $this->assign("vo", $borrowinfo);
         $user_info = M('member_money')->field("account_money+back_money as money ")->where("uid='{$this->uid}'")->find();
         $this->assign('user_info', $user_info);
         $paypass = M("members")->field('pin_pass')->where('id=' . $this->uid)->find();
         $this->assign('paypass', $paypass['pin_pass']);
         $this->display();
     }
 }
Exemplo n.º 2
0
 public function tinvestmoney()
 {
     $jsoncode = file_get_contents("php://input");
     //alogsm("tinvestmoney",0,1,session("u_id").$jsoncode);
     if (!$this->uid) {
         ajaxmsg('请先登录', 0);
         exit;
     }
     $arr = array();
     $arr = json_decode($jsoncode, true);
     if (intval($arr['uid']) != $this->uid) {
         ajaxmsg("查询错误!", 0);
     }
     if (!is_array($arr) || empty($arr) || empty($arr['borrow_id']) || empty($arr['zhifu_money']) || $arr['type'] != 2) {
         ajaxmsg("查询错误!", 0);
     }
     $_pin = $arr['pin'];
     $_month = $arr['month'];
     $borrow_id = $arr['borrow_id'];
     $month = intval($_month);
     $binfo = M("transfer_borrow_info")->field("borrow_max,borrow_uid,borrow_interest_rate,transfer_out,transfer_back,transfer_total,per_transfer,is_show,deadline,min_month,increase_rate,reward_rate,borrow_duration,borrow_money")->find($borrow_id);
     //$_tnum = $arr['zhifu_money']/$binfo['per_transfer'];
     $tnum = $arr['zhifu_money'] / $binfo['per_transfer'];
     $m = M("member_money")->field('account_money,back_money,money_collect')->find($this->uid);
     $amoney = $m['account_money'] + $m['back_money'];
     $uname = session("u_user_name");
     //ajaxmsg($binfo);die;
     if ($this->uid == $binfo['borrow_uid']) {
         ajaxmsg("不能去投自己的标", 0);
     }
     $max_month = $binfo['borrow_duration'];
     //getTransferLeftmonth($binfo['deadline']);
     $min_month = $binfo['min_month'];
     $max_num = $binfo['transfer_total'] - $binfo['transfer_out'];
     if ($tnum < 1) {
         ajaxmsg("购买份数必须大于等于1份!" . $binfo['per_transfer'], 0);
     }
     if ($month < $min_month || $max_month < $month) {
         ajaxmsg("本标认购期限只能在'" . $min_month . "个月---" . $max_month . "个月'之间", 0);
     }
     //echo $max_num;die();
     // echo $tnum;die();
     //echo $max_num;die();
     if ($max_num * $binfo['per_transfer'] < $tnum * $binfo['per_transfer']) {
         ajaxmsg("本标还能认购最大金额为" . $max_num . "元,请重新输入认购金额", 0);
     }
     $map['i.investor_uid'] = $this->uid;
     $map['i.status'] = 1;
     $map['i.borrow_id'] = $borrow_id;
     $map['i.loanno'] = array('neq', '');
     $list = getttenderlist($map, 15);
     $invested_money_t = $tnum * $binfo['per_transfer'] + $list['total_money'];
     if ($binfo['borrow_max'] != 0) {
         if ($binfo['borrow_max'] * $binfo['per_transfer'] < $invested_money_t) {
             ajaxmsg("本标个人认购最大金额为" . $binfo['borrow_max'] * $binfo['per_transfer'] . "元", 0);
         }
     }
     $money = $tnum;
     if ($amoney < $money) {
         ajaxmsg("尊敬的{$uname},您准备认购{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再认购", 0);
     }
     $vm = getMinfo($this->uid, "m.pin_pass,mm.invest_vouch_cuse,mm.money_collect");
     $pin_pass = $vm['pin_pass'];
     $pin = md5($_pin);
     $tinvest_id = TinvestMoney($this->uid, $borrow_id, $tnum, $month);
     //投企业直投
     if ($tinvest_id) {
         $loanconfig = FS("Webconfig/loanconfig");
         $orders = date("YmdHi") . $tinvest_id;
         // 发送到乾多多
         $invest_qdd = M("escrow_account")->field('*')->where("uid={$this->uid}")->find();
         $borrow_qdd = M("escrow_account")->field('*')->where("uid={$binfo['borrow_uid']}")->find();
         $invest_info = M("transfer_borrow_investor")->field("reward_money, borrow_fee")->where("id={$tinvest_id}")->find();
         $secodary = '';
         import("ORG.Loan.Escrow");
         $loan = new Escrow();
         if ($invest_info['reward_money'] > 0.0) {
             // 投标奖励
             // $secodary[] = $loan->secondaryJsonList($invest_qdd['qdd_marked'], $invest_info['reward_money'],'二次分配', '支付投标奖励');
             $secodary['LoanInMoneymoremore'] = $invest_qdd['qdd_marked'];
             $secodary['Amount'] = $invest_info['reward_money'];
             $secodary['TransferName'] = '二次分配';
             $secodary['Remark'] = '支付投标奖励';
             $secodarys['reward_money'] = $secodary;
         }
         if ($invest_info['borrow_fee'] > 0.0) {
             // 借款管理费
             // $secodary[] = $loan->secondaryJsonList($loanconfig['pfmmm'], $invest_info['borrow_fee'],'二次分配', '支付平台借款管理费');
             $secodary['LoanInMoneymoremore'] = $loanconfig['pfmmm'];
             $secodary['Amount'] = $invest_info['borrow_fee'];
             $secodary['TransferName'] = '二次分配';
             $secodary['Remark'] = '支付平台借款管理费';
             $secodarys['borrow_fee'] = $secodary;
         }
         //$secodarys && $secodarys = json_encode($secodarys);
         // 投标奖励
         // $loanList[] = $loan->loanJsonList($invest_qdd['qdd_marked'], $borrow_qdd['qdd_marked'], $orders, $borrow_id, $money, $binfo['borrow_money'],'投标',"对{$borrow_id}号投标",$secodary);
         $loanJsonList = array();
         $loanJsonList['LoanOutMoneymoremore'] = $invest_qdd['qdd_marked'];
         $loanJsonList['LoanInMoneymoremore'] = $borrow_qdd['qdd_marked'];
         $loanJsonList['OrderNo'] = 'T' . $orders;
         $loanJsonList['BatchNo'] = 'T_' . $borrow_id;
         $loanJsonList['Amount'] = $money * $binfo['per_transfer'];
         $loanJsonList['FullAmount'] = $binfo['borrow_money'];
         $loanJsonList['TransferName'] = '投标';
         $loanJsonList['Remark'] = "对{$borrow_id}号投标";
         $loanJsonList['NeedAudit'] = '1';
         //$loanJsonList['SecondaryJsonList'] = $secodarys;
         //$loanJsonList = json_encode($loanList);
         //$returnURL = C('WEB_URL').U("invest/investReturn");
         // $notifyURL = C('WEB_URL').U("notify/notifys");
         $notifyURL = C('WEB_URL') . "/tinvest/notify";
         //echo $notify;die();
         //$data =  $loan->transfer('',$returnURL , $notifyURL);
         $data1 = $loan->transfer('', $returnURL, $notifyURL, 1, 1, 2, 1);
         // 自动到帐
         //$data['LoanJsonList']=$data1['LoanJsonList'];
         //$data['LoanJsonList'] = $loanJsonList;
         $data['PlatformMoneymoremore'] = $data1['PlatformMoneymoremore'];
         $data['TransferAction'] = $data1['TransferAction'];
         $data['Action'] = $data1['Action'];
         $data['TransferType'] = $data1['TransferType'];
         $data['NeedAudit'] = $data1['NeedAudit'];
         $data['RandomTimeStamp'] = $data1['RandomTimeStamp'];
         $data['Remark1'] = $data1['Remark1'];
         $data['Remark2'] = $data1['Remark2'];
         $data['Remark3'] = $data1['Remark3'];
         $data['NotifyURL'] = $data1['NotifyURL'];
         $data['LoanJsonList'] = $loanJsonList;
         $data['SecondaryJsonList'] = $secodarys;
         ajaxmsg($data);
         //          $loanconfig = FS("Webconfig/loanconfig");
         //          $orders = date("YmdHi").$tinvest_id;
         // // 发送到乾多多
         //          $invest_qdd = M("escrow_account")->field('*')->where("uid={$this->uid}")->find();
         //          $borrow_qdd = M("escrow_account")->field('*')->where("uid={$binfo['borrow_uid']}")->find();
         //          $invest_info = M("transfer_borrow_investor")->field("reward_money, borrow_fee")->where("id={$tinvest_id}")->find();
         //          $secodary = '';
         //          import("ORG.Loan.Escrow");
         //          $loan = new Escrow();
         //  if($invest_info['reward_money']>0.00){  // 投标奖励
         //             // $secodary[] = $loan->secondaryJsonList($invest_qdd['qdd_marked'], $invest_info['reward_money'],'二次分配', '支付投标奖励');
         //     $secodary['LoanInMoneymoremore'] = $invest_qdd['qdd_marked'];
         // 	$secodary['Amount'] = $invest_info['reward_money'];
         // 	$secodary['TransferName'] = '二次分配';
         // 	$secodary['Remark'] = '支付投标奖励';
         // 	//$secodarys['reward_money'] = $secodary;
         //          }
         //          if($invest_info['borrow_fee']>0.00){  // 借款管理费
         //             // $secodary[] = $loan->secondaryJsonList($loanconfig['pfmmm'], $invest_info['borrow_fee'],'二次分配', '支付平台借款管理费');
         //     $secodary['LoanInMoneymoremore'] = $loanconfig['pfmmm'];
         // 	$secodary['Amount'] = $invest_info['borrow_fee'];
         // 	$secodary['TransferName'] = '二次分配';
         // 	$secodary['Remark'] = '支付平台借款管理费';
         // 	//$secodarys['borrow_fee'] = $secodary;
         //          }
         //          //$secodarys && $secodarys = json_encode($secodarys);
         //          // 投标奖励
         //         // $loanList[] = $loan->loanJsonList($invest_qdd['qdd_marked'], $borrow_qdd['qdd_marked'], $orders, $borrow_id, $money, $binfo['borrow_money'],'投标',"对{$borrow_id}号投标",$secodary);
         // 	$loanJsonList = array();
         //     $loanJsonList['LoanOutMoneymoremore'] = $invest_qdd['qdd_marked'];
         // 	$loanJsonList['LoanInMoneymoremore'] = $borrow_qdd['qdd_marked'];
         // 	$loanJsonList['OrderNo'] = 'T'.$orders;
         // 	$loanJsonList['BatchNo'] = 'T_'.$borrow_id;
         // 	$loanJsonList['Amount'] = $money*$binfo['per_transfer'];
         // 	$loanJsonList['FullAmount'] = $binfo['borrow_money'];
         // 	$loanJsonList['TransferName'] = '投标';
         // 	$loanJsonList['Remark'] = "对{$borrow_id}号投标";
         // 	//$loanJsonList['NeedAudit']='1';
         // 	$loanJsonList['SecondaryJsonList']=$secodary;
         // $notifyURL = C('WEB_URL').U("tinvest/notify");
         //          //$data1 =  $loan->transfer('',$returnURL , $notifyURL);
         //          $data1=  $loan->transfer($loanJsonList, $returnURL , $notifyURL,1,1,2,1); // 自动到帐
         // //$data['LoanJsonList']=$data1['LoanJsonList'];
         // $data['LoanJsonList'] = $loanJsonList;
         // $data['PlatformMoneymoremore']=$data1['PlatformMoneymoremore'];
         // $data['TransferAction']=$data1['TransferAction'];
         // $data['Action']=$data1['Action'];
         // $data['TransferType']=$data1['TransferType'];
         // $data['NeedAudit']=$data1['NeedAudit'];
         // $data['RandomTimeStamp']=$data1['RandomTimeStamp'];
         // $data['Remark1']=$data1['Remark1'];
         // $data['Remark2']=$data1['Remark2'];
         // $data['Remark3']=$data1['Remark3'];
         // $data['NotifyURL']=$data1['NotifyURL'];
         //$data['SecondaryJsonList'] = $secodarys;
     } else {
         $ajaxmsg("对不起,认购失败,请重试!");
     }
 }
Exemplo n.º 3
0
 public function invest()
 {
     if (!$this->uid) {
         if ($this->isAjax()) {
             die("请先登录后投资");
         } else {
             $this->redirect('M/pub/login');
         }
     }
     if ($this->isAjax()) {
         $borrow_id = intval($this->_get('bid'));
         $tnum = intval($_POST['cnum']);
         $pre = c("DB_PREFIX");
         $m = M("member_money")->field('account_money,back_money,money_collect')->find($this->uid);
         $amoney = $m['account_money'] + $m['back_money'];
         $uname = session("u_user_name");
         $binfo = M("transfer_borrow_info")->field("borrow_uid,borrow_interest_rate,transfer_out,transfer_back,transfer_total,\n                                per_transfer,is_show,deadline,min_month,increase_rate,reward_rate,borrow_duration")->find($borrow_id);
         if ($this->uid == $binfo['borrow_uid']) {
             ajaxmsg("不能去投自己的标", 0);
         }
         $month = $binfo['borrow_duration'];
         //手机版默认投资最大期限
         $max_num = $binfo['transfer_total'] - $binfo['transfer_out'];
         if ($max_num < $tnum) {
             die("本标还能认购最大份数为" . $max_num . "份,请重新输入认购份数");
         }
         $money = $binfo['per_transfer'] * $tnum;
         if ($amoney < $money) {
             die("尊敬的{$uname},您准备认购{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再认购");
         }
         $vm = getMinfo($this->uid, "m.pin_pass,mm.invest_vouch_cuse,mm.money_collect");
         $pin_pass = $vm['pin_pass'];
         $pin = md5($_POST['paypass']);
         if ($pin != $pin_pass) {
             die("支付密码错误,请重试");
         }
         $done = TinvestMoney($this->uid, $borrow_id, $tnum, $month);
         //投企业直投
         if ($done === true) {
             die('TRUE');
         } else {
             if ($done) {
                 die($done);
             } else {
                 die("很遗憾,认购失败,请重试!");
             }
         }
     } else {
         $borrow_id = $this->_get('bid');
         $pre = C('DB_PREFIX');
         $borrowinfo = M("transfer_borrow_info b")->join("{$pre}transfer_detail d ON d.borrow_id=b.id")->field(true)->find($borrow_id);
         $borrowinfo['progress'] = getfloatvalue($borrowinfo['transfer_out'] / $borrowinfo['transfer_total'] * 100, 2);
         $borrowinfo['need'] = getfloatvalue(($borrowinfo['transfer_total'] - $borrowinfo['transfer_out']) * $borrowinfo['per_transfer'], 2);
         $borrowinfo['updata'] = unserialize($borrowinfo['updata']);
         $this->assign("vo", $borrowinfo);
         $user_info = M('member_money')->field("account_money+back_money as money ")->where("uid='{$this->uid}'")->find();
         $this->assign('user_info', $user_info);
         $paypass = M("members")->field('pin_pass')->where('id=' . $this->uid)->find();
         $this->assign('paypass', $paypass['pin_pass']);
         $this->display();
     }
 }
Exemplo n.º 4
0
function autotInvest($borrow_id)
{
    $datag = get_global_setting();
    $binfo = M("transfer_borrow_info")->field('borrow_money,borrow_uid,per_transfer,borrow_type,borrow_interest_rate,borrow_duration,progress,transfer_total,transfer_out')->find($borrow_id);
    $map['a.is_use'] = 1;
    $map['a.borrow_type'] = 3;
    $map['a.end_time'] = array("gt", time());
    $autolist = M("auto_borrow a")->join(C('DB_PREFIX') . "member_money m ON a.uid=m.uid")->field("a.*, m.account_money+m.back_money as money")->where($map)->order("a.invest_time asc")->select();
    $needMoney = $binfo['borrow_money'] - $binfo['borrow_money'] * $binfo['progress'] / 100;
    foreach ($autolist as $key => $v) {
        if (!$needMoney) {
            break;
        }
        if ($v['uid'] == $binfo['borrow_uid']) {
            continue;
        }
        if ($v['money'] <= 0 || $v['money'] == NULL) {
            continue;
        }
        $num_max1 = floor(($v['money'] - $v['account_money']) / $binfo['per_transfer']);
        //余额最多可购买份数
        $num_max2 = floor($v['invest_money'] / $binfo['per_transfer']);
        //最大投资总额可购买份数
        $num_max3 = $needMoney / $binfo['per_transfer'];
        //$binfo['transfer_total'] - $binfo['transfer_out'];//剩余多少份
        $num_max4 = $binfo['transfer_total'] * $datag['auto_rate'] / 100;
        //不能超过10%
        $num_min = ceil($v['min_invest'] / $binfo['per_transfer']);
        //最少要买多少份
        if ($num_max1 > $num_max2) {
            $num = $num_max2;
        } else {
            $num = $num_max1;
        }
        if ($num > $num_max3) {
            $num = $num_max3;
        }
        if ($num > $num_max4) {
            $num = $num_max4;
        }
        if ($v['interest_rate'] > 0) {
            if (!($binfo['borrow_interest_rate'] >= $v['interest_rate'])) {
                //利率范围
                continue;
            }
        }
        if ($v['duration_from'] > 0 && $v['duration_to'] > 0 && $v['duration_from'] <= $v['duration_to']) {
            //借款期限范围
            if (!($binfo['borrow_duration'] >= $v['duration_from'] && $binfo['borrow_duration'] <= $v['duration_to'])) {
                continue;
            }
        }
        if (!($num >= $num_min)) {
            //
            continue;
        }
        if (!($v['money'] - $v['account_money'] >= $num * $binfo['per_transfer'])) {
            //余额限制
            continue;
        }
        if ($needMoney <= 0) {
            //可投金额必须大于0
            continue;
        }
        TinvestMoney($v['uid'], $borrow_id, $num, $binfo['borrow_duration'], 1);
        //
        $needMoney = $needMoney - $num * $binfo['per_transfer'];
        // 减去剩余已投金额
        MTip('chk27', $v['uid'], $borrow_id, $v['id']);
        //sss
        M('auto_borrow')->where('id = ' . $v['id'])->save(array("invest_time" => time()));
    }
    return true;
}
Exemplo n.º 5
0
 public function investmoney()
 {
     if (!$this->uid) {
         exit;
     }
     $borrow_id = intval($_POST['T_borrow_id']);
     $tnum = intval($_POST['transfer_invest_num']);
     $month = intval($_POST['transfer_invest_month']);
     $m = M("member_money")->field('account_money,back_money,money_collect')->find($this->uid);
     $amoney = $m['account_money'] + $m['back_money'];
     $uname = session("u_user_name");
     $binfo = M("transfer_borrow_info")->field("borrow_uid,borrow_interest_rate,transfer_out,transfer_back,transfer_total,per_transfer,is_show,deadline,min_month,increase_rate,reward_rate,borrow_duration")->find($borrow_id);
     if ($this->uid == $binfo['borrow_uid']) {
         ajaxmsg("不能去投自己的标", 0);
     }
     $max_month = $binfo['borrow_duration'];
     //getTransferLeftmonth($binfo['deadline']);
     $min_month = $binfo['min_month'];
     $max_num = $binfo['transfer_total'] - $binfo['transfer_out'];
     if ($tnum < 1) {
         ajaxmsg("购买份数必须大于等于1份!", 3);
     }
     if ($month < $min_month || $max_month < $month) {
         $this->error("本标认购期限只能在'" . $min_month . "个月---" . $max_month . "个月'之间");
     }
     if ($max_num < $tnum) {
         $this->error("本标还能认购最大份数为" . $max_num . "份,请重新输入认购份数");
     }
     $money = $binfo['per_transfer'] * $tnum;
     if ($amoney < $money) {
         $this->error("尊敬的{$uname},您准备认购{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再认购.", __APP__ . "/member/charge#fragment-1");
     }
     $vm = getMinfo($this->uid, "m.pin_pass,mm.invest_vouch_cuse,mm.money_collect");
     $pin_pass = $vm['pin_pass'];
     $pin = md5($_POST['T_pin']);
     if ($pin != $pin_pass) {
         $this->error("支付密码错误,请重试");
     }
     $done = TinvestMoney($this->uid, $borrow_id, $tnum, $month);
     //投企业直投
     if ($done === true) {
         $this->success("恭喜成功认购{$tnum}份,共计{$money}元");
     } else {
         if ($done) {
             $this->error($done);
         } else {
             $this->error("对不起,认购失败,请重试!");
         }
     }
 }
Exemplo n.º 6
0
 public function tinvestmoney()
 {
     $jsoncode = file_get_contents("php://input");
     //alogsm("tinvestmoney",0,1,session("u_id").$jsoncode);
     if (!$this->uid) {
         ajaxmsg('请先登录', 0);
         exit;
     }
     $arr = array();
     $arr = json_decode($jsoncode, true);
     if (intval($arr['uid']) != $this->uid) {
         ajaxmsg("查询错误!", 0);
     }
     if (!is_array($arr) || empty($arr) || empty($arr['borrow_id']) || empty($arr['pin']) || empty($arr['num']) || empty($arr['month']) || $arr['type'] != 2) {
         ajaxmsg("查询错误!", 0);
     }
     $_pin = $arr['pin'];
     $_borrow_id = $arr['borrow_id'];
     $_tnum = $arr['num'];
     $_month = $arr['month'];
     $borrow_id = intval($_borrow_id);
     $tnum = intval($_tnum);
     $month = intval($_month);
     $m = M("member_money")->field('account_money,back_money,money_collect')->find($this->uid);
     $amoney = $m['account_money'] + $m['back_money'];
     $uname = session("u_user_name");
     $binfo = M("transfer_borrow_info")->field("borrow_uid,borrow_interest_rate,transfer_out,transfer_back,transfer_total,per_transfer,is_show,deadline,min_month,increase_rate,reward_rate,borrow_duration")->find($borrow_id);
     if ($this->uid == $binfo['borrow_uid']) {
         ajaxmsg("不能去投自己的标", 0);
     }
     $max_month = $binfo['borrow_duration'];
     //getTransferLeftmonth($binfo['deadline']);
     $min_month = $binfo['min_month'];
     $max_num = $binfo['transfer_total'] - $binfo['transfer_out'];
     if ($tnum < 1) {
         ajaxmsg("购买份数必须大于等于1份!", 3);
     }
     if ($month < $min_month || $max_month < $month) {
         ajaxmsg("本标认购期限只能在'" . $min_month . "个月---" . $max_month . "个月'之间", 3);
     }
     if ($max_num < $tnum) {
         ajaxmsg("本标还能认购最大份数为" . $max_num . "份,请重新输入认购份数", 3);
     }
     $money = $binfo['per_transfer'] * $tnum;
     if ($amoney < $money) {
         ajaxmsg("尊敬的{$uname},您准备认购{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再认购.", __APP__ . "/member/charge#fragment-1", 2);
     }
     $vm = getMinfo($this->uid, "m.pin_pass,mm.invest_vouch_cuse,mm.money_collect");
     $pin_pass = $vm['pin_pass'];
     $pin = md5($_pin);
     if ($pin != $pin_pass) {
         ajaxmsg("支付密码错误,请重试", 0);
     }
     $done = TinvestMoney($this->uid, $borrow_id, $tnum, $month);
     //投省心宝
     if ($done === true) {
         $_msg['type'] = 2;
         $_msg['id'] = $borrow_id;
         $_msg['message'] = "恭喜成功认购{$tnum}份,共计{$money}元";
         ajaxmsg($_msg, 1);
     } else {
         if ($done) {
             ajaxmsg($done, 3);
         } else {
             ajaxmsg("对不起,认购失败,请重试!", 3);
         }
     }
 }