<?php

namespace app\admin\model;

use think\Model;

/**
 * 分组模型
 */
class Countmidtable extends Model
{
    public function getQueryDay($dayarray, $key = 0)
    {
        // $dayarray => ['2019-07-07','2019-07-08'....];

        $ret = $this->where(['dtype' => 'user.queue.day.length', 'mdate' => ['IN', $dayarray]])->select();
        $tmpData = [];
        if (count($ret) > 0) {
            foreach ($ret as $val) {
                $tmpData[$val['mdate']] = intval($val['dcontent']);
            }
        }
        $return = [];
        foreach ($dayarray as $sval) {
            if ($key) {
                $return[$sval] = isset($tmpData[$sval]) ? $tmpData[$sval] : 0;
            } else {
                $return[] = isset($tmpData[$sval]) ? $tmpData[$sval] : 0;
            }
        }
        return $return;
    }

}
