<?php
|
|
namespace app\common\model\plus\bonus;
|
|
use app\common\model\BaseModel;
|
use app\common\enum\order\OrderTypeEnum;
|
|
/**
|
* 业绩统计模型
|
*/
|
class Performance extends BaseModel
|
{
|
protected $name = 'bonus_performance';
|
protected $pk = 'id';
|
|
/**
|
* 业绩所属用户
|
* @return \think\model\relation\BelongsTo
|
*/
|
public function user()
|
{
|
return $this->belongsTo('app\common\model\user\User');
|
}
|
|
/**
|
* 业绩明细
|
* @param $data
|
*/
|
public static function add($data)
|
{
|
$model = new static;
|
return $model->save($data);
|
}
|
|
public static function getPerformanceCount($user_id, $is_own = false)
|
{
|
$where = ['performance_id' => $user_id];
|
if ($is_own) {
|
$where['is_own'] = 1;
|
}
|
return (new static())->where($where)->count();
|
}
|
|
}
|