1
This commit is contained in:
@@ -1094,12 +1094,14 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
String orderNumberKey = "order_number:" + orderNumberForDedup;
|
||||
String existedOrderNumber = stringRedisTemplate.opsForValue().get(orderNumberKey);
|
||||
if (existedOrderNumber != null) {
|
||||
String warn = "[炸弹] [炸弹] [炸弹] 此订单编号(" + orderNumberForDedup + ")已经存在,请勿重复生成订单 [炸弹] [炸弹] [炸弹] ";
|
||||
StringBuilder warnOut = new StringBuilder();
|
||||
warnOut.append(warn).append("\n");
|
||||
return warnOut.toString().trim();
|
||||
// 如果强制生成,跳过订单编号重复检查
|
||||
if (!forceGenerate) {
|
||||
// 返回特殊错误码,前端会识别并弹出验证码
|
||||
return "ERROR_CODE:ORDER_NUMBER_DUPLICATE\n此订单编号(" + orderNumberForDedup + ")已经存在,请勿重复生成订单";
|
||||
}
|
||||
// forceGenerate为true时,跳过订单编号重复检查,继续执行
|
||||
}
|
||||
// 记录订单编号,24小时过期
|
||||
// 只有在不强制生成或订单编号不存在时才设置Redis(强制生成时也更新Redis记录)
|
||||
stringRedisTemplate.opsForValue().set(orderNumberKey, orderNumberForDedup, 1, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user