华南城更新

1 个父辈 a9c3782c
...@@ -6,7 +6,7 @@ import java.util.Date; ...@@ -6,7 +6,7 @@ import java.util.Date;
import javax.persistence.Id; import javax.persistence.Id;
public class Lotterylog implements Serializable{ public class Lotterylog implements Serializable {
/** /**
* *
*/ */
...@@ -18,7 +18,7 @@ public class Lotterylog implements Serializable{ ...@@ -18,7 +18,7 @@ public class Lotterylog implements Serializable{
private BigDecimal mny; private BigDecimal mny;
private Integer status; private Integer status;
private Integer turn; private Integer turn;
private Integer prizeId;
private Date createdtime; private Date createdtime;
public Integer getId() { public Integer getId() {
...@@ -33,7 +33,6 @@ public class Lotterylog implements Serializable{ ...@@ -33,7 +33,6 @@ public class Lotterylog implements Serializable{
this.prizeName = prizeName; this.prizeName = prizeName;
} }
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
...@@ -53,6 +52,7 @@ public class Lotterylog implements Serializable{ ...@@ -53,6 +52,7 @@ public class Lotterylog implements Serializable{
public void setMny(BigDecimal mny) { public void setMny(BigDecimal mny) {
this.mny = mny; this.mny = mny;
} }
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }
...@@ -77,5 +77,11 @@ public class Lotterylog implements Serializable{ ...@@ -77,5 +77,11 @@ public class Lotterylog implements Serializable{
this.createdtime = createdtime; this.createdtime = createdtime;
} }
public Integer getPrizeId() {
return prizeId;
}
public void setPrizeId(Integer prizeId) {
this.prizeId = prizeId;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -132,6 +132,7 @@ public class ActivityService { ...@@ -132,6 +132,7 @@ public class ActivityService {
public void updateActivityPrize(Integer type, Prize prize) { public void updateActivityPrize(Integer type, Prize prize) {
Activity setting = getActivitySetting(); Activity setting = getActivitySetting();
prize.setId(type);
switch (type) { switch (type) {
case 1: case 1:
setting.setP1(prize); setting.setP1(prize);
......
...@@ -76,16 +76,12 @@ public class AutoreplyService { ...@@ -76,16 +76,12 @@ public class AutoreplyService {
AutoreplyDao autoreplyDao; AutoreplyDao autoreplyDao;
static List<RegexKeywordFilter> filterList = Lists.newArrayList(); static List<RegexKeywordFilter> filterList = Lists.newArrayList();
static RegexKeywordFilter projectNameFilter = new RegexKeywordFilter();
static Map<String, Integer> projectNameMap = Maps.newHashMap();
static boolean inited = false; static boolean inited = false;
public void init(boolean hard) { public void init(boolean hard) {
if (hard) { if (hard) {
inited = false; inited = false;
filterList = Lists.newArrayList(); filterList = Lists.newArrayList();
projectNameFilter = new RegexKeywordFilter();
projectNameMap = Maps.newHashMap();
} }
init(); init();
} }
...@@ -105,33 +101,15 @@ public class AutoreplyService { ...@@ -105,33 +101,15 @@ public class AutoreplyService {
filter.compile(); filter.compile();
filterList.add(filter); filterList.add(filter);
}); });
projectNameMap.put("全部", 0);
projectNameFilter.add("全部");
projectNameFilter.compile();
inited = true; inited = true;
} }
@Autowired @Autowired
RedisTemplate<String, String> redisTemplate; RedisTemplate<String, String> redisTemplate;
public void conentProjectName(String content, String fromUserName) {
boolean b = projectNameFilter.hasKeywords(content);
if (b) {
Set<String> set = projectNameMap.keySet();
set.stream().forEach(s -> {
int count = projectNameFilter.count(content, s);
if (count > 0) {
log.info("包含{},修改projectId为{}", s, projectNameMap.get(s));
redisTemplate.opsForValue().set("dvmini171027_dvmini_cache_project_" + fromUserName,
projectNameMap.get(s) + "");
}
});
}
}
public Autoreply autoreply(String string, Integer projectId) { public Autoreply autoreply(String string) {
List<Set> sets = Lists.newArrayList(); List<Set> sets = Lists.newArrayList();
...@@ -164,7 +142,7 @@ public class AutoreplyService { ...@@ -164,7 +142,7 @@ public class AutoreplyService {
return null; return null;
List<String> list = Lists.newArrayList(); List<String> list = Lists.newArrayList();
list.addAll(sets.get(0)); list.addAll(sets.get(0));
List<Autoreply> autoreplys = autoreplyDao.findByKeys(list, projectId); List<Autoreply> autoreplys = autoreplyDao.findByKeys(list, null);
if (autoreplys.isEmpty()) if (autoreplys.isEmpty())
return null; return null;
...@@ -218,14 +196,6 @@ public class AutoreplyService { ...@@ -218,14 +196,6 @@ public class AutoreplyService {
return pageresult; return pageresult;
} }
/*
* (非 Javadoc) Description:
*
* @see
* com.w1hd.zzhnc.service.AutoreplyService#addAutoReply(java.lang.String,
* boolean, java.lang.String)
*/
public String addAutoReply(String keywords, boolean isRedirectStaff, String content, Integer projectId, public String addAutoReply(String keywords, boolean isRedirectStaff, String content, Integer projectId,
String projectName, Integer sort) { String projectName, Integer sort) {
if (Strings.isNullOrEmpty(keywords)) if (Strings.isNullOrEmpty(keywords))
...@@ -321,15 +291,10 @@ public class AutoreplyService { ...@@ -321,15 +291,10 @@ public class AutoreplyService {
} }
public HashMap<Object, Object> autoreply(String content, Integer projectId, String fromUserName) { public HashMap<Object, Object> autoreply(String content, Integer projectId, String fromUserName) {
conentProjectName(content, fromUserName);
String projectIdStr = redisTemplate.opsForValue().get("dvmini171027_dvmini_cache_project_" + fromUserName);
Autoreply autoreply = null; Autoreply autoreply = null;
if (!Strings.isNullOrEmpty(projectIdStr)) {
projectId = Integer.parseInt(projectIdStr);
autoreply = autoreply(content, projectId);
}
if (autoreply == null) { if (autoreply == null) {
autoreply = autoreply(content, 0); autoreply = autoreply(content);
} }
HashMap<Object, Object> result = Maps.newHashMap(); HashMap<Object, Object> result = Maps.newHashMap();
......
...@@ -131,9 +131,10 @@ public class PrizeService { ...@@ -131,9 +131,10 @@ public class PrizeService {
lotterylog.setFansid(fansId); lotterylog.setFansid(fansId);
lotterylog.setMny(mny); lotterylog.setMny(mny);
lotterylog.setPrizeName(p.getName()); lotterylog.setPrizeName(p.getName());
if("谢谢".equals(p.getName())) { lotterylog.setPrizeId(pType);
if ("谢谢".equals(p.getName())) {
lotterylog.setStatus(3); lotterylog.setStatus(3);
}else { } else {
lotterylog.setStatus(1); lotterylog.setStatus(1);
} }
lotterylog.setTurn(setting.getTurn()); lotterylog.setTurn(setting.getTurn());
...@@ -174,6 +175,29 @@ public class PrizeService { ...@@ -174,6 +175,29 @@ public class PrizeService {
Activity activity = activityService.getActivitySetting(); Activity activity = activityService.getActivitySetting();
int nextInt = RandomUtils.nextInt(0, 100); int nextInt = RandomUtils.nextInt(0, 100);
System.out.println("幸运数字 ---》》》" + nextInt); System.out.println("幸运数字 ---》》》" + nextInt);
int sumNum = 0;
int sumPro = 0;
Prize tmp = null;
List<Prize> prizeList = activityService.getPrizeList();
for (Prize p : prizeList) {
if (p != null) {
sumNum += p.getNum();
sumPro += p.getProbability();
if (p.getName().contains("谢谢")) {
tmp = p;
}
}
}
int mny = 0;
Integer logId = 0;
if (nextInt > sumPro) {
if (tmp != null) {
if (tmp.getIsMoney()) {
mny = RandomUtils.nextInt(tmp.getMixMoney(), tmp.getMaxMoney());
}
logId = insert(fansId, tmp.getId(), new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
}
} else {
Prize p8 = activity.getP8(); Prize p8 = activity.getP8();
Prize p7 = activity.getP7(); Prize p7 = activity.getP7();
Prize p6 = activity.getP6(); Prize p6 = activity.getP6();
...@@ -182,9 +206,7 @@ public class PrizeService { ...@@ -182,9 +206,7 @@ public class PrizeService {
Prize p3 = activity.getP3(); Prize p3 = activity.getP3();
Prize p2 = activity.getP2(); Prize p2 = activity.getP2();
Prize p1 = activity.getP1(); Prize p1 = activity.getP1();
nextInt = 51;
int mny = 0;
Integer logId = 0;
if (p1 != null && nextInt < p1.getProbability() && p1.getNum() > 1) { if (p1 != null && nextInt < p1.getProbability() && p1.getNum() > 1) {
if (p1.getIsMoney()) { if (p1.getIsMoney()) {
mny = RandomUtils.nextInt(p1.getMixMoney(), p1.getMaxMoney()); mny = RandomUtils.nextInt(p1.getMixMoney(), p1.getMaxMoney());
...@@ -201,9 +223,8 @@ public class PrizeService { ...@@ -201,9 +223,8 @@ public class PrizeService {
mny = RandomUtils.nextInt(p3.getMixMoney(), p3.getMaxMoney()); mny = RandomUtils.nextInt(p3.getMixMoney(), p3.getMaxMoney());
} }
logId = insert(fansId, 3, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP)); logId = insert(fansId, 3, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p4 != null } else if (p4 != null && nextInt < (p4.getProbability() + p3.getProbability() + p2.getProbability()
&& nextInt < (p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability()) + p1.getProbability()) && p4.getNum() > 1) {
&& p4.getNum() > 1) {
if (p4.getIsMoney()) { if (p4.getIsMoney()) {
mny = RandomUtils.nextInt(p4.getMixMoney(), p4.getMaxMoney()); mny = RandomUtils.nextInt(p4.getMixMoney(), p4.getMaxMoney());
} }
...@@ -220,24 +241,28 @@ public class PrizeService { ...@@ -220,24 +241,28 @@ public class PrizeService {
mny = RandomUtils.nextInt(p6.getMixMoney(), p6.getMaxMoney()); mny = RandomUtils.nextInt(p6.getMixMoney(), p6.getMaxMoney());
} }
logId = insert(fansId, 6, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP)); logId = insert(fansId, 6, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p7 != null && nextInt < (p7.getProbability() + p6.getProbability() + p5.getProbability() } else if (p7 != null
&& nextInt < (p7.getProbability() + p6.getProbability() + p5.getProbability()
+ p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability()) + p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability())
&& p7.getNum() > 1) { && p7.getNum() > 1) {
if (p7.getIsMoney()) { if (p7.getIsMoney()) {
mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney()); mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney());
} }
logId = insert(fansId, 7, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP)); logId = insert(fansId, 7, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else if (p8 != null } else if (p8 != null && nextInt < (p8.getProbability() + p7.getProbability() + p6.getProbability()
&& nextInt < (p8.getProbability() + p7.getProbability() + p6.getProbability() + p5.getProbability() + p5.getProbability() + p4.getProbability() + p3.getProbability() + p2.getProbability()
+ p4.getProbability() + p3.getProbability() + p2.getProbability() + p1.getProbability()) + p1.getProbability()) && p8.getNum() > 1) {
&& p8.getNum() > 1) {
if (p8.getIsMoney()) { if (p8.getIsMoney()) {
mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney()); mny = RandomUtils.nextInt(p7.getMixMoney(), p7.getMaxMoney());
} }
logId = insert(fansId, 8, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP)); logId = insert(fansId, 8, new BigDecimal(mny * 0.01).setScale(2, RoundingMode.HALF_UP));
} else { } else {
return -0; if (sumNum > 0) {
return randomKill(fansId);
}
} }
}
redisTemplate.opsForValue().set(PRIZE_KILL_FANSID + fansId, logId); redisTemplate.opsForValue().set(PRIZE_KILL_FANSID + fansId, logId);
return logId; return logId;
} }
......
Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
请先完成此消息的编辑!