OptData.php 4.03 KB
<?php

namespace LibModels\Wap\Guang;

use Api\Yohobuy;
use Api\Sign;

/**
 * 逛操作相关的数据模型
 * 
 * @name OptData
 * @package LibModels/Wap/Guang
 * @copyright yoho.inc
 * @version 1.0 (2015-10-10 11:51:16)
 * @author fei.hong <fei.hong@yoho.cn>
 */
class OptData
{

    /**
     * 品牌收藏/取消收藏
     * 
     * @param int $uid 用户ID
     * @param int $id 唯一的ID
     * @param string $opt 操作(ok:表示确定,cancel:表示取消)
     * @return array
     */
    public static function favoriteBrand($uid, $id, $opt = 'ok')
    {
        $param = Yohobuy::param();
        $param['uid'] = $uid;
        $param['id'] = $id;
        $param['client_secret'] = Sign::getSign($param);
        return Yohobuy::get(Yohobuy::SERVICE_URL.'guang/service/v2/favorite/toggleBrand', $param);

//        if ($opt == 'ok') {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v2/favorite/', 'toggleBrand', array($uid, $id));
//        } else {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v2/favorite/', 'toggleBrand', array($uid, $id));
//        }
    }

    /**
     * 商品收藏/取消收藏
     * 
     * @param int $uid 用户ID
     * @param int $skn 商品标识
     * @param string $opt 操作(ok:表示确定,cancel:表示取消)
     * @return array
     */
    public static function favoriteProduct($uid, $skn, $opt = 'ok')
    {
        $param = Yohobuy::param();
        $param['uid'] = $uid;
        $param['productSkn'] = $skn;
        $param['client_secret'] = Sign::getSign($param);

        if ($opt === 'cancel') {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'addUidProductFav', array($uid, $skn));

            return Yohobuy::get(Yohobuy::SERVICE_URL.'shops/service/v1/favorite/addUidProductFav', $param);
        } else {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'delUidProductFav', array($uid, $skn));

            return Yohobuy::get(Yohobuy::SERVICE_URL.'shops/service/v1/favorite/delUidProductFav', $param);
        }
    }

    /**
     * 逛资讯点赞/取消赞
     * 
     * @param int $udid 唯一客户端标识
     * @param int $id 唯一资讯的ID
     * @param string $opt 操作(ok:表示确定,cancel:表示取消)
     * @return array
     */
    public static function praiseArticle($udid, $id, $opt = 'ok')
    {
        $param = Yohobuy::param();
        $param['article_id'] = $id;
        $param['udid'] = $udid;
        $param['client_secret'] = Sign::getSign($param);

        if ($opt === 'cancel') {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v2/praise', 'cancelPraise', array($id, $udid));

            return Yohobuy::get(Yohobuy::SERVICE_URL.'guang/api/v2/praise/cancel', $param);
        } else {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v2/praise', 'setPraise', array($id, $udid));

            return Yohobuy::get(Yohobuy::SERVICE_URL.'guang/api/v2/praise/setPraise', $param);
        }
    }

    /**
     * 逛资讯收藏/取消收藏 (APP里调用)
     * 
     * @param int $udid 唯一客户端标识
     * @param int $id 唯一资讯的ID
     * @param string $opt 操作(ok:表示确定,cancel:表示取消)
     * @return array
     */
    public static function collectArticle($uid, $id, $opt = 'ok')
    {
        $param = Yohobuy::param();
        $param['article_id'] = $id;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        if ($opt === 'cancel') {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v2/favorite/', 'cancelFavorite', array($id, $uid));

            return Yohobuy::get(Yohobuy::SERVICE_URL.'guang/api/v1/favorite/cancelFavorite', $param);
        } else {
//            return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v2/favorite/', 'setFavorite', array($id, $uid));

            return Yohobuy::get(Yohobuy::SERVICE_URL.'guang/api/v1/favorite/setFavorite', $param);
        }
    }

}