Files
commie c9c8a120ab 11
2026-02-24 21:02:17 +08:00

67 lines
1.8 KiB
PHP
Executable File

<?php
namespace app\model;
use app\model\Base;
/**
* @property integer $id 主键(ID) - 无注释
* @property string $title 名称
* @property float $price 价格
* @property number $role_id 关联角色
* @property number $month_discount 月折扣
* @property number $quarter_discount 季折扣
* @property number $year_discount 年折扣
* @property number $month_price 月价
* @property number $quarter_price 季价
* @property number $year_price 年价
* @property string $label 标签
* @property integer $status 0:禁用,1启用
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
*/
class Thali extends Base
{
protected function getOptions(): array
{
// 所有的参数配置统一返回
return array_merge(parent::getOptions(),[
'append' => [
'month_price',
'quarter_price',
'year_price'
],
]);
}
/**
* 月价
*/
public function getMonthPriceAttr($value,$row)
{
return round(bcmul($row['price'],$row['month_discount'],2));
}
/**
* 季价
*/
public function getQuarterPriceAttr($value,$row)
{
return round(bcmul($row['price']*3,$row['quarter_discount'],2));
}
/**
* 年价
*/
public function getYearPriceAttr($value,$row)
{
return round(bcmul($row['price']*12,$row['year_discount'],2));
}
function Role(){
return $this->hasOne('UserRole','id','role_id')->bind([
'name'=>'role_name',
'max_send_msg_count'=>'max_send_msg_count',
'max_friend_count'=>'max_friend_count',
'max_group_join_count'=>'max_group_join_count',
'max_gourp_create_count'=>'max_gourp_create_count'
]);
}
}