コード例 #1
0
ファイル: School.php プロジェクト: krisrita/udo
 function getSchoolPrice($schoolId, $uid)
 {
     $tblPrice = new DB_Udo_SchoolPrice();
     $tblBought = new DB_Udo_UserBought();
     $tblResource = new DB_Sso_Resource();
     $bought = 0;
     //查找出频道的定价信息
     $price = $tblPrice->scalar("priceType,price", "where resourceId = {$schoolId}");
     //没有查询到定价信息的频道一律按照免费处理
     if (!$price) {
         $price = array("priceType" => Common_Config::UDO_PRICETYPE_FREE, "price" => 0);
     }
     //查找用户的购买信息
     //原则上免费课程不能加入购买表中
     $isBought = $tblBought->fetchAll("resourceId", "where schoolId = {$schoolId} and resourceType = 2 and userId = {$uid}");
     //print_r($isBought);
     //查找该频道下的所有非免费课程
     $resource = $tblResource->fetchAll("id", "where entrance_id = {$schoolId} and type = 6 and price_type <> 3 and enabled = 1");
     //如果定价免费
     if ($price['priceType'] == 3) {
         $bought = 1;
     } else {
         $boughtCount = 0;
         foreach ($resource as $k => $value) {
             foreach ($isBought as $l => $val) {
                 if ($value['id'] == $val['resourceId']) {
                     $boughtCount++;
                     break;
                 }
             }
         }
         //考虑到频道中的课程可能会有更新,所以不能以当前频道的购买状态作为频道是否购买的依据,
         //而是要以非免费课程和已购买课程的数量是否相等作为依据
         if ($boughtCount == count($resource) && count($resource) != 0) {
             $bought = 1;
         }
     }
     return array("price" => $price['price'], "priceType" => $price['priceType'], "isBought" => $bought);
 }
コード例 #2
0
ファイル: Account.php プロジェクト: krisrita/udo
 function searchBought($uid, $key)
 {
     //$key = "金";
     $tblBought = new DB_Udo_UserBought();
     $tblResource = new DB_Sso_Resource();
     $tblEntrance = new DB_Sso_Entrance();
     $tblSta = new DB_Udo_SchoolStatistics();
     $tradeModel = new TradeModel();
     //首先获取用户购买的课程和所在的频道
     $bought = $tblBought->fetchAll("id,resourceId,schoolId", "where userId ={$uid} and resourceType = 2 ", "order by id asc");
     //print_r($bought);
     //print_r($bought);
     $resultArray = [];
     //接下来对逐个课程,获取频道的具体信息和课程的具体信息
     foreach ($bought as $k => $value) {
         $entrance = $tblEntrance->scalar("customer_name,customer_title,logo,api_udo_url", "where id = {$value['schoolId']} and (customer_name like '%{$key}%'\r\n            or customer_title like '%{$key}%')");
         $resource = $tblResource->scalar("name", "where id = {$value['resourceId']} and name like '%{$key}%'");
         //如果搜索到了频道或课程包含关键词,再显示该条信息
         if ($entrance || $resource) {
             $sta = $tblSta->queryCount("where schoolId = {$value['schoolId']} group by userId");
             if (!$sta) {
                 $sta = 0;
             }
             $entrance = $tblEntrance->scalar("customer_name,customer_title,logo,api_udo_url", "where id = {$value['schoolId']}");
             $resource = $tblResource->scalar("name", "where id = {$value['resourceId']} ");
             $info = $sta . "人已学";
             //获取课程的localId供在列表中进行跳转
             $localId = $tradeModel->getLocalId($value['resourceId'], $value['schoolId']);
             array_push($resultArray, array("id" => $value['resourceId'], "localId" => $localId['local_id'], "logo" => $entrance['logo'], "name" => $resource['name'], "schoolName" => $entrance['customer_name'], "schoolTitle" => $entrance['customer_title'], "info" => $info, "schoolId" => $value['schoolId'], "apiUdoUrl" => $entrance['api_udo_url'], "courseType" => 0));
         }
     }
     return $resultArray;
 }