Sfoglia il codice sorgente

邮件加已读字段

licailing 5 anni fa
parent
commit
4197ce68eb

+ 5 - 1
src/main/java/com/izouma/dingdong/domain/backstage/Email.java

@@ -12,6 +12,7 @@ import org.hibernate.annotations.Where;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 
 @Data
 @Entity
@@ -33,7 +34,7 @@ public class Email extends BaseEntity {
     private Long receiveUserId;
 
     @ApiModelProperty(value = "发送时间", name = "sendTime")
-    private LocalDate sendTime;
+    private LocalDateTime sendTime;
 
     @ApiModelProperty(value = "标题", name = "title")
     private String title;
@@ -41,6 +42,9 @@ public class Email extends BaseEntity {
     @ApiModelProperty(value = "内容", name = "content")
     private String content;
 
+    @ApiModelProperty(value = "是否已读", name = "isRead")
+    private Boolean isRead;
+
     @Column(nullable = false)
     private Boolean enabled = true;
 

+ 0 - 1
src/main/java/com/izouma/dingdong/service/UserService.java

@@ -244,7 +244,6 @@ public class UserService {
         }
         user.setNotOrder(-1);
         userRepo.save(user);
-
     }
 
 }

+ 6 - 3
src/main/java/com/izouma/dingdong/service/WithdrawApplyService.java

@@ -64,7 +64,8 @@ public class WithdrawApplyService {
         emailRepo.save(Email.builder()
                 .receiveUserId(user.getId())
                 .title("提现申请提交")
-                .sendTime(LocalDate.now())
+                .sendTime(LocalDateTime.now())
+                .isRead(false)
                 .content(apply.getAmount() + "元," + "提现到:" + bankCard.userInfo())
                 .build()
         );
@@ -114,7 +115,8 @@ public class WithdrawApplyService {
             email = Email.builder()
                     .receiveUserId(user.getId())
                     .title("提现申请通过")
-                    .sendTime(LocalDate.now())
+                    .isRead(false)
+                    .sendTime(LocalDateTime.now())
                     .content(withdrawals.getAmount() + "元," + "提现到:" + bankCard.userInfo())
                     .build();
 
@@ -125,8 +127,9 @@ public class WithdrawApplyService {
             email = Email.builder()
                     .receiveUserId(withdrawals.getUserId())
                     .title("提现申请失败")
-                    .sendTime(LocalDate.now())
+                    .sendTime(LocalDateTime.now())
                     .content("提现失败")
+                    .isRead(false)
                     .build();
 
             //失败返还金额

+ 17 - 16
src/main/java/com/izouma/dingdong/service/merchant/GoodsService.java

@@ -198,31 +198,32 @@ public class GoodsService {
         Goods goods = goodsRepo.findById(goodsId).orElseThrow(new BusinessException("无商品"));
         Long userId = merchantRepo.findUserIdById(goods.getMerchantId());
 
-        Email email;
-
         if (pass) {
 //            goods.setIsPass(true);
             goods.setStatus(ApplyStatus.PASS);
             //发送邮件
-            email = Email.builder()
-                    .sendTime(LocalDate.now())
+            emailRepo.save(Email.builder()
+                    .sendTime(LocalDateTime.now())
                     .title("提交商品审核通过")
+                    .isRead(false)
                     .content(goods.getName() + ":恭喜你所提交的商品已审核通过!")
                     .receiveUserId(userId)
-                    .build();
+                    .build());
+
+            return goodsRepo.save(goods);
 
-        } else {
-//            goods.setIsPass(false);
-            goods.setStatus(ApplyStatus.DENY);
-            //发送邮件
-            email = Email.builder()
-                    .sendTime(LocalDate.now())
-                    .title("提交商品审核未通过")
-                    .content(goods.getName() + ":" + reason)
-                    .receiveUserId(userId)
-                    .build();
         }
-        emailRepo.save(email);
+//            goods.setIsPass(false);
+        goods.setStatus(ApplyStatus.DENY);
+        //发送邮件
+        emailRepo.save(Email.builder()
+                .sendTime(LocalDateTime.now())
+                .title("提交商品审核未通过")
+                .isRead(false)
+                .content(goods.getName() + ":" + reason)
+                .receiveUserId(userId)
+                .build());
+
         return goodsRepo.save(goods);
     }
 

+ 1 - 1
src/main/java/com/izouma/dingdong/web/AuthenticationController.java

@@ -111,7 +111,7 @@ public class AuthenticationController {
     }
 
     @PostMapping("/merchantRegister")
-    @ApiOperation("注册登录")
+    @ApiOperation("商家注册")
     public String registerMerchant(MerchantDTO merchantDTO) {
         try {
             User user = userService.merUser(merchantDTO);