[色子游戏]玩家抽奖记录-新增字段保存中奖详情记录信息
This commit is contained in:
@@ -23,6 +23,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'is_win' => 'require',
|
||||
'win_coin' => 'require',
|
||||
'reward_config_id' => 'require',
|
||||
'roll_array' => 'require|checkRollArray',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'is_win' => '中奖必须填写',
|
||||
'win_coin' => '赢取平台币必须填写',
|
||||
'reward_config_id' => '奖励配置必须填写',
|
||||
'roll_array.require' => '摇取点数必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -48,6 +50,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'is_win',
|
||||
'win_coin',
|
||||
'reward_config_id',
|
||||
'roll_array',
|
||||
],
|
||||
'update' => [
|
||||
'player_id',
|
||||
@@ -56,7 +59,36 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'is_win',
|
||||
'win_coin',
|
||||
'reward_config_id',
|
||||
'roll_array',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证 roll_array:必须为 6 个元素,每个值在 1~6 之间
|
||||
* @param mixed $value
|
||||
* @param mixed $rule
|
||||
* @param array $data
|
||||
* @param string $field
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkRollArray($value, $rule = '', array $data = [], string $field = '')
|
||||
{
|
||||
if (is_string($value)) {
|
||||
$decoded = json_decode($value, true);
|
||||
$value = is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
if (!is_array($value)) {
|
||||
return '摇取点数必须为数组';
|
||||
}
|
||||
if (count($value) !== 6) {
|
||||
return '摇取点数必须为 6 个数';
|
||||
}
|
||||
foreach ($value as $i => $n) {
|
||||
$v = is_numeric($n) ? (int) $n : null;
|
||||
if ($v === null || $v < 1 || $v > 6) {
|
||||
return '摇取点数第' . ($i + 1) . '个值必须在 1~6 之间';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user