Onlinereg.class.php 7.05 KB
<?php
class Service_Onlinereg extends Lib_Service
{
    const ROUTER = 'onlinereg.yohood.onlinereg';
    private static $_seller_tag = 'tag_yohood_seller_';
    private static $_seller_key = 'key_yohood_seller_';
    private static $_download_tag = 'tag_yohood_download_';
    private static $_download_key = 'key_yohood_download_';
    
    /**
     * 设置商家信息
     * 
     * @param string $name
     * @param string $type
     * @param int $brand_reg_type
     * @param int $is_enter_yohobuy
     * @param string $product_type
     * @param string $country
     * @param string $company
     * @param string $contact
     * @param string $telphone
     * @param string $email
     * @param string $relation
     * @param string $website
     * @param int $is_3c
     * @param string $place
     * @param string $files
     * @return int
     */
    public function setSellerInfo($name, $type, $brand_reg_type, $is_enter_yohobuy, $product_type, $country,
        $company, $contact, $telphone, $email, $relation, $website, $is_3c, $place, $files)
    {
        $params = array(
            'name' => $name, 'type' => $type,'brand_reg_type'=> intval($brand_reg_type), 'is_enter_yohobuy'=> intval($is_enter_yohobuy),
            'product_type'=> $product_type,'company'=> $company,'contact'=> $contact,'telphone' => $telphone,'email'=> $email,
            'country'=>$country,'relation'=> $relation,'website' => $website,'is_3c'=> intval($is_3c), 'place' => $place,'files'=> $files
        );
        return  self::service(self::ROUTER)->tag(self::$_seller_tag)->insert('setSellerInfo', $params)->lastInsertId();
    }
    
    /**
     * 根据type获取商家列表
     * 
     * @param int $type
     * @param int $offset
     * @param int $limit
     * @return array 
     */
    public function getSellerListByType($type, $offset, $limit)
    {
        $params = array('type' => intval($type),'offset' => intval($offset), 'limit' => intval($limit));
        $key = sprintf("%s_%s_%s_%s", self::$_seller_key, $type, $offset, $limit);
        return self::service(self::ROUTER)->tag(self::$_seller_tag)->key($key)->fetchAssoc('getSellerListByType', $params);
    }
    
    /**
     * 根据type获取总数
     * 
     * @param int $type
     * @return array
     */
    public function getSellerTotalByType($type) 
    {
        $params = array('type' => intval($type));
        return self::service(self::ROUTER)->cache(false)->fetchOne('getSellerTotalByType', $params);
    }
    
    /**
     * 根据ID获取商家
     * 
     * @param int $id
     * @return array 
     */
    public function getSellerById($id)
    {
        $params = array('id'=> $id);
        $key = self::$_seller_key . $id;
        return self::service(self::ROUTER)->tag(self::$_seller_tag)->key($key)->fetchRow('getSellerById', $params);
    }
    
    /**
     * 设置媒体信息
     * 
     * @param string $name
     * @param int $type
     * @param string $profession
     * @param int $sex
     * @param string $company
     * @param string $introduction
     * @param string $website
     * @param string $city
     * @param string $email
     * @param string $mobile
     * @param string $telphone
     * @param string $address
     * @param string $zipcode
     * @return int
     */
    public function setMediaInfo($name, $type, $profession, $sex, $company, $introduction, $website, $city, 
        $email, $mobile, $telphone, $address, $zipcode)
    {
        $params = array(
                'name' => addslashes($name),'type'=>$type, 'profession' => addslashes($profession),'sex'=> $sex, 'company'=> addslashes($company),
                'introduction'=> addslashes($introduction),'website' => $website,'city'=> $city,
                'email'=> addslashes($email),'mobile' =>addslashes($mobile), 'telphone'=> $telphone,'address' => addslashes($address),
                'zipcode' => $zipcode);
        return self::service(self::ROUTER)->tag(self::$_seller_tag)->insert('setMediaInfo', $params)->status();
    }
    
    /**
     * 设置下载信息
     * 
     * @param string $title
     * @param string $cover
     * @param string $file
     * @param string $source
     * @param string $source_link
     * @param string $type
     * @return boolean
     */
    public function setDownloadInfo($title, $cover, $file, $source, $source_link, $type)
    {
        $params = array('title'=> addslashes($title), 'cover' => $cover, 'file'=> $file, 'source' => addslashes($source), 
            'source_link' => addslashes($source_link), 'type' => intval($type));
        return self::service(self::ROUTER)->tag(self::$_download_tag)->insert('setDownloadInfo', $params)->status();
    }

    /**
     * 根据ID设置下载信息
     * 
     * @param int $id
     * @param string $title
     * @param string $cover
     * @param string $file
     * @param string $source
     * @param string $source_link
     * @return boolean
     */
    public function setDownloadInfoById($id, $title, $cover, $file, $source, $source_link)
    {
        $params = array('title'=> addslashes($title), 'cover' => $cover, 'file'=> $file, 'source' => addslashes($source), 
            'source_link' => addslashes($source_link),'id'=> intval($id));
        return self::service(self::ROUTER)->tag(self::$_download_tag)->update('setDownloadInfoById', $params)->status();
    }
    
    /**
     * 获取下载列表
     * 
     * @param int $type
     * @param int $offset
     * @param int $limit
     * @return array
     */
    public function getDownloadListByType($type, $offset, $limit)
    {
        $params = array('type' => intval($type),'offset' => intval($offset), 'limit' => intval($limit));
        $key = sprintf("%s_%s_%s_%s", self::$_download_key, $type, $offset, $limit);
        return self::service(self::ROUTER)->tag(self::$_download_tag)->fetchAssoc('getDownloadListByType', $params);
    }
    
    /**
     * 获取下载总数
     * 
     * @param int $type
     * @return array
     */
    public function getDownloadTotalByType($type)
    {
        $params = array('type' => intval($type));
        return self::service(self::ROUTER)->tag(self::$_download_tag)->fetchOne('getDownloadTotalByType', $params);
    }
    
    /**
     * 获取下载信息
     * 
     * @param int $id
     * @return array
     */
    public function getDownloadById($id)
    {
        $params = array('id' => intval($id));
        return self::service(self::ROUTER)->tag(self::$_download_tag)->fetchRow('getDownloadById', $params);
    }
    
    /**
     * 删除下载信息
     * 
     * @param int $id
     * @return boolean
     */
    public function delDownload($id)
    {
        $params = array('id' => intval($id));
        return self::service(self::ROUTER)->tag(self::$_download_tag)->delete('delDownload', $params);
    }
    
    /**
     * 设置商家信息
     * 
     * @param array $data
     * @return boolean
     */
    public function setSeller(array $data)
    {   
        $up = Util_Utils_SqlString::mergeSqlUpstring($data);
        $replaces = array('up' => $up);
        return self::service(self::ROUTER)->tag(self::$_seller_tag)->update('setSeller', $data, $replaces)->status();
    }
}

?>