<?php

namespace app\index\controller;

use think\exception\ValidateException;
use app\model\OrderTimescardRecord;

class OrdertimescardtecordController extends Base
{
    public function writeoff()
    {
        $orderid = input('post.orderid', '', 'serach_in');
        $uid = input('post.uid', '', 'serach_in');
        $is_timing = input('post.is_timing', '', 'serach_in');
        $time = time();

        if ($is_timing == 1) {
            $data = OrderTimescardRecord::where([
                'order_id' => $orderid,
                'is_complete' => 0,
            ])->find();
        } else {

            $data =  OrderTimescardRecord::create([
                'order_id' => $orderid,
                'uid' => $uid,
                'yue_begin_time' => $time,
                'yue_end_time' => $time,
                'begin_time' => $time,
                'is_complete' => 1,
                'end_time' => $time
            ]);
        }

        return $this->json(['data' => $data]);
    }
}
