no message
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryAiAnalysis extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_ai_analysis';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryCategory extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_category';
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryDraw extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_draw';
|
||||
|
||||
// JSON字段自动转数组
|
||||
protected $json = ['numbers', 'zodiac', 'elements', 'color'];
|
||||
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(LotteryCategory::class, 'category_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryDrawResult extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_draw_result';
|
||||
|
||||
protected $json = ['trend'];
|
||||
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
public function game()
|
||||
{
|
||||
return $this->belongsTo(LotteryGame::class, 'code', 'code');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryGame extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_game';
|
||||
|
||||
public function gameCategory()
|
||||
{
|
||||
return $this->belongsTo(LotteryGameCategory::class, 'category', 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryGameCategory extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_game_category';
|
||||
|
||||
public function games()
|
||||
{
|
||||
return $this->hasMany(LotteryGame::class, 'category', 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryNumberMapping extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_number_mapping';
|
||||
|
||||
// 类型常量
|
||||
const TYPE_ZODIAC = 1; // 生肖
|
||||
const TYPE_COLOR = 2; // 波色
|
||||
const TYPE_ELEMENT = 3; // 五行
|
||||
|
||||
protected $json = ['numbers'];
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
/**
|
||||
* 获取指定年份的全部映射数据
|
||||
*/
|
||||
public static function getByYear(int $year): array
|
||||
{
|
||||
$list = self::where('year', $year)->order('type asc, sort asc')->select()->toArray();
|
||||
$result = ['zodiac' => [], 'color' => [], 'element' => []];
|
||||
foreach ($list as $item) {
|
||||
$item['numbers'] = is_string($item['numbers']) ? json_decode($item['numbers'], true) : $item['numbers'];
|
||||
match ((int)$item['type']) {
|
||||
self::TYPE_ZODIAC => $result['zodiac'][] = $item,
|
||||
self::TYPE_COLOR => $result['color'][] = $item,
|
||||
self::TYPE_ELEMENT => $result['element'][] = $item,
|
||||
};
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定年份某类型的映射(按attr_name索引)
|
||||
*/
|
||||
public static function getMapByType(int $year, int $type): array
|
||||
{
|
||||
$list = self::where('year', $year)->where('type', $type)->order('sort asc')->select()->toArray();
|
||||
$map = [];
|
||||
foreach ($list as $item) {
|
||||
$nums = is_string($item['numbers']) ? json_decode($item['numbers'], true) : $item['numbers'];
|
||||
$map[$item['attr_name']] = $nums;
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据号码反查属性名(如:号码1 → 生肖"马"、波色"红波"、五行"水")
|
||||
*/
|
||||
public static function lookupNumber(int $year, int $number): array
|
||||
{
|
||||
$all = self::where('year', $year)->order('type asc, sort asc')->select()->toArray();
|
||||
$result = ['zodiac' => '', 'color' => '', 'element' => ''];
|
||||
foreach ($all as $item) {
|
||||
$nums = is_string($item['numbers']) ? json_decode($item['numbers'], true) : $item['numbers'];
|
||||
if (in_array($number, $nums)) {
|
||||
match ((int)$item['type']) {
|
||||
self::TYPE_ZODIAC => $result['zodiac'] = $item['attr_name'],
|
||||
self::TYPE_COLOR => $result['color'] = $item['attr_name'],
|
||||
self::TYPE_ELEMENT => $result['element'] = $item['attr_name'],
|
||||
};
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从上一年份复制映射数据到新年份(用于年度轮转后微调)
|
||||
*/
|
||||
public static function copyToNextYear(int $fromYear, int $toYear): int
|
||||
{
|
||||
$exists = self::where('year', $toYear)->count();
|
||||
if ($exists > 0) {
|
||||
return 0;
|
||||
}
|
||||
$list = self::where('year', $fromYear)->select()->toArray();
|
||||
$count = 0;
|
||||
foreach ($list as $item) {
|
||||
unset($item['id']);
|
||||
$item['year'] = $toYear;
|
||||
$item['create_time'] = time();
|
||||
$item['update_time'] = time();
|
||||
self::create($item);
|
||||
$count++;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\lottery;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class LotteryRegion extends BaseModel
|
||||
{
|
||||
protected $name = 'lottery_region';
|
||||
}
|
||||
Reference in New Issue
Block a user