Esempio n. 1
0
 /**
  * 手机普通标投资
  */
 public function Invest()
 {
     if (!$this->uid) {
         if ($this->isAjax()) {
             die("请先登录后投资");
         } else {
             $this->redirect('M/pub/login');
         }
     }
     if ($this->isAjax()) {
         // ajax提交投资信息
         $borrow_id = intval($this->_get('bid'));
         $invest_money = intval($this->_post('invest_money'));
         $paypass = $this->_post('paypass');
         $invest_pass = isset($_POST['invest_pass']) ? $_POST['invest_pass'] : '';
         $status = checkInvest($this->uid, $borrow_id, $invest_money, $paypass, $invest_pass);
         if ($status == 'TRUE') {
             $done = investMoney($this->uid, $borrow_id, $invest_money);
             if ($done === true) {
                 die('TRUE');
             } elseif ($done) {
                 die($done);
             } else {
                 die(L('investment_failure'));
             }
         } else {
             die($status);
         }
     } else {
         $borrow_id = $this->_get('bid');
         $borrow_info = M("borrow_info")->field('borrow_duration, borrow_money, borrow_interest, borrow_interest_rate, has_borrow,
                          borrow_min, borrow_max, password, repayment_type')->where("id='{$borrow_id}'")->find();
         $this->assign('borrow_info', $borrow_info);
         $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();
     }
 }
 public function Invest()
 {
     if (!$this->uid) {
         if ($this->isAjax()) {
             die("请先登录后投资");
         } else {
             $this->redirect('M/pub/login');
         }
     }
     $loanconfig = FS("Webconfig/loanconfig");
     if ($this->isAjax()) {
         // ajax提交投资信息
         $borrow_id = intval($this->_get('bid'));
         //$borrow_id ='22';
         $invest_money = intval($this->_post('invest_money'));
         //die($borrow_id);
         $paypass = $this->_post('paypass');
         $invest_pass = isset($_POST['invest_pass']) ? $_POST['invest_pass'] : '';
         $binfo = M("borrow_info")->field('borrow_money,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect, borrow_uid')->find($borrow_id);
         $status = checkInvest($this->uid, $borrow_id, $invest_money, $paypass, $invest_pass);
         if ($status == 'TRUE') {
             $invest_id = investMoney($this->uid, $borrow_id, $invest_money);
             if ($invest_id == true) {
                 $orders = date("YmdHi") . $invest_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("borrow_investor")->field("reward_money, borrow_fee")->where("id={$invest_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, $borrow_id, $invest_money, $binfo['borrow_money'], '投标', "对{$borrow_id}号投标", $secodary);
                 $loanJsonList = json_encode($loanList);
                 //$returnURL = C('WEB_URL').U("invest/investReturn");
                 $returnURL = 'http://' . $_SERVER['HTTP_HOST'] . U("/invest/wapinvestReturn");
                 $notifyURL = 'http://' . $_SERVER['HTTP_HOST'] . U("invest/notify");
                 //echo $returnURL."    notifyURL:".$notifyURL;die();
                 //var_dump($loanJsonList);die();
                 $data = $loan->transfer($loanJsonList, $returnURL, $notifyURL);
                 //var_dump($data);die();
                 $form = $loan->setForm($data, 'transfer');
                 echo $form . "正在跳转至乾多多。。。";
                 //die('TRUE');
                 exit;
                 //die('TURE');
             } elseif ($invest_id) {
                 die($invest_id);
             } else {
                 die(L('investment_failure'));
             }
         } else {
             die($status);
         }
     } else {
         $borrow_id = $this->_get('bid');
         $borrow_info = M("borrow_info")->field('borrow_duration, borrow_money, borrow_interest, borrow_interest_rate, has_borrow,
                          borrow_min, borrow_max, password, repayment_type')->where("id='{$borrow_id}'")->find();
         $this->assign('borrow_info', $borrow_info);
         $this->assign('borrow_pass', $borrow_info . password);
         $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();
     }
 }
Esempio n. 3
0
function autoInvest($borrow_id)
{
    $binfo = M("borrow_info")->field('borrow_name,borrow_uid,borrow_money,borrow_type,repayment_type,borrow_interest_rate,borrow_duration,has_vouch,has_borrow,borrow_max,borrow_min,can_auto')->find($borrow_id);
    if ($binfo['borrow_type'] == 3) {
        return true;
    }
    if ($binfo['can_auto'] == 0) {
        return true;
    }
    if ($binfo['borrow_type'] == 2 && $binfo['has_vouch'] < $binfo['borrow_money']) {
        return true;
    }
    $map['status'] = 1;
    $autolist = M("auto_borrow")->field(true)->where($map)->order("id asc")->select();
    $needMoney = $binfo['borrow_money'] - $binfo['has_borrow'];
    $borrow_user_info = M('members')->field('user_type,scores')->find($binfo['borrow_uid']);
    $xmemtype = C('XMEMBER_TYPE');
    $allrepaytype = C('REPAYMENT_TYPE');
    $allbortype = C('BORROW_TYPE');
    $have_auto_do = array();
    $smsUid = "";
    $emailUid = "";
    $errinfo = array();
    $errinfo['borrow_id'] = $borrow_id;
    foreach ($autolist as $key => $v) {
        $errinfo['fail_reason'] = "";
        $errinfo['result'] = null;
        $errinfo['auto_id'] = $v['id'];
        if (in_array($v['uid'], $have_auto_do)) {
            $errinfo['fail_reason'] = "您已有其他自动投标设置已完成自动投标";
            MTip("autoinvest", $v['uid'], $errinfo);
            continue;
        }
        if ($v['uid'] == $binfo['borrow_uid']) {
            $errinfo['fail_reason'] = "您不能投自己的标";
            MTip("autoinvest", $v['uid'], $errinfo);
            continue;
        }
        if ($v['my_friend'] == 1 || $v['not_black'] == 1) {
            $vo = M('member_friend')->where("uid={$v['uid']} AND friend_id={$binfo['borrow_uid']}")->find();
            if ($v['my_friend'] == 1 && $vo['apply_status'] != 1) {
                $errinfo['fail_reason'] = "您限制借款方必须是您的好友,但借款方不在您的好友列表或您未通过对方的好友请求";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
            if ($v['not_black'] == 1 && $vo['apply_status'] == 3) {
                $errinfo['fail_reason'] = "您限制借款方必须不在您的黑名单中,但借款方已被您列入黑名单";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
        }
        if (intval($v['target_user']) > 0 && intval($v['target_user']) != $borrow_user_info['user_type']) {
            $errinfo['fail_reason'] = "您限制借款方必须为网站的[{$xmemtype[$v['target_user']]}],但借款方为[{$xmemtype[$borrow_user_info['user_type']]}]";
            MTip("autoinvest", $v['uid'], $errinfo);
            continue;
        }
        if ($v['borrow_credit_status'] == 1) {
            if (!($borrow_user_info['scores'] <= $v['borrow_credit_last'] && $borrow_user_info['scores'] >= $v['borrow_credit_first'])) {
                $errinfo['fail_reason'] = "您限制借款方信用积分必须在{$v['borrow_credit_first']}-{$v['borrow_credit_last']}之间,但借款方信用积分实为{$borrow_user_info['scores']}";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
        }
        if (intval($v['repayment_type']) > 0) {
            if ($v['repayment_type'] != $binfo['repayment_type']) {
                $errinfo['fail_reason'] = "您限制借款方还款方式为[{$allrepaytype[$v['repayment_type']]}],但借款方还款方式为[{$allrepaytype[$binfo['repayment_type']]}]";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
        }
        if ($v['timelimit_status'] == 1) {
            if (!($binfo['borrow_duration'] <= $v['timelimit_month_last'] && $binfo['borrow_duration'] >= $v['timelimit_month_first'])) {
                $durstr = "月";
                if ($binfo['repayment_type'] == 1) {
                    $durstr = "天";
                }
                $errinfo['fail_reason'] = "您限制借款期限必须{$v['timelimit_month_first']}个月-{$v['timelimit_month_last']}个月之间,但该借款期限为{$binfo['borrow_duration']}{$durstr}";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
        }
        if ($v['apr_status'] == 1) {
            if (!($binfo['borrow_interest_rate'] <= $v['apr_last'] && $binfo['borrow_interest_rate'] >= $v['apr_first'])) {
                $errinfo['fail_reason'] = "您限制借款年化利率必须在{$v['apr_first']}%-{$v['apr_last']}%之间,但该借款年化利率为{$binfo['borrow_interest_rate']}%";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
        }
        if (intval($v['borrow_type']) > 0) {
            if ($v['borrow_type'] != $binfo['borrow_type']) {
                $errinfo['fail_reason'] = "您限制借款标类型必须为[{$allbortype[$v['borrow_type']]}],但该借款标类型为[{$allbortype[$binfo['borrow_type']]}]";
                MTip("autoinvest", $v['uid'], $errinfo);
                continue;
            }
        }
        if ($v['tender_type'] == 1) {
            $investMoney = $v['tender_account'];
        } elseif ($v['tender_type'] == 2) {
            $investMoney = $v['tender_rate'] * $binfo['borrow_money'] / 100;
        } elseif ($v['tender_type'] == 3) {
            $vminfo = getMinfo($v['uid'], 'm.user_leve,m.time_limit,mm.account_money');
            $investMoney = floor($vminfo['account_money']);
        }
        if ($investMoney < $binfo['borrow_min']) {
            if ($investMoney > 0) {
                $errinfo['fail_reason'] = "您的自动投资金额为{$investMoney}元,该标最低投资金额限制最低为{$binfo['borrow_min']}元";
                MTip("autoinvest", $v['uid'], $errinfo);
            }
            continue;
            //不符合最低投资金额
        }
        if ($investMoney > $binfo['borrow_max'] && $binfo['borrow_max'] > 0) {
            $errinfo['fail_reason'] = "您的自动投资金额为{$investMoney}元,该标投资金额限制最高为{$binfo['borrow_max']}元,已自动为您调整成{$binfo['borrow_max']}元";
            $investMoney = $binfo['borrow_max'];
        }
        //不能超过标金额比例20%
        $sysmax = floor($binfo['borrow_money'] * 20 / 100);
        if ($investMoney > $sysmax && $sysmax > 0) {
            if (!empty($errinfo['fail_reason'])) {
                $errinfo['fail_reason'] = $errinfo['fail_reason'] . ";";
            }
            $errinfo['fail_reason'] = $errinfo['fail_reason'] . "系统限制自动投标金额不能超过标金额20%,即{$sysmax}元,您的投标金额为{$investMoney}元,超过系统最大限制,已自动调整成{$sysmax}元";
            $investMoney = $sysmax;
        }
        // 投标后的状态
        $x = investMoney($v['uid'], $borrow_id, $investMoney, 1, $v['id']);
        if ($x === true) {
            $have_auto_do[] = $v['uid'];
            MTip('chk27', $v['uid'], $borrow_id);
            //sss
            $systips = M("sys_tip")->find($v['uid']);
            if (checkNeedTip($systips, 'autoborrow_3')) {
                $smsUid .= empty($smsUid) ? $v['uid'] : ",{$v['uid']}";
            }
            if (checkNeedTip($systips, 'autoborrow_2')) {
                $emailUid .= empty($emailUid) ? $v['uid'] : ",{$v['uid']}";
            }
        } else {
            if (strpos($x, "对不起,此标还差") !== false && strpos($x, "对不起,此标还差0元满标") === false) {
                $extbinfo = M("borrow_info")->field("borrow_money,has_borrow")->find($borrow_id);
                $havemoney = $extbinfo['has_borrow'];
                $investMoney = $extbinfo['borrow_money'] - $havemoney;
                if (!empty($errinfo['fail_reason'])) {
                    $errinfo['fail_reason'] = $errinfo['fail_reason'] . ";";
                }
                $x = "";
                if ($investMoney > 0) {
                    $errinfo['fail_reason'] = $errinfo['fail_reason'] . "此标剩余金额{$investMoney},已自动为您调整";
                    $x = investMoney($v['uid'], $borrow_id, $investMoney, 1, $v['id']);
                } else {
                    $errinfo['fail_reason'] = $errinfo['fail_reason'] . "此标剩余金额{$investMoney},无法再投标";
                }
                if ($x === true) {
                    $errinfo['result'] = "成功";
                    MTip("autoinvest", $v['uid'], $errinfo);
                    $have_auto_do[] = $v['uid'];
                    $systips = M("sys_tip")->find($v['uid']);
                    if (checkNeedTip($systips, 'autoborrow_3')) {
                        $smsUid .= empty($smsUid) ? $v['uid'] : ",{$v['uid']}";
                    }
                    if (checkNeedTip($systips, 'autoborrow_2')) {
                        $emailUid .= empty($emailUid) ? $v['uid'] : ",{$v['uid']}";
                    }
                } else {
                    if (!empty($errinfo['fail_reason']) && !empty($x)) {
                        $errinfo['fail_reason'] = $errinfo['fail_reason'] . ";";
                        $errinfo['fail_reason'] = $errinfo['fail_reason'] . $x;
                    }
                    MTip("autoinvest", $v['uid'], $errinfo);
                }
            } else {
                if (!empty($errinfo['fail_reason'])) {
                    $errinfo['fail_reason'] = $errinfo['fail_reason'] . ";";
                }
                $errinfo['fail_reason'] = $errinfo['fail_reason'] . $x;
                MTip("autoinvest", $v['uid'], $errinfo);
            }
        }
    }
    $pre = C("DB_PREFIX");
    //短信提醒
    if (!empty($smsUid)) {
        $vphone = M("members")->alias("m")->join("{$pre}members_status ms on ms.uid=m.id")->field("m.user_phone")->where("m.id in({$smsUid}) and ms.phone_status=1")->select();
        $sphone = "";
        foreach ($vphone as $v) {
            $sphone .= empty($sphone) ? $v['user_phone'] : ",{$v['user_phone']}";
        }
        $innerbody = "您设置的自动投标对第{$borrow_id}号借_款进行了投标";
        SMStip3("autoinvest", $sphone, $innerbody, $borrow_id, $smsUid);
    }
    //邮件提醒
    if (!empty($emailUid)) {
        $link = '<br /><a href="http://' . $_SERVER['HTTP_HOST'] . '/invest/' . $borrow_id . '.html" style="color:#91273d">点击查看借款标[' . $binfo['borrow_name'] . ']</a>';
        $msgconfig = FS("Webconfig/msgconfig");
        $sender = $msgconfig['stmp']['user'];
        $receivers = M("members")->alias("m")->join("{$pre}members_status ms on ms.uid=m.id")->field("m.user_email email,m.id uid,'to' type")->where("m.id in({$emailUid}) and ms.email_status=1")->select();
        massEmailLog($innerbody, $innerbody . $link, "autoinvest", $sender, $receivers, null, null, $borrow_id);
    }
}
Esempio n. 4
0
 public function investmoney()
 {
     if (!$this->uid) {
         ajaxmsg('请先登录', 3);
         exit;
     }
     $money = intval($_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 ($amoney < $money) {
         $this->error("尊敬的{$uname},您准备投标{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再投标.", __APP__ . "/member/charge#fragment-1");
     }
     $vm = getMinfo($this->uid, 'm.pin_pass,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,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect')->find($borrow_id);
     ////////////////////////////////////待收金额限制 2013-08-26  fan///////////////////
     if ($binfo['money_collect'] > 0) {
         if ($m['money_collect'] < $binfo['money_collect']) {
             ajaxmsg("此标设置有投标待收金额限制,您账户里必须有足够的待收才能投此标", 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("您已投标{$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) {
         $this->error("尊敬的{$uname},此标还差{$need}元满标,您最多只能再投{$need}元");
     } else {
         $done = investMoney($this->uid, $borrow_id, $money);
     }
     if ($done === true) {
         $this->success("恭喜成功投标{$money}元");
     } else {
         if ($done) {
             $this->error($done);
         } else {
             $this->error("对不起,投标失败,请重试!");
         }
     }
 }
Esempio n. 5
0
 public function investmoney()
 {
     $jsoncode = file_get_contents("php://input");
     //alogsm("investmoney",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("查询错误f!", 0);
     }
     if (!is_array($arr) || empty($arr) || empty($arr['borrow_id']) || empty($arr['zhifu_money']) || !in_array($arr['type'], array(3, 4, 5, 6, 7))) {
         ajaxmsg("查询错误g!", 0);
     }
     $pre = C('DB_PREFIX');
     $_pin = $arr['pin'];
     $pin = md5($_pin);
     $borrow_id = intval($arr['borrow_id']);
     $money = $arr['zhifu_money'];
     //		$_pin = "123456";
     //		$pin = md5($_pin);
     //		$borrow_id = 23;
     //		$money = 60;
     //
     $borrow_pass = $arr['borrow_pass'];
     $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 ($amoney < $money) {
         ajaxmsg("尊敬的{$uname},您准备投标{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再投标.", 0);
     }
     $vm = getMinfo($this->uid, 'm.pin_pass,mm.account_money,mm.back_money,mm.money_collect');
     $pin_pass = $vm['pin_pass'];
     //if($pin<>$pin_pass) ajaxmsg("支付密码错误,请重试",2);
     $binfo = M("borrow_info")->field('borrow_money,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect,borrow_uid')->find($borrow_id);
     ////////////////////////////////////待收金额限制 2013-08-26  fan///////////////////
     if ($binfo['money_collect'] > 0) {
         if ($m['money_collect'] < $binfo['money_collect']) {
             ajaxmsg("此标设置有投标待收金额限制,您账户里必须有足够的待收才能投此标", 0);
         }
     }
     ////////////////////////////////////待收金额限制 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;
         ajaxmsg("您已投标{$capital}元,此投上限为{$binfo['borrow_max']}元,你最多只能再投{$xtee}", 0);
     }
     //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 - $money != 0) {
         $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>或者投标金额必须<font color='#FF0000'>小于等于{$caninvest}元</font>";
         if ($caninvest < $binfo['borrow_min']) {
             $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>即投标金额必须<font color='#FF0000'>等于{$need}元</font>";
         }
         ajaxmsg($msg, 0);
     }
     if ($need - $money < 0) {
         ajaxmsg("尊敬的{$uname},此标还差{$need}元满标,您最多只能再投{$need}元", 0);
     } else {
         $invest_id = investMoney($this->uid, $borrow_id, $money);
     }
     $loanconfig = FS("Webconfig/loanconfig");
     if ($invest_id) {
         // 发送到乾多多
         $orders = date("YmdHi") . $invest_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("borrow_investor")->field("reward_money, borrow_fee")->where("id={$invest_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'] = $orders;
         $loanJsonList['BatchNo'] = $borrow_id;
         $loanJsonList['Amount'] = $money;
         $loanJsonList['FullAmount'] = $binfo['borrow_money'];
         $loanJsonList['TransferName'] = '投标';
         $loanJsonList['Remark'] = "对{$borrow_id}号投标";
         //$loanJsonList['SecondaryJsonList'] = $secodarys;
         //$loanJsonList = json_encode($loanList);
         //$returnURL = C('WEB_URL').U("invest/investReturn");
         //$returnURL = 'http://'.$_SERVER ['HTTP_HOST'].U("/invest/investReturn");
         //  $notifyURL = C('WEB_URL').U("member/notify/notifys");
         //$returnURL = 'http://'.$_SERVER ['HTTP_HOST'].U("/invest/investReturn");
         $notifyURL = C('WEB_URL') . "/invest/notify";
         $data1 = $loan->transfer('', $returnURL, $notifyURL);
         $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;
         // $data['loanJsonLists'] = $loanJsonList;
         // $data['SecondaryJsonList'] = $secodarys;
         ajaxmsg($data);
     } else {
         $this->error("对不起,投标失败,请重试!");
     }
 }
Esempio n. 6
0
 public function doMoneyComplete()
 {
     $pre = C('DB_PREFIX');
     $borrow_id = $_REQUEST['id'];
     $money = intval($_POST['lastmoney']);
     $uid = $_REQUEST['uid'];
     if (empty($uid)) {
         $this->error("请选择投资人");
     }
     $vm = M('borrow_info')->field('borrow_status')->find($borrow_id);
     if ($vm['borrow_status'] != 2) {
         $this->error('该标借款状态不在借款中,无法执行满标处理!');
         exit;
     } else {
         $done = investMoney($uid, $borrow_id, $money);
         if ($done === true) {
             alogs("doMoneyComplete", 0, 1, '人工处理低于最小投标金额无法正常满标的数据操作成功!');
             //管理员操作日志
             $this->success("恭喜成功投标{$money}元");
         } else {
             if ($done) {
                 $this->error($done);
             } else {
                 alogs("doMoneyComplete", 0, 1, '人工处理低于最小投标金额无法正常满标的数据操作成功!');
                 //管理员操作日志
                 $this->error("对不起,投标失败,请重试!");
             }
         }
     }
 }
Esempio n. 7
0
 public function _initiativetenderreturnAct()
 {
     file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " returnplant异步:" . print_r($_POST, true) . "\n", FILE_APPEND);
     $is_avail = $this->is_avail($_POST);
     if ($is_avail) {
         $usrid = $_POST['UsrCustId'];
         $db = core::Singleton('comm.db.activeRecord');
         $db->connect('CAILAI');
         $info = $db->get_one($where = array('usrid' => $usrid), '', 'lzh_huifulog');
         //                file_get_contents('/tmp/3',json_encode($_POST));
         //$info = M("huifulog")->distinct(true)->field("uid,username")->where('usrid' => $usrid)->find();
         $data = array();
         $data['uid'] = $info['uid'];
         //用户UID
         $data['username'] = $info['username'];
         //用户名
         $data['rescode'] = $_POST['RespCode'];
         //返回码
         $data['cmdid'] = $_POST['CmdId'];
         //消息类型
         $data['usrid'] = $_POST['UsrCustId'];
         //用户客户号
         $data['ordid'] = $_POST['OrdId'];
         //订单号
         $data['orddate'] = $_POST['OrdDate'];
         //订单日期
         $data['trxid'] = $_POST['TrxId'];
         //交易流水号
         $data['merpriv'] = $_POST['MerPriv'];
         $data['addtime'] = time();
         //记录时间
         //防止钱投完使用红包不扣款的bug出现
         $reqext = $_POST['RespExt'];
         //代金券的内容json字符串
         $reqext = urldecode($reqext);
         $reqext = json_decode($reqext, 1);
         $reqext = $reqext['Vocher']['VocherAmt'];
         file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " returnplant异步红包:" . print_r($reqext, true) . "\n", FILE_APPEND);
         sleep(1);
         //防止与前台回调同步到达
         $condition['uid'] = $data['uid'];
         $condition['ordid'] = $data['ordid'];
         $num = $db->count_all($condition, 'lzh_huifulog');
         if ($num === 0) {
             //                        $db = core::Singleton('comm.db.activeRecord');
             //                        $db->connect('CAILAI');
             $db->insert($data, 'lzh_huifulog');
             if (strcmp($_POST['RespCode'], "000") == 0) {
                 $temp = base64_decode($data['merpriv']);
                 $pos1 = strpos($temp, '{');
                 $pos2 = strpos($temp, '}');
                 $len = $pos2 - $pos1 + 1;
                 $merpriv = substr($temp, $pos1, $len);
                 $merpriv = json_decode($merpriv, true);
                 //				file_put_contents('/tmp/4.txt',date('m-d H:i:s')." return  ".print_r($merpriv,true)."\n",FILE_APPEND);
                 $borrow_id = $merpriv['borrowid'];
                 //标ID
                 $money = str2val_money($_POST['TransAmt']);
                 //交易金额
                 $info = array();
                 $info['ordid'] = $data['ordid'];
                 //订单号
                 $info['orddate'] = $data['orddate'];
                 //订单日期
                 $info['freezeordid'] = $_POST['FreezeOrdId'];
                 //冻结订单号
                 $info['freezetrxid'] = $_POST['FreezeTrxId'];
                 //冻结流水号
                 //                                $db = core::Singleton('comm.db.activeRecord');
                 $db->connect('CAILAI');
                 $invest_info_id = $db->insert($info, 'lzh_borrow_investor');
                 //				$invest_info_id = M('borrow_investor')->add($info);
                 //剪去红包的钱 才是真正扣掉的钱
                 //$money=$money-$reqext;
                 file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " returnplant真钱:" . print_r($money, true) . "\n", FILE_APPEND);
                 $l = investMoney($data['uid'], $borrow_id, $money, 0, $invest_info_id, $reqext);
                 $borrowName = getBorrowName($borrow_id);
                 $realName = getRealName($data['uid']);
                 $content = "尊敬的财来网投资人" . $realName['real_name'] . ",您于" . date("Y") . "年" . date("m") . "月" . date("d") . "日" . date("H") . ":" . date("i") . "分向" . $borrowName['borrow_name'] . "标的投资" . $money . "元,资金已冻结,将于满标复审后计息,详情请咨询客户经理,或致电400-079-8558";
                 sendsms(trim($data['username']), $content);
             }
         }
         echo "RECV_ORD_ID_" . $_POST['OrdId'];
     }
     exit;
 }
Esempio n. 8
0
function autoInvest($borrow_id)
{
    $datag = get_global_setting();
    $binfo = M("borrow_info")->field('borrow_uid,borrow_money,borrow_type,repayment_type,borrow_interest_rate,borrow_duration,has_vouch,has_borrow,borrow_max,borrow_min,can_auto')->find($borrow_id);
    if ($binfo['can_auto'] == '0') {
        return;
    }
    $map['a.is_use'] = 1;
    $map['a.borrow_type'] = 1;
    $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['has_borrow'];
    foreach ($autolist as $key => $v) {
        if (!$needMoney) {
            break;
        }
        if ($v['uid'] == $binfo['borrow_uid']) {
            continue;
        }
        $num_max1 = intval($v['money'] - $v['account_money']);
        //账户余额-设置的最少剩余金额,即可用的投资金额数
        $num_max4 = $binfo['borrow_money'] * $datag['auto_rate'] / 100;
        //不能超过10%
        if ($v['invest_money'] > $binfo['borrow_max'] && $binfo['borrow_max'] > 0) {
            // 大于最大投标 且设置最大投标
            $investMoney = $binfo['borrow_max'];
        }
        if ($num_max1 > $v['invest_money']) {
            //如果可用的投资金额大于最大投资金额,则投资金额等于最大投资金额
            $investMoney = $v['invest_money'];
        } else {
            $investMoney = $num_max1;
            //如果未设置投标后账户余额,则会投出全部余额
        }
        if ($investMoney > $needMoney) {
            $investMoney = $needMoney;
        } else {
            if ($binfo['borrow_min']) {
                //设置了最小投标    如果直接满标则不考虑最小投标
                if ($investMoney < $binfo['borrow_min']) {
                    // 小于最低投标
                    continue;
                    //不符合最低投资金额
                } elseif ($needMoney - $investMoney > 0 && $needMoney - $investMoney < $binfo['borrow_min']) {
                    // 剩余金额小于最小投标金额
                    if ($investMoney - $binfo['borrow_min'] >= $binfo['borrow_min']) {
                        // 投资金额- 最小投资金额 大于最小投资金额
                        $investMoney = $investMoney - $binfo['borrow_min'];
                        // 投资 = 投资-最小投资(保证下次投资金额大于最小投资金额)
                    } else {
                        continue;
                    }
                }
            }
        }
        if ($investMoney > $num_max4) {
            //投资金额不能大于借款金额的10%
            $investMoney = $num_max4;
        }
        if ($investMoney % $binfo['borrow_min'] != 0 && $investMoney % $binfo['borrow_min'] > 0) {
            //如果当前可投金额不是最小投资金额的整数倍
            $investMoney = $binfo['borrow_min'] * floor($investMoney % $binfo['borrow_min']);
        }
        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 (!($investMoney >= $v['min_invest'])) {
            //
            continue;
        }
        if (!($v['money'] - $v['account_money'] >= $investMoney)) {
            //余额限制
            continue;
        }
        if ($needMoney <= 0) {
            //可投金额必须大于0
            continue;
        }
        $x = investMoney($v['uid'], $borrow_id, $investMoney, 1);
        if ($x === true) {
            $needMoney = $needMoney - $investMoney;
            // 减去剩余已投金额
            MTip('chk27', $v['uid'], $borrow_id, $v['id']);
            //sss
            M('auto_borrow')->where('id = ' . $v['id'])->save(array("invest_time" => time()));
        }
    }
    return true;
}
Esempio n. 9
0
 public function investmoney()
 {
     $jsoncode = file_get_contents("php://input");
     //alogsm("investmoney",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['pin']) || empty($arr['borrow_id']) || empty($arr['money']) || !in_array($arr['type'], array(3, 4, 5, 6, 7))) {
         ajaxmsg("查询错误!", 0);
     }
     $pre = C('DB_PREFIX');
     $_pin = $arr['pin'];
     $pin = md5($_pin);
     $borrow_id = intval($arr['borrow_id']);
     $money = intval($arr['money']);
     //		$_pin = "123456";
     //		$pin = md5($_pin);
     //		$borrow_id = 23;
     //		$money = 60;
     //
     $borrow_pass = $arr['borrow_pass'];
     $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 ($amoney < $money) {
         ajaxmsg("尊敬的{$uname},您准备投标{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再投标.", 3);
     }
     $vm = getMinfo($this->uid, 'm.pin_pass,mm.account_money,mm.back_money,mm.money_collect');
     $pin_pass = $vm['pin_pass'];
     if ($pin != $pin_pass) {
         ajaxmsg("支付密码错误,请重试", 2);
     }
     $binfo = M("borrow_info")->field('borrow_money,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect')->find($borrow_id);
     ////////////////////////////////////待收金额限制 2013-08-26  fan///////////////////
     if ($binfo['money_collect'] > 0) {
         if ($m['money_collect'] < $binfo['money_collect']) {
             ajaxmsg("此标设置有投标待收金额限制,您账户里必须有足够的待收才能投此标", 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;
         ajaxmsg("您已投标{$capital}元,此投上限为{$binfo['borrow_max']}元,你最多只能再投{$xtee}", 3);
     }
     //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 - $money != 0) {
         $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>或者投标金额必须<font color='#FF0000'>小于等于{$caninvest}元</font>";
         if ($caninvest < $binfo['borrow_min']) {
             $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>即投标金额必须<font color='#FF0000'>等于{$need}元</font>";
         }
         ajaxmsg($msg, 3);
     }
     if ($need - $money < 0) {
         ajaxmsg("尊敬的{$uname},此标还差{$need}元满标,您最多只能再投{$need}元", 3);
     } else {
         $done = investMoney($this->uid, $borrow_id, $money);
     }
     if ($done === true) {
         $_msg['type'] = $arr['type'];
         $_msg['id'] = $borrow_id;
         $_msg['message'] = "恭喜成功投标{$money}元";
         ajaxmsg($_msg, 1);
     } else {
         if ($done) {
             ajaxmsg($done, 3);
         } else {
             ajaxmsg("对不起,投标失败,请重试!", 3);
         }
     }
 }
Esempio n. 10
0
 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("对不起,投标失败,请重试!");
         }
     }
 }
Esempio n. 11
0
 public function autotenderret()
 {
     $usrid = $_POST['UsrCustId'];
     $info = M("huifulog")->distinct(true)->field("uid,username")->where("usrid=" . $usrid)->find();
     $data = array();
     $data['uid'] = $info['uid'];
     //用户UID
     $data['username'] = $info['username'];
     //用户名
     $data['rescode'] = $_POST['RespCode'];
     //返回码
     $data['cmdid'] = $_POST['CmdId'];
     //消息类型
     $data['usrid'] = $_POST['UsrCustId'];
     //用户客户号
     $data['ordid'] = $_POST['OrdId'];
     //订单号
     $data['orddate'] = $_POST['OrdDate'];
     //订单日期
     $data['trxid'] = $_POST['TrxId'];
     //交易流水号
     $data['merpriv'] = $_POST['MerPriv'];
     $data['addtime'] = time();
     //记录时间
     $condition['uid'] = $data['uid'];
     $condition['ordid'] = $data['ordid'];
     $num = M("huifulog")->where($condition)->count();
     if ($num == 0) {
         M("huifulog")->add($data);
         if (strcmp($_POST['RespCode'], "000") == 0) {
             $temp = base64_decode($data['merpriv']);
             $pos1 = strpos($temp, '{');
             $pos2 = strpos($temp, '}');
             $len = $pos2 - $pos1 + 1;
             $merpriv = substr($temp, $pos1, $len);
             $merpriv = json_decode($merpriv, true);
             $borrow_id = $merpriv['borrowid'];
             //标ID
             $money = str2val_money($_POST['TransAmt']);
             $info = array();
             $info['ordid'] = $data['ordid'];
             $info['orddate'] = $data['orddate'];
             $info['freezeordid'] = $_POST['FreezeOrdId'];
             $info['freezetrxid'] = $_POST['FreezeTrxId'];
             $invest_info_id = M('borrow_investor')->add($info);
             investMoney($data['uid'], $borrow_id, $money, 1, $invest_info_id);
         }
     }
     echo "RECV_ORD_ID_" . $_POST['OrdId'];
 }
Esempio n. 12
0
 public function investmoney()
 {
     if (!$this->uid) {
         exit;
     }
     /****** 防止模拟表单提交 *********/
     $cookieKeyS = cookie(strtolower(MODULE_NAME) . "-invest");
     /*if($cookieKeyS!=$_REQUEST['cookieKey']){
     			$this->error("数据校验有误");
     		}*/
     /****** 防止模拟表单提交 *********/
     $money = intval($_POST['money']);
     $borrow_id = intval($_POST['borrow_id']);
     $amoney = M("member_money")->getFieldByUid($this->uid, 'account_money');
     $uname = session('u_user_name');
     if ($amoney < $money) {
         $this->error("尊敬的{$uname},您准备投标{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再投标.");
     }
     $vm = getMinfo($this->uid);
     $pin_pass = $vm['pin_pass'];
     $pin = md5($_POST['pin']);
     if ($pin != $pin_pass) {
         $this->error("支付密码错误,请重试");
     }
     $binfo = M("borrow_info")->field('borrow_money,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min')->find($borrow_id);
     //投标总数检测
     $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("您已投标{$capital}元,此投上限为{$binfo['borrow_max']}元,你最多只能再投{$xtee}", 3);
     }
     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 - $money != 0) {
         $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>或者投标金额必须<font color='#FF0000'>小于等于{$caninvest}元</font>";
         if ($caninvest < $binfo['borrow_min']) {
             $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>即投标金额必须<font color='#FF0000'>等于{$need}元</font>";
         }
         $this->error($msg);
     }
     $done = investMoney($this->uid, $borrow_id, $money);
     //$this->display("Public:_footer");
     //$this->assign("waitSecond",1000);
     if ($done === true) {
         $this->success("恭喜成功投标{$money}元");
     } elseif ($done) {
         $this->error($done);
     } else {
         $this->error("对不起,投标失败,请重试!");
     }
 }
Esempio n. 13
0
 public function investmoney()
 {
     $jsoncode = file_get_contents("php://input");
     //alogsm("investmoney",0,1,session("u_id").$jsoncode);
     if (!$this->uid) {
         ajaxmsg('请先登录', 0);
     }
     $arr = array();
     $arr = json_decode($jsoncode, true);
     if (intval($arr['uid']) != $this->uid) {
         ajaxmsg("查询错误f!", 0);
     }
     if (!is_array($arr) || empty($arr) || empty($arr['borrow_id']) || empty($arr['zhifu_money'])) {
         ajaxmsg("查询错误g!", 0);
     }
     $pre = C('DB_PREFIX');
     $_pin = $arr['pin'];
     $pin = md5($_pin);
     $borrow_id = intval($arr['borrow_id']);
     $money = $arr['zhifu_money'];
     //
     $borrow_pass = $arr['borrow_pass'];
     $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 ($amoney < $money) {
         ajaxmsg("尊敬的{$uname},您准备投标{$money}元,但您的账户可用余额为{$amoney}元,请先去充值再投标.", 0);
     }
     $vm = getMinfo($this->uid, 'm.pin_pass,m.user_phone,mm.account_money,mm.back_money,mm.money_collect');
     //$pin_pass = $vm['pin_pass'];
     //var_dump($vm);die;
     if ($pin != $vm['pin_pass']) {
         ajaxmsg("支付密码错误,请重试", 2);
     }
     $binfo = M("borrow_info")->field('borrow_money,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect,borrow_uid,password')->find($borrow_id);
     if (!empty($binfo['password'])) {
         if (empty($borrow_pass)) {
             ajaxmsg("此标是定向标,必须验证定向标密码", 3);
         } else {
             if ($binfo['password'] != md5($borrow_pass)) {
                 ajaxmsg("定向标密码不正确", 3);
             }
         }
     }
     ////////////////////////////////////待收金额限制 2013-08-26  fan///////////////////
     if ($money % $binfo['borrow_min'] != 0) {
         ajaxmsg("投标金额必须为起投金额的整数倍", 3);
     }
     if ($binfo['money_collect'] > 0) {
         if ($m['money_collect'] < $binfo['money_collect']) {
             ajaxmsg("此标设置有投标待收金额限制,您账户里必须有足够的待收才能投此标", 0);
         }
     }
     $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;
         ajaxmsg("您已投标{$capital}元,此投上限为{$binfo['borrow_max']}元,你最多只能再投{$xtee}", 0);
     }
     //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 - $money != 0) {
         $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>或者投标金额必须<font color='#FF0000'>小于等于{$caninvest}元</font>";
         if ($caninvest < $binfo['borrow_min']) {
             $msg = "尊敬的{$uname},此标还差{$need}元满标,如果您投标{$money}元,将导致最后一次投标最多只能投" . ($need - $money) . "元,小于最小投标金额{$binfo['borrow_min']}元,所以您本次可以选择<font color='#FF0000'>满标</font>即投标金额必须<font color='#FF0000'>等于{$need}元</font>";
         }
         ajaxmsg($msg, 0);
     }
     if ($need - $money < 0) {
         ajaxmsg("尊敬的{$uname},此标还差{$need}元满标,您最多只能再投{$need}元", 0);
     } else {
         $done = investMoney($this->uid, $borrow_id, $money);
     }
     if ($done === true) {
         //$_msg['type'] = $arr['type'];
         $info = "恭喜您在手投网成功投了" . $borrow_id . "号标,投标金额为:{$money}元!【手投网】";
         sendsms($vm['user_phone'], $info);
         $_msg['id'] = $borrow_id;
         $_msg['message'] = "恭喜成功投标{$money}元";
         ajaxmsg($_msg, 1);
     } else {
         if ($done) {
             ajaxmsg($done, 3);
         } else {
             ajaxmsg("对不起,投标失败,请重试!", 3);
         }
     }
 }