From e319db47efe31618ca8ca99529facb7b178b82fd Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Mon, 19 Mar 2018 15:27:49 +0800 Subject: [PATCH] unread add act info --- .../app_index/core/AppActService.java | 2 + .../core/impls/AppActServiceImp.java | 10 +++- .../core/impls/RetailAppServiceImp.java | 48 ++++++++++++------- .../appclient/web/RetailAppController.java | 7 +-- .../manage/mappers/act/ActAppMapper.java | 5 ++ .../manage/mappers/act/ActAppMapper.xml | 15 ++++++ 6 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java index 11ebc3c2d..39f1f771e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java @@ -18,4 +18,6 @@ public interface AppActService { JSONObject getActDetail(JSONObject manager,String act_id); void updateAct(JSONObject manager,String act_id,AppActBean appActBean); + + JSONObject getLatestWindowNotice(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java index 5a78e66de..f100e4d72 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java @@ -4,17 +4,20 @@ import au.com.royalpay.payment.manage.activities.app_index.beans.AppActBean; import au.com.royalpay.payment.manage.activities.app_index.beans.AppActQueryBean; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.mappers.act.ActAppMapper; + 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.springframework.stereotype.Service; import org.springframework.util.Assert; -import javax.annotation.Resource; import java.util.Date; import java.util.List; +import javax.annotation.Resource; + @Service public class AppActServiceImp implements AppActService { @@ -52,6 +55,11 @@ public class AppActServiceImp implements AppActService { actAppMapper.updateAct(params); } + @Override + public JSONObject getLatestWindowNotice() { + return actAppMapper.getLatestWindowNotice(new Date()); + } + @Override public JSONObject newAppAct(JSONObject manager, AppActBean appActBean) { JSONObject params = appActBean.toJsonParam(); 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 c4bc65572..857e5d35a 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 @@ -1,6 +1,7 @@ package au.com.royalpay.payment.manage.appclient.core.impls; import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; @@ -29,7 +30,6 @@ import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; -import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport; import au.com.royalpay.payment.tools.device.DeviceSupport; @@ -37,7 +37,6 @@ import au.com.royalpay.payment.tools.device.message.AppMessage; import au.com.royalpay.payment.tools.device.message.AppMsgSender; import au.com.royalpay.payment.tools.device.support.DeviceRegister; import au.com.royalpay.payment.tools.env.PlatformEnvironment; -import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; @@ -138,11 +137,9 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private ClientDeviceTokenMapper clientDeviceTokenMapper; @Resource - private ClientContractService clientContractService; - @Resource - private SysConfigManager sysConfigManager; - @Resource private NoticePartnerMapper noticePartnerMapper; + @Resource + private AppActService appActService; private Map senderMap = new HashMap<>(); @@ -875,24 +872,41 @@ public class RetailAppServiceImp implements RetailAppService { @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"); + JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id); + if (latestNotice != null) { + latestNotice.put("id", latestNotice.getString("notice_id")); + latestNotice.remove("notice_id"); } - notice.put("data",lastNotice); + notice.put("data", latestNotice); JSONObject unReadParams = new JSONObject(); - unReadParams.put("client_id",client_id); - unReadParams.put("status",0); + unReadParams.put("client_id", client_id); + unReadParams.put("status", 0); int counts = noticePartnerMapper.countNoticePartner(unReadParams); - notice.put("unReadCounts",counts); - notice.put("type","notice"); + notice.put("unReadCounts", counts); + notice.put("type", "notice"); List result = new ArrayList<>(); result.add(notice); - return result; - } + JSONObject latestAct = appActService.getLatestWindowNotice(); + if (latestAct != null) { + latestAct.put("id", latestAct.getString("act_id")); + if (latestAct.getIntValue("show_type") == 0) { + latestAct.put("url", latestAct.getString("act_url")); + } + latestAct.put("title", latestAct.getString("act_name")); + latestAct.put("img", latestAct.getString("window_img")); + latestAct.remove("act_id"); + latestAct.remove("act_name"); + latestAct.remove("window_img"); + latestAct.remove("act_url"); + JSONObject act = new JSONObject(); + act.put("data", latestAct); + act.put("type", "act"); + result.add(act); + } + return result; + } @Override public void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id) { 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 f747fb1c2..bdd407628 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 @@ -15,8 +15,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; @@ -30,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import java.math.BigDecimal; @@ -42,7 +41,7 @@ import javax.validation.Valid; /** * Created by yishuqian on 28/03/2017. */ -@AppClientController +@RestController @RequestMapping("/api/v1.0/retail/app") public class RetailAppController { @Resource @@ -59,8 +58,6 @@ public class RetailAppController { private AppActService appActService; @Resource private ClientContractService clientContractService; - @Resource - private SysConfigManager sysConfigManager; @RequestMapping(value = "/token", method = RequestMethod.PUT) public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java index b3e23c836..317b7b985 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.java @@ -8,6 +8,9 @@ import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; import java.util.List; @AutoMapper(tablename = "act_app_list", pkName = "act_id") @@ -28,4 +31,6 @@ public interface ActAppMapper { @AutoSql(type = SqlType.INSERT) void newAppAct(JSONObject params); + + JSONObject getLatestWindowNotice(@Param("now") Date now); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml new file mode 100644 index 000000000..c919ff09e --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActAppMapper.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file