作者 开飞机的舒克
1 个管道 的构建 通过 耗费 3 秒

修改预约时间间隙问题

... ... @@ -69,8 +69,8 @@ class Subscribe extends Api
}
$id = $this->auth->id;
$model = new SeverSku();
$time = $model->timeLimit($param['tech'],$param['date'],$param['duration'],$param['time']);
if ($time != null){
$bool = $model->timeLimit($param['tech'],$param['date'],$param['duration'],$param['time']);
if ($bool === false){
$this->error('当前时间不可选,请重新选择');
}
$book_id = \db('book')->insertGetId([
... ...
... ... @@ -9,6 +9,25 @@ use think\Config;
*/
class Resource
{
/**
* 判断数组中数据是否为同一
*/
public static function areAllValuesSame($array) {
if (count($array) <= 1) {
return true; // 如果数组为空或只有一个元素,它们被认为是相同的
}
$firstValue = $array[0];
foreach ($array as $value) {
if ($value !== $firstValue) {
return false;
}
}
return true;
}
/**
* 计算两点地理坐标之间的距离
* @param Decimal $longitude1 起点经度
... ...
... ... @@ -2,6 +2,7 @@
namespace app\common\model;
use app\common\controller\Resource;
use think\Model;
class SeverSku extends Model
... ... @@ -31,49 +32,15 @@ class SeverSku extends Model
*/
public function timeLimit($tech_id, $date, $duration, $time)
{
$tech = db('tech_status')->where(['date' => $date, 'tech_id' => $tech_id, 'status' => 0])->column('time');
$mins = db('duration')->where('id', $duration)->value('time');
$year = date('Y', time());
$dates = $date;
$yue = $year . "-" . $dates;
$shi = $time;
$time1 = strtotime("$yue $shi");
$time2 = $time1 + ($mins * 60);
$t1 = date('H:i', $time1);
$t2 = date('H:i', $time2);
//判断是否有间隔
$ti1 = $time1 + 15 * 60;
$tis1 = date('H:i', $ti1);
$ti2 = $time1 + 30 * 60;
$tis2 = date('H:i', $ti2);
$ti3 = $time1 + 45 * 60;
$tis3 = date('H:i', $ti3);
$ti4 = $time1 + 60 * 60;
$tis4 = date('H:i', $ti4);
$ti5 = $time1 + 75 * 60;
$tis5 = date('H:i', $ti5);
$ti6 = $time1 + 90 * 60;
$tis6 = date('H:i', $ti6);
$t3 = null;
if (in_array($tis1, $tech)) {
$t3 = $t2;
}
if (in_array($tis2, $tech)) {
$t3 = $t2;
}
if (in_array($tis3, $tech)) {
$t3 = $t2;
}
if (in_array($tis4, $tech)) {
$t3 = $t2;
}
if (in_array($tis5, $tech)) {
$t3 = $t2;
}
if (in_array($tis6, $tech)) {
$t3 = $t2;
}
return $t3;
$yue = $year . "-" . $date;
$time1 = strtotime("$yue $time");
$endTime = $time1 + ($mins * 60);
$end_time = date('H:i',$endTime);
$status = db('tech_status')->where(['date' => $date, 'tech_id' => $tech_id, 'time' => ['between',[$time,$end_time]]])->column('status');
$bool = (new Resource())::areAllValuesSame($status);
return $bool;
}
... ...
... ... @@ -15,8 +15,8 @@ use think\Env;
return [
//测试服务器
//数据库类型
// 'type' => Env::get('database.type', 'mysql'),
// 服务器地址
'type' => Env::get('database.type', 'mysql'),
// 服务器地址
// 'hostname' => Env::get('database.hostname', '114.115.130.49'),
// // 数据库名
// 'database' => Env::get('database.database', 'soospa_shs_broin'),
... ... @@ -26,8 +26,8 @@ return [
// 'password' => Env::get('database.password', 'zS4miWxHJszykZEc'),
// // 端口
// 'hostport' => Env::get('database.hostport', ''),
'type' => Env::get('database.type', 'mysql'),
// 服务器地址
// 'type' => Env::get('database.type', 'mysql'),
// // 服务器地址
'hostname' => Env::get('database.hostname', '119.3.83.59'),
// 数据库名
'database' => Env::get('database.database', 'soospa'),
... ...