CouponData.php 1.08 KB
<?php

namespace LibModels\Web\Home;

use Api\Yohobuy;
use Api\Sign;

class CouponData
{

    /**
     * 获取领券频道资源
     * @param type $code 资源码
     * @param type $uid  用户uid
     */
    public static function getCouponRousource($contentCode, $uid)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.promotion.queryCouponCenter';
        $param['contentCode'] = $contentCode;
        if($uid !== 0){
           $param['uid'] = $uid; 
        }        
        $param['client_secret'] = Sign::getSign($param);
        return Yohobuy::get(Yohobuy::API_URL , $param);
    }

    /**
     * 领取优惠券
     * @param type $id  优惠券id
     * @param type $uid  用户uid
     */
    public static function sendCoupon($id, $uid)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.promotion.getCoupon';
        $param['couponId'] = $id;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

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

}