优化抽奖方式,以及记录相关信息

This commit is contained in:
2026-03-26 18:10:41 +08:00
parent 77ec0dcade
commit e32f3890f1
32 changed files with 304 additions and 244 deletions

View File

@@ -30,7 +30,7 @@ use think\model\relation\BelongsTo;
* @property $reward_win_coin 摇色子中奖平台币
* @property $use_coins 消耗平台币(兼容字段:付费局=paid_amount免费局=0
* @property $direction 方向:0=顺时针,1=逆时针
* @property $reward_config_id 奖励配置id
* @property $reward_tier 中奖档位T1,T2,T3,T4,T5,BIGWIN
* @property $lottery_id 奖池
* @property $start_index 起始索引
* @property $target_index 结束索引
@@ -64,15 +64,6 @@ class DicePlayRecord extends BaseModel
return $this->belongsTo(DicePlayer::class, 'player_id', 'id');
}
/**
* 中奖配置
* 关联模型 diceRewardConfig
*/
public function diceRewardConfig(): BelongsTo
{
return $this->belongsTo(DiceRewardConfig::class, 'reward_config_id', 'id');
}
/**
* 彩金池配置
* 关联模型 diceLotteryPoolConfig
@@ -252,24 +243,19 @@ class DicePlayRecord extends BaseModel
}
$ids = DiceRewardConfig::where('ui_text', 'like', '%' . $value . '%')->column('id');
if (!empty($ids)) {
$query->whereIn('reward_config_id', $ids);
$query->whereIn('target_index', $ids);
} else {
$query->whereRaw('1=0');
}
}
/** 按奖励档位(diceRewardConfig.tier中奖名 T1-T5 */
/** 按奖励档位(表字段 reward_tier中奖名 T1-T5/BIGWIN */
public function searchRewardTierAttr($query, $value)
{
if ($value === '' || $value === null) {
return;
}
$ids = DiceRewardConfig::where('tier', '=', $value)->column('id');
if (!empty($ids)) {
$query->whereIn('reward_config_id', $ids);
} else {
$query->whereRaw('1=0');
}
$query->where('reward_tier', '=', $value);
}
/** 方向 0=顺时针 1=逆时针 */

View File

@@ -7,7 +7,6 @@
namespace app\dice\model\play_record_test;
use plugin\saiadmin\basic\think\BaseModel;
use app\dice\model\reward_config\DiceRewardConfig;
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
use think\model\relation\BelongsTo;
@@ -25,7 +24,7 @@ use think\model\relation\BelongsTo;
* @property int|null $ante 底注/注数dice_ante_config.mult
* @property int|null $paid_amount 付费金额(付费局=ante*100免费局=0
* @property $direction 方向:0=顺时针,1=逆时针
* @property $reward_config_id 奖励配置id
* @property $reward_tier 中奖档位T1,T2,T3,T4,T5,BIGWIN
* @property $create_time 创建时间
* @property $update_time 修改时间
* @property $start_index 起始索引
@@ -61,15 +60,6 @@ class DicePlayRecordTest extends BaseModel
return $this->belongsTo(DiceLotteryPoolConfig::class, 'lottery_config_id', 'id');
}
/**
* 奖励配置(终点格 = target_index 对应 DiceRewardConfig.id表中为 reward_config_id
* 关联 reward_config_id -> DiceRewardConfig.id
*/
public function diceRewardConfig(): BelongsTo
{
return $this->belongsTo(DiceRewardConfig::class, 'reward_config_id', 'id');
}
/**
* 关联的权重测试记录
* reward_config_record_id -> DiceRewardConfigRecord.id
@@ -135,18 +125,13 @@ class DicePlayRecordTest extends BaseModel
}
}
/** 中奖档位(按 reward_config_id 对应 DiceRewardConfig.tier */
/** 中奖档位(按表字段 reward_tier */
public function searchRewardTierAttr($query, $value)
{
if ($value === '' || $value === null) {
return;
}
$ids = DiceRewardConfig::where('tier', '=', $value)->column('id');
if (!empty($ids)) {
$query->whereIn('reward_config_id', $ids);
} else {
$query->whereRaw('1=0');
}
$query->where('reward_tier', '=', $value);
}
/** 点数和 roll_number摇取点数和 5-30 */

View File

@@ -32,6 +32,7 @@ use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
* @property $total_ticket_count 总抽奖次数
* @property $paid_ticket_count 购买抽奖次数
* @property $free_ticket_count 赠送抽奖次数
* @property array|null $free_ticket 免费抽奖券:{"ante":1,"count":1}
* @property $create_time 创建时间
* @property $update_time 更新时间
* @property $delete_time 删除时间
@@ -54,6 +55,10 @@ class DicePlayer extends BaseModel
protected $updateTime = 'update_time';
protected $json = ['free_ticket'];
protected $jsonAssoc = true;
/**
* 新增前:生成唯一 uid昵称 name 默认使用 uid
* 用 try-catch 避免表尚未含 uid 时 getAttr/getData 抛 InvalidArgumentException