Commit 8e8ff346 authored by zhangzc's avatar zhangzc

修复消息问题

parent 47ebdf28
......@@ -51,6 +51,7 @@ public class AccountConstants {
/**
* 消息类型
**/
public static final Integer MESSAGE_TYPE_SYSTEM = 11; // 系统消息
public static final Integer MESSAGE_TYPE_BILL_CONFIRM = 101; // 账单生成后用户确认消息
public static final Integer MESSAGE_TYPE_WAYBILL_GRAB = 102; // 司机抢单结果提醒消息
}
......@@ -26,6 +26,7 @@ import com.esv.freight.app.module.account.vo.DriverAccountDetailVO;
import com.esv.freight.app.module.account.vo.LoginVO;
import com.esv.freight.app.module.message.form.AccountDeviceForm;
import com.esv.freight.app.module.message.service.AccountDeviceInfoService;
import com.esv.freight.app.module.message.service.BusinessMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -55,6 +56,7 @@ public class DriverAccountController {
private CarrierInterface carrierInterface;
private TokenComponent tokenComponent;
private AccountDeviceInfoService accountDeviceInfoService;
private BusinessMessageService businessMessageService;
@Autowired
public DriverAccountController(TokenComponent tokenComponent, AccountDeviceInfoService accountDeviceInfoService, CarrierInterface carrierInterface, DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
......@@ -64,6 +66,7 @@ public class DriverAccountController {
this.carrierInterface = carrierInterface;
this.tokenComponent = tokenComponent;
this.accountDeviceInfoService = accountDeviceInfoService;
this.businessMessageService = businessMessageService;
}
/**
......@@ -339,6 +342,7 @@ public class DriverAccountController {
detailVO.setCertificateEndDate(result.getJSONObject("data").getString("certificateEndDate"));
detailVO.setCertificateNumber(result.getJSONObject("data").getString("certificateNumber"));
detailVO.setCertificateUrl(result.getJSONObject("data").getString("certificateUrl"));
detailVO.setHasUnReadMessage(businessMessageService.hasUnReadMessage(Long.valueOf(detailVO.getId())));
return EResponse.ok(detailVO);
}
......
......@@ -20,6 +20,7 @@ import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.module.account.vo.LoginVO;
import com.esv.freight.app.module.message.form.AccountDeviceForm;
import com.esv.freight.app.module.message.service.AccountDeviceInfoService;
import com.esv.freight.app.module.message.service.BusinessMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -45,14 +46,16 @@ public class OwnerAccountController {
private AppLoginService appLoginService;
private TokenComponent tokenComponent;
private AccountDeviceInfoService accountDeviceInfoService;
private BusinessMessageService businessMessageService;
@Autowired
public OwnerAccountController(TokenComponent tokenComponent, AccountDeviceInfoService accountDeviceInfoService, GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
public OwnerAccountController(BusinessMessageService businessMessageService, TokenComponent tokenComponent, AccountDeviceInfoService accountDeviceInfoService, GoodsOwnerInterface goodsOwnerInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
this.goodsOwnerInterface = goodsOwnerInterface;
this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.tokenComponent = tokenComponent;
this.accountDeviceInfoService = accountDeviceInfoService;
this.businessMessageService = businessMessageService;
}
/**
......@@ -284,6 +287,7 @@ public class OwnerAccountController {
accountDetailVO.setCreditCopyUrl(result.getJSONObject("data").getString("creditCopyUrl"));
accountDetailVO.setLegalPerson(result.getJSONObject("data").getString("legalPerson"));
accountDetailVO.setLegalPhone(result.getJSONObject("data").getString("legalPhone"));
accountDetailVO.setHasUnReadMessage(businessMessageService.hasUnReadMessage(Long.valueOf(accountDetailVO.getId())));
return EResponse.ok(accountDetailVO);
}
......
......@@ -113,6 +113,9 @@ public class DriverAccountDetailVO {
// 道路运输从业资格证-正面图片URL
private String certificateUrl;
// 是否有未读消息 0-无 1-有
private Integer hasUnReadMessage;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
......
......@@ -82,6 +82,9 @@ public class OwnerAccountDetailVO {
// 企业法人手机号
private String legalPhone;
// 是否有未读消息 0-无 1-有
private Integer hasUnReadMessage;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
......
......@@ -81,4 +81,13 @@ public interface BusinessMessageService extends IService<BusinessMessageEntity>
* createTime 2020/06/10 16:56
**/
MessageDetailVO getMessageDetail(MessageForm messageForm);
/**
* description 用户是否有未读消息
* param [messageForm]
* return
* author Administrator
* createTime 2020/06/11 15:00
**/
Integer hasUnReadMessage(Long accountId);
}
......@@ -108,7 +108,7 @@ public class BusinessMessageServiceImpl extends ServiceImpl<BusinessMessageDao,
String billNo = jo.getString("billNo");
JSONObject reqMessage = new JSONObject();
reqMessage.put("title", "账单提醒");
String content = "您的新账单"+billNo+"已经生成,请尽快确认";
String content = "您的新账单 "+billNo+" 已经生成,请尽快确认";
reqMessage.put("msg_content", content);
JSONObject extras = new JSONObject();
extras.put("messageType", AccountConstants.MESSAGE_TYPE_BILL_CONFIRM);
......@@ -121,9 +121,18 @@ public class BusinessMessageServiceImpl extends ServiceImpl<BusinessMessageDao,
public List<MessageTypeVO> getMessageType(MessageForm messageForm) {
// 1.分类查询消息,每个type类型消息只取最后生成的一个消息
List<MessageTypeVO> messageTypeVOList = new ArrayList<>();
MessageTypeVO systemMessage = new MessageTypeVO();
systemMessage.setIsRead(true);
systemMessage.setMessageType(AccountConstants.MESSAGE_TYPE_SYSTEM);
systemMessage.setMessageContent(null);
systemMessage.setMessageTitle(null);
systemMessage.setCreateTime(null);
messageTypeVOList.add(systemMessage);
List<BusinessMessageEntity> lst102 = lambdaQuery()
.eq(BusinessMessageEntity::getAccountId, messageForm.getAccountId())
.eq(BusinessMessageEntity::getMessageType, AccountConstants.MESSAGE_TYPE_WAYBILL_GRAB)
.eq(BusinessMessageEntity::getMessageType, AccountConstants.MESSAGE_TYPE_BILL_CONFIRM)
.orderByDesc(BusinessMessageEntity::getCreateTime).list();
if(lst102 != null && lst102.size() > 0) {
......@@ -166,6 +175,13 @@ public class BusinessMessageServiceImpl extends ServiceImpl<BusinessMessageDao,
}
PageResultVO pageResultVO = new PageResultVO(page, list);
lambdaUpdate()
.eq(BusinessMessageEntity::getAccountId, messageForm.getAccountId())
.eq(BusinessMessageEntity::getMessageType, messageForm.getMessageType())
.set(BusinessMessageEntity::getIsRead, 1)
.update();
return pageResultVO;
}
......@@ -204,4 +220,18 @@ public class BusinessMessageServiceImpl extends ServiceImpl<BusinessMessageDao,
BeanUtils.copyProperties(entity, messageDetailVO);
return messageDetailVO;
}
@Override
public Integer hasUnReadMessage(Long accountId) {
List<BusinessMessageEntity> entityList = lambdaQuery()
.eq(BusinessMessageEntity::getAccountId, accountId)
.eq(BusinessMessageEntity::getIsRead, 0)
.list();
if(entityList == null || entityList.size() == 0) {
return 0;
}
return 1;
}
}
......@@ -36,6 +36,11 @@ public class MessageListItemVO {
*/
private String messageTitle;
/**
* 消息内容(根据message_type由终端自行解析)
*/
private String messageData;
/**
* 是否已读 0-未读;1-已读
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment