|
|
@@ -18,10 +18,7 @@ import com.uas.platform.b2b.model.OrderRedDotAll;
|
|
|
import com.uas.platform.b2b.model.OrderRedDotDone;
|
|
|
import com.uas.platform.b2b.model.OrderType;
|
|
|
import com.uas.platform.b2b.model.Role;
|
|
|
-import com.uas.platform.b2b.model.SearchFilter;
|
|
|
-import com.uas.platform.b2b.model.User;
|
|
|
import com.uas.platform.b2b.service.OrderRedDotService;
|
|
|
-import com.uas.platform.b2b.service.UserService;
|
|
|
import com.uas.platform.b2b.support.CollectionUtil;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
@@ -33,7 +30,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
@@ -53,9 +49,6 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
@Autowired
|
|
|
private OrderRedDotDoneDao redDotDoneDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserService userService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private CommonDao commonDao;
|
|
|
|
|
|
@@ -169,70 +162,6 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
return redDotDoneDao.countByOrderTypeAndOrderId(orderType, id);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 通过企业UU,用户UU,单据类型和id查询是否已读
|
|
|
- *
|
|
|
- * @param enUU 企业UU
|
|
|
- * @param userUU 用户UU
|
|
|
- * @param orderType 单据类型
|
|
|
- * @param orderId id
|
|
|
- * @return 阅读数量
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Integer countByEnUUAndUserUUAndOrderTypeAndOrderId(Long enUU, Long userUU, String orderType, Long orderId) {
|
|
|
- return redDotDoneDao.countByEnUUAndUserUUAndOrderTypeAndOrderId(enUU, userUU, orderType, orderId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过企业UU,用户UU,单据类型和id查询是否已读
|
|
|
- *
|
|
|
- * @param orderType 单据类型
|
|
|
- * @return 阅读数量
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Integer countByOrderType(String orderType) {
|
|
|
- return redDotDoneDao.countByEnUUAndUserUUAndOrderType(SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU(), orderType);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 消息总数(针对卖家)
|
|
|
- *
|
|
|
- * @param orderType 单据类型
|
|
|
- * @param roleName 角色
|
|
|
- * @return 数量
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Integer countAllByOrderTypeAndRole(String orderType, String roleName) {
|
|
|
- User user = SystemSession.getUser();
|
|
|
- final Integer[] countAll = {0};
|
|
|
- if (Role.SELLER.equals(roleName)) {
|
|
|
- Set<Role> roles = user.getRoles();
|
|
|
- Long enUU = user.getEnterprise().getUu();
|
|
|
- if (!CollectionUtils.isEmpty(roles)) {
|
|
|
- Iterator<Role> iterator = roles.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- Role role = iterator.next();
|
|
|
- if (!role.getEnUU().equals(enUU)) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- roles.forEach(role -> {
|
|
|
- if (role.isSys() || Role.ADMIN.equals(role.getName())) {
|
|
|
- countAll[0] = redDotAllDao.countByVendUUAndOrderType(user.getEnterprise().getUu(), orderType);
|
|
|
- } else {
|
|
|
- SearchFilter filter = userService.distribute();
|
|
|
- if (null != filter && CollectionUtil.isEmpty(filter.getDistribute())) {
|
|
|
- countAll[0] = redDotAllDao.countByVendUUAndOrderTypeAndEnUU(user.getEnterprise().getUu(), orderType, filter.getDistribute());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (Role.BUYER.equals(roleName)) {
|
|
|
- countAll[0] = redDotAllDao.countByEnUUAndOrderType(user.getEnterprise().getUu(), orderType);
|
|
|
- }
|
|
|
- return countAll[0];
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取未读单据id
|
|
|
*
|
|
|
@@ -264,9 +193,7 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
public Integer setReadByState(String orderType, String roleName) {
|
|
|
List<Long> redAllIdList = getUnreadRedAllIdList(orderType, roleName);
|
|
|
List<List<Long>> idsList = SplitArray.splitAry(redAllIdList, SplitArray.QUERY_MAX_NUMBER);
|
|
|
- idsList.forEach(ids -> {
|
|
|
- setReadByIdList(ids);
|
|
|
- });
|
|
|
+ idsList.forEach(ids -> setReadByIdList(ids));
|
|
|
return redAllIdList.size();
|
|
|
}
|
|
|
|
|
|
@@ -310,10 +237,10 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
for (List<Long> ids : idsArray) {
|
|
|
if (repliedCount < 100) {
|
|
|
// 超过100不再查询,页面显示99+,减少服务器负担
|
|
|
- repliedCount = repliedCount + makeOrderDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
+ repliedCount = repliedCount + makeOrderDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
}
|
|
|
if (notReplyCount < 100) {
|
|
|
- notReplyCount = notReplyCount + makeOrderDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
+ notReplyCount = notReplyCount + makeOrderDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
}
|
|
|
if (notReplyCount > 99 && repliedCount > 99) {
|
|
|
break;
|
|
|
@@ -343,10 +270,10 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
for (List<Long> ids : idsArray) {
|
|
|
// 超过100不再查询,页面显示99+,减少服务器负担
|
|
|
if (repliedCount < 100) {
|
|
|
- repliedCount = repliedCount + purchaseNoticeDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
+ repliedCount = repliedCount + purchaseNoticeDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
}
|
|
|
if (notReplyCount < 100) {
|
|
|
- notReplyCount = notReplyCount + purchaseNoticeDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
+ notReplyCount = notReplyCount + purchaseNoticeDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
}
|
|
|
// 当需要查询的数量大于99时停止循环,减少不必要的操作
|
|
|
if (notReplyCount > 99 && repliedCount > 99) {
|
|
|
@@ -422,10 +349,10 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
for (List<Long> ids : idsArray) {
|
|
|
// 超过100不再查询,页面显示99+,减少服务器负担
|
|
|
if (repliedCount < 100) {
|
|
|
- repliedCount = repliedCount + purchaseOrderDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
+ repliedCount = repliedCount + purchaseOrderDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
}
|
|
|
if (notReplyCount < 100) {
|
|
|
- notReplyCount = notReplyCount + purchaseOrderDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
+ notReplyCount = notReplyCount + purchaseOrderDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
}
|
|
|
if (notReplyCount > 99 && repliedCount > 99) {
|
|
|
break;
|
|
|
@@ -629,10 +556,10 @@ public class OrderRedDotServiceImpl implements OrderRedDotService {
|
|
|
for (List<Long> ids : idsArray) {
|
|
|
if (repliedCount < 100) {
|
|
|
// 超过100不再查询,页面显示99+,减少服务器负担
|
|
|
- repliedCount = repliedCount + purchaseInquiryMouldDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
+ repliedCount = repliedCount + purchaseInquiryMouldDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
}
|
|
|
if (notReplyCount < 100) {
|
|
|
- notReplyCount = notReplyCount + purchaseInquiryMouldDao.findReadCount(ids, (short) Status.REPLIED.value());
|
|
|
+ notReplyCount = notReplyCount + purchaseInquiryMouldDao.findReadCount(ids, (short) Status.NOT_REPLY.value());
|
|
|
}
|
|
|
if (notReplyCount > 99 && repliedCount > 99) {
|
|
|
break;
|