コード例 #1
0
 public function payback($payinfo = '', $type = true)
 {
     $data = M('ProjectInvestor')->where(array('id' => $payinfo['orderid'], 'status' => array('egt', '0')))->find();
     if ($data['status'] == 8) {
         M('ProjectInvestor')->save(array('status' => 9, 'pay_way' => 1, 'id' => $payinfo['orderid'], 'update_time' => NOW_TIME));
         //更新待办事件
         update_pj_dolist($data['investor_id'], 2);
     }
     if ($type == true) {
         $this->success('投资处理成功。', U('MCenter/pj_support'));
     }
 }
コード例 #2
0
 public function follow()
 {
     $id = I('id');
     if ($id == 2) {
         $this->display('Tea/invest');
         return;
     }
     $uid = is_login();
     if (!$uid) {
         $this->redirect('User/login');
     }
     /*
     		$where = array('uid' => $uid, 'status' => 9, 'auth_id'=>1);
     		$auth = M('UserAuth')->where($where)->count();
     		$phone = M('UcenterMember')->find($uid);
     		
     		if (!$auth || empty($phone['mobile'])) {
     			$this->error('您还没有完成实名认证或绑定手机,完善后方可投资。'.showface('waiting'),
     			 U('User/savecenter'));
     		}*/
     $project = D('ProjectFundView')->where(array('p.id' => $id))->find();
     if (!$project) {
         $this->error('项目不存在!');
     } else {
         if ($project['uid'] == $uid) {
             $this->error('不允许项目发起人,对自己的项目进行投资。');
         }
     }
     $inve = M('ProjectInvestor')->where(array('project_id' => $id, 'investor_id' => $uid))->select();
     $count = 0;
     foreach ($inve as $k => $v) {
         if ($v['status'] >= 2) {
             $message = "您的投资已经被项目方接受,不能重复投资。如需更改投资金额,请先前往用户中心撤消投资。";
             $this->error($message, U('./MCenter'));
             break;
         }
         if ($v['status'] == -1) {
             $count++;
             if ($count >= 5) {
                 $message = '您不能对该项目进行投资(该项目您有五次撤消投资记录)。';
                 break;
             }
         }
     }
     if (isset($message)) {
         $this->error($message);
     }
     if (IS_POST) {
         $thisProject = D('Project');
         $validateUser = $thisProject->checkAuth();
         if (!$validateUser['success']) {
             $this->error('没有实名认证');
         }
         $investor = array('project_id' => $id, 'fund' => $_POST['fund'], 'others' => $_POST['others'], 'lead_type' => 3);
         if ($project['need_fund'] < $investor['fund']) {
             $this->error('跟投额必须小于' . round($project['need_fund'], 2) . '元。');
         } else {
             if ($project['follow_fund'] > $investor['fund']) {
                 $this->error('跟投额必须大于或者等于' . round($project['follow_fund'], 2) . '元。');
             }
         }
         //			if ($project['type'] == 0 && ($investor['fund'] % 1000) > 0) {
         //				$this->error('投资金额必须是1000的倍数。');
         //			}
         if ($_POST['leader_type'] == 1) {
             if (!empty($project['leader_id'])) {
                 $this->error('该项目已经指定了领投人,不能申请领投。');
             }
             if (empty($investor['others'])) {
                 $this->error('如果您想申请成为领投人,请填写投资理由。以方便项目方确认。');
             }
             $investor['lead_type'] = 2;
             $count = M('ProjLeader')->where(array('pid' => $id, 'uid' => $uid, 'status' => array('egt', 0), 'del_flag' => 0))->count();
             if ($count > 0) {
                 $this->error('您已经申请了该项目的领投,请不要重复申请。');
             }
             $temp = array('pid' => $id, 'uid' => $uid, 'fund' => $investor['fund'], 'step' => 4, 'message' => $investor['others'], 'create_time' => NOW_TIME);
             M('ProjLeader')->add($temp);
         }
         // $leader = M('ProjectLeader')->where(array('leader_id'=>$uid, 'project_id'=>$id))->find();
         // if ($leader  && $leader['status'] == 0) {
         // 	M('ProjectLeader')->save(array('id'=>$leader['id'],
         // 		'status'=>1, 'update_time'=>NOW_TIME));
         // }
         $investor['step'] = $project['stage'];
         $investor['project_valuation'] = $project['final_valuation'];
         $investor['project_id'] = $id;
         $investor['investor_id'] = $uid;
         $investor['create_time'] = NOW_TIME;
         $investor['create_id'] = $uid;
         $investor['update_time'] = NOW_TIME;
         $investor['update_id'] = $uid;
         $investor['status'] = 4;
         M('ProjectInvestor')->add($investor);
         //todo 添加到投资列表,但状态是未付款
         M('ProjectFund')->where('project_id=' . $id)->setInc('has_fund', $investor['fund']);
         M('ProjectFund')->where('project_id=' . $id)->setInc('agree_fund', $investor['fund']);
         // 发送系统消息(通知项目方有人跟投)
         $ulink = '<a href="' . U('MCenter/profile?id=' . $uid) . '">' . get_membername($uid) . '</a>';
         $plink = '<a href="' . U('Manage/foundfollow') . '">《' . $project['project_name'] . '》</a>';
         $content = $ulink . '跟投了您的' . $plink . '项目';
         D('Message')->send(0, $project['uid'], '', $content, 3);
         //增加一个待办事件
         update_pj_dolist($uid, 0);
         $this->success('恭喜您,跟投成功!现在,去签署一下代持协议吧!' . showface('hand'), U('Agreement/touzi?id=' . $id));
     } else {
         if ($project['type'] == 1) {
             $project['final_valuation'] = $project['need_fund'];
         }
         $project['rate_fund'] = $project['need_fund'] * 100 / $project['final_valuation'];
         $project['rate'] = $project['follow_fund'] * 100 / $project['final_valuation'];
         $this->project = $project;
         //返回跳转
         $this->assign("backurl", U('Project/detail?id=' . $id));
         $this->display();
     }
 }
コード例 #3
0
 public function cancel()
 {
     if (IS_AJAX) {
         $id = $_GET['id'];
         if ($id) {
             $ivest = M('ProjectInvestor')->field('fund,investor_id, project_id, status, lead_type')->find($id);
             if ($ivest['investor_id'] != is_login()) {
                 $this->error('非法操作。');
             }
             $proj = M('Project')->where(array('id' => $ivest['project_id']))->field('project_name, uid, stage')->find();
             if ($ivest['status'] >= 2 && $proj['stage'] < 8) {
                 M('ProjectFund')->where('project_id=' . $ivest['project_id'])->setDec('has_fund', $ivest['fund']);
                 if ($ivest['status'] >= 3) {
                     M('ProjectFund')->where('project_id=' . $ivest['project_id'])->setDec('agree_fund', $ivest['fund']);
                 }
                 if ($ivest['status'] == 4) {
                     $data = M('AccountInvest')->where(array('iid' => $id))->find();
                     if ($data) {
                         M('AccountUser')->where(array('uid' => $data['uid']))->setInc('use_able', $data['amount']);
                         M('AccountInvest')->where(array('iid' => $id))->delete();
                     }
                 }
                 M('AgreementInvest')->where(array('pid' => $ivest['project_id'], 'uid' => $ivest['investor_id']))->delete();
             }
             // 删除领投记录
             M('ProjLeader')->where(array('pid' => $ivest['project_id'], 'uid' => $ivest['investor_id'], 'del_flag' => 0))->save(array('del_flag' => -1));
             $data = array('status' => -1, 'id' => $id, 'update_time' => NOW_TIME, 'update_id' => is_login());
             M('ProjectInvestor')->save($data);
             // 发送系统消息(通知项目方有人询价)
             $ulink = '<a href="' . U('MCenter/profile?id=' . $ivest['investor_id']) . '">' . get_membername($ivest['investor_id']) . '</a>';
             $plink = '<a href="' . U('Manage/investinquiry') . '">《' . $proj['project_name'] . '》</a>';
             $content = $ulink . '撤消了对您' . $plink . "项目的认投";
             D('Message')->send(0, $proj['uid'], '', $content, 3);
             //更新待办事件
             update_pj_dolist($ivest['investor_id'], -1);
             $this->success('您撤消了对' . $proj['project_name'] . '项目的投资');
         }
     } else {
     }
 }