<?php
/**
 * Created by PhpStorm.
 * User: sicilon_IT
 * Date: 2023/3/2
 * Time: 18:09
 */
namespace app\index\model;
use think\Model;
class workerindaymodel extends Model{
    protected $table='t_workerdayinenclose';

    public function insinfo($arr){
        $res=$this->allowField(true)->save($arr);
        return $this->id;
    }

    public function selinfobywid($wid,$recdate,$pid){
        $where_arr['wid']=$wid;
        $where_arr['peid']=$pid;
        $where_arr['checkdate']=$recdate;
        $rec=$this->where($where_arr)->find();
        return $rec;
    }


    public function updateinstatus($wid,$recdate,$pid,$updatearr){
        $where_arr['wid']=$wid;
        $where_arr['peid']=$pid;
        $where_arr['checkdate']=$recdate;
        $where_arr['nowstatus']=2;
        $rec=$this->where($where_arr)->update($updatearr);
        return $rec;
    }

    /*
     * 数据层只处理操作，业务由上一层处理
     */
    public function updateoutstatus($wid,$recdate,$pid,$updatearr){
        $where_arr['wid']=$wid;
        $where_arr['peid']=$pid;
        $where_arr['checkdate']=$recdate;
        $where_arr['nowstatus']=1;
        $rec=$this->where($where_arr)->update($updatearr);
        return $rec;
    }
}