<?php

namespace app\model;
//红包记录
class Redpack extends Base
{

    public  const userTypeDistribution  = "distribution";//分销者
    public  const userTypeDistributed   = "distributed";//被分销者
    public  const userTypeAgency        = "agency"; //  渠道商
    /**
     * 获取分销红包记录
     * @param string $userType 红包获取人的角色
     * @param string $distributionUserCode 分销人/渠道商/被分销者 user_code
     * @param mixed $couponMainId 分销的couponMain 优惠券id
     * 以上三个参数就可以确定 分销数据的唯一性
     * */
    public static function getDistributionRedpack($userType,$distributionUserCode,$couponMainId)
    {
        return self::where([
            ["user_type","=",$userType],
            ["user_code","=",$distributionUserCode],
            ["coupon_id","=",$couponMainId],
        ])
            ->find();
    }
}