Parcourir la source

Merge remote-tracking branch 'origin/develop' into develop

FengChaoYu il y a 5 mois
Parent
commit
c48242a71e

+ 0 - 8
mall-server-api/src/main/java/com/gree/mall/manager/bean/notice/NoticeWebsitVO.java

@@ -48,14 +48,6 @@ public class NoticeWebsitVO   {
     private String issueNickName;
 
 
-    @ApiModelProperty(value = "创建人(制单人)")
-    @TableField(fill = FieldFill.INSERT)
-    private String createBy;
-
-    @ApiModelProperty(value = "创建时间")
-    @TableField(fill = FieldFill.INSERT)
-    private Date createTime;
-
     @ApiModelProperty(value = "更新人")
     @TableField(fill = FieldFill.INSERT_UPDATE)
     private String updateBy;

+ 22 - 18
mall-server-api/src/main/java/com/gree/mall/manager/logic/notice/NoticeLogic.java

@@ -354,24 +354,28 @@ public class NoticeLogic {
                 .between(NoticeRecord::getIssueTime, dateTime, date1)
                 .list());
 
-        List<NoticeWebsitRecord> noticeWebsitRecords = noticeWebsitRecordService.lambdaQuery()
-                .in(!StringUtil.isEmpty(adminUser.getCompanyWechatId()), NoticeWebsitRecord::getCompanyWechatId, adminUser.getCompanyWechatId())
-                .in(!StringUtil.isEmpty(adminUser.getAdminUserId()), NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
-                .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.NO.getKey())
-                .between(NoticeWebsitRecord::getIssueTime, dateTime, date1).list();
-
-        if (CollectionUtils.isNotEmpty(noticeWebsitRecords)){
-            List<NoticeWebsit> noticeWebsits = noticeWebsitService.lambdaQuery().in(NoticeWebsit::getNoticeWebsitId,
-                    noticeWebsitRecords.stream().map(NoticeWebsitRecord::getNoticeWebsitId).collect(Collectors.toList()))
-                    .list();
-
-            for (NoticeWebsit noticeWebsit : noticeWebsits) {
-                NoticeRecord noticeRecord = new NoticeRecord();
-                noticeRecord.setId(noticeWebsit.getNoticeWebsitId());
-                noticeRecord.setType(noticeWebsit.getType());
-                noticeRecord.setAdminNoticeType("WDTZ");
-                noticeRecord.setTitle(noticeWebsit.getTitle());
-                list.add(noticeRecord);
+        if (adminUser.getType().equals(0) && CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds())) {
+            List<NoticeWebsitRecord> noticeWebsitRecords = noticeWebsitRecordService.lambdaQuery()
+                    .in(!StringUtil.isEmpty(adminUser.getCompanyWechatId()), NoticeWebsitRecord::getCompanyWechatId, adminUser.getCompanyWechatId())
+                    .in(!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds()), NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
+                    .eq(NoticeWebsitRecord::getReadFlag, IsYesNoEnum.NO.getKey())
+                    .between(NoticeWebsitRecord::getIssueTime, dateTime, date1).list();
+
+            if (CollectionUtils.isNotEmpty(noticeWebsitRecords)) {
+                List<NoticeWebsit> noticeWebsits = noticeWebsitService.lambdaQuery().in(NoticeWebsit::getNoticeWebsitId,
+                        noticeWebsitRecords.stream().map(NoticeWebsitRecord::getNoticeWebsitId)
+                                .collect(Collectors.toList()))
+                        .eq(NoticeWebsit::getStatus,"SEND")
+                        .list();
+
+                for (NoticeWebsit noticeWebsit : noticeWebsits) {
+                    NoticeRecord noticeRecord = new NoticeRecord();
+                    noticeRecord.setId(noticeWebsit.getNoticeWebsitId());
+                    noticeRecord.setType(noticeWebsit.getType());
+                    noticeRecord.setAdminNoticeType("WDTZ");
+                    noticeRecord.setTitle(noticeWebsit.getTitle());
+                    list.add(noticeRecord);
+                }
             }
         }
 

+ 49 - 14
mall-server-api/src/main/java/com/gree/mall/manager/logic/notice/NoticeWebsitLogic.java

@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -102,6 +103,7 @@ public class NoticeWebsitLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         noticeBean.setCompanyWechatId(adminUser.getCompanyWechatId());
         noticeBean.setCompanyWechatName(adminUser.getCompanyName());
+
         noticeBean.updateById();
 
         List<NoticeWebsitRecord> noticeWebsitRecords = new ArrayList<>();
@@ -126,10 +128,11 @@ public class NoticeWebsitLogic {
     }
 
     public void ofOrSend(String id, String status) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
         NoticeWebsit noticeWebsit = noticeWebsitService.getById(id);
         noticeWebsit.setStatus(status);
-        if (status.equals("SEND"))
-            noticeWebsit.setIssueTime(new Date());
+
+
         noticeWebsit.updateById();
 
         noticeWebsitRecordService.lambdaUpdate()
@@ -154,7 +157,17 @@ public class NoticeWebsitLogic {
 
     public Object unreadCount(HttpServletRequest request, String readFlag) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        List<String> collect = noticeWebsitService.lambdaQuery()
+                .eq(NoticeWebsit::getStatus, "SEND").select(NoticeWebsit::getNoticeWebsitId)
+                .list().stream().map(NoticeWebsit::getNoticeWebsitId).collect(Collectors.toList());
+
+        if (CollectionUtils.isEmpty(collect)) {
+            return 0;
+        }
+
         Integer count = noticeWebsitRecordService.lambdaQuery()
+                .in(NoticeWebsitRecord::getNoticeWebsitId,collect)
                 .eq(NoticeWebsitRecord::getReadFlag, readFlag)
                 .in(!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds()),NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
                 .count();
@@ -167,6 +180,7 @@ public class NoticeWebsitLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         noticeWebsitRecordService.lambdaUpdate()
                 .in(NoticeWebsitRecord::getNoticeWebsitId,noticeIds)
+                .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.NO.getKey())
                 .in(!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds()),NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
                 .set(NoticeWebsitRecord::getReadFlag, IsYesNoEnum.YES.getKey())
                 .set(NoticeWebsitRecord::getReadTime, new Date())
@@ -175,10 +189,15 @@ public class NoticeWebsitLogic {
         for (String id : noticeIds) {
 
 
+
             NoticeWebsit one = noticeWebsitService.getById(id);
             if (one != null){
-                one.setNum(one.getNum()+1);
-                one.updateById();
+
+                noticeWebsitService.lambdaUpdate()
+                        .eq(NoticeWebsit::getNoticeWebsitId,one.getNoticeWebsitId())
+                        .set(NoticeWebsit::getNum,noticeWebsitRecordService.lambdaQuery()
+                                .eq(NoticeWebsitRecord::getNoticeWebsitId,id)
+                                .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.YES.getKey()).count()).update();
             }
         }
 
@@ -190,24 +209,36 @@ public class NoticeWebsitLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         if (!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds())) {
 
+            List<String> collect = noticeWebsitService.lambdaQuery()
+                    .eq(NoticeWebsit::getStatus, "SEND").select(NoticeWebsit::getNoticeWebsitId)
+                    .list().stream().map(NoticeWebsit::getNoticeWebsitId).collect(Collectors.toList());
+
+            if (CollectionUtils.isEmpty(collect)) {
+                return ;
+            }
+
             List<NoticeWebsitRecord> list = noticeWebsitRecordService.lambdaQuery()
+                    .in(NoticeWebsitRecord::getNoticeWebsitId,collect)
+                    .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.NO.getKey())
                     .in(!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds()), NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
                     .list();
             for (NoticeWebsitRecord websitRecord : list) {
 
-
+                websitRecord.setReadFlag(IsYesNoEnum.YES.getKey());
+                websitRecord.setReadTime(new Date());
+                websitRecord.updateById();
                 NoticeWebsit one = noticeWebsitService.getById(websitRecord.getNoticeWebsitId());
                 if (one != null){
-                    one.setNum(one.getNum()+1);
-                    one.updateById();
+                    noticeWebsitService.lambdaUpdate()
+                            .eq(NoticeWebsit::getNoticeWebsitId,one.getNoticeWebsitId())
+                            .set(NoticeWebsit::getNum,noticeWebsitRecordService.lambdaQuery()
+                                    .eq(NoticeWebsitRecord::getNoticeWebsitId,one.getNoticeWebsitId())
+                                    .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.YES.getKey()).count()).update();
                 }
+
+
             }
 
-            noticeWebsitRecordService.lambdaUpdate()
-                    .in(!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds()), NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
-                    .set(NoticeWebsitRecord::getReadFlag, IsYesNoEnum.YES.getKey())
-                    .set(NoticeWebsitRecord::getReadTime, new Date())
-                    .update();
         }
     }
 
@@ -216,6 +247,7 @@ public class NoticeWebsitLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         noticeWebsitRecordService.lambdaUpdate()
                 .in(NoticeWebsitRecord::getId,id)
+                .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.NO.getKey())
                 .in(!CollectionUtils.isEmpty(adminUser.getAdminWebsitIds()),NoticeWebsitRecord::getAdminWebsitId, adminUser.getAdminWebsitIds())
                 .set(NoticeWebsitRecord::getReadFlag, IsYesNoEnum.YES.getKey())
                 .set(NoticeWebsitRecord::getReadTime, new Date())
@@ -226,8 +258,11 @@ public class NoticeWebsitLogic {
             NoticeWebsitRecord noticeWebsitRecord = noticeWebsitRecordService.getById(idOne);
             NoticeWebsit one = noticeWebsitService.getById(noticeWebsitRecord.getNoticeWebsitId());
             if (one != null){
-                one.setNum(one.getNum()+1);
-                one.updateById();
+                noticeWebsitService.lambdaUpdate()
+                        .in(NoticeWebsit::getNoticeWebsitId,one.getNoticeWebsitId())
+                        .set(NoticeWebsit::getNum,noticeWebsitRecordService.lambdaQuery()
+                                .eq(NoticeWebsitRecord::getNoticeWebsitId,one.getNoticeWebsitId())
+                                .eq(NoticeWebsitRecord::getReadFlag,IsYesNoEnum.YES.getKey()).count()).update();
             }
         }
     }