diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/back/NotificationsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/back/NotificationsController.java index aa3a1a8..b2917bd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/back/NotificationsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/back/NotificationsController.java @@ -19,7 +19,7 @@ import java.util.List; /** * 【请填写功能名称】Controller - * + * * @author ruoyi * @date 2025-08-23 */ @@ -77,7 +77,7 @@ public class NotificationsController extends BaseController recordsService.bind(id, shopUsers); return AjaxResult.success("绑定用户成功"); } - + /** * 获取通知已绑定的用户列表 */ @@ -86,7 +86,7 @@ public class NotificationsController extends BaseController List list = recordsService.getBindUsers(id); return AjaxResult.success(list); } - + /** * 发布通知 */ @@ -95,6 +95,12 @@ public class NotificationsController extends BaseController public AjaxResult publish(@PathVariable("id") Long id) { return notificationsService.publishNotification(id); } + // 发送全部 + @Log(title = "发送全部通知", businessType = BusinessType.OTHER) + @PostMapping("/sendAll/{id}") + public AjaxResult sendAll(@PathVariable("id") Long id) { + return notificationsService.publishSendAll(id); + } /** * 新增【请填写功能名称】 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java index d98c484..1fcc705 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java @@ -35,9 +35,9 @@ public class ClientShopUserController { * 获取验证码 */ @PostMapping("/getCode") - public AjaxResult getCode(@RequestBody ShopUser shopUser){ + public AjaxResult getCode(@RequestBody ShopUser shopUser) { String result = aliConfigService.sendMsg(shopUser); - if (result != null){ + if (result != null) { return AjaxResult.success(); } return AjaxResult.error("发送验证码失败"); @@ -49,13 +49,14 @@ public class ClientShopUserController { * @return 结果 */ @PostMapping("/shopLogin") - public AjaxResult shopLogin(@RequestBody ShopUserResq userResq) - { + public AjaxResult shopLogin(@RequestBody ShopUserResq userResq) { AjaxResult ajax = AjaxResult.success(); ShopUser shopUser = shopUserService.login(userResq); - if (shopUser == null || shopUser.getMsg() != null){ - return new AjaxResult(999,"登录失败"); - }else { + if (shopUser == null) { + return new AjaxResult(999, "登录失败"); + } else if (shopUser.getMsg() != null) { + return new AjaxResult(999, shopUser.getMsg()); + } else { // 生成令牌 String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword()); ajax.put("data", shopUser); @@ -66,14 +67,15 @@ public class ClientShopUserController { /** * 修改个人信息 + * * @param shopUser 个人信息 * @return 成功 */ @PostMapping("/updateUser") - public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser){ + public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser) { Long userId = SecurityUtils.getUserId(); if (userId == null) { - return AjaxResult.error(401,"用户未登录"); + return AjaxResult.error(401, "用户未登录"); } shopUser.setUserId(userId); return AjaxResult.success(shopUserService.modifyUser(shopUser)); @@ -81,6 +83,7 @@ public class ClientShopUserController { /** * 获取个人信息 + * * @return 个人信息 */ @GetMapping("/getUserInfo") @@ -88,23 +91,24 @@ public class ClientShopUserController { // 获取当前登录用户名 Long userId = SecurityUtils.getUserId(); if (userId == null) { - return AjaxResult.error(401,"用户未登录"); + return AjaxResult.error(401, "用户未登录"); } - + // 根据用户ID查询完整的用户信息 ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId); if (shopUser == null) { return AjaxResult.error("未找到用户信息"); } - + // 出于安全考虑,清除敏感信息 shopUser.setPassword(null); - + return AjaxResult.success(shopUser); } - + /** * 根据用户ID获取个人信息 + * * @param userId 用户ID * @return 个人信息 */ @@ -113,20 +117,19 @@ public class ClientShopUserController { if (userId == null) { return AjaxResult.error("用户ID不能为空"); } - + // 根据用户ID查询完整的用户信息 ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId); if (shopUser == null) { return AjaxResult.error("未找到用户信息"); } - + // 出于安全考虑,清除敏感信息 shopUser.setPassword(null); - + return AjaxResult.success(shopUser); } - @PostMapping("/user/file") public AjaxResult addConfigFile( @RequestParam("file") MultipartFile file @@ -134,17 +137,17 @@ public class ClientShopUserController { // 检查是否已经登录 Long userId = SecurityUtils.getUserId(); if (userId == null) { - return AjaxResult.error(401,"用户未登录"); + return AjaxResult.error(401, "用户未登录"); } // 1. 处理文件上传 if (file != null && !file.isEmpty()) { // 保存文件逻辑 String url = AliConfig.ossUp("user/", file.getOriginalFilename(), file.getInputStream()); - Map head = new HashMap<>(); - head.put("headImg",url); + Map head = new HashMap<>(); + head.put("headImg", url); return AjaxResult.success("请求成功", head); } return AjaxResult.error("文件不能为空"); } -} \ No newline at end of file +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PushMsgInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PushMsgInfo.java index a858519..fa801a9 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PushMsgInfo.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/PushMsgInfo.java @@ -10,5 +10,6 @@ public class PushMsgInfo { private String title; private String text; private String ticker; + private String deviceIds; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java index 7af254a..81869fc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java @@ -7,9 +7,13 @@ import com.ruoyi.common.core.domain.UmResp; import com.ruoyi.common.core.domain.entity.PushMsgInfo; import com.ruoyi.common.enums.DeviceTypeEnum; import com.ruoyi.common.utils.uuid.UUID; +import com.ruoyi.system.config.push.AndroidColumnOn; import com.ruoyi.system.config.push.AndroidNotification; +import com.ruoyi.system.config.push.IOSColumnOn; import com.ruoyi.system.config.push.PushClient; +import com.ruoyi.system.config.push.android.AndroidBroadcast; import com.ruoyi.system.config.push.android.AndroidCustomizedcast; +import com.ruoyi.system.config.push.ios.IOSBroadcast; import com.ruoyi.system.config.push.ios.IOSCustomizedcast; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.digest.DigestUtils; @@ -158,12 +162,101 @@ public class UmengConfig { client.send(customizedcast); } + public void sendIOSBroadcast(PushMsgInfo pushMsgInfo) throws Exception { + IOSBroadcast broadcast = new IOSBroadcast(AliKeyConfig.UMApp_IOS_Key,AliKeyConfig.IOS_SECRET); + //alert值设置为字符串 + //broadcast.setAlert("IOS 广播测试"); + //alert的值设置为字典 + broadcast.setAlert(pushMsgInfo.getTitle()); + broadcast.setBadge(0); + broadcast.setSound( "default"); + // TODO set 'production_mode' to 'true' if your app is under production mode + broadcast.setTestMode(); + // Set customized fields + broadcast.setCustomizedField(pushMsgInfo.getTitle(), pushMsgInfo.getText()); + client.send(broadcast); + } + + public void sendIOSColumnOn(PushMsgInfo pushMsgInfo) throws Exception { + // 自定义实体类, 附有代码 + IOSColumnOn columnOn = new IOSColumnOn(AliKeyConfig.UMApp_IOS_Key,AliKeyConfig.IOS_SECRET); + columnOn.setDeviceToken(pushMsgInfo.getDeviceIds()); + // 列播中 传入的deviceToken类似于 1,2,3,4,5 + columnOn.setDeviceToken(pushMsgInfo.getDeviceIds()); + columnOn.setAlert(pushMsgInfo.getTicker()); + columnOn.setBadge(0); + columnOn.setSound("default"); + // 点击"通知"的后续行为,默认为打开app。 + columnOn.setTestMode(); + columnOn.setCustomizedField(pushMsgInfo.getTitle(), pushMsgInfo.getText()); + client.send(columnOn); + } + + public void sendAndroidBroadcast(PushMsgInfo pushMsgInfo) throws Exception { + //"68a9988ce563686f4288e26d","vxq4qfnb3jbb3jahrcxpbtpjgcuu7dtm" + AndroidBroadcast broadcast = new AndroidBroadcast(AliKeyConfig.UMApp_Android_Key,AliKeyConfig.Android_SECRET); + broadcast.setTicker(pushMsgInfo.getTicker()); + broadcast.setTitle(pushMsgInfo.getTitle()); + broadcast.setText(pushMsgInfo.getText()); + broadcast.goAppAfterOpen(); + broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); + // TODO Set 'production_mode' to 'false' if it's a test device. + // For how to register a test device, please see the developer doc. + broadcast.setProductionMode(); + // Set customized fields + //broadcast.setExtraField("test", "helloworld"); + //厂商通道相关参数 + // broadcast.setChannelActivity("your channel activity"); + // broadcast.setChannelProperties("abc"); + client.send(broadcast); + } + + /** + * 列播推送 + * + * @param deviceToken 多个device_tokens是用英文逗号间隔, 不能超过五百个 + */ + public void sendAndroidColumnOn(PushMsgInfo pushMsgInfo) throws Exception { + // 自定义实体类, 附有代码 + AndroidColumnOn columnOn = new AndroidColumnOn(AliKeyConfig.UMApp_Android_Key,AliKeyConfig.Android_SECRET); + // 列播中 传入的deviceToken类似于 1,2,3,4,5 + columnOn.setDeviceToken(pushMsgInfo.getDeviceIds()); + // 当你没有下拉通知栏的时候, 写入的文字会在顶端翻转显示, 有的可以显示有的不可以显示, 看你设置和设备的允许情况 + columnOn.setTicker(pushMsgInfo.getTicker()); + // 标题 + columnOn.setTitle(pushMsgInfo.getTitle()); + // 内容 + columnOn.setText(pushMsgInfo.getText()); + // 点击"通知"的后续行为,默认为打开app。 + columnOn.goAppAfterOpen(); + /** + * NOTIFICATION 是友盟做处理在通知栏上显示通知内容 + * MESSAGE 是传给应用自身进行解析处理 + */ + columnOn.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); + + // 测试模式使用false, 正式模式使用true + columnOn.setProductionMode(); + + // Set customized fields + columnOn.setExtraField("test", "helloworld"); + + // 自定义的一些东西 + columnOn.setChannelActivity("your channel activity"); + columnOn.setChannelProperties("abc"); + client.send(columnOn); + } + public static void main(String[] args) throws Exception { + UmengConfig umengConfig = new UmengConfig(); - System.out.println(DeviceTypeEnum.ANDROID.name()); - UmResp sss1 = umengConfig.send( - "eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5UlFPSHo3U25ZMmNcL3ZpbUI3ZHN2THFwQXlkbmRJeDB4NHhLSytFR2pvVEF4eU1oUnpUVHlrNHYzZThCSjNIajJOamJoK0VPdUtRTXV3N2pnS0dIdHJoT3FJRFF4QXJ0NisrUTI1ODhhQWdEVnp5TUVZdmxpTFhKeDUwS1wvZWI5VjdSb1VoNkMzc2E5Mm1xcHI1S3FxMm9KZHk3THoyYkVPQUVnM1hvWHJWVlwvcmtOMFluV1AyMVBZb0xrVFgxXC84TWZhVXZJRkY2aWJldDVaYkNzMVNhZU9LVU1rcnlicVpINHBMNlF5TzBFRjkrUHljT01hOGlVTjZabVZ6dm1HOFJHK3BjQjF1amVpSVpRN2N5bDRPOGxnPT0iLCJjIjoiSW02VTJVV3IxYTlDTkpmN29WR2FpRGxCZ3RSamQ5djUwaENCajJMWXd5N2Y3dzV2SndnWHFSXC8zeTlWYzFpSDFITnFHN1wvcUZpN2cxXC94cGQ5RGNsVjE0SXFKYmsxSHppZkNcL0JSU0NaeGpFTm5qWndTR3l1K1VnR3luajhnMWlHbkFhOHRmVWRUN0lGNWdrOGpVSVlteTZBNllkXC92Z2RXXC9wa1krcE9pczVWZEUrTjhXMjhEXC9idXhjQm1Wbm5obHpMWmdzRHUrdWcwQ0FMY2M0V3JybWdGdFcyOWN4Mkh5SGNNZ3AwY2xuOW5GQnNaS20zbDV3QWZIeUd2WkRpU1R3Q0lpSjFHUzNXUm1oZFVVdXo4NHRqMnBhWHZ1Y01Sa0tnNGt6Mk9cLyt4QmMrRzJ1VGpETXNtcW1nVUdBSWFoMlNyaGs5MEJMZWlKSFRLY0diTjlZbmN2cjZlMTBlZE1nSDR3QTB5K0lnTzlXd2t5OVAwb1FUbEZpUHd1Tm9PMm1OUEFpTDVwb3ZkZEp0QmY4TDZmb3B1NWl4a0FnVzBUdFM2OHN3Y3BaeWhuT25zRks0dXI2OHc3YWIySWJPNWpZMnhLTHZvb1NjMmRcLzhcL2JSTmxFM0txUUFLcDRGQUpxdWJ2bjhQRzdPcGN2bXhuSkF4bTJYNTFkQUZtaTdsSjZuZlc0MlJSNDRZWDBtMlhkczAwY3hZa2s5Q29zeVdWVUdGUkVDMjdjUUFURU9PMWp2TzdlMHEwOTRLZjdnaEx2UFJadlo2bFIxSUxmTTJxeWlQc0V5dmRiSUJyaG1yVEtJOWdqRW5Qc3U2dEZPc1RiZ0oxaVwvNGZBRFBKWDhOczF1Ym9taVl2KzZnVGsyNzlZTmQ3WU9OT21mMzlTOG05RktrNEN3Uk1QT1wvcVVSMGRJN25HbER4U1wvWEFFbWNHU0wxcDllczN0U0lsVUIrbHNcL3luWWZFNWNicDIwRE9NV3ZcL0xLa0I2cXA5RkVtaXV6eDY2MWYzZE9hZnk2WUJ2V2dsQnljU05TSkdDNkpYeTZnWHEwR1wvNE9XTkRPdjFhakIxMnhGRk9PK1dhbUVKcG9Takxic0FFV0V5eEtDb3pXaU9meG0ydEJ0bHdoM2hwXC9Vb3RyRCtIbkY2Z1NOOGtCblVtYnJRU3FzYUdsM2g3WDZSZUREbXdRSmMzSzY0QkxNcCJ9", "IOS"); + //umengConfig.sendAndroidBroadcast(); + // umengConfig.sendAndroidColumnOn("ArQoP2TkOFOCc11xP_biFmEO_DLfdKO0PZ4lvoWp5enm"); + // umengConfig.sendAndroidColumnOn("ApqqKzPuBZdgILvIrX0Hq099e3qN_Z8ub_P0qoIvwEdi"); + // System.out.println(DeviceTypeEnum.ANDROID.name()); + // UmResp sss1 = umengConfig.send( + // "eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5UlFPSHo3U25ZMmNcL3ZpbUI3ZHN2THFwQXlkbmRJeDB4NHhLSytFR2pvVEF4eU1oUnpUVHlrNHYzZThCSjNIajJOamJoK0VPdUtRTXV3N2pnS0dIdHJoT3FJRFF4QXJ0NisrUTI1ODhhQWdEVnp5TUVZdmxpTFhKeDUwS1wvZWI5VjdSb1VoNkMzc2E5Mm1xcHI1S3FxMm9KZHk3THoyYkVPQUVnM1hvWHJWVlwvcmtOMFluV1AyMVBZb0xrVFgxXC84TWZhVXZJRkY2aWJldDVaYkNzMVNhZU9LVU1rcnlicVpINHBMNlF5TzBFRjkrUHljT01hOGlVTjZabVZ6dm1HOFJHK3BjQjF1amVpSVpRN2N5bDRPOGxnPT0iLCJjIjoiSW02VTJVV3IxYTlDTkpmN29WR2FpRGxCZ3RSamQ5djUwaENCajJMWXd5N2Y3dzV2SndnWHFSXC8zeTlWYzFpSDFITnFHN1wvcUZpN2cxXC94cGQ5RGNsVjE0SXFKYmsxSHppZkNcL0JSU0NaeGpFTm5qWndTR3l1K1VnR3luajhnMWlHbkFhOHRmVWRUN0lGNWdrOGpVSVlteTZBNllkXC92Z2RXXC9wa1krcE9pczVWZEUrTjhXMjhEXC9idXhjQm1Wbm5obHpMWmdzRHUrdWcwQ0FMY2M0V3JybWdGdFcyOWN4Mkh5SGNNZ3AwY2xuOW5GQnNaS20zbDV3QWZIeUd2WkRpU1R3Q0lpSjFHUzNXUm1oZFVVdXo4NHRqMnBhWHZ1Y01Sa0tnNGt6Mk9cLyt4QmMrRzJ1VGpETXNtcW1nVUdBSWFoMlNyaGs5MEJMZWlKSFRLY0diTjlZbmN2cjZlMTBlZE1nSDR3QTB5K0lnTzlXd2t5OVAwb1FUbEZpUHd1Tm9PMm1OUEFpTDVwb3ZkZEp0QmY4TDZmb3B1NWl4a0FnVzBUdFM2OHN3Y3BaeWhuT25zRks0dXI2OHc3YWIySWJPNWpZMnhLTHZvb1NjMmRcLzhcL2JSTmxFM0txUUFLcDRGQUpxdWJ2bjhQRzdPcGN2bXhuSkF4bTJYNTFkQUZtaTdsSjZuZlc0MlJSNDRZWDBtMlhkczAwY3hZa2s5Q29zeVdWVUdGUkVDMjdjUUFURU9PMWp2TzdlMHEwOTRLZjdnaEx2UFJadlo2bFIxSUxmTTJxeWlQc0V5dmRiSUJyaG1yVEtJOWdqRW5Qc3U2dEZPc1RiZ0oxaVwvNGZBRFBKWDhOczF1Ym9taVl2KzZnVGsyNzlZTmQ3WU9OT21mMzlTOG05RktrNEN3Uk1QT1wvcVVSMGRJN25HbER4U1wvWEFFbWNHU0wxcDllczN0U0lsVUIrbHNcL3luWWZFNWNicDIwRE9NV3ZcL0xLa0I2cXA5RkVtaXV6eDY2MWYzZE9hZnk2WUJ2V2dsQnljU05TSkdDNkpYeTZnWHEwR1wvNE9XTkRPdjFhakIxMnhGRk9PK1dhbUVKcG9Takxic0FFV0V5eEtDb3pXaU9meG0ydEJ0bHdoM2hwXC9Vb3RyRCtIbkY2Z1NOOGtCblVtYnJRU3FzYUdsM2g3WDZSZUREbXdRSmMzSzY0QkxNcCJ9", "IOS"); // String sss; // sss = "{\"success\":true,\"data\":{\"mobile\":\"18518753918\",\"score\":null,\"activeScore\":null,\"aesEncryptKey\":null},\"code\":2001,\"message\":\"gain mobile's result success\",\"requestId\":\"0E87E249-42A0-42C0-94D3-7424D45E571E\"}\n"; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/push/AndroidColumnOn.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/AndroidColumnOn.java new file mode 100644 index 0000000..d3ee514 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/AndroidColumnOn.java @@ -0,0 +1,18 @@ +package com.ruoyi.system.config.push; + +/** + * 列播(要求不超过500个device_token) 用英文逗号隔开 + */ +public class AndroidColumnOn extends AndroidNotification { + + public AndroidColumnOn(String appkey,String appMasterSecret) throws Exception { + setAppMasterSecret(appMasterSecret); + setPredefinedKeyValue("appkey", appkey); + this.setPredefinedKeyValue("type", "listcast"); // type = listcast 是群体发送 + } + + public void setDeviceToken(String token) throws Exception { + setPredefinedKeyValue("device_tokens", token); + } + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/push/Demo.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/Demo.java index 9a8de1b..4cc8091 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/config/push/Demo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/Demo.java @@ -11,7 +11,7 @@ public class Demo { private String appMasterSecret = null; private String timestamp = null; private PushClient client = new PushClient(); - + public Demo(String key, String secret) { try { appkey = key; @@ -21,25 +21,9 @@ public class Demo { System.exit(1); } } - - public void sendAndroidBroadcast() throws Exception { - AndroidBroadcast broadcast = new AndroidBroadcast(appkey,appMasterSecret); - broadcast.setTicker( "Android broadcast ticker"); - broadcast.setTitle( "中文的title"); - broadcast.setText( "Android broadcast text"); - broadcast.goAppAfterOpen(); - broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); - // TODO Set 'production_mode' to 'false' if it's a test device. - // For how to register a test device, please see the developer doc. - broadcast.setProductionMode(); - // Set customized fields - broadcast.setExtraField("test", "helloworld"); - //厂商通道相关参数 - broadcast.setChannelActivity("your channel activity"); - broadcast.setChannelProperties("abc"); - client.send(broadcast); - } - + + + public void sendAndroidUnicast() throws Exception { AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret); // TODO Set your device token @@ -49,7 +33,7 @@ public class Demo { unicast.setText( "Android unicast text"); unicast.goAppAfterOpen(); unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); - // TODO Set 'production_mode' to 'false' if it's a test device. + // TODO Set 'production_mode' to 'false' if it's a test device. // For how to register a test device, please see the developer doc. unicast.setProductionMode(); // Set customized fields @@ -58,14 +42,14 @@ public class Demo { unicast.setChannelProperties("abc"); client.send(unicast); } - + public void sendAndroidGroupcast() throws Exception { AndroidGroupcast groupcast = new AndroidGroupcast(appkey,appMasterSecret); /* TODO * Construct the filter condition: - * "where": + * "where": * { - * "and": + * "and": * [ * {"tag":"test"}, * {"tag":"Test"} @@ -91,7 +75,7 @@ public class Demo { groupcast.goAppAfterOpen(); groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); groupcast.setChannelActivity("your channel activity"); - // TODO Set 'production_mode' to 'false' if it's a test device. + // TODO Set 'production_mode' to 'false' if it's a test device. // For how to register a test device, please see the developer doc. groupcast.setProductionMode(); //厂商通道相关参数 @@ -99,7 +83,7 @@ public class Demo { groupcast.setChannelProperties("abc"); client.send(groupcast); } - + // public void sendAndroidCustomizedcast() throws Exception { // AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret); // // TODO Set your alias here, and use comma to split them if there are multiple alias. @@ -119,11 +103,11 @@ public class Demo { // customizedcast.setChannelProperties("abc"); // client.send(customizedcast); // } - + public void sendAndroidCustomizedcastFile() throws Exception { AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret); // TODO Set your alias here, and use comma to split them if there are multiple alias. - // And if you have many alias, you can also upload a file containing these alias, then + // And if you have many alias, you can also upload a file containing these alias, then // use file_id to send customized notification. String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"+"\n"+"alias"); customizedcast.setFileId(fileId, "alias_type"); @@ -132,7 +116,7 @@ public class Demo { customizedcast.setText( "Android customizedcast text"); customizedcast.goAppAfterOpen(); customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); - // TODO Set 'production_mode' to 'false' if it's a test device. + // TODO Set 'production_mode' to 'false' if it's a test device. // For how to register a test device, please see the developer doc. customizedcast.setProductionMode(); //厂商通道相关参数 @@ -140,10 +124,10 @@ public class Demo { customizedcast.setChannelProperties("abc"); client.send(customizedcast); } - + public void sendAndroidFilecast() throws Exception { AndroidFilecast filecast = new AndroidFilecast(appkey,appMasterSecret); - // TODO upload your device tokens, and use '\n' to split them if there are multiple tokens + // TODO upload your device tokens, and use '\n' to split them if there are multiple tokens String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"); filecast.setFileId( fileId); filecast.setTicker( "Android filecast ticker"); @@ -156,7 +140,7 @@ public class Demo { filecast.setChannelProperties("abc"); client.send(filecast); } - + public void sendIOSBroadcast() throws Exception { IOSBroadcast broadcast = new IOSBroadcast(appkey,appMasterSecret); //alert值设置为字符串 @@ -171,7 +155,7 @@ public class Demo { broadcast.setCustomizedField("test", "helloworld"); client.send(broadcast); } - + public void sendIOSUnicast() throws Exception { IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret); // TODO Set your device token @@ -189,14 +173,14 @@ public class Demo { client.send(unicast); } - + public void sendIOSGroupcast() throws Exception { IOSGroupcast groupcast = new IOSGroupcast(appkey,appMasterSecret); /* TODO * Construct the filter condition: - * "where": + * "where": * { - * "and": + * "and": * [ * {"tag":"iostest"} * ] @@ -211,7 +195,7 @@ public class Demo { whereJson.put("and", tagArray); filterJson.put("where", whereJson); System.out.println(filterJson.toString()); - + // Set filter condition into rootJson groupcast.setFilter(filterJson); //groupcast.setAlert("IOS 组播测试"); @@ -223,11 +207,11 @@ public class Demo { groupcast.setTestMode(); client.send(groupcast); } - + public void sendIOSCustomizedcast() throws Exception { IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey,appMasterSecret); // TODO Set your alias and alias_type here, and use comma to split them if there are multiple alias. - // And if you have many alias, you can also upload a file containing these alias, then + // And if you have many alias, you can also upload a file containing these alias, then // use file_id to send customized notification. customizedcast.setAlias("alias", "alias_type"); //customizedcast.setAlert("IOS 个性化测试"); @@ -239,10 +223,10 @@ public class Demo { customizedcast.setTestMode(); client.send(customizedcast); } - + public void sendIOSFilecast() throws Exception { IOSFilecast filecast = new IOSFilecast(appkey,appMasterSecret); - // TODO upload your device tokens, and use '\n' to split them if there are multiple tokens + // TODO upload your device tokens, and use '\n' to split them if there are multiple tokens String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"); filecast.setFileId( fileId); //filecast.setAlert("IOS 文件播测试"); @@ -254,7 +238,7 @@ public class Demo { filecast.setTestMode(); client.send(filecast); } - + public static void main(String[] args) { // TODO set your appkey and master secret here Demo demo = new Demo("your appkey", "your master secret"); @@ -267,7 +251,7 @@ public class Demo { * demo.sendAndroidGroupcast(); * demo.sendAndroidCustomizedcast(); * demo.sendAndroidFilecast(); - * + * * demo.sendIOSBroadcast(); * demo.sendIOSUnicast(); * demo.sendIOSGroupcast(); @@ -278,6 +262,6 @@ public class Demo { ex.printStackTrace(); } } - + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/push/IOSColumnOn.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/IOSColumnOn.java new file mode 100644 index 0000000..919b375 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/IOSColumnOn.java @@ -0,0 +1,21 @@ +package com.ruoyi.system.config.push; + +/** + * 描述: + * + * @author MXP by 2025/10/14 + */ +public class IOSColumnOn extends IOSNotification{ + + public IOSColumnOn(String appkey,String appMasterSecret) throws Exception { + setAppMasterSecret(appMasterSecret); + setPredefinedKeyValue("appkey", appkey); + this.setPredefinedKeyValue("type", "listcast"); // type = listcast 是群体发送 + } + + public void setDeviceToken(String token) throws Exception { + setPredefinedKeyValue("device_tokens", token); + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/push/PushClient.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/PushClient.java index 3625b92..80a0e5f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/config/push/PushClient.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/push/PushClient.java @@ -2,6 +2,7 @@ package com.ruoyi.system.config.push; import java.io.BufferedReader; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import com.alibaba.fastjson2.JSONObject; import org.apache.commons.codec.digest.DigestUtils; @@ -11,19 +12,19 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; public class PushClient { - + // The user agent protected final String USER_AGENT = "Mozilla/5.0"; // This object is used for sending the post request to Umeng protected HttpClient client = new DefaultHttpClient(); - + // The host protected static final String host = "http://msg.umeng.com"; - + // The upload path protected static final String uploadPath = "/upload"; - + // The post path protected static final String postPath = "/api/send"; @@ -32,7 +33,7 @@ public class PushClient { msg.setPredefinedKeyValue("timestamp", timestamp); String url = host + postPath; String postBody = msg.getPostBody(); - String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes("utf8")); + String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes(StandardCharsets.UTF_8)); url = url + "?sign=" + sign; HttpPost post = new HttpPost(url); post.setHeader("User-Agent", USER_AGENT); @@ -93,7 +94,7 @@ public class PushClient { JSONObject data = respJson.getJSONObject("data"); String fileId = data.getString("file_id"); // Set file_id into rootJson using setPredefinedKeyValue - + return fileId; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java index 2e1e549..199621b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java @@ -1,6 +1,7 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.domain.entity.ShopUser; +import com.ruoyi.common.core.domain.entity.ShopUserResq; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -69,7 +70,7 @@ public interface ShopUserMapper { * @return 结果 */ public int deleteShopUserByIds(String[] ids); - + /** * 更新用户在线时长 * @@ -77,7 +78,7 @@ public interface ShopUserMapper { * @return 结果 */ public int updateUserOnlineTime(ShopUser shopUser); - + /** * 查询用户的音乐标签 * @@ -88,5 +89,9 @@ public interface ShopUserMapper { List selectPhoneShopUserByUserIds(List userIds); + List selectDeviceIdShopUserByUserIds(List userIds); + int updateShopUserId(ShopUser shopUser); -} \ No newline at end of file + + int updateDeviceIdByPhone(ShopUserResq shopUser); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/INotificationsService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/INotificationsService.java index c075e63..a0aa742 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/INotificationsService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/INotificationsService.java @@ -7,15 +7,15 @@ import java.util.List; /** * 【请填写功能名称】Service接口 - * + * * @author ruoyi * @date 2025-08-23 */ -public interface INotificationsService +public interface INotificationsService { /** * 查询【请填写功能名称】 - * + * * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ @@ -23,7 +23,7 @@ public interface INotificationsService /** * 查询【请填写功能名称】列表 - * + * * @param notifications 【请填写功能名称】 * @return 【请填写功能名称】集合 */ @@ -31,7 +31,7 @@ public interface INotificationsService /** * 新增【请填写功能名称】 - * + * * @param notifications 【请填写功能名称】 * @return 结果 */ @@ -39,7 +39,7 @@ public interface INotificationsService /** * 修改【请填写功能名称】 - * + * * @param notifications 【请填写功能名称】 * @return 结果 */ @@ -47,7 +47,7 @@ public interface INotificationsService /** * 批量删除【请填写功能名称】 - * + * * @param ids 需要删除的【请填写功能名称】主键集合 * @return 结果 */ @@ -55,17 +55,19 @@ public interface INotificationsService /** * 删除【请填写功能名称】信息 - * + * * @param id 【请填写功能名称】主键 * @return 结果 */ public int deleteNotificationsById(Long id); - + /** * 发布通知 - * + * * @param id 通知ID * @return 结果 */ public AjaxResult publishNotification(Long id); + + AjaxResult publishSendAll(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CShopUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CShopUserServiceImpl.java index 475a751..5ccaaec 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CShopUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CShopUserServiceImpl.java @@ -51,7 +51,7 @@ public class CShopUserServiceImpl implements ShopUserService { // 验证码 String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone()); // TODO:写死 - // String code="9527"; + //String code="9527"; String reqCode = shopUser.getCode(); if (code != null && code.equals(reqCode)){ // 登录 @@ -143,6 +143,8 @@ public class CShopUserServiceImpl implements ShopUserService { return null; } } + // 修改外设id + shopUserMapper.updateDeviceIdByPhone(shopUser); return member; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationRecordsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationRecordsServiceImpl.java index c5479a5..1a17d85 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationRecordsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationRecordsServiceImpl.java @@ -15,20 +15,20 @@ import java.util.stream.Collectors; /** * 【请填写功能名称】Service业务层处理 - * + * * @author ruoyi * @date 2025-08-23 */ @Transactional @Service -public class NotificationRecordsServiceImpl implements INotificationRecordsService +public class NotificationRecordsServiceImpl implements INotificationRecordsService { @Autowired private NotificationRecordsMapper notificationRecordsMapper; /** * 查询【请填写功能名称】 - * + * * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ @@ -40,7 +40,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi /** * 查询【请填写功能名称】列表 - * + * * @param notificationRecords 【请填写功能名称】 * @return 【请填写功能名称】 */ @@ -52,7 +52,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi /** * 新增【请填写功能名称】 - * + * * @param notificationRecords 【请填写功能名称】 * @return 结果 */ @@ -65,7 +65,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi /** * 修改【请填写功能名称】 - * + * * @param notificationRecords 【请填写功能名称】 * @return 结果 */ @@ -78,7 +78,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi /** * 批量删除【请填写功能名称】 - * + * * @param ids 需要删除的【请填写功能名称】主键 * @return 结果 */ @@ -90,7 +90,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi /** * 删除【请填写功能名称】信息 - * + * * @param id 【请填写功能名称】主键 * @return 结果 */ @@ -99,7 +99,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi { return notificationRecordsMapper.deleteNotificationRecordsById(id); } - + /** * 绑定用户到通知记录 * @@ -110,22 +110,22 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi @Transactional public void bind(Long id, List shopUsers) { System.out.println("开始绑定用户,通知ID: " + id + ", 用户数量: " + (shopUsers != null ? shopUsers.size() : 0)); - + if (id == null || shopUsers == null || shopUsers.isEmpty()) { System.out.println("通知ID为空或用户列表为空,无法绑定"); return; } - + // 打印用户列表信息 System.out.println("用户列表详情:"); - for (ShopUser user : shopUsers) { - System.out.println("用户ID: " + (user != null ? user.getUserId() : "null") + - ", 类型: " + (user != null && user.getUserId() != null ? user.getUserId().getClass().getName() : "null")); - } - + // for (ShopUser user : shopUsers) { + // System.out.println("用户ID: " + (user != null ? user.getUserId() : "null") + + // ", 类型: " + (user != null && user.getUserId() != null ? user.getUserId().getClass().getName() : "null")); + // } + // 获取当前时间 Date now = DateUtils.getNowDate(); - + // 查询该通知已经绑定的用户ID列表 NotificationRecords query = new NotificationRecords(); query.setNotificationId(id); @@ -134,33 +134,33 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi .map(NotificationRecords::getUserId) .filter(Objects::nonNull) .collect(Collectors.toSet()); - + System.out.println("已绑定用户数量: " + existingUserIds.size()); - + // 创建通知记录列表 List recordsList = new ArrayList<>(); - + // 遍历用户列表,为每个用户创建通知记录(排除已绑定的用户) int validUserCount = 0; int invalidUserCount = 0; int duplicateUserCount = 0; - + for (ShopUser user : shopUsers) { try { // 验证用户ID是否有效 if (user == null || user.getUserId() == null) { - System.out.println("用户或用户ID为空,跳过"); + //System.out.println("用户或用户ID为空,跳过"); invalidUserCount++; continue; } - + if (existingUserIds.contains(user.getUserId())) { - System.out.println("用户ID: " + user.getUserId() + " 已绑定,跳过"); + // System.out.println("用户ID: " + user.getUserId() + " 已绑定,跳过"); duplicateUserCount++; continue; } - + // 创建通知记录 NotificationRecords record = new NotificationRecords(); record.setUserId(user.getUserId()); @@ -172,19 +172,19 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi record.setNotificationId(id); recordsList.add(record); validUserCount++; - + System.out.println("添加用户ID: " + user.getUserId() + " 到待绑定列表"); } catch (Exception e) { // 记录错误日志,但继续处理其他用户 - System.err.println("处理用户ID时出错: " + (user != null ? user.getUserId() : "null") + ", 错误: " + e.getMessage()); + //lo.error("处理用户ID时出错: " + (user != null ? user.getUserId() : "null") + ", 错误: " + e.getMessage()); e.printStackTrace(); invalidUserCount++; } } - + System.out.println("有效用户数: " + validUserCount + ", 无效用户数: " + invalidUserCount + ", 重复用户数: " + duplicateUserCount); System.out.println("待插入记录数: " + recordsList.size()); - + // 批量插入通知记录 if (!recordsList.isEmpty()) { try { @@ -199,7 +199,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi System.out.println("没有需要插入的记录"); } } - + /** * 获取通知已绑定的用户列表 * @@ -211,25 +211,25 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi if (notificationId == null) { return new ArrayList<>(); } - + // 创建查询条件 NotificationRecords query = new NotificationRecords(); query.setNotificationId(notificationId); - + // 查询通知记录 List records = notificationRecordsMapper.selectNotificationRecordsList(query); - + // 提取用户ID列表 List userIds = records.stream() .map(NotificationRecords::getUserId) .filter(Objects::nonNull) .collect(Collectors.toList()); - + // 如果没有绑定用户,返回空列表 if (userIds.isEmpty()) { return new ArrayList<>(); } - + // 查询用户信息 // 这里需要调用ShopUserMapper来查询用户信息 // 由于没有提供ShopUserMapper,这里简单处理,将用户ID封装成ShopUser对象返回 @@ -239,7 +239,7 @@ public class NotificationRecordsServiceImpl implements INotificationRecordsServi user.setUserId(userId); users.add(user); } - + return users; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationsServiceImpl.java index cd9d6c3..2d0a5a4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/NotificationsServiceImpl.java @@ -22,19 +22,19 @@ import java.util.stream.Collectors; /** * 【请填写功能名称】Service业务层处理 - * + * * @author ruoyi * @date 2025-08-23 */ @Transactional @Service -public class NotificationsServiceImpl implements INotificationsService +public class NotificationsServiceImpl implements INotificationsService { private static final Logger log = LoggerFactory.getLogger(NotificationsServiceImpl.class); - + @Autowired private NotificationsMapper notificationsMapper; - + @Autowired private NotificationRecordsMapper notificationRecordsMapper; @@ -46,7 +46,7 @@ public class NotificationsServiceImpl implements INotificationsService /** * 查询【请填写功能名称】 - * + * * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ @@ -58,7 +58,7 @@ public class NotificationsServiceImpl implements INotificationsService /** * 查询【请填写功能名称】列表 - * + * * @param notifications 【请填写功能名称】 * @return 【请填写功能名称】 */ @@ -70,7 +70,7 @@ public class NotificationsServiceImpl implements INotificationsService /** * 新增【请填写功能名称】 - * + * * @param notifications 【请填写功能名称】 * @return 结果 */ @@ -83,7 +83,7 @@ public class NotificationsServiceImpl implements INotificationsService /** * 修改【请填写功能名称】 - * + * * @param notifications 【请填写功能名称】 * @return 结果 */ @@ -95,7 +95,7 @@ public class NotificationsServiceImpl implements INotificationsService /** * 批量删除【请填写功能名称】 - * + * * @param ids 需要删除的【请填写功能名称】主键 * @return 结果 */ @@ -107,7 +107,7 @@ public class NotificationsServiceImpl implements INotificationsService /** * 删除【请填写功能名称】信息 - * + * * @param id 【请填写功能名称】主键 * @return 结果 */ @@ -116,10 +116,10 @@ public class NotificationsServiceImpl implements INotificationsService { return notificationsMapper.deleteNotificationsById(id); } - + /** * 发布通知 - * + * * @param id 通知ID * @return 结果 */ @@ -133,7 +133,7 @@ public class NotificationsServiceImpl implements INotificationsService { return AjaxResult.error("通知不存在"); } - + // 查询该通知的所有记录 NotificationRecords query = new NotificationRecords(); query.setNotificationId(id); @@ -145,14 +145,11 @@ public class NotificationsServiceImpl implements INotificationsService { return AjaxResult.error("该通知没有绑定任何用户,请先绑定用户"); } - List phones = shopUserMapper.selectPhoneShopUserByUserIds(userIds); + List deviceIds = shopUserMapper.selectDeviceIdShopUserByUserIds(userIds); // 当前时间 Date now = DateUtils.getNowDate(); - int successCount = 0; - int failCount = 0; - - sendNotificationToThirdParty(notification, phones); + sendNotificationToThirdParty(notification, deviceIds); query.setStatus("sent"); notificationRecordsMapper.updateNotificationRecords(query); @@ -201,23 +198,44 @@ public class NotificationsServiceImpl implements INotificationsService // } // } // } - + // 更新通知状态为已发布 // notification.setStatus("published"); // notification.setPublishTime(now); // notificationsMapper.updateNotifications(notification); - - return AjaxResult.success("通知发布完成,成功:" + successCount + ",失败:" + failCount); + + return AjaxResult.success("通知发布完成,成功"); } - + + @Override + public AjaxResult publishSendAll(Long id) { + // 查询通知信息 + Notifications notification = notificationsMapper.selectNotificationsById(id); + sendAllToThirdParty(notification); + return AjaxResult.success("通知发布完成"); + } + + private void sendAllToThirdParty(Notifications notification) { + PushMsgInfo pushMsgInfo = new PushMsgInfo(); + pushMsgInfo.setTitle(notification.getTitle()); + pushMsgInfo.setText(notification.getContent()); + pushMsgInfo.setTicker(notification.getTitle()); + try { + umengConfig.sendAndroidBroadcast(pushMsgInfo); + umengConfig.sendIOSBroadcast(pushMsgInfo); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + /** * 调用第三方接口发送通知 - * + * * @param notification 通知信息 * @param record 通知记录 * @return 发送结果 */ - private boolean sendNotificationToThirdParty(Notifications notification, List phones) + private boolean sendNotificationToThirdParty(Notifications notification, List deviceIds) { try { @@ -227,18 +245,18 @@ public class NotificationsServiceImpl implements INotificationsService // notification.getId(), record.getUserId(), notification.getTitle(), notification.getContent()); // // 按照499个手机号一组进行分批处理 - for (int i = 0; i < phones.size(); i += 499) { - int endIndex = Math.min(i + 499, phones.size()); - List phoneBatch = phones.subList(i, endIndex); - String phoneS = String.join(",", phoneBatch); + for (int i = 0; i < deviceIds.size(); i += 499) { + int endIndex = Math.min(i + 499, deviceIds.size()); + List phoneBatch = deviceIds.subList(i, endIndex); + String deviceIdS = String.join(",", phoneBatch); PushMsgInfo pushMsgInfo = new PushMsgInfo(); - pushMsgInfo.setAlias(phoneS); + pushMsgInfo.setDeviceIds(deviceIdS); pushMsgInfo.setTitle(notification.getTitle()); pushMsgInfo.setText(notification.getContent()); - umengConfig.sendAndroidCustomizedcast(pushMsgInfo); - umengConfig.sendIOSCustomizedcast(pushMsgInfo); - log.info("发送通知批次 {}/{}, 本批次包含 {} 个手机号", - (i / 499) + 1, (phones.size() + 498) / 499, phoneBatch.size()); + umengConfig.sendAndroidColumnOn(pushMsgInfo); + umengConfig.sendIOSColumnOn(pushMsgInfo); + log.info("发送通知批次 {}/{}, 本批次包含 {} 个手机号", + (i / 499) + 1, (deviceIds.size() + 498) / 499, phoneBatch.size()); } // 模拟发送成功 return true; diff --git a/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml index e80e940..3731d9b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml @@ -204,7 +204,7 @@ where shop_user.user_id = #{userId} - + update shop_user @@ -214,19 +214,19 @@ where user_id = #{userId} - + @@ -256,4 +256,15 @@ where shop_user.id = #{id} - \ No newline at end of file + + + update shop_user set device_id = #{deviceId} where shop_user.phone = #{phone} + + + +