|
|
@@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
@@ -102,9 +103,9 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void saveByOriginId(Long id, String orderType, Long enUU) {
|
|
|
- OrderRedDotAll redDotAll = redDotAllDao.findByOrderTypeAndOrderId(orderType, id);
|
|
|
- if (null == redDotAll) {
|
|
|
- redDotAll = new OrderRedDotAll(orderType, enUU);
|
|
|
+ Integer count = redDotAllDao.countByOrderTypeAndOrderId(orderType, id);
|
|
|
+ if (0 == count) {
|
|
|
+ OrderRedDotAll redDotAll = new OrderRedDotAll(orderType, enUU);
|
|
|
redDotAll.setOrderId(id);
|
|
|
redDotAllDao.save(redDotAll);
|
|
|
}
|
|
|
@@ -138,13 +139,13 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void setReadByIds(String orderType, Long... sourceIds) {
|
|
|
- List<OrderRedDotDone> redDotDoneList = new ArrayList<>();
|
|
|
+ Set<OrderRedDotDone> redDotDoneList = new HashSet<>();
|
|
|
Arrays.stream(sourceIds).forEach(id -> {
|
|
|
Integer count = countByOrderTypeAndOrderId(orderType, id);
|
|
|
if (count == 0) {
|
|
|
- OrderRedDotAll redDotAll = redDotAllDao.findByOrderTypeAndOrderId(orderType, id);
|
|
|
- if (null != redDotAll) {
|
|
|
- OrderRedDotDone redDotDone = new OrderRedDotDone(redDotAll);
|
|
|
+ List<OrderRedDotAll> redDotAllList = redDotAllDao.findByOrderTypeAndOrderId(orderType, id);
|
|
|
+ if (!CollectionUtils.isEmpty(redDotAllList)) {
|
|
|
+ OrderRedDotDone redDotDone = new OrderRedDotDone(redDotAllList.get(0));
|
|
|
redDotDoneList.add(redDotDone);
|
|
|
}
|
|
|
}
|