From 74861c60f79b39feb513f9b7248edb6742c62000 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 16 Mar 2018 09:45:37 +0800 Subject: [PATCH] add unread interface --- .../appclient/core/RetailAppService.java | 2 + .../core/impls/RetailAppServiceImp.java | 42 ++++++++++++++---- .../appclient/web/RetailAppController.java | 10 ++++- .../mappers/notice/NoticeManageMapper.java | 13 ++++-- .../manage/notice/core/NoticeManage.java | 1 + .../notice/core/impls/NoticeManageImpl.java | 44 ++++++++++--------- .../mappers/notice/NoticeManageMapper.xml | 11 ++++- 7 files changed, 89 insertions(+), 34 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index bd5a7ba1d..0f1f5213b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -55,6 +55,8 @@ public interface RetailAppService { JSONObject getNoticeDetailById(JSONObject device, String noticeId); + List getLatestNotice(int client_id); + void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id); JSONObject bankAccountInfo(JSONObject device); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 8860a6ea4..c4bc65572 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -12,6 +12,7 @@ import au.com.royalpay.payment.manage.fund.core.impls.XPlanFundConfigServiceImpl import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; +import au.com.royalpay.payment.manage.mappers.notice.NoticePartnerMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; @@ -140,6 +141,8 @@ public class RetailAppServiceImp implements RetailAppService { private ClientContractService clientContractService; @Resource private SysConfigManager sysConfigManager; + @Resource + private NoticePartnerMapper noticePartnerMapper; private Map senderMap = new HashMap<>(); @@ -422,14 +425,14 @@ public class RetailAppServiceImp implements RetailAppService { switch (order.getString("channel")) { case "Alipay": JSONObject alipayUser = customerRelationAlipayMapper.findCustomerByUserId(customer_id); - if (alipayUser!=null){ + if (alipayUser != null) { order.put("nickname", alipayUser.getString("nickname")); order.put("headimg", alipayUser.getString("headimg")); } break; case "Wechat": JSONObject weUser = customerMapper.findCustomerByOpenId(customer_id); - if (weUser!=null){ + if (weUser != null) { order.put("nickname", weUser.getString("nickname")); order.put("headimg", weUser.getString("headimg")); } @@ -442,12 +445,12 @@ public class RetailAppServiceImp implements RetailAppService { String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss"); order.put("trade_date", trade_date); order.put("trade_time", trade_time); - //todo - if ("Debit".equals(order.getString("transaction_type"))){ - order.put("currency","AUD"); + // todo + if ("Debit".equals(order.getString("transaction_type"))) { + order.put("currency", "AUD"); } - if ("CNY".equals(order.getString("currency"))){ - order.put("clearing_amount",order.getBigDecimal("total_amount")); + if ("CNY".equals(order.getString("currency"))) { + order.put("clearing_amount", order.getBigDecimal("total_amount")); } if (!date_contains.contains(trade_date)) { String re_date = trade_date.replaceAll("-", ""); @@ -869,6 +872,28 @@ public class RetailAppServiceImp implements RetailAppService { return res; } + @Override + public List getLatestNotice(int client_id) { + JSONObject notice = new JSONObject(); + JSONObject lastNotice = noticeManage.getLatestWindowNotice(client_id); + if(lastNotice!=null){ + lastNotice.put("id",lastNotice.getString("notice_id")); + lastNotice.remove("notice_id"); + } + notice.put("data",lastNotice); + JSONObject unReadParams = new JSONObject(); + unReadParams.put("client_id",client_id); + unReadParams.put("status",0); + int counts = noticePartnerMapper.countNoticePartner(unReadParams); + notice.put("unReadCounts",counts); + notice.put("type","notice"); + List result = new ArrayList<>(); + result.add(notice); + + return result; + } + + @Override public void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id) { String clientType = device.getString("client_type"); @@ -1343,8 +1368,9 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject getCheckClientInfo(JSONObject device) { - return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); + return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); } + private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index bc6589931..a98121197 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; +import au.com.royalpay.payment.manage.apps.AppController; import au.com.royalpay.payment.manage.bill.bean.NewBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean; @@ -13,7 +14,6 @@ import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.tools.CommonConsts; -import au.com.royalpay.payment.tools.device.advise.AppClientController; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; @@ -39,7 +39,7 @@ import javax.validation.Valid; /** * Created by yishuqian on 28/03/2017. */ -@AppClientController +@AppController @RequestMapping("/api/v1.0/retail/app") public class RetailAppController { @Resource @@ -132,6 +132,11 @@ public class RetailAppController { public JSONObject getNoticeId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId) { return retailAppService.getNoticeDetailById(device, noticeId); } + + @RequestMapping(value = "/notice/unread", method = RequestMethod.GET) + public List latestNotice(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + return retailAppService.getLatestNotice(device.getIntValue("client_id")); + } /* 消息模块end */ /* 我的页面begin */ @@ -347,4 +352,5 @@ public class RetailAppController { public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id"),"App"); } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.java index 1a07ec4c3..b1d461579 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.java @@ -1,12 +1,17 @@ package au.com.royalpay.payment.manage.mappers.notice; -import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; -import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; -import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import java.util.Date; + +import org.apache.ibatis.annotations.Param; + import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; + /** * Created by yishuqian on 10/10/2016. */ @@ -20,4 +25,6 @@ public interface NoticeManageMapper { void createNotice(JSONObject notice); @AutoSql(type = SqlType.UPDATE) void updateNotice(JSONObject notice); + + JSONObject getLatestWindowNotice(@Param("client_id") int client_id,@Param("end_time")Date end_time); } diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java b/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java index 6bb834d75..afc69868c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/core/NoticeManage.java @@ -24,4 +24,5 @@ public interface NoticeManage { JSONObject listNoticeReadClients(String noticeId, int page, int limit); + JSONObject getLatestWindowNotice(int client_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java index 13a6d9d10..02284aa0a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/NoticeManageImpl.java @@ -1,25 +1,5 @@ package au.com.royalpay.payment.manage.notice.core.impls; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; - -import com.alibaba.fastjson.JSONObject; -import com.github.miemiedev.mybatis.paginator.domain.Order; -import com.github.miemiedev.mybatis.paginator.domain.PageBounds; -import com.github.miemiedev.mybatis.paginator.domain.PageList; - import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.mappers.log.NotifyErrorLogMapper; import au.com.royalpay.payment.manage.mappers.notice.NoticeManageMapper; @@ -32,6 +12,26 @@ import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.notice.core.NoticeManage; import au.com.royalpay.payment.tools.utils.PageListUtils; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + /** * Created by yishuqian on 28/09/2016. */ @@ -201,6 +201,10 @@ public class NoticeManageImpl implements NoticeManage { return PageListUtils.buildPageListResult(clients); } + @Override + public JSONObject getLatestWindowNotice(int client_id) { + return noticeManageMapper.getLatestWindowNotice(client_id,new Date()); + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml index 4432f989f..67997bf16 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/notice/NoticeManageMapper.xml @@ -14,5 +14,14 @@ - + \ No newline at end of file