| | |
| | | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.push.exception.BPushDeviceTokenException; |
| | | import com.ks.push.pojo.DO.BPushDeviceToken; |
| | | import com.ks.push.pojo.DO.PushPlatform; |
| | | import com.ks.push.exception.BPushTaskException; |
| | | import com.ks.push.pojo.DO.*; |
| | | import com.ks.push.service.BDeviceTokenService; |
| | | import com.ks.push.service.BPushTaskService; |
| | | import com.ks.push.utils.JPushUtil; |
| | | import com.yeshi.makemoney.app.entity.SystemEnum; |
| | | import com.yeshi.makemoney.app.entity.config.AppJumpType; |
| | | import com.yeshi.makemoney.app.entity.config.SystemConfigKey; |
| | | import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; |
| | | import com.yeshi.makemoney.app.vo.AcceptData; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author hxh |
| | |
| | | @Component |
| | | public class PushManager { |
| | | |
| | | // @Reference(version = "1.0",check = false) |
| | | @Reference(version = "1.0", check = false) |
| | | private BDeviceTokenService bdeviceTokenService; |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | private BPushTaskService bPushTaskService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 推送签到 |
| | | * @date 16:40 2022/5/7 |
| | | * @param: system |
| | | * @param: uid |
| | | **/ |
| | | public void pushSignIn(SystemEnum system, List<Long> uidList) throws BPushTaskException { |
| | | if (uidList == null || uidList.size() == 0) { |
| | | return; |
| | | } |
| | | Map<String, String> extras = new HashMap<>(); |
| | | extras.put("type", AppJumpType.signIn.name()); |
| | | String title = "签到提醒"; |
| | | String content = "今日你还未签到,签到最高可领150金币!"; |
| | | push(system, uidList, title, content, extras); |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 推送金币结算 |
| | | * @date 16:41 2022/5/7 |
| | | * @param: system |
| | | * @param: uid |
| | | * @param: goldCorn |
| | | * @param: money |
| | | **/ |
| | | public void pushGoldCornSettle(SystemEnum system, Long uid, int goldCorn, BigDecimal money) throws BPushTaskException { |
| | | Map<String, String> extras = new HashMap<>(); |
| | | extras.put("type", AppJumpType.extract.name()); |
| | | String title = "到账提醒"; |
| | | String content = String.format("昨日金币折算成功,入账%s元", money.setScale(2).toString()); |
| | | push(system, Arrays.asList(new Long[]{uid}), title, content, extras); |
| | | } |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | | * @description 推送内容 |
| | | * @date 16:55 2022/5/7 |
| | | * @param: system |
| | | * @param: uid |
| | | * @param: title |
| | | * @param: content |
| | | * @param: extras |
| | | **/ |
| | | private void push(SystemEnum system, List<Long> uidList, String title, String content, Map<String, String> extras) throws BPushTaskException { |
| | | BPushTask bPushTask = new BPushTask(); |
| | | BPushMessage message = new BPushMessage(); |
| | | message.setMessage(false); |
| | | message.setExtras(extras); |
| | | message.setAndroidActivity(getPushIntent(system)); |
| | | message.setTitle(title); |
| | | message.setContent(content); |
| | | |
| | | |
| | | bPushTask.setMessage(message); |
| | | bPushTask.setAppCode(systemConfigService.getValueCache(system, SystemConfigKey.androidPushAppCode)); |
| | | |
| | | BPushFilter filter = new BPushFilter(); |
| | | if (uidList == null || uidList.size() == 0) { |
| | | //推送30天内还活跃的用户 |
| | | filter.setMinActiveTime(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 30)); |
| | | } else { |
| | | filter.setUidList(uidList.stream().map(item -> item + "").collect(Collectors.toList())); |
| | | } |
| | | bPushTask.setFilter(filter); |
| | | String taskId = bPushTaskService.createTask(bPushTask); |
| | | bPushTaskService.startPush(taskId); |
| | | } |
| | | |
| | | private String getPushIntent(SystemEnum system) { |
| | | return JPushUtil.createIntent(systemConfigService.getValueCache(system, SystemConfigKey.androidPushActivity), system.getPackageName()); |
| | | } |
| | | |
| | | |
| | | } |