コード例 #1
0
ファイル: InvestAction.class.php プロジェクト: GStepOne/CI
 public function newbieinvest()
 {
     if (!$this->uid) {
         ajaxmsg('请先登录', 3);
         exit;
     }
     $type = member_type($this->uid);
     if ($type['status'] != 3) {
         ajaxmsg("您是" . $type['type'] . "用户不能投标", 3);
     }
     $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'];
     //是否使用了红包
     $redvalue = intval($_POST['redvalue']);
     //红包面值
     $uname = session('u_user_name');
     if ($redvalue) {
         // $redtotal=M("active_redpacket")->field('sum(facevalue) as f')->where('owner='.$this->uid)->select();
         //查询红包总额
         $myown = $redvalue + $amoney;
         //包括我的红包
         if ($money > $myown) {
             $msg = '您的账户可用余额与所选红包总额' . $myown . ',不足支付所投资的金额';
             ajaxmsg($msg, 5);
         }
     } else {
         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']);
     //这里用来判断 是否投过此新手标 根据$uid
     $is_access = M('newbie_record')->getFieldByInvest_uid($this->uid, 'id');
     //$this->uid
     if ($is_access) {
         ajaxmsg("尊敬的财来用户,此标只能进行一次投标,您已经投过此标。", 3);
     }
     $binfo = M("newbie_bid")->find($borrow_id);
     //查询此新手标信息
     if ($binfo['min'] > $money) {
         $this->error("尊敬的{$uname},本标最低投标金额为{$binfo['min']}元,请重新输入投标金额", 3);
     } else {
         if ($binfo['max'] < $money) {
             $this->error("尊敬的{$uname},本标最高投标金额为{$binfo['max']}元,请重新输入投标金额", 3);
         }
     }
     $pre = C('DB_PREFIX');
     $info1 = M("members")->field("usrid")->where("id=" . $this->uid)->find();
     $info2 = M("members m")->field("m.usrid")->join("{$pre}newbie_bid s ON s.borrow_uid=m.id")->where("s.id = {$borrow_id}")->find();
     //  $info2=M("newbie_bid")->field('borrow_uid')->where('id='.$borrowid)->find();
     $usrid = $info1['usrid'];
     $borrowerid = $info2['usrid'];
     $redvalue = number_format($_POST['redvalue'], 2);
     //红包的面值
     $redid = $_POST['redid'];
     //红包的id
     $transamt = $money;
     $type = "S";
     //表示散标
     $borrowid = $borrow_id;
     //标id $borrow_id
     if ($redvalue != 0) {
         $ext = array('Vocher' => array('AcctId' => 'MDT000001', 'VocherAmt' => $redvalue));
         $reqExt = $ext;
     }
     import("ORG.Huifu.Huifu");
     $huifu = new Huifu();
     //新手标投资要重写
     $huifu->newbie_initiativeTender($usrid, $transamt, $borrowerid, $borrowid, $reqExt, $redvalue, $redid);
 }