MessageData.php 2.88 KB
<?php

namespace LibModels\Web\Home;

use Api\Yohobuy;
use Api\Sign;

class MessageData
{

    /**
     * 获取我的消息列表数据
     * @param type $uid 用户id 
     * @param type $page 当前页
     * @param type $size 每页显示个数
     * @return type
     */
    public static function getInboxList($uid, $page, $size)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.inbox.getlist';
        $param['uid'] = $uid;
        $param['page'] = $page;
        $param['size'] = $size;
        $param['client_secret'] = Sign::getSign($param);

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

    /**
     * 删除我的消息
     * @param type $uid 用户id
     * @param type $id 消息id
     * @return type
     */
    public static function delMessageData($uid, $id)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.inbox.delmessage';
        $param['uid'] = $uid;
        $param['id'] = $id;
        $param['client_secret'] = Sign::getSign($param);

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

    /**
     * 批量设置消息为已读
     * @param type $uid 用户id
     * @param type $ids 选中消息id
     */
    public static function setRead($uid, $ids)
    {
        $param = Yohobuy::param();
        $param['method'] = 'web.inbox.setread';
        $param['uid'] = $uid;
        $param['ids'] = $ids;
        $param['client_secret'] = Sign::getSign($param);

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

    /**
     * 获取未读数量
     * @param type $uid 用户id
     */
    public static function unredTotal($uid)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.inbox.getTotal';
        $param['uid'] = $uid;
        $param['is_read'] = 'N';
        $param['client_secret'] = Sign::getSign($param);

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

    /**
     * 根据用户uid获取生日券id
     * @param type $uid
     * @return type
     */
    public static function getCouponId($uid)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.promotion.queryBirthCoupon';
        $param['uid'] = $uid;
        $param['couponType'] = 4;
        $param['client_secret'] = Sign::getSign($param);

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

    /**
     * vip会员领取生日券
     * @param type $uid 用户id
     * @param type $couponId 生日券号
     * @return type
     */
    public static function getBirthCoupon($uid, $couponId)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.promotion.getCoupon';
        $param['uid'] = $uid;
        $param['couponId'] = $couponId;
        $param['client_secret'] = Sign::getSign($param);

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

}