|
|
|
|
@ -195,12 +195,16 @@ class GateController extends CommonController
|
|
|
|
|
if ($today < $check->start_date || $today > $check->end_date) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '当前不在长期访客有效周期内']);
|
|
|
|
|
}
|
|
|
|
|
// 按自然日 biz_date:每日独立先进后离;昨日仅进或未核销等,不影响今日也需当日先「进厂」再「离厂」
|
|
|
|
|
$todayLastLog = GateLog::where('visit_id', $check->id)->where('biz_date', $today)->orderByDesc('id')->first();
|
|
|
|
|
if (!$todayLastLog && !empty($check->code)) {
|
|
|
|
|
$todayLastLog = GateLog::where('code', $check->code)->where('biz_date', $today)->orderByDesc('id')->first();
|
|
|
|
|
}
|
|
|
|
|
if ((int)$all['type'] === 1 && $todayLastLog && (int)$todayLastLog->action === 1) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '今日已进厂,请先离厂后再进厂']);
|
|
|
|
|
}
|
|
|
|
|
if ((int)$all['type'] === 2 && (!$todayLastLog || (int)$todayLastLog->action !== 1)) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '今日无有效进厂记录,无法离厂']);
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '今日暂无有效进厂记录,无法离厂。请以当日为准先核销进厂(若昨日仅有进厂或昨日未离,今日也需先核销进厂)。']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$remark = '进厂';
|
|
|
|
|
|