提交 c7afa481 authored 作者: 吴德鹏's avatar 吴德鹏

update activity

上级 8b2ad21e
......@@ -138,7 +138,6 @@ public class ActivityController {
}
public Activity checkActivity(String itemId) {
Result result = new Result();
Activity activity = null;
......@@ -207,12 +206,12 @@ public class ActivityController {
StringBuffer msg = new StringBuffer();
map.put("activity", activity);
boolean exist=false;
boolean exist = false;
int itemCount = 0;
for (String cartId : cartIds) {
Optional<TbCfCartRecordR> byId = cartRecordRRepository.findById(cartId);
if (byId.isPresent()) {
exist=true;
exist = true;
TbCfCartRecordR cart = byId.get();
itemCount += cart.getItemNum();
itemPrice = itemPrice.add(cart.getItemPrice()
......@@ -220,8 +219,8 @@ public class ActivityController {
}
}
if (!exist){
map.put("message",activity.getContent());
if (!exist) {
map.put("message", activity.getContent().trim());
return new Result(map);
}
......@@ -243,10 +242,9 @@ public class ActivityController {
BigDecimal threshold = new BigDecimal(key);
if (itemPrice.compareTo(threshold) >= 0) {
msg.delete(0,msg.length());
msg.delete(0, msg.length());
msg.append("Congrats, you've got " + discount + " off! ");
}
else {
} else {
lessAmount = threshold.subtract(itemPrice);
String less = nf.format(lessAmount);
msg.append("Spend " + less + " more to Enjoy " + discount + " off !");
......@@ -271,10 +269,9 @@ public class ActivityController {
int num = (int) con.getKey();
if (itemCount >= num) {
msg.delete(0,msg.length());
msg.delete(0, msg.length());
msg.append("Congrats, you've got " + discount + " off ! ");
}
else {
} else {
msg.append("Buy " + (num - itemCount) + " more item to Enjoy " + discount + " off !");
break;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论