<?php

namespace app\manager\model;

use fastphp\base\Model;
use enum\user\User as UserEnum;

class FollowRecord extends Model
{
    protected $table = 'follow_record';

    /**
     * @description: 获取最新的跟进记录
     * @param {*}
     * @return {*}
     */
    public function getNewRecord($where,$limit = '3')
    {
        return $this->where($where)->order()->limit($limit)->fetchAll();
    }

    /**
     * @description: 获取待跟进状态超过15天
     * @param {*}
     * @return {*}
     */
    public function getOverTime()
    {
        $user_enum = new UserEnum;
        $time = date('Y-m-d H:i:s', time() - (86400 * 15));
        $where = [
            'active' => 1,
            'follow_status' => ['in', $user_enum::$Unfollow],
            'create_time' => ['<',$time]
        ];
        return $this->field('user_id,follow_status')->where($where)->fetchAll();
    }

    //获取营业销售信息
    public function getSellInfo($where1 = [], $where2 = '') {
        return $this->field('product_type,sell_money,sell_type')
            ->where($where1)
            ->where($where2)
            ->fetchAll();
    }
}
