Merge remote-tracking branch 'origin/yhq' into lyf
# Conflicts: # src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopInfo.java # src/main/java/com/chaozhanggui/system/cashierservice/entity/TbSystemCoupons.java # src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConfig.java # src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitProducer.java # src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java # src/main/java/com/chaozhanggui/system/cashierservice/util/RandomUtil.java # src/main/resources/application-dev.yml # src/main/resources/application-dev2.yml # src/main/resources/application-prod.yml # src/main/resources/application-prod2.yml # src/main/resources/mapper/TbShopInfoMapper.xml
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CacheMap {
|
||||
Map<String,String> map = new HashMap(){{
|
||||
put("sign","1");
|
||||
}};
|
||||
Map<String,String> notOpenMap = new HashMap(){{
|
||||
put("sign","1");
|
||||
put("openId","1");
|
||||
}};
|
||||
}
|
||||
@@ -105,7 +105,9 @@ public class DateUtils {
|
||||
public static String getTime() {
|
||||
return sdfTime.format(new Date());
|
||||
}
|
||||
|
||||
public static String getStrTime(Date date) {
|
||||
return sdfTime.format(date);
|
||||
}
|
||||
/**
|
||||
* @Title: compareDate
|
||||
* @Description: TODO(日期比较,如果s>=e 返回true 否则返回false)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class NicknameGenerator {
|
||||
private static final String[] FIRST_NAMES = {
|
||||
"晓", "小", "云", "飞", "宝", "琳", "静", "翔", "晨", "昊", "若", "萌", "悦", "舒", "婷", "紫", "凡", "佳", "雨", "阳"
|
||||
};
|
||||
|
||||
private static final String[] LAST_NAMES = {
|
||||
"天", "星", "月", "琪", "雪", "梦", "婷", "晨", "宇", "瑞", "颖", "欣", "莹", "妍", "娜", "辰", "楠", "妮", "欢", "瑶"
|
||||
};
|
||||
|
||||
private static final String[] WORDS = {
|
||||
"烟火", "夜景", "小巷", "阳光", "雨滴", "星空", "花海", "梦境", "魔法", "飞翔", "童话", "温柔", "快乐", "微笑", "甜蜜", "浪漫", "幸福"
|
||||
};
|
||||
|
||||
private static final String[] EMOJIS = {
|
||||
"(^-^)", "( ̄▽ ̄)~■干杯□~( ̄▽ ̄)", "(*^▽^*)", "≧◡≦", "ヾ(≧▽≦*)o",
|
||||
"(*^3^)/~☆", "(*^▽^*)", "╰( ̄▽ ̄)╮", "(o^^)o", "(づ ̄ 3 ̄)づ"
|
||||
};
|
||||
|
||||
public static String generateRandomWeChatNickname() {
|
||||
Random random = new Random();
|
||||
String firstName = FIRST_NAMES[random.nextInt(FIRST_NAMES.length)];
|
||||
String lastName = LAST_NAMES[random.nextInt(LAST_NAMES.length)];
|
||||
String word = WORDS[random.nextInt(WORDS.length)];
|
||||
String emoji = EMOJIS[random.nextInt(EMOJIS.length)];
|
||||
return firstName + lastName + word + emoji;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -33,4 +37,24 @@ public class RandomUtil {
|
||||
|
||||
return random.nextInt(46) + 1;
|
||||
}
|
||||
|
||||
//获取BigDeciaml随机数
|
||||
public static BigDecimal getRandomBigDecimal(BigDecimal minAmount, BigDecimal maxAmount) {
|
||||
BigDecimal randomBigDecimal = maxAmount.subtract(minAmount).multiply(new BigDecimal(Math.random())).add(minAmount);
|
||||
return randomBigDecimal.setScale(2, RoundingMode.HALF_UP); // 设置保留两位小数并四舍五入
|
||||
}
|
||||
//获取中奖随机数
|
||||
public static TbOrderInfo selectWinner(List<TbOrderInfo> list, Map<Integer,Integer> map) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null; // 如果用户列表为空,则返回null
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
int randomIndex = random.nextInt(list.size()); // 生成一个随机的索引值
|
||||
TbOrderInfo orderInfo = list.get(randomIndex);
|
||||
if (map.containsKey(orderInfo.getId())){
|
||||
return selectWinner(list,map);
|
||||
}
|
||||
return list.get(randomIndex); // 返回对应索引的用户
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user