This commit is contained in:
li
2026-01-28 23:48:20 +08:00
commit b8cd0c9418
1293 changed files with 184011 additions and 0 deletions
+117
View File
@@ -0,0 +1,117 @@
<?php
namespace app\models\process;
use app\models\table\Table;
use app\services\connect\InitTableService;
use freedom\basic\BaseModel;
use freedom\traits\ModelTrait;
use think\facade\Db;
/**
* TODO 靴Model
* Class Boot
* @package app\models\process
*/
class Boot extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'boot';
use ModelTrait;
/**
* TODO 根据桌子获取最后一靴
* @param array $tableInfo
* @return array
*/
public static function getByTableIdOrderByIdDesc(array $tableInfo): array
{
$find = self::where(['table_id' => $tableInfo['id']])->order('id DESC')->find();
if ($find) return $find->toArray();
else return [];
}
/**
* TODO 根据日结创建新一局
* @param array $sumdayInfo
* @return array
*/
public static function addBySumday(array $sumdayInfo): array
{
$insert = array(
'table_id' => $sumdayInfo['table_id'],
'table_name' => $sumdayInfo['table_name'],
'game_id' => $sumdayInfo['game_id'],
'game_name' => $sumdayInfo['game_name'],
'sumday_id' => $sumdayInfo['id'],
'day' => $sumdayInfo['day'],
'boot_num' => 1,
'create_time' => time()
);
$newBoot = self::create($insert);
return $newBoot->toArray();
}
/**
* TODO 换靴
* @param array $tableInfo
* @return array
*/
public static function changeBoot(array $tableInfo): array
{
$bootInfo = self::getByTableIdOrderByIdDesc($tableInfo);
$numberTabInfo = NumberTab::getByBootIdOrderByIdDesc($bootInfo);
if (!$numberTabInfo){
return ['status' => false, 'msg' => 'change_boot_fail'];
}
if($numberTabInfo['bet_status'] != 0){
return ['status' => false, 'msg' => 'change_boot_false'];
}
try {
$insertBoot = [
'table_id' => $bootInfo['table_id'],
'table_name' => $bootInfo['table_name'],
'game_id' => $bootInfo['game_id'],
'game_name' => $bootInfo['game_name'],
'sumday_id' => $bootInfo['sumday_id'],
'day' => $bootInfo['day'],
'boot_num' => $bootInfo['boot_num']+1,
'create_time' => time()
];
$createBootRes = self::create($insertBoot);
$createBootRes = $createBootRes->toArray();
$createNumberTabRes = NumberTab::addByBoot($createBootRes);
WaybillRemind::where(['table_id' => $tableInfo['id']])->delete();
if ($tableInfo['in_checkout'] > 0){
Table::where(['id' => $tableInfo['id']])->update(['in_checkout' => 0]);
}
Db::commit();
return [
'status' => true,
'data' => [
'boot_id' => $createBootRes['id'],
'boot_num' => $createBootRes['boot_num'],
'number_tab_id' => $createNumberTabRes['id'],
'number_tab_number' => $createNumberTabRes['number'],
'in_checkout' => 0,
'number_tab_status' => InitTableService::numberTabStatus($createNumberTabRes)
]
];
} catch (\Exception $e) {
Db::rollback();
return ['status' => false, 'msg' => 'change_boot_fail'];
}
}
}
File diff suppressed because it is too large Load Diff
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\models\process;
use freedom\basic\BaseModel;
use freedom\traits\ModelTrait;
/**
* TODO 作废日志Model
* Class Bet
* @package app\models\process
*/
class RetreatedLog extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'retreatedLog';
use ModelTrait;
}
+123
View File
@@ -0,0 +1,123 @@
<?php
namespace app\models\process;
use app\models\table\Table;
use app\services\connect\InitTableService;
use freedom\basic\BaseModel;
use freedom\traits\ModelTrait;
use think\facade\Db;
/**
* TODO 日结Model
* Class Sumday
* @package app\models\process
*/
class Sumday extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'sumday';
use ModelTrait;
/**
* TODO 根据桌子获取最新的日结数据
* @param array $tableInfo
* @return array
*/
public static function getByTableIdOrderByIdDesc(array $tableInfo): array
{
$find = self::where(['table_id' => $tableInfo['id']])->order('id DESC')->find();
if ($find) return $find->toArray();
else return [];
}
/**
* TODO 插入一条新的日结数据
* @param array $tableInfo
* @return array
*/
public static function addByTable(array $tableInfo): array
{
$day = date('Y-m-d',time());
$insert = array(
'game_id' => $tableInfo['game_id'],
'game_name' => $tableInfo['game_name'],
'table_id' => $tableInfo['id'],
'table_name' => $tableInfo['table_name'],
'create_time' => time(),
'day' => $day,
'start_time' => time()
);
$newSumDay = self::create($insert);
return $newSumDay->toArray();
}
/**
* TODO 日结
* @param array $tableInfo
* @return array
*/
public static function resetBoot(array $tableInfo): array
{
$sumdayInfo = self::getByTableIdOrderByIdDesc($tableInfo);
$time = time();
$day = date('Y-m-d',$time);
if($day == $sumdayInfo['day']){
return ['status' => false, 'msg' => 'in_top_sumday'];
}
$bootInfo = Boot::getByTableIdOrderByIdDesc($tableInfo);
$numberTabInfo = NumberTab::getByBootIdOrderByIdDesc($bootInfo);
if (!$numberTabInfo){
return ['status' => false, 'msg' => 'reset_boot_fail'];
}
if($numberTabInfo['bet_status'] != 0){
return ['status' => false, 'msg' => 'reset_boot_false'];
}
Db::startTrans();
try {
//更新现在的sumday
$updateLastSumdayRes = self::where(['id' => $sumdayInfo['id']])->update(['is_checkout' => 1, 'end_time' => $time]);
$createSumdayRes = self::create([
'game_id' => $tableInfo['game_id'],
'game_name' => $tableInfo['game_name'],
'table_id' => $tableInfo['id'],
'table_name' => $tableInfo['table_name'],
'create_time' => $time,
'day' => $day,
'start_time' => $time
]);
$createSumdayRes = $createSumdayRes->toArray();
$createBootRes = Boot::addBySumday($createSumdayRes);
$createNumberTabRes = NumberTab::addByBoot($createBootRes);
WaybillRemind::where(['table_id' => $tableInfo['id']])->delete();
if ($tableInfo['in_checkout'] > 0) Table::where(['id' => $tableInfo['id']])->update(['in_checkout' => 0]);
Db::commit();
return [
'status' => true,
'data' => [
'boot_id' => $createBootRes['id'],
'boot_num' => $createBootRes['boot_num'],
'number_tab_id' => $createNumberTabRes['id'],
'number_tab_number' => $createNumberTabRes['number'],
'in_checkout' => 0,
'number_tab_status' => InitTableService::numberTabStatus($createNumberTabRes)
]
];
} catch (\Exception $e) {
Db::rollback();
return ['status' => false, 'msg' => 'reset_boot_fail'];
}
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace app\models\process;
use freedom\basic\BaseModel;
use freedom\traits\ModelTrait;
/**
* TODO 好路Model
* Class WaybillRemind
* @package app\models\process
*/
class WaybillRemind extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'waybillRemind';
use ModelTrait;
}