| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Override
|
| | | public List<UserInfo> preAutoUser() throws Exception {
|
| | | int page = 0;
|
| | | int pageSize = 100;
|
| | | int maxSize = 300;
|
| | | Date nowDate = new Date();
|
| | | // 条件3:距离上一次成功领取微信红包已经超过了30天时间,可在第31天再次下发;
|
| | | String receivedDate = DateUtil.reduceDayTostring(30, nowDate);
|
| | | // 条件4:距离上一次未成功领取微信红包已经超过了15天时间,可在第16天再次下发;
|
| | | String refundDate = DateUtil.reduceDayTostring(15, nowDate);
|
| | | |
| | | // 余额最低限制
|
| | | BigDecimal minSurplus = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MIN_SURPLUS);
|
| | | |
| | | List<UserInfo> list = new ArrayList<UserInfo>();
|
| | | |
| | | while (true) {
|
| | | // 查询满足条件 1、2 的uid
|
| | | List<UserInfo> listUser = userInfoService.getAutoExtractUserIds(page * pageSize, pageSize, minSurplus);
|
| | | if (listUser == null || listUser.isEmpty())
|
| | | break;
|
| | | |
| | | List<Long> listId = new ArrayList<Long>();
|
| | | for (UserInfo userInfo: listUser) {
|
| | | listId.add(userInfo.getId());
|
| | | }
|
| | | |
| | | // 查询记录是否满足
|
| | | List<Long> listValid = extractWeiXinRecordService.getValidUsers(listId, receivedDate, refundDate);
|
| | | if (listValid == null || listValid.isEmpty()) {
|
| | | page ++;
|
| | | continue;
|
| | | }
|
| | | |
| | | for (Long uid: listValid) {
|
| | | if (list.size() >= maxSize)
|
| | | break;
|
| | | for (UserInfo userInfo: listUser) {
|
| | | if (list.size() >= maxSize)
|
| | | break;
|
| | | |
| | | if (userInfo.getId().longValue() == uid.longValue()) {
|
| | | list.add(userInfo);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (list.size() >= maxSize)
|
| | | break;
|
| | | |
| | | page ++;
|
| | | }
|
| | | return list;
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public List<String> getAutoExtractOpenIds() throws Exception {
|
| | | int page = 0;
|
| | | int pageSize = 100;
|
| | | int maxSize = 300;
|
| | | int maxSize = 301; // appId + 实际openid300个
|
| | | Date nowDate = new Date();
|
| | | // 条件3:距离上一次成功领取微信红包已经超过了30天时间,可在第31天再次下发;
|
| | | String receivedDate = DateUtil.reduceDayTostring(30, nowDate);
|
| | |
| | |
|
| | | while (true) {
|
| | | // 查询满足条件 1、2 的uid
|
| | | List<Long> listId = userInfoService.getAutoExtractUserIds(page * pageSize, pageSize, minSurplus);
|
| | | if (listId == null || listId.isEmpty())
|
| | | List<UserInfo> listUser = userInfoService.getAutoExtractUserIds(page * pageSize, pageSize, minSurplus);
|
| | | if (listUser == null || listUser.isEmpty())
|
| | | break;
|
| | | |
| | | List<Long> listId = new ArrayList<Long>();
|
| | | for (UserInfo userInfo: listUser) {
|
| | | listId.add(userInfo.getId());
|
| | | }
|
| | |
|
| | | // 查询记录是否满足
|
| | | List<Long> listValid = extractWeiXinRecordService.getValidUsers(listId, receivedDate, refundDate);
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private UserInfo subHongBaoByUid(Long uid, BigDecimal money, BigDecimal minSurplus) {
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo != null && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
|
| | | if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getWxOpenId())
|
| | | && !StringUtil.isNullOrEmpty(userInfo.getWxUnionId()) && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
|
| | | // 微信提现记录
|
| | | ExtractWeiXinRecord extractRecord = new ExtractWeiXinRecord();
|
| | | extractRecord.setUid(uid);
|