| | |
| | | <version>1.1.1</version> |
| | | </dependency> |
| | | |
| | | <!-- 腾讯云短信 --> |
| | | <dependency> |
| | | <groupId>com.github.qcloudsms</groupId> |
| | | <artifactId>qcloudsms</artifactId> |
| | | <version>1.0.2</version> |
| | | </dependency> |
| | | |
| | | |
| | | |
| | | </dependencies> |
New file |
| | |
| | | package com.yeshi.makemoney.app.config; |
| | | |
| | | import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class XXLJobConfig { |
| | | |
| | | Logger log = LoggerFactory.getLogger(XXLJobConfig.class); |
| | | |
| | | @Value("${xxl.job.admin.addresses}") |
| | | private String adminAddresses; |
| | | |
| | | @Value("${xxl.job.executor.appname}") |
| | | private String appName; |
| | | |
| | | @Value("${xxl.job.executor.ip}") |
| | | private String ip; |
| | | |
| | | @Value("${xxl.job.executor.port}") |
| | | private int port; |
| | | |
| | | @Value("${xxl.job.accessToken}") |
| | | private String accessToken; |
| | | |
| | | @Value("${xxl.job.executor.logpath}") |
| | | private String logPath; |
| | | |
| | | @Value("${xxl.job.executor.logretentiondays}") |
| | | private int logRetentionDays; |
| | | |
| | | |
| | | @Bean(initMethod = "start", destroyMethod = "destroy") |
| | | public XxlJobSpringExecutor xxlJobExecutor() { |
| | | log.info(">>>>>>>>>>> xxl-job config init."); |
| | | XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); |
| | | xxlJobSpringExecutor.setAdminAddresses(adminAddresses); |
| | | xxlJobSpringExecutor.setAppName(appName); |
| | | xxlJobSpringExecutor.setIp(ip); |
| | | xxlJobSpringExecutor.setPort(port); |
| | | xxlJobSpringExecutor.setAccessToken(accessToken); |
| | | xxlJobSpringExecutor.setLogPath(logPath); |
| | | xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); |
| | | return xxlJobSpringExecutor; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.app.controller; |
| | | |
| | | import com.ks.push.exception.BPushTaskException; |
| | | import com.yeshi.makemoney.app.entity.SystemEnum; |
| | | import com.yeshi.makemoney.app.service.manager.PushManager; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | |
| | | @Controller |
| | | @RequestMapping("test") |
| | | public class TestController { |
| | | Logger logger = LoggerFactory.getLogger(TestController.class); |
| | | |
| | | |
| | | @Resource |
| | | private PushManager pushManager; |
| | | |
| | | @RequestMapping("push") |
| | | public void push(Long uid, PrintWriter out) { |
| | | try { |
| | | pushManager.pushGoldCornSettle(SystemEnum.svmm, uid, Math.abs(1000), new BigDecimal("22")); |
| | | out.print("success"); |
| | | } catch (BPushTaskException e) { |
| | | e.printStackTrace(out); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.yeshi.makemoney.app.vo.goldcorn.*; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | @Controller |
| | | @RequestMapping("api/v1/goldcorn") |
| | | public class GoldCornController { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(GoldCornController.class); |
| | | |
| | | @Resource |
| | | private GoldCornGetRecordService goldCornGetRecordService; |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } catch (GoldCornMakeException e) { |
| | | e.printStackTrace(); |
| | | finish=false; |
| | | } |
| | | } else { |
| | | finish = false; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("price", price.getCornNum()); |
| | | data.put("finish", finish); |
| | |
| | | package com.yeshi.makemoney.app.controller.client.api; |
| | | |
| | | import com.github.qcloudsms.SmsSingleSenderResult; |
| | | import com.yeshi.makemoney.app.entity.config.SystemConfigKey; |
| | | import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; |
| | | import com.yeshi.makemoney.app.service.manager.VerifyCodeManager; |
| | |
| | | String msg = systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.tencentVerifySMSTemplate); |
| | | String appId = systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.tencentSMSAppId); |
| | | String appKey = systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.tencentSMSAppKey); |
| | | // SmsSingleSenderResult result= |
| | | // TencentSMSUtil.sendSingleMsg(Integer.parseInt(appId), appKey, phone, msg.replace("{验证码}", code)); |
| | | SmsSingleSenderResult result = |
| | | TencentSMSUtil.sendSingleMsg(Integer.parseInt(appId), appKey, phone, msg.replace("{验证码}", code)); |
| | | verifyCodeManager.sendSMSSuccess(acceptData.getSystem(), phone, code); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } else { |
| | |
| | | } |
| | | |
| | | |
| | | private Criteria getCriteria(DaoQuery daoQuery) { |
| | | public Criteria getCriteria(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.uid != null) { |
| | | andList.add(Criteria.where("uid").is(daoQuery.uid)); |
| | | } |
| | | |
| | | |
| | | if (daoQuery.uidList != null && daoQuery.uidList.size() > 0) { |
| | | Criteria[] ors = new Criteria[daoQuery.uidList.size()]; |
| | | for (int i = 0; i < ors.length; i++) { |
| | | ors[i] = Criteria.where("uid").is(daoQuery.uidList.get(i)); |
| | | } |
| | | andList.add(new Criteria().orOperator(ors)); |
| | | } |
| | | |
| | | if (daoQuery.day != null) { |
| | | andList.add(Criteria.where("day").is(daoQuery.day)); |
| | | } |
| | |
| | | return new Criteria(); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | public Query getQuery(DaoQuery daoQuery) { |
| | | Query query = new Query(); |
| | | query.addCriteria(getCriteria(daoQuery)); |
| | | return query; |
| | |
| | | |
| | | public static class DaoQuery { |
| | | public Long uid; |
| | | public List<Long> uidList; |
| | | public String day; |
| | | public List<String> dayList; |
| | | |
| | | public Long fromUid; |
| | | public String fromId; |
| | | public GoldCornGetType type; |
| | |
| | | * @date 2022/4/2 14:10 |
| | | */ |
| | | public enum AppJumpType { |
| | | //消息 |
| | | msg, |
| | | //邀请 |
| | | invite, |
| | | //短视频 |
| | |
| | | testAccount(SystemConfigType.system, "测试账号"), |
| | | appLink(SystemConfigType.system, "应用二合一链接"), |
| | | androidPushAppCode(SystemConfigType.system, "android推送应用编码"), |
| | | androidPushActivity(SystemConfigType.system, "android推送落地页Activity"), |
| | | |
| | | //返回给前端的数据 |
| | | kefu(SystemConfigType.common, "客服链接"), |
| | |
| | | splashAd(SystemConfigType.ad, "开屏广告"), |
| | | rewardAd(SystemConfigType.ad, "激励视频广告"), |
| | | exitAppAd(SystemConfigType.ad, "退出应用广告"), |
| | | |
| | | |
| | | //资金相关配置 |
| | | extractConfig(SystemConfigType.extract, "提现配置"), |
| | |
| | | /** |
| | | * @author hxh |
| | | * @title: UserMsgType |
| | | * @description: TODO |
| | | * @description: 用户消息类型 |
| | | * @date 2022/4/7 15:19 |
| | | */ |
| | | public enum UserMsgType { |
| | | |
| | | goldcornexchange("金币折算",""), extract("余额提现",""), system("系统消息",""); |
| | | goldcornexchange("金币折算","http://img.mm.yeshitv.com/imgs/msg/icon_msg_goldcorn_exchange.png"), extract("余额提现","http://img.mm.yeshitv.com/imgs/msg/icon_msg_extract.png"), system("系统消息","http://img.mm.yeshitv.com/imgs/msg/icon_msg_system.png"); |
| | | |
| | | private String name; |
| | | private String icon; |
| | |
| | | |
| | | public class GoldCornMakeException extends BaseException { |
| | | |
| | | //获取频率受限 |
| | | public final static int CODE_GET_FREQUENCY_LIMIT = 101; |
| | | //获取频率受限(时间频率) |
| | | public final static int CODE_GET_FREQUENCY_TIME_LIMIT = 101; |
| | | |
| | | public final static int CODE_GET_FREQUENCY_COUNT_LIMIT = 102; |
| | | |
| | | //添加记录出错 |
| | | public final static int CODE_ADD_RECORD_ERROR = 201; |
New file |
| | |
| | | package com.yeshi.makemoney.app.job; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.yeshi.makemoney.app.entity.SystemEnum; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService; |
| | | import com.yeshi.makemoney.app.service.manager.PushManager; |
| | | import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: PushJob |
| | | * @description: 推送任务 |
| | | * @date 2022/5/7 17:44 |
| | | */ |
| | | @Component |
| | | public class PushJob { |
| | | |
| | | @Resource |
| | | private PushManager pushManager; |
| | | |
| | | @Resource |
| | | private GoldCornGetRecordService goldCornGetRecordService; |
| | | |
| | | |
| | | /** |
| | | * @return com.xxl.job.core.biz.model.ReturnT<java.lang.String> |
| | | * @author hxh |
| | | * @description 推送签到 |
| | | * @date 18:18 2022/5/7 |
| | | * @param: param |
| | | **/ |
| | | @XxlJob("pushSignIn") |
| | | public ReturnT<String> pushSignIn(String param) throws Exception { |
| | | SystemEnum system = SystemEnum.valueOf(param); |
| | | //从近30日活跃用户中寻找今日还未签到的活跃用户 |
| | | Date now = new Date(); |
| | | int page = 1; |
| | | int PAGE_SIZE = 500; |
| | | List<Long> uidList; |
| | | |
| | | do { |
| | | uidList = goldCornGetRecordService.listUids(new Date(now.getTime() - 1000 * 60 * 60 * 24L * 30), now, page, PAGE_SIZE); |
| | | page++; |
| | | if (uidList != null && uidList.size() > 0) { |
| | | //查询是否签到 |
| | | Map<Long, Boolean> map = goldCornGetRecordService.isSignIned(uidList, GoldCornUtil.getFormatDay(now)); |
| | | List<Long> pushUids = new ArrayList<>(); |
| | | for (Long uid : map.keySet()) { |
| | | if (!map.get(uid)) { |
| | | pushUids.add(uid); |
| | | } |
| | | } |
| | | try { |
| | | pushManager.pushSignIn(system, pushUids); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | } while (uidList != null && uidList.size() > 0); |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class GoldCornGetRecordServiceImpl implements GoldCornGetRecordService { |
| | |
| | | return goldCornGetRecordDao.sumEventCount(createDaoQuery(goldCornGetRecordQuery)); |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> listUids(Date minCreateTime, Date maxCreateTime, int page, int pageSize) { |
| | | List<AggregationOperation> list = new ArrayList<>(); |
| | | list.add(Aggregation.match(Criteria.where("createTime").gte(minCreateTime).lt(maxCreateTime))); |
| | | list.add(Aggregation.group("uid")); |
| | | list.add(Aggregation.sort(Sort.Direction.DESC,"_id")); |
| | | list.add(Aggregation.skip(Long.parseLong((page - 1) * pageSize + ""))); |
| | | list.add(Aggregation.limit(pageSize)); |
| | | AggregationResults<Map<String, Object>> results = goldCornGetRecordDao.aggregate(list, Map.class); |
| | | List<Map<String, Object>> resultList = results.getMappedResults(); |
| | | List<Long> uidList = new ArrayList<>(); |
| | | for (Map<String, Object> result : resultList) { |
| | | Long uid = Long.parseLong(result.get("_id") + ""); |
| | | uidList.add(uid); |
| | | } |
| | | return uidList; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Long, Boolean> isSignIned(List<Long> uidList, String day) { |
| | | DaoQuery daoQuery = new DaoQuery(); |
| | | daoQuery.type = GoldCornGetType.signIn; |
| | | daoQuery.day = day; |
| | | daoQuery.uidList = uidList; |
| | | |
| | | List<AggregationOperation> list = new ArrayList<>(); |
| | | list.add(Aggregation.match(goldCornGetRecordDao.getCriteria(daoQuery))); |
| | | list.add(Aggregation.group("uid")); |
| | | |
| | | |
| | | AggregationResults<Map<String, Object>> results = goldCornGetRecordDao.aggregate(list, Map.class); |
| | | List<Map<String, Object>> resultList = results.getMappedResults(); |
| | | Set<Long> signInedList = new HashSet<>(); |
| | | for (Map<String, Object> result : resultList) { |
| | | Long uid = Long.parseLong(result.get("_id") + ""); |
| | | signInedList.add(uid); |
| | | } |
| | | |
| | | return uidList.stream().collect(Collectors.toMap(uid -> uid, uid -> signInedList.contains(uid))); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | //间隔判断 |
| | | if (config.getMinSpaceTime() != null) { |
| | | List<GoldCornGetRecord> list = goldCornGetRecordService.list(query, 1, 1); |
| | | if (list != null && list.size() > 0 && System.currentTimeMillis() - list.get(0).getCreateTime().getTime() < config.getMinSpaceTime() * 1000L) { |
| | | if (list != null && list.size() > 0 && time.getTime() - list.get(0).getCreateTime().getTime() < config.getMinSpaceTime() * 1000L) { |
| | | String msg = String.format("需要间隔%s秒以上", config.getMinSpaceTime()); |
| | | throw new GoldCornMakeException(GoldCornMakeException.CODE_GET_FREQUENCY_LIMIT, msg); |
| | | throw new GoldCornMakeException(GoldCornMakeException.CODE_GET_FREQUENCY_TIME_LIMIT, msg); |
| | | } |
| | | } |
| | | |
| | |
| | | Map<GoldCornGetType, Long> countMap = goldCornGetRecordService.sumEventCount(query); |
| | | if (countMap.get(type) != null && (countMap.get(type) >= config.getLimitCount())) { |
| | | String msg = String.format("超出%s次/%s的限制", config.getLimitCount(), config.getTimeUnit().getName()); |
| | | throw new GoldCornMakeException(GoldCornMakeException.CODE_GET_FREQUENCY_LIMIT, msg); |
| | | throw new GoldCornMakeException(GoldCornMakeException.CODE_GET_FREQUENCY_COUNT_LIMIT, msg); |
| | | } |
| | | return config.getLimitCount() - (countMap.get(type) != null ? countMap.get(type) : 0); |
| | | } |
| | |
| | | package com.yeshi.makemoney.app.service.impl.goldcorn; |
| | | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.push.exception.BPushTaskException; |
| | | import com.yeshi.makemoney.app.dto.mq.GoldCornSettleMQMsg; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeRecord; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeType; |
| | |
| | | import com.yeshi.makemoney.app.service.inter.money.UserMoneyService; |
| | | import com.yeshi.makemoney.app.service.inter.msg.UserMsgNotifyService; |
| | | import com.yeshi.makemoney.app.service.inter.user.UserInfoService; |
| | | import com.yeshi.makemoney.app.service.manager.PushManager; |
| | | import com.yeshi.makemoney.app.utils.factory.UserMoneyRecordFactory; |
| | | import com.yeshi.makemoney.app.utils.factory.goldcorn.GoldCornConsumeRecordFactory; |
| | | import com.yeshi.makemoney.app.utils.factory.msg.UserMsgFactory; |
| | |
| | | import com.yeshi.makemoney.app.utils.mq.CMQManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.ThreadUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | @Resource |
| | | private UserMsgNotifyService userMsgNotifyService; |
| | | |
| | | @Resource |
| | | private PushManager pushManager; |
| | | |
| | | @Override |
| | | public void startSettle(Date date) { |
| | | String day = GoldCornUtil.getFormatDay(date); |
| | |
| | | throw new UserMoneyRecordException(e.getCode(), e.getMsg()); |
| | | } |
| | | goldCornConsumeRecordService.add(record); |
| | | //添加消息通知 |
| | | try { |
| | | userMsgNotifyService.notify(UserMsgFactory.createGoldCornExchange(record, userMoneyService.getBalance(uid))); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //消息通知不需要在主线程 |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | userMsgNotifyService.notify(UserMsgFactory.createGoldCornExchange(record, userMoneyService.getBalance(uid))); |
| | | //添加站外推送 |
| | | UserInfo user = userInfoService.get(uid); |
| | | if (user == null) { |
| | | return; |
| | | } |
| | | pushManager.pushGoldCornSettle(user.getSystem(), record.getUid(), Math.abs(record.getCornNum()), record.getMoney()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | //保存 |
| | | userMsgDao.save(userMsg); |
| | | |
| | | //添加消息数量 |
| | | userExtraInfoService.addUnReadMsgCount(userMsg.getUid(), 1); |
| | | } |
| | | |
| | | @Override |
| | |
| | | //保存 |
| | | userInfoMapper.insertSelective(userInfo); |
| | | |
| | | //添加验证码 |
| | | //添加邀请码 |
| | | userExtraInfoService.setInviteCode(userInfo.getId(), InviteCodeUtil.createInviteCode(userInfo.getId())); |
| | | } |
| | | |
| | |
| | | package com.yeshi.makemoney.app.service.inter.goldcorn; |
| | | |
| | | import com.yeshi.makemoney.app.entity.SystemEnum; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetRecord; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType; |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetRecordException; |
| | |
| | | |
| | | |
| | | /** |
| | | * @return java.util.Map<java.lang.Long , java.math.BigDecimal> |
| | | * @return java.util.Map<java.lang.Long , java.math.BigDecimal> |
| | | * @author hxh |
| | | * @description 统计FromUid产生的金币数量 |
| | | * @date 15:36 2022/4/8 |
| | |
| | | * @date 10:32 2022/4/28 |
| | | * @param: goldCornGetRecordQuery |
| | | **/ |
| | | public Map<GoldCornGetType,Long> sumEventCount(GoldCornGetRecordQuery goldCornGetRecordQuery); |
| | | public Map<GoldCornGetType, Long> sumEventCount(GoldCornGetRecordQuery goldCornGetRecordQuery); |
| | | |
| | | |
| | | /** |
| | | * @return java.util.List<java.lang.Long> |
| | | * @author hxh |
| | | * @description 获取活跃用户列表 |
| | | * @date 18:33 2022/5/7 |
| | | * @param: minCreateTime 最小的活跃时间 |
| | | * @param: maxCreateTime 最大的活跃时间 |
| | | * @param: page |
| | | * @param: pageSize |
| | | **/ |
| | | public List<Long> listUids(Date minCreateTime, Date maxCreateTime, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * @return java.util.List<java.util.Map < java.lang.Long , java.lang.Boolean>> |
| | | * @author hxh |
| | | * @description 批量查询用户是否签到 |
| | | * @date 18:42 2022/5/7 |
| | | * @param: uidList |
| | | * @param: day |
| | | **/ |
| | | public Map<Long, Boolean> isSignIned(List<Long> uidList, String day); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public class Constant { |
| | | |
| | | //是否需要验证验证码 |
| | | public final static boolean VERIFY_VCODE = false; |
| | | public final static boolean VERIFY_VCODE = true; |
| | | |
| | | |
| | | public static AlipayConfig alipayConfig; |
| | |
| | | record.setMoney(rate.multiply(new BigDecimal(record.getCornNum())).setScale(2, RoundingMode.FLOOR)); |
| | | record.setType(GoldCornConsumeType.changeMoney); |
| | | record.setId(uid + "-" + record.getType().name() + "-" + day); |
| | | //积分兑换少于1分的按照1分计算 |
| | | if (record.getMoney().compareTo(new BigDecimal(0)) == 0 && cornNum > 0) { |
| | | record.setMoney(new BigDecimal("0.01")); |
| | | } |
| | | return record; |
| | | } |
| | | |
| | |
| | | spring: |
| | | profiles: |
| | | active: dev |
| | | active: pro |
| | |
| | | <if test="query.email!=null"> |
| | | and email = #{query.email} |
| | | </if> |
| | | |
| | | <if test="query.maxCreateTime!=null"> |
| | | and create_time <![CDATA[<]]> #{query.maxCreateTime} |
| | | </if> |
| | |
| | | </if> |
| | | |
| | | <if test="query.status!=null"> |
| | | and status >= #{query.status} |
| | | and status = #{query.status} |
| | | </if> |
| | | </sql> |
| | | |
| | |
| | | package test.msg; |
| | | |
| | | import com.yeshi.makemoney.app.Application; |
| | | import com.yeshi.makemoney.app.entity.SystemEnum; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetRecord; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType; |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetFrequencyConfigException; |
| | |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetRecordException; |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornMakeException; |
| | | import com.yeshi.makemoney.app.exception.user.UserInfoException; |
| | | import com.yeshi.makemoney.app.job.PushJob; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornMakeService; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornSettleService; |
| | |
| | | userMsgNotifyService.notify(UserMsgFactory.createExtractFail(22392L, new BigDecimal(10), "这是测试备注,测试备注,测试备注")); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private PushJob pushJob; |
| | | |
| | | @Test |
| | | public void push() throws Exception { |
| | | pushJob.pushSignIn(SystemEnum.svmm.name()); |
| | | } |
| | | |
| | | } |