Author: jason (yangjs17@yeah.net)
Inheritance: extends Model
Exemplo n.º 1
0
 function simpleCreditAction()
 {
     $request = $this->getRequest();
     if ('POST' == $request->getMethod()) {
         $userId = $this->post()->get("userId");
         $actionId = $this->post()->get("actionId");
         $schoolId = $this->post()->get("schoolId");
     } else {
         $userId = $this->get("userId");
         $actionId = $this->get("actionId");
         $schoolId = $this->get("schoolId");
     }
     //如果所传参数有空值(无效),json返回错误信息
     if (!$userId || !$actionId) {
         $this->displayJsonUdo(Common_Error::ERROR_PARAM);
     }
     //获取用户权限,用户是否是“私有”频道的授权用户
     /*$userModel = new UserModel();
       $userAuth = $userModel->getUserAuth($userId,$schoolId);*/
     $creditModel = new CreditModel();
     $result = $creditModel->getCredit($userId, $actionId, $schoolId);
     //如果不是
     //if(!$userAuth)
     //print_r($result);
     $this->displayJsonUdo($result);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('users_credits', function (Blueprint $table) {
         $table->integer('staff_id')->unsigned()->after('expires');
     });
     // Update any existing credits
     $all = CreditModel::all();
     if ($all->count() > 0) {
         foreach ($all as $credit) {
             $credit->update(['staff_id' => 1]);
         }
     }
 }
Exemplo n.º 3
0
 function shareAction()
 {
     $request = $this->getRequest();
     if ('POST' == $request->getMethod()) {
         $type = $this->post()->get('type');
         $newsId = $this->post()->get('newsId');
         $schoolId = $this->post()->get('schoolId');
         $courseId = (int) $this->post()->get('courseId');
         $courseName = $this->post()->get('courseName');
         $sectionId = (int) $this->post()->get('sectionId');
         $sectionName = $this->post()->get('sectionName');
         $defeatRate = $this->post()->get('defeatRate');
         $rank = $this->post()->get('rank');
         $title = $this->post()->get('title');
         $uid = $this->post()->get('uid');
         $bannerId = $this->post()->get('bannerId');
     } else {
         $type = (int) $this->get('type');
         $newsId = $this->get('newsId');
         $schoolId = (int) $this->get('schoolId');
         $courseId = (int) $this->get('courseId');
         $courseName = $this->get('courseName');
         $sectionId = (int) $this->get('sectionId');
         $sectionName = $this->get('sectionName');
         $defeatRate = $this->get('defeatRate');
         $rank = $this->get('rank');
         $title = $this->get('title');
         $uid = $this->get('uid');
         $bannerId = $this->get('bannerId');
     }
     $creditModel = new CreditModel();
     $increase = $creditModel->getCredit($uid, 201, 0);
     $schoolModel = new SchoolModel();
     switch ($type) {
         case Common_Config::SHARE_SCHOOL:
             $school = $schoolModel->getResourceInfo(Common_Config::UDO_RESOURCE_SCHOOL, $schoolId, 0, 0);
             $title = "听课做题用UDO";
             $info = "我在UDO微课堂看'" . $school['customer_name'] . "'推出的'" . $school['customer_title'] . "'微课,居然一不小心全懂了,快当学霸了好紧张....";
             $url = Common_Config::STATIC_BASE_URL . "/share/" . "school?name=" . $school['customer_name'] . "&title=" . $school['customer_title'] . "&logo=" . $school['logo'];
             $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, array("url" => $url, "title" => $title, "intro" => $info, "logo" => $school['logo']));
             break;
         case Common_Config::SHARE_REPORT:
             //$this->redirect("report?defeatRate=".$defeatRate."&rank=".$rank."&title=".$title);
             $url = Common_Config::STATIC_BASE_URL . "/share/" . "report?sectionName=" . $sectionName . "&defeatRate=" . $defeatRate . "&rank=" . $rank . "&title=" . $title;
             $logo = $schoolModel->getResourceInfo(Common_Config::PUBLIC_COURSE_TYPE, 0, $courseId, $courseName);
             $info = "我在udo微课堂的" . $sectionName . "测验中排名第" . $rank . ",求超越!手机答题还能看解析,果然是哪里不会点哪里";
             $title = "听课做题用UDO";
             $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, array("url" => $url, "title" => $title, "intro" => $info, "logo" => $logo['logo']));
             break;
         case Common_Config::SHARE_COURSE:
             $course = $schoolModel->getResourceInfo(Common_Config::PUBLIC_COURSE_TYPE, 0, $courseId, $courseName);
             $info = "我在UDO微课堂看'" . $course['customer_name'] . "'推出的'" . $courseName . "'微课,居然一不小心全懂了,快当学霸了好紧张....";
             $title = "听课做题用UDO";
             $url = Common_Config::STATIC_BASE_URL . "/share/" . "school?name=" . $course['customer_name'] . "&title=" . $courseName . "&logo=" . $course['logo'];
             $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, array("url" => $url, "title" => $title, "intro" => $info, "logo" => $course['logo']));
             break;
         case Common_Config::SHARE_NEWS:
             $news = $schoolModel->getSingleNews($newsId);
             $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, array("url" => $news['url'], "title" => $news['title'], "logo" => $news['logo'], "intro" => $news['intro']));
             break;
         case Common_Config::SHARE_BANNER:
             $banner = $schoolModel->getSingleBanner($bannerId);
             //print_r($banner);
             //如果是寒假宣传banner
             if ($bannerId == 8) {
                 $schoolModel = new SchoolModel();
                 $count = $schoolModel->bannerData(2780, $uid);
                 //print_r($count);
                 $boughtCount = $count['boughtCount'];
                 $courseCount = $count['courseCount'];
                 $banner['bannerUrl'] = Common_Config::STATIC_BASE_URL . "/share/holiday1?bCount={$boughtCount}&cCount={$courseCount}";
             }
             $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, array("url" => $banner['bannerUrl'], "title" => $banner['customerName'], "logo" => Common_Config::SITE_DOMAIN . $banner['logo'], "intro" => $banner['intro']));
             break;
     }
 }