yujian
2019-12-19 626d711cb15896055c13fe344eb7fcc824589715
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
@@ -328,7 +328,6 @@
         LogHelper.userInfo("uid=" + user.getId() + ",提交转账申请!");
      } else {// 暂时不自动提现
         // transfer(extract, null);
         ;
      }
      return null;
   }
@@ -1087,6 +1086,112 @@
      }
      return listOpendIDs;
   }
   @Override
   public List<UserInfo> preAutoUserTo1212() 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);
      // 余额最低限制
      List<UserInfo> list = new ArrayList<UserInfo>();
      while (true) {
         // 查询满足条件 1、2 的uid
         List<UserInfo> listUser = userInfoService.getAutoExtractUserTo1212(page * pageSize, pageSize);
         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> getAutoExtractOpenIdsTo1212() throws Exception {
      int page = 0;
      int pageSize = 100;
      int maxSize = 301; // appId + 实际openid300个
      Date nowDate = new Date();
      // 条件3:距离上一次成功领取微信红包已经超过了30天时间,可在第31天再次下发;
      String receivedDate = DateUtil.reduceDayTostring(30, nowDate);
      // 条件4:距离上一次未成功领取微信红包已经超过了15天时间,可在第16天再次下发;
      String refundDate = DateUtil.reduceDayTostring(15, nowDate);
      // 提现金额
      BigDecimal money = BigDecimal.valueOf(1);
      List<String> listOpendIDs = new ArrayList<String>();
      // 首行appID
      listOpendIDs.add(Constant.getWXAccount(null, null).getAppId());
      while (true) {
         // 查询满足条件 1、2 的uid
         List<UserInfo> listUser = userInfoService.getAutoExtractUserTo1212(page * pageSize, pageSize);
         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) {
            UserInfo userInfo = subHongBaoByUid(uid, money, money);
            if (userInfo != null) {
               listOpendIDs.add(userInfo.getWxOpenId());
               if (listOpendIDs.size() >= maxSize)
                  break;
            }
         }
         if (listOpendIDs.size() >= maxSize)
            break;
         page++;
      }
      return listOpendIDs;
   }
   @Transactional(rollbackFor = Exception.class)
   private UserInfo subHongBaoByUid(Long uid, BigDecimal money, BigDecimal minSurplus) {
@@ -1164,15 +1269,14 @@
      String billno = redPackRecord.getBillno();
      if (!StringUtil.isNullOrEmpty(billno)) {
         updeteRecord.setBillno(billno.replace("`", ""));
         updeteRecord.setBillno(billno.replace("`", "").replace("'", ""));
      }
      String detailno = redPackRecord.getDetailno();
      if (!StringUtil.isNullOrEmpty(detailno)) {
         updeteRecord.setDetailno(detailno.replace("`", ""));
         updeteRecord.setDetailno(detailno.replace("`", "").replace("'", ""));
      }
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
      String rcvTime = redPackRecord.getRcvTime();
      if (!StringUtil.isNullOrEmpty(rcvTime)) {
         try {