quanwei
2 days ago 73b874c72ad55eb9eef21c36160ac0de58f0189e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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();
    }
 
}