红包添加备注 和校验

This commit is contained in:
2025-10-13 15:56:46 +08:00
parent 72f56a4fb4
commit 4dcccc2896
2 changed files with 6 additions and 1 deletions

View File

@@ -97,7 +97,8 @@ class Redpacket extends Model
'status' => $data['countdown'] > 0 ? self::STATUS_PENDING : self::STATUS_ACTIVE,
'start_time' => $startTime,
'end_time' => $endTime,
'createtime' => time()
'createtime' => time(),
'remark' => $data['remark'] ?? '大吉大利,红包拿来啦!'
];
$redpacketId = $this->insertGetId($redpacketData);

View File

@@ -450,6 +450,10 @@ class RedpacketService
return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null];
}
if (empty($data['room_id'])) {
return ['code' => 0, 'msg' => '房间ID不能为空', 'data' => null];
}
if (!in_array($data['type'], [Redpacket::TYPE_NORMAL, Redpacket::TYPE_PASSWORD])) {
return ['code' => 0, 'msg' => '红包类型错误', 'data' => null];
}