Skip to content

Commit

Permalink
新增多个商品随机延迟预约 (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu0823 authored Mar 24, 2024
1 parent ecedc46 commit 7a45518
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Random;

@Service
public class IMTServiceImpl implements IMTService {
Expand Down Expand Up @@ -191,6 +192,11 @@ public void reservation(IUser iUser) {
//预约
JSONObject json = reservation(iUser, itemId, shopId);
logContent += String.format("[预约项目]:%s\n[shopId]:%s\n[结果返回]:%s\n\n", itemId, shopId, json.toString());

//随机延迟3~5秒
Random random = new Random();
int sleepTime = random.nextInt(3) + 3;
Thread.sleep(sleepTime * 1000);
} catch (Exception e) {
logContent += String.format("执行报错--[预约项目]:%s\n[结果返回]:%s\n\n", itemId, e.getMessage());
}
Expand Down

0 comments on commit 7a45518

Please sign in to comment.