function getResourceInfo($type, $id = 0, $localId = 0, $name = "") { $tblEntrance = new DB_Sso_Entrance(); $tblResource = new DB_Sso_Resource(); switch ($type) { case Common_Config::PUBLIC_SCHOOL_TYPE: $entrance = $tblEntrance->scalar("customer_name,customer_title,logo", "where id = {$id}"); return $entrance; case Common_Config::PUBLIC_COURSE_TYPE || Common_Config::PUBLIC_CHAPTER_TYPE || Common_Config::PUBLIC_SECTION_TYPE: if ($id) { $course = $tblResource->scalar("name,entrance_id", "where id = {$id}"); $logo = $tblEntrance->scalar("logo", "where id = {$id}"); $course = array_merge($course, $logo); return $course; } else { $schoolId = $tblResource->scalar("entrance_id", "where name='{$name}' and local_id = {$localId}"); //print_r($schoolId); $logo = $tblEntrance->scalar("logo,customer_name", "where id = {$schoolId['entrance_id']}"); return $logo; } } }
function newResourcePrice($resourcePrice, $schoolId) { $tblResource = new DB_Sso_Resource(); $tblSchoolPrice = new DB_Udo_SchoolPrice(); $priceSchool = 0; $school = $tblSchoolPrice->scalar("*", "where resourceId = {$schoolId}"); //print_r(count($resourcePrice)); foreach ($resourcePrice as $k => $val) { //print_r($val); $resource = $tblResource->scalar("type,price_type,cur_price", "where id ={$val['resourceId']}"); //print_r($resource); $notFree = $val['notFree']; $freeStr = ""; if (!$notFree) { $priceType = Common_Config::UDO_PRICETYPE_FREE; $freeStr = ",price_type = 3"; } else { $priceType = $school['priceType']; $freeStr = ",price_type={$priceType}"; } $price = $val['price']; $id = $val['resourceId']; $resourceUpdate = $tblResource->query("update resource set cur_price = {$price}" . $freeStr . " where id ={$id}"); //print_r($resource['type']." "); if ($resource['type'] == Common_Config::PUBLIC_COURSE_TYPE) { $priceSchool += $price; //print_r($priceSchool." "); } } $priceSchool *= $school['discount']; $priceSchool = ceil($priceSchool); /*print_r($school['discount']); print_r($priceSchool);*/ $schoolPrice = $tblSchoolPrice->query("update udo_school_price set price={$priceSchool} where resourceId={$schoolId}"); return $resourceUpdate; }
function alterAccount($uid, $schoolId) { $tblSchoolPrice = new DB_Udo_SchoolPrice(); $tblResource = new DB_Sso_Resource(); $tblBought = new DB_Udo_UserBought(); $tblOrder = new DB_Udo_Order(); $schoolPrice = $tblSchoolPrice->scalar("*", "where resourceId = {$schoolId}"); $courseType = Common_Config::PUBLIC_COURSE_TYPE; $free = Common_Config::UDO_PRICETYPE_FREE; $course = $tblResource->fetchAll("id", "where type = {$courseType} and price_type <> {$free} and entrance_id = {$schoolId}"); $resource = []; foreach ($course as $key => $value) { array_push($resource, array("resourceType" => 2, "resourceId" => $value['id'])); } //print_r($resource); $courseIds = $tblResource->columnRow($course, "id"); $resourceType = Common_Config::UDO_RESOURCE_COURSE; $newOrder = $tblOrder->insert(array("userId" => $uid, "resource" => json_encode($resource), "createTime" => time(), "status" => Common_Config::ORDER_SUCCESS, "payType" => $schoolPrice['priceType'] == 1 ? 2 : 1)); foreach ($courseIds as $key => $value) { $tblBought->insert(array("resourceId" => $value, "userId" => $uid, "schoolId" => $schoolId, "createTime" => time(), "resourceType" => $resourceType, "orderId" => $newOrder)); } return 1; }