40 lines
804 B
PHP
Executable File
40 lines
804 B
PHP
Executable File
<?php
|
|
/**
|
|
* @createtime 2023/4/20
|
|
* @author wild
|
|
* @copyright PhpStorm
|
|
*/
|
|
|
|
|
|
namespace App\Model\Seller;
|
|
|
|
use App\Enums\BoolEnum;
|
|
use App\Enums\CooperateState;
|
|
use App\Model\BaseModel;
|
|
use App\Model\LotteryType;
|
|
|
|
class ShopCooperateLottery extends BaseModel
|
|
{
|
|
const METHOD_AUTO = 1;
|
|
const METHOD_MANUAL = 2;
|
|
|
|
public function lotteryType() {
|
|
return $this->belongsTo(LotteryType::class, 'lottery_type_id', 'id');
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('opened', BoolEnum::YES)
|
|
->where('audit_state', CooperateState::SUCCESS);
|
|
}
|
|
|
|
public function getBrokerageMoney($money)
|
|
{
|
|
if (bc_lte($this->brokerage, 0)) {
|
|
return 0;
|
|
}
|
|
|
|
return $money * ($this->brokerage/100);
|
|
}
|
|
}
|