[色子游戏]玩家抽奖记录-新增字段保存中奖详情记录信息

This commit is contained in:
2026-03-04 10:21:05 +08:00
parent 5b39efc7a3
commit 894a562eb4
7 changed files with 269 additions and 10 deletions

View File

@@ -24,4 +24,36 @@ class DicePlayRecordLogic extends BaseLogic
$this->model = new DicePlayRecord();
}
/**
* 添加前roll_array 转为 JSON 字符串(数据库为 string 类型)
*/
public function add(array $data): mixed
{
$data = $this->normalizeRollArray($data);
return parent::add($data);
}
/**
* 修改前roll_array 转为 JSON 字符串(数据库为 string 类型)
*/
public function edit($id, array $data): mixed
{
$data = $this->normalizeRollArray($data);
return parent::edit($id, $data);
}
/**
* 将 roll_array 从数组转为 JSON 字符串
*/
private function normalizeRollArray(array $data): array
{
if (!array_key_exists('roll_array', $data)) {
return $data;
}
$val = $data['roll_array'];
if (is_array($val)) {
$data['roll_array'] = json_encode($val, JSON_UNESCAPED_UNICODE);
}
return $data;
}
}