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

update activity

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