<commit_before><?php

namespace App\Http\Controllers\Api;

use App\Models\Busi\Employee;
use App\Models\Busi\VisitStoreCalendar;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Busi\Attendance as Entity;
use DB;

class AttendanceController extends ApiController
{
    public function newEntity(array $attributes = [])
    {
        return new Entity($attributes);
    }

	/**
	 * Store a newly created resource in storage.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @return \Illuminate\Http\Response
	 */
	public function store(Request $request)
	{
		//
		$data = $request->all();
		unset($data['_sign']);
		$data['ftime'] = date('Y-m-d H:i:s');
		$employee = Employee::find($data['femp_id']);
		if(!empty($employee)){
			$data['fdept_id'] = $employee->fdept_id;
		}
		if(empty($data['type'])){
		    $data['type'] = 0;
        }
        if($data['type'] == 1){
		    //检查是否有日开始
            $c = Entity::where(DB::raw("date_format(ftime, '%Y-%m-%d')"), date('Y-m-d'))
                ->where('ftype', 0)
                ->where('femp_id', $data['femp_id'])
                ->count();
            if($c == 0){
                return $this->fail('未日开始, 不能日完成');
            }
            $s = VisitStoreCalendar::where('fdate', date('Y-m-d'))->where('femp_id', $data['femp_id'])->where('fstatus', '<', 3)->count();
            if($s > 0){
                return $this->fail('存在未拜访完成门店, 不能日完成');
            }
        }
		$entity = $this->newEntity($data);
		//$entity = Entity::create($data);
		$re = $entity->save();
		//LogSvr::Sync()->info('ModelCreated : '.json_encode($entity));
		//$status = $re ? 200 : 400;<commit_msg>bug fix<commit_after><?php

namespace App\Http\Controllers\Api;

use App\Models\Busi\Employee;
use App\Models\Busi\VisitStoreCalendar;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Busi\Attendance as Entity;
use DB;

class AttendanceController extends ApiController
{
    public function newEntity(array $attributes = [])
    {
        return new Entity($attributes);
    }

	/**
	 * Store a newly created resource in storage.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @return \Illuminate\Http\Response
	 */
	public function store(Request $request)
	{
		//
		$data = $request->all();
		unset($data['_sign']);
		$data['ftime'] = date('Y-m-d H:i:s');
		$employee = Employee::find($data['femp_id']);
		if(!empty($employee)){
			$data['fdept_id'] = $employee->fdept_id;
		}
		if(empty($data['ftype'])){
		    $data['ftype'] = 0;
        }
        if($data['ftype'] == 1){
		    //检查是否有日开始
            $c = Entity::where(DB::raw("date_format(ftime, '%Y-%m-%d')"), date('Y-m-d'))
                ->where('ftype', 0)
                ->where('femp_id', $data['femp_id'])
                ->count();
            if($c == 0){
                return $this->fail('未日开始, 不能日完成');
            }
            $s = VisitStoreCalendar::where('fdate', date('Y-m-d'))->where('femp_id', $data['femp_id'])->where('fstatus', '<', 3)->count();
            if($s > 0){
                return $this->fail('存在未拜访完成门店, 不能日完成');
            }
        }
		$entity = $this->newEntity($data);
		//$entity = Entity::create($data);
		$re = $entity->save();
		//LogSvr::Sync()->info('ModelCreated : '.json_encode($entity));
		//$status = $re ? 200 : 400;
{'fraction_non_alphanumeric': 0.2032983508245877, 'fraction_numerical': 0.00719640179910045, 'mean_word_length': 2.7315436241610738, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2552472', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1183, 'n_words': 194}