예제 #1
0
 function app()
 {
     load::logic('event');
     $EventLogic = new EventLogic();
     $id = (int) $this->Get['id'];
     $type = $this->Get['type'];
     $time = TIMESTAMP;
     $rs = $EventLogic->get_event_info($id);
     if ($rs['tot'] < TIMESTAMP) {
         json_error("活动已截止");
     } else {
         $user_info = $EventLogic->getMemberInfo($id);
         if ($type == 'cancle') {
             if ($user_info['play']) {
                 json_error("你已参加该活动,请先联系活动发起者取消你的参加资格");
             } elseif ($user_info['app'] == 0) {
                 json_error("你未报名该活动");
             } else {
                 $EventLogic->doCancle($id);
                 json_result("取消报名成功");
             }
         } else {
             if ($user_info['app'] == 1) {
                 json_error("你已报名该活动");
             }
             $qua = unserialize($rs['qualification']);
             if ($rs['postman'] != MEMBER_ID) {
                 if ($qua['fans_num']) {
                     $fans_num = $this->Member['fans_count'];
                     if ($fans_num < $qua['fans_num']) {
                         json_error("报名活动者的粉丝数不能少于" . $qua['fans_num'] . "人");
                     }
                 }
                 if ($qua['same_city']) {
                     $city_name = DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '" . (int) trim($rs['city_id']) . "'");
                     if ($city_name != $this->Member[city]) {
                         json_error("该活动仅限" . $city_name . "的朋友参与,您当前不符合要求");
                     }
                 }
                 if ($qua['inqun']) {
                     $inqun = DB::result_first("select count(*) from " . TABLE_PREFIX . "qun_user where qid = '{$qua[inqun]}' and uid = '" . MEMBER_ID . "'");
                     if (!$inqun) {
                         $qun_name = DB::result_first("select name from " . TABLE_PREFIX . "qun where qid = '{$qua['inqun']}'");
                         json_error("该活动仅限<a href='index.php?mod=qun&qid={$qua['inqun']}' target='_blank'>" . $qun_name . "</a>的朋友参与,您当前不符合要求");
                     }
                 }
             }
             $need_info = unserialize($rs['need_app_info']);
             if (count($need_info)) {
                 $html = $this->_makeSimpleHtml($need_info);
                 include template('need_info');
                 exit;
             } else {
                 $EventLogic->doApp($id);
                 json_result("1");
             }
         }
     }
 }