示例#1
0
 public function applyPersonSubmitAction()
 {
     if ($this->request->isPost()) {
         //图片上传
         $img_list = array();
         $project_log = array();
         list($img_list, $project_log) = $this->_upload_img();
         $user_id = $this->request->getPost('user_id');
         $params = array();
         $ubm = new DtbUserBasic();
         $uipm = new DtbInvestorPerson();
         $ilm = new DtbInvestLeaderCases();
         $user_data = $ubm->get($user_id);
         if (!$user_data || $user_data->getAccountType() > 0) {
             die('value is invaild');
         }
         $real_name = $this->request->getPost('real_name');
         $identity_card = $this->request->getPost('identity_card');
         $prov = $this->request->getPost('prov');
         $city = $this->request->getPost('city');
         $dist = $this->request->getPost('dist');
         $address = $this->request->getPost('address');
         // $idc_img1 = $this->request->getPost('idc_img1');
         //$idc_img2 = $this->request->getPost('idc_img2');
         $idc_img1 = isset($img_list['idc_img1']) ? $img_list['idc_img1'] : '';
         $idc_img2 = isset($img_list['idc_img2']) ? $img_list['idc_img2'] : '';
         $income_y = $this->request->getPost('income_y');
         $company = $this->request->getPost('company');
         $position = $this->request->getPost('position');
         $person_fund = $this->request->getPost('person_fund');
         $singel_invest_range_start = $this->request->getPost('singel_invest_range_start');
         $singel_invest_range_end = $this->request->getPost('singel_invest_range_end');
         $invest_exp = $this->request->getPost('invest_exp');
         $attention_direct = $this->request->getPost('attention_direct');
         $invest_idea = $this->request->getPost('invest_idea');
         $available_extra_price = $this->request->getPost('available_extra_price');
         #案列
         $project_logo = $this->request->getPost('project_logo');
         $project_name = $this->request->getPost('project_name');
         $web_url = $this->request->getPost('web_url');
         $project_desc = $this->request->getPost('project_desc');
         $invest_person_info = $uipm->getDataByUserId($user_id);
         if ($invest_person_info) {
             die('用户已存在');
         } else {
             $params = array('real_name' => $real_name, 'identity_card' => $identity_card, 'idc_img1' => $idc_img1, 'idc_img2' => $idc_img2, 'country' => 'china', 'province' => $prov, 'city' => $city, 'dist' => $dist, 'address' => $address, 'income_y' => $income_y, 'company' => $company, 'position' => $position, 'person_fund' => $person_fund, 'singel_invest_range' => json_encode(array($singel_invest_range_start, $singel_invest_range_end)), 'person_fund' => $person_fund, 'invesrt_exp' => json_encode($invest_exp), 'attention_direct' => $attention_direct, 'invest_idea' => $invest_idea, 'available_extra_price' => $available_extra_price);
             $res = $uipm->applyPerson($user_id, $params);
             if ($res) {
                 if ($this->request->getPost('check_leader') == 1) {
                     //申请领头人
                     $project_name_list = $this->request->getPost('project_name');
                     $web_url_list = $this->request->getPost('web_url');
                     $project_desc_list = $this->request->getPost('project_desc');
                     $this->_add_leader_cases($user_id, $project_name_list, $web_url_list, $project_desc_list, $project_log);
                 }
                 $this->flash->success('认证成功');
                 return $this->response->redirect('/user/center');
                 return $this->dispatcher->forward(array('controller' => 'user', 'action' => 'center'));
             }
         }
         $check_value = true;
     }
 }
 public function applyPerson($user_id, $params)
 {
     $flag = false;
     try {
         $this->di['db']->begin();
         $invest_person = new DtbInvestorPerson();
         $invest_person->user_id = $user_id;
         $invest_person->address = $params['address'];
         $invest_person->real_name = $params['real_name'];
         $invest_person->identity_card = isset($params['identity_card']) ? $params['identity_card'] : null;
         $invest_person->idc_img1 = isset($params['idc_img1']) ? $params['idc_img1'] : null;
         $invest_person->idc_img2 = isset($params['idc_img2']) ? $params['idc_img2'] : null;
         $invest_person->province = $params['province'];
         $invest_person->city = $params['city'];
         $invest_person->dist = $params['dist'];
         $invest_person->income_y = isset($params['income_y']) ? $params['income_y'] : 0;
         $invest_person->company = $params['company'];
         $invest_person->position = $params['position'];
         $invest_person->person_fund = isset($params['person_fund']) ? $params['person_fund'] : 0;
         $invest_person->available_extra_price = isset($params['available_extra_price']) ? $params['available_extra_price'] : 0;
         $invest_person->singel_invest_range = isset($params['singel_invest_range']) ? $params['singel_invest_range'] : 0;
         $invest_person->invest_exp = $params['invest_exp'];
         $invest_person->attention_direct = $params['attention_direct'];
         $invest_person->invest_idea = $params['invest_idea'];
         $invest_person->available_extra_price = $params['available_extra_price'];
         $invest_person->create_ts = time();
         $invest_person->update_ts = time();
         $invest_person->country = $params['country'];
         $invest_person->result = 0;
         if (!$invest_person->create()) {
             foreach ($invest_person->getMessages() as $message) {
                 echo $message;
             }
             $this->di['db']->rollback();
             return $flag;
         } else {
             $action_type = $this->di['config']->log_user->applyperson;
             $log_ts = time();
             $sql = "insert into DtbLogUser (user_id,action_type,log_ts) values('{$user_id}','{$action_type}','{$log_ts}' )";
             $query = new Phalcon\Mvc\Model\Query($sql, $this->getDI());
             $res1 = $query->execute();
             $sql = "update  DtbUserBasic set account_type=2 where user_id={$user_id} and account_type=0";
             $query = new Phalcon\Mvc\Model\Query($sql, $this->getDI());
             $res2 = $query->execute();
             if (!$res1) {
                 $this->di['db']->rollback();
             } else {
                 if (!$res2) {
                     $this->di['db']->rollback();
                 } else {
                     $flag = true;
                     $this->di['db']->commit();
                 }
             }
             return $flag;
         }
     } catch (Exception $ex) {
         $this->di['db']->rollback();
         return $flag;
     }
 }