From 8eacb056dcde51170549fa17c8cd7ae1f737bfdc Mon Sep 17 00:00:00 2001 From: duLingLing Date: Thu, 28 Nov 2019 17:25:05 +0800 Subject: [PATCH] =?UTF-8?q?Upd:=E4=BF=AE=E5=A4=8DApp=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=80=80=E5=87=BA=E5=90=8E=E4=BE=9D=E7=84=B6=E4=BC=9A=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E6=8E=A8=E9=80=81=E6=B6=88=E6=81=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../core/impls/RetailAppServiceImp.java | 5 ++++- .../web/RetailValidationController.java | 19 ++++++++++++------- .../manage/device/core/DeviceManager.java | 8 ++++++++ .../device/core/impls/DeviceManagerImp.java | 13 +++++++++++++ .../mappers/system/ClientDeviceMapper.java | 4 ++++ .../mappers/system/ClientDeviceMapper.xml | 16 ++++++++++++++++ 7 files changed, 58 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index d93a4f177..3ec96afb5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.2.94 + 1.2.95 UTF-8 1.4.0 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 e040bfce4..f09c96da7 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 @@ -13,6 +13,7 @@ import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.appclient.extend.GatewayOAuthRegister; import au.com.royalpay.payment.manage.cashback.core.CashbackService; import au.com.royalpay.payment.manage.customers.core.CouponValidateService; +import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.fund.core.impls.XPlanFundConfigServiceImpl; import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.mappers.client.AuthAppMessageMapper; @@ -209,6 +210,8 @@ public class RetailAppServiceImp implements RetailAppService { private StringRedisTemplate stringRedisTemplate; @Resource private MpClientAppWechatApiProvider mpClientAppWechatApiProvider; + @Resource + private DeviceManager deviceManager; private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf"; private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/10/22/1571723034726_5xK6A0FGv5aQPbMIDJzXJrUPKHFutv.pdf"; @@ -1100,7 +1103,7 @@ public class RetailAppServiceImp implements RetailAppService { String clientType = device.getString("client_type"); DeviceRegister register = deviceSupport.findRegister(clientType); register.signout(device); - + deviceManager.deviceOffline(device.getString("account_id")); } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java index 5e9b27285..76ee48bf5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.appclient.beans.RetailLoginInfo; import au.com.royalpay.payment.manage.appclient.core.ManageAppService; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService; +import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.signin.beans.LoginInfo; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; @@ -61,6 +62,8 @@ public class RetailValidationController implements ApplicationEventPublisherAwar private ApplicationEventPublisher publisher; @Resource private ManageAppService manageAppService; + @Resource + private DeviceManager deviceManager; @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { @@ -95,6 +98,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar client = JSON.parseObject(client.toJSONString()); if (loginInfo.getDevId() != null) { deviceSupport.validDeviceWithClient(client, loginInfo.getDevId()); + deviceManager.offlineNotCurrentUserByDevIdAndAccountId(loginInfo.getDevId(),client.getString("account_id")); } client.put("sign_key", signKey); return client; @@ -219,7 +223,10 @@ public class RetailValidationController implements ApplicationEventPublisherAwar result.put("account",account); result.put("status","success"); result.put("bind_status", true); - + if (params.getString("devId") != null) { + deviceSupport.validDeviceWithClient(account, params.getString("devId")); + deviceManager.offlineNotCurrentUserByDevIdAndAccountId(params.getString("devId"),account.getString("account_id")); + } this.publisher.publishEvent(new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "MOBILE")); }else{ result.put("status","success"); @@ -254,9 +261,6 @@ public class RetailValidationController implements ApplicationEventPublisherAwar account = JSON.parseObject(account.toJSONString()); JSONObject result = new JSONObject(); result.put("account",account); - if (params.getString("devId") != null) { - deviceSupport.validDeviceWithClient(account, params.getString("devId")); - } result.put("bind_status", true); this.publisher.publishEvent(new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "MOBILE")); return result; @@ -276,6 +280,10 @@ public class RetailValidationController implements ApplicationEventPublisherAwar deviceSupport.validDeviceWithClient(account, params.getString("app_openid")); return account; } + if (params.getString("devId") != null) { + deviceSupport.validDeviceWithClient(account, params.getString("devId")); + deviceManager.offlineNotCurrentUserByDevIdAndAccountId(params.getString("devId"),account.getString("account_id")); + } this.publisher.publishEvent(new ClientLoginEvent(this, account.getJSONObject("account").getIntValue("client_id"), account.getJSONObject("account").getString("account_id"), RequestEnvironment.getClientIp(), "wechat")); return account; } @@ -297,9 +305,6 @@ public class RetailValidationController implements ApplicationEventPublisherAwar params.put("union_id",wechatInfo.getString("union_id")); retailAppService.updateLoginClientAccountOpenId(account,params); account = JSON.parseObject(account.toJSONString()); - if (params.getString("devId") != null) { - deviceSupport.validDeviceWithClient(account, params.getString("devId")); - } JSONObject result = new JSONObject(); account.put("sign_key", signKey); result.put("account",account); diff --git a/src/main/java/au/com/royalpay/payment/manage/device/core/DeviceManager.java b/src/main/java/au/com/royalpay/payment/manage/device/core/DeviceManager.java index 8f200db18..992b5c171 100644 --- a/src/main/java/au/com/royalpay/payment/manage/device/core/DeviceManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/device/core/DeviceManager.java @@ -17,4 +17,12 @@ public interface DeviceManager { void deviceOffline(String accountId); JSONObject listDevOrders(JSONObject manager, String devId, TradeLogQuery query); + + /** + * 离线当前设备非当前登录用户 + * @param devId + * @param accountId + */ + void offlineNotCurrentUserByDevIdAndAccountId(String devId,String accountId); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/device/core/impls/DeviceManagerImp.java b/src/main/java/au/com/royalpay/payment/manage/device/core/impls/DeviceManagerImp.java index c7e513220..8195c77ec 100644 --- a/src/main/java/au/com/royalpay/payment/manage/device/core/impls/DeviceManagerImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/device/core/impls/DeviceManagerImp.java @@ -118,4 +118,17 @@ public class DeviceManagerImp implements DeviceManager { return result; } + /** + * 离线当前设备非当前登录用户 + * @param devId + * @param accountId + */ + @Override + public void offlineNotCurrentUserByDevIdAndAccountId(String devId, String accountId) { + //离线当前设备非当前用户 + clientDeviceMapper.updateByDevIdAndAccountId(devId,accountId); + //离线当前用户以前登录的设备 + clientDeviceMapper.updateAccountIdAndByDevId(devId,accountId); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java index cc87aaed2..6ffbed7bb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.java @@ -45,4 +45,8 @@ public interface ClientDeviceMapper { PageList listDevices(JSONObject params, PageBounds pagination); void deviceOffline(@Param("account_id") String accountId); + + void updateByDevIdAndAccountId(@Param("client_dev_id") String devId, @Param("account_id")String accountId); + + void updateAccountIdAndByDevId(@Param("client_dev_id") String devId, @Param("account_id")String accountId); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.xml index af5953388..e28faef60 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceMapper.xml @@ -55,4 +55,20 @@ where account_id = #{account_id} + + + UPDATE sys_clients_devices device + LEFT JOIN sys_clients_devices_token dtoken + ON device.dev_id = dtoken.dev_id + SET device.is_offline = 1,dtoken.is_valid=0 + WHERE device.client_dev_id = #{client_dev_id} AND device.account_id != #{account_id} + + + + UPDATE sys_clients_devices device + LEFT JOIN sys_clients_devices_token dtoken + ON device.dev_id = dtoken.dev_id + SET device.is_offline = 1,dtoken.is_valid=0 + WHERE device.client_dev_id != #{client_dev_id} AND device.account_id = #{account_id} + \ No newline at end of file