Ejemplo n.º 1
0
 public function doEditWaitverify()
 {
     $m = D(ucfirst($this->getActionName()));
     if (false === $m->create()) {
         $this->error($m->getError());
     }
     $vm = M('borrow_info')->field('id,borrow_name,reward_num,borrow_money,capital_name,borrow_duration,repayment_type,borrow_interest_rate,borrow_uid,borrow_status,borrow_type,first_verify_time,password,updata,danbao,vouch_money,money_collect,can_auto')->find($m->id);
     $rate_lixt = explode("|", $this->glo['rate_lixi']);
     $borrow_duration = explode("|", $this->glo['borrow_duration']);
     $borrow_duration_day = explode("|", $this->glo['borrow_duration_day']);
     if (floatval($_POST['borrow_interest_rate']) > $rate_lixt[1] || floatval($_POST['borrow_interest_rate']) < $rate_lixt[0]) {
         $this->error("提交的借款利率不在允许范围,请重试", 0);
         exit;
     }
     if ($m->repayment_type == '1' && ($m->borrow_duration > $borrow_duration_day[1] || $m->borrow_duration < $borrow_duration_day[0])) {
         $this->error("提交的借款期限不在允许范围,请去网站设置处重新设置系统参数", 0);
         exit;
     }
     if ($m->repayment_type != '1' && ($m->borrow_duration > $borrow_duration[1] || $m->borrow_duration < $borrow_duration[0])) {
         $this->error("提交的借款期限不在允许范围,请去网站设置处重新设置系统参数", 0);
         exit;
     }
     ////////////////////图片编辑///////////////////////
     if (!empty($_POST['swfimglist'])) {
         foreach ($_POST['swfimglist'] as $key => $v) {
             $row[$key]['img'] = substr($v, 1);
             $row[$key]['info'] = $_POST['picinfo'][$key];
         }
         $m->updata = serialize($row);
     }
     ////////////////////图片编辑///////////////////////
     if ($vm['borrow_status'] != 2 && $m->borrow_status == 2) {
         //新标提醒
         //newTip($m->id);
         MTip('chk8', $vm['borrow_uid'], $m->id);
         //自动投标
         if ($m->borrow_type == 1) {
             memberLimitLog($vm['borrow_uid'], 1, -$m->borrow_money, $info = "{$m->id}号标初审通过");
         } elseif ($m->borrow_type == 2) {
             memberLimitLog($vm['borrow_uid'], 2, -$m->borrow_money, $info = "{$m->id}号标初审通过");
         }
         $vss = M("members")->field("user_phone,user_name")->where("id = {$vm['borrow_uid']}")->find();
         SMStip("firstV", $vss['user_phone'], array("#USERANEM#", "ID"), array($vss['user_name'], $m->id));
     }
     //if($m->borrow_status==2) $m->collect_time = strtotime("+ {$m->collect_day} days");
     if ($m->borrow_status == 2) {
         $m->collect_time = strtotime("+ {$m->collect_day} days");
         $m->reward_num = $_POST['reward_num'];
         //$m->is_tuijian = 1;
     }
     $m->money_invest_place = intval($_POST['money_invest_place']);
     $m->borrow_interest = getBorrowInterest($m->repayment_type, $m->borrow_money, $m->borrow_duration, $m->borrow_interest_rate);
     //保存当前数据对象
     if ($m->borrow_status == 2 || $m->borrow_status == 1) {
         $m->first_verify_time = time();
     } else {
         unset($m->first_verify_time);
     }
     unset($m->borrow_uid);
     $bs = intval($_POST['borrow_status']);
     //新加接口数据准备
     $toId = M('member_to')->where(array('username' => array('like', $vm['capital_name'])))->getField('id');
     if (empty($toId)) {
         $toId = M('member_to')->add(array('username' => $vm['capital_name']));
     }
     //按天到期还款、一次性还款    4
     //按月分期还款  3
     //每月还息到期还本  1
     $lilv = array(1 => 4, 5 => 4, 2 => 3, 4 => 1);
     $yottarr = array('subject_id' => $m->id, 'is_test' => '0', 'type' => 0, 'name' => $m->borrow_name, 'borrow_type' => '1', 'desc' => $m->borrow_info, 'reward' => $vm['reward_num'], 'reward_type' => '1', 'url' => MU("Home/invest", "invest", array("id" => $m->id, "suffix" => C("URL_HTML_SUFFIX")), true), 'borrow_username' => $toId, 'account' => $m->borrow_money, 'period' => $m->borrow_duration, 'period_type' => 1 == $m->repayment_type ? 1 : 0, 'apr' => $m->borrow_interest_rate, 'repay_style' => $lilv[$m->repayment_type], 'status' => '2', 'addtime' => time());
     //结束新加
     if ($result = $m->save()) {
         //保存成功
         if (2 == $bs && $this->yott()) {
             $yott = new yott();
             $res = json_decode($yott->createP2p($yottarr));
             //记录日志
             M('yott_log')->add(array('dateline' => time(), 'apitype' => 'createp2p', 'apidata' => json_encode($yottarr), 'code' => $res->code, 'msg' => $res->msg));
         }
         if ($bs == 2 || $bs == 1) {
             $verify_info['borrow_id'] = intval($_POST['id']);
             $verify_info['deal_info'] = text($_POST['deal_info']);
             $verify_info['deal_user'] = $this->admin_id;
             $verify_info['deal_time'] = time();
             $verify_info['deal_status'] = $bs;
             if ($vm['first_verify_time'] > 0) {
                 M('borrow_verify')->save($verify_info);
             } else {
                 M('borrow_verify')->add($verify_info);
             }
         }
         if ($vm['borrow_status'] != 2 && $_POST['borrow_status'] == 2 && $vm['can_auto'] == 1 && empty($vm['password']) == true) {
             if ($vm['borrow_type'] != 3) {
                 autoInvest(intval($_POST['id']));
             }
         }
         //if($vm['borrow_status']<>2 && $_POST['borrow_status']==2)) autoInvest(intval($_POST['id']));
         alogs("doEditWait", $result, 1, '初审操作成功!');
         //管理员操作日志
         //成功提示
         $this->assign('jumpUrl', __URL__ . "/" . session('listaction'));
         $this->success(L('修改成功'));
     } else {
         alogs("doEditWait", $result, 0, '初审操作失败!');
         //管理员操作日志
         //失败提示
         $this->error(L('修改失败'));
     }
 }
Ejemplo n.º 2
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("对不起,投标失败,请重试!");
         }
     }
 }
Ejemplo n.º 3
0
 protected function getSign()
 {
     $sign = $_REQUEST['sign'];
     session('sign', $sign);
     $yott = new yott();
     $decode = $yott->decodeSign($sign);
     $result = $this->VerifiStr($decode);
     return $result;
 }