public function investmoney() { //if(!$this->uid) exit; if (!$this->uid) { ajaxmsg('请先登录', 3); exit; } $money = floatval($_POST['money']); $borrow_id = intval($_POST['borrow_id']); $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'); if (bccomp($money, $amoney) == 1) { $this->error("尊敬的{$uname},您准备投标{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再投标.", __APP__ . "/member/charge#fragment-1"); } $vm = getMinfo($this->uid, 'm.pin_pass,m.user_phone,mm.account_money,mm.back_money,mm.money_collect'); $pin_pass = $vm['pin_pass']; $pin = md5($_POST['pin']); if ($pin != $pin_pass) { $this->error("支付密码错误,请重试"); } $binfo = M("borrow_info")->field('borrow_money,money_invest_place,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect')->find($borrow_id); if ($money % $binfo['borrow_min'] != 0) { // ajaxmsg("投标金额必须为起投金额的整数倍",3); } ////////////////////////////////////待收金额限制 2013-08-26 fan/////////////////// if ($binfo['money_collect'] > 0) { if ($m['money_collect'] < $binfo['money_collect']) { ajaxmsg("此标设有限制,待收金额需达到" . $binfo['money_collect'] . "元以上", 3); } } $today_start = strtotime(date('Y-m-d', time()) . "00:00:00"); //$today_end = strtotime(date('Y-m-d', time())."23:59:59"); if ($binfo['borrow_type'] == 3) { if ($binfo['money_invest_place'] > 0) { $M_affect_money = M('member_moneylog')->where('uid = ' . $this->uid . " AND type in (6,37) AND add_time > " . $today_start . " AND add_time < " . time())->sum('affect_money'); $money_place = $binfo['money_invest_place'] + $M_affect_money; if ($money_place > 0) { ajaxmsg("此标设置有当日投标金额限制,您还需投资" . $money_place . "元才能投此秒标", 3); } } } ////////////////////////////////////待收金额限制 2013-08-26 fan/////////////////// //投标总数检测 $capital = M('borrow_investor')->where("borrow_id={$borrow_id} AND investor_uid={$this->uid}")->sum('investor_capital'); if ($capital + $money > $binfo['borrow_max'] && $binfo['borrow_max'] > 0) { $xtee = $binfo['borrow_max'] - $capital; $this->error("投资上限为{$binfo['borrow_max']}元,您已达到上限,不能再投"); //$this->error("您已投标{$capital}元,此投上限为{$binfo['borrow_max']}元,你最多只能再投{$xtee}"); } //if($binfo['has_vouch']<$binfo['borrow_money'] && $binfo['borrow_type'] == 2) $this->error("此标担保还未完成,您可以担保此标或者等担保完成再投标"); $need = $binfo['borrow_money'] - $binfo['has_borrow']; $caninvest = $need - $binfo['borrow_min']; if ($money > $caninvest && $need == 0) { $msg = "尊敬的{$uname},此标已被抢投满了,下次投标手可一定要快呦!"; $this->error($msg); } if ($binfo['borrow_min'] - $money > 0) { $this->error("尊敬的{$uname},本标最低投标金额为{$binfo['borrow_min']}元,请重新输入投标金额"); } if ($need - $money < 0) { $money = $need; } /*问题区域开始*/ // if(($need-$money)<0 ){ // $this->error("尊敬的{$uname},此标还差{$need}元满标,您最多只能再投{$need}元"); // }else{ $done = investMoney($this->uid, $borrow_id, $money); // } /*结束*/ if ($done === true) { /*5411*/ $info = "恭喜您在手投网成功投了" . $borrow_id . "号标,投标金额为:{$money}元!"; //sendsms($vm['user_phone'],$info); $progress = ($binfo['has_borrow'] + $money) / $binfo['borrow_money'] * 100; $progress = $progress > 50 ? floor($progress) : ceil($progress); //增加floor if ($this->yott()) { $yott = new yott(); $yottarr = array('subject_id' => $borrow_id, 'account_has' => $binfo['has_borrow'] + $money, 'account_wait' => $need - $money, 'has_numbers' => M("borrow_investor")->where('borrow_id=' . $borrow_id)->count('id'), 'progress' => $progress, 'status' => 100 == $progress ? 3 : 2, 'updatetime' => time(), 'reverify' => time(), 'repay_time' => time()); $res = json_decode($yott->updateP2p($yottarr)); //记录日志 M('yott_log')->add(array('dateline' => time(), 'apitype' => 'updatep2p', 'apidata' => json_encode($yottarr), 'code' => $res->code, 'msg' => $res->msg)); } if (1 == intval($_POST['isphone'])) { ajaxmsg($info); } $this->success("恭喜成功投标{$money}元"); } else { if ($done) { if (1 == intval($_POST['isphone'])) { ajaxmsg($done); } $this->error($done); } else { if (1 == intval($_POST['isphone'])) { ajaxmsg('对不起,投标失败,请刷新后重试!'); } $this->error("对不起,投标失败,请重试!"); } } }