46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
<?php
 | 
						|
 | 
						|
namespace app\model;
 | 
						|
 | 
						|
use think\Collection;
 | 
						|
use think\db\exception\DataNotFoundException;
 | 
						|
use think\db\exception\DbException;
 | 
						|
use think\db\exception\ModelNotFoundException;
 | 
						|
 | 
						|
/**
 | 
						|
 * 优惠券验证记录  各个角色的提成
 | 
						|
 * Class Coupon
 | 
						|
 * @package app\model
 | 
						|
 */
 | 
						|
class CouponBill extends Base
 | 
						|
{
 | 
						|
    public const  agency_money              = "agency_money";//渠道商的流水字段
 | 
						|
    public const  admin_money               = "admin_money";//平台的流水字段
 | 
						|
    public const  consumer_money            = "consumer_money";//消费者的流水字段
 | 
						|
    public const  distribution_money_money  = "distribution_money";//分销者的流水字段
 | 
						|
    public function couponMain()
 | 
						|
    {
 | 
						|
        return $this->hasOne(CouponMain::class, 'id',"coupon_main_id");
 | 
						|
    }
 | 
						|
 | 
						|
    public function business()
 | 
						|
    {
 | 
						|
        return $this->hasOne(Business::class, 'code',"business_code");
 | 
						|
    }
 | 
						|
    public function account()
 | 
						|
    {
 | 
						|
        return $this->hasOne(Account::class, 'user_code',"user_code");
 | 
						|
    }
 | 
						|
 | 
						|
    public static function getUserOne($userCode,$couponMainId,$couponId)
 | 
						|
    {
 | 
						|
        return self::where(
 | 
						|
            [
 | 
						|
                ["user_code","=",$userCode],
 | 
						|
                ["coupon_main_id","=",$couponMainId],
 | 
						|
                ["coupon_id","=",$couponId],
 | 
						|
            ]
 | 
						|
        )->find();
 | 
						|
 | 
						|
    }
 | 
						|
} |