[色子游戏]玩家购买抽奖记录-优化样式

This commit is contained in:
2026-03-03 15:28:13 +08:00
parent 1b62a4f3e0
commit c02d19b1fd
8 changed files with 424 additions and 42 deletions

View File

@@ -6,7 +6,9 @@
// +----------------------------------------------------------------------
namespace app\dice\model\player_coin_record;
use app\dice\model\player\DicePlayer;
use plugin\saiadmin\basic\think\BaseModel;
use think\model\relation\BelongsTo;
/**
* 玩家购买抽奖记录模型
@@ -40,9 +42,104 @@ class DicePlayerCoinRecord extends BaseModel
/**
* 关联模型 dicePlayer
*/
public function dicePlayer()
public function dicePlayer(): BelongsTo
{
return $this->belongsTo(DicePlayer::class, 'player_id', 'id');
}
/**
* 按关联玩家用户名搜索dicePlayer.username
*/
public function searchUsernameAttr($query, $value)
{
if ($value === '' || $value === null) {
return;
}
$playerIds = DicePlayer::where('username', 'like', '%' . $value . '%')->column('id');
if (!empty($playerIds)) {
$query->whereIn('player_id', $playerIds);
} else {
$query->whereRaw('1=0');
}
}
/** 消耗硬币下限 */
public function searchUseCoinsMinAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('use_coins', '>=', $value);
}
}
/** 消耗硬币上限 */
public function searchUseCoinsMaxAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('use_coins', '<=', $value);
}
}
/** 总抽奖次数下限 */
public function searchTotalDrawCountMinAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('total_draw_count', '>=', $value);
}
}
/** 总抽奖次数上限 */
public function searchTotalDrawCountMaxAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('total_draw_count', '<=', $value);
}
}
/** 购买抽奖次数下限 */
public function searchPaidDrawCountMinAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('paid_draw_count', '>=', $value);
}
}
/** 购买抽奖次数上限 */
public function searchPaidDrawCountMaxAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('paid_draw_count', '<=', $value);
}
}
/** 赠送抽奖次数下限 */
public function searchFreeDrawCountMinAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('free_draw_count', '>=', $value);
}
}
/** 赠送抽奖次数上限 */
public function searchFreeDrawCountMaxAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('free_draw_count', '<=', $value);
}
}
/** 创建时间起始 */
public function searchCreateTimeMinAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('create_time', '>=', $value);
}
}
/** 创建时间结束 */
public function searchCreateTimeMaxAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('create_time', '<=', $value);
}
}
}