UserData.php 10.1 KB
<?php

namespace LibModels\Wap\Home;

use Api\Sign;
use Api\Yohobuy;

/**
 * 个人中心的数据模型
 *
 * @name UserData
 * @package LibModels/Wap/Home
 * @copyright yoho.inc
 * @version 1.0 (2015-11-09 16:30:27)
 * @author Gtskk <tttt6399998@126.com>
 */
class UserData
{

	/**
	 * 个人详情数据
	 *
	 * @param int $uid 用户ID
	 * @return array 个人详情接口返回的数据
	 */
	public static function userData($uid)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.passport.profile';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 个人中心页面优惠券,收藏的商品等的数目数据
	 *
	 * @param int $uid 用户ID
	 * @return array 接口返回的数据
	 */
	public static function infoNum($uid)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.home.getInfoNum';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 个人中心页面优选新品数据
	 *
	 * @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
	 * @return array 接口返回的数据
	 */
	public static function preference($yh_channel)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.home.preference';
		$param['yh_channel'] = $yh_channel;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 订单数据
	 *
	 * @param int $uid 用户ID
	 * @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价
	 * @param int $page 第几页,默认1
	 * @param int $limit 限制读取的数目,默认10
	 * @return array 订单接口返回的数据
	 */
	public static function orderData($uid, $type, $page = 1, $limit = 10)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.SpaceOrders.get';
		$param['uid'] = $uid;
		$param['type'] = $type;
		$param['page'] = $page;
		$param['limit'] = $limit;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 收藏的商品数据
	 *
	 * @param int $uid 用户ID
	 * @param int $page 第几页,默认1
	 * @param int $limit 限制读取的数目,默认10
	 * @return array 收藏的商品接口返回的数据
	 */
	public static function favoriteProductData($uid, $page = 1, $limit = 10)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.favorite.product';
		$param['uid'] = $uid;
		$param['page'] = $page;
		$param['limit'] = $limit;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 收藏的品牌数据
	 *
	 * @param int $uid 用户ID
	 * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
	 * @param int $page 第几页,默认1
	 * @param int $limit 限制读取的数目,默认10
	 * @return array 收藏的品牌接口返回的数据
	 */
	public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.favorite.brand';
		$param['uid'] = $uid;
		$param['gender'] = $gender;
		$param['page'] = $page;
		$param['limit'] = $limit;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 取消收藏的商品数据
	 *
	 * @param int $uid 用户ID
	 * @param int $fav_id 要取消的收藏id
	 * @return array 接口返回的数据
	 */
	public static function favoriteDelete($uid, $fav_id)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.favorite.cancel';
		$param['type'] = 'product';
		$param['fav_id'] = $fav_id;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * YOHO币数据
	 *
	 * @param int $uid 用户ID
	 * @param int $page 第几页,默认1
	 * @param int $limit 限制读取的数目,默认10
	 * @return array YOHO币接口返回的数据
	 */
	public static function yohoCoinData($uid, $page = 1, $limit = 10)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.yohocoin.lists';
		$param['uid'] = $uid;
		$param['page'] = $page;
		$param['limit'] = $limit;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 优惠券数据
	 *
	 * @param int $uid 用户ID
	 * @param int $status 优惠券状态,0表示未使用,1表示已使用
	 * @param int $page 第几页,默认1
	 * @param int $limit 限制读取的数目,默认10
	 * @return array 优惠券接口返回的数据
	 */
	public static function couponData($uid, $status, $page = 1, $limit = 10)
	{
		$urlList = array();

		$param = Yohobuy::param();
		$param['method'] = 'app.coupons.li';
		$param['uid'] = $uid;
		$param['status'] = 0;
		$param['page'] = $page;
		$param['limit'] = $limit;

		$param['client_secret'] = Sign::getSign($param);
		$urlList['unused'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);

		unset($param['client_secret']);
		$param['status'] = 1;
		$param['client_secret'] = Sign::getSign($param);
		$urlList['used'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);

		return Yohobuy::getMulti($urlList);
	}

	/**
	 * 地址数据
	 *
	 * @param int $uid 用户ID
	 * @return array 地址接口返回的数据
	 */
	public static function addressData($uid)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.address.get';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 获取三级地址列表数据
	 *
	 * @param int $uid 用户ID
	 * @return array 地址接口返回的数据
	 */
	public static function addressListData($uid)
	{
		$param = Yohobuy::param();
		$param['method'] = 'app.address.getlist';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 保存地址数据
	 *
	 * @param int $uid 用户ID
	 * @param string $address 地址信息
	 * @param int $area_code 城市码
	 * @param string $consignee 收货人
	 * @param string $email 邮箱地址
	 * @param int $id 地址唯一标识符id
	 * @param string $mobile 手机号码
	 * @param string $zip_code 邮编
	 * @return array 地址接口返回的数据
	 */
	public static function saveAddressData($uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code)
	{
		$param = Yohobuy::param();
		$param['address'] = $address;
		$param['area_code'] = $area_code;
		$param['consignee'] = $consignee;
		$param['email'] = $email;

		if (!empty($id)) { // 修改
			$param['id'] = $id;
			$param['method'] = 'app.address.update';
		} else { // 添加
			$param['method'] = 'app.address.add';
		}

		$param['mobile'] = $mobile;
		$param['zip_code'] = $zip_code;
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 设置默认地址
	 *
	 * @param int $uid 用户ID
	 * @param int $id 地址唯一标识符id
	 * @return array 接口返回的数据
	 */
	public static function setDefaultAddress($uid, $id)
	{
		$param = Yohobuy::param();
		$param['id'] = $id;
		$param['method'] = 'app.address.setdefault';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 删除地址
	 *
	 * @param int $uid 用户ID
	 * @param int $id 地址唯一标识符id
	 * @return array 接口返回的数据
	 */
	public static function deleteAddress($uid, $id)
	{
		$param = Yohobuy::param();
		$param['id'] = $id;
		$param['method'] = 'app.address.del';
		$param['uid'] = $uid;
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 意见反馈数据
	 *
	 * @param string $udid 客户端唯一标识
	 * @param int $page 第几页,默认1
	 * @param int $limit 限制读取的数目,默认10
	 * @return array 意见反馈接口返回的数据
	 */
	public static function suggestData($udid, $page = 1, $limit = 30)
	{
		$param = Yohobuy::param();
		$param['udid'] = $udid;
		$param['page'] = $page;
		$param['limit'] = $limit;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/getList', $param);
	}

	/**
	 * 意见靠谱,不靠谱接口
	 *
	 * @param int $uid 用户ID
	 * @param string $udid 客户端唯一标识
	 * @param int $suggest_id 意见id
	 * @return array 接口返回的数据
	 */
	public static function upAndDown($uid, $udid, $suggest_id)
	{
		$param = Yohobuy::param();
		$param['uid'] = $uid;
		$param['udid'] = $udid;
		$param['content'] = $suggest_id;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/is_reliable', $param);
	}

	/**
	 * 提交意见反馈接口
	 *
	 * @param int $uid 用户ID
	 * @param string $content 意见内容
	 * @param int $suggest_type 意见类型
	 * @return array 意见反馈接口返回的数据
	 */
	public static function savesuggestData($uid, $content, $suggest_type)
	{
		$param = Yohobuy::param();
		$param['uid'] = $uid;
		$param['content'] = $content;
		$param['suggest_type'] = $suggest_type;
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param);
	}

	/**
	 * 我的消息接口
	 *
	 * @param int $uid 用户ID
	 * @param int $page 获取第一页,默认是0
	 * @param int $size 获取数目,默认是10
	 * @return array 消息接口返回的数据
	 */
	public static function messageData($uid, $page = 0, $size = 10)
	{
		$param = Yohobuy::param();
		$param['uid'] = $uid;
		$param['size'] = $size;
		$param['page'] = $page;
		$param['method'] = 'app.inbox.getlist';
		$param['client_secret'] = Sign::getSign($param);

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

	/**
	 * 在线客服接口
	 *
	 * @return array 消息接口返回的数据
	 */
	public static function onlineServiceData()
	{
		$param = Yohobuy::param();
		$param['client_secret'] = Sign::getSign($param);

		return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v1/help/getCategory', $param);
	}

}