CartData.php 1.88 KB
<?php

namespace LibModels\Wap\Home;

use Api\Sign;
use Api\Yohobuy;

/**
 * 购物车的数据模型
 *
 * @name CartData
 * @package LibModels/Wap/Home
 * @copyright yoho.inc
 * @version 1.0 (2015-11-09 13:58:27)
 * @author Gtskk <tttt6399998@126.com>
 */
class CartData
{

	/**
	 * 购物车数据
	 *
	 * @return array 购物车接口返回的数据
	 */
	public static function cartData($uid)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.Shopping.cart';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::API_URL, $param);
	}

	/**
	 * 移出购物车
	 *
	 * @param int $uid 用户ID
	 * @param string $sku 商品sku列表
	 * @return array 接口返回的数据
	 */
	public static function removeFromCart($uid, $sku)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.Shopping.remove';
		$param['product_sku_list'] = $sku;
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::API_URL, $param);
	}

	/**
	 * 修改购物车商品数据
	 *
	 * @param int $uid 用户ID
	 * @param string $swapData 商品数据
	 * @return array 接口返回的数据
	 */
	public static function modifyCartProduct($uid, $swapData)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.Shopping.swap';
		$param['swap_data'] = $swapData;
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::API_URL, $param);
	}

	/**
	 * 移入收藏夹
	 *
	 * @param int $uid 用户ID
	 * @param string $sku 商品sku列表
	 * @return array 接口返回的数据
	 */
	public static function addToFav($uid, $sku)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.Shopping.addfavorite';
		$param['product_sku_list'] = $sku;
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::API_URL, $param);
	}

}