yujian
2019-05-14 ad9fbd2c18f280ef9bba47f28353d367cf2d94e8
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java
@@ -47,6 +47,7 @@
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.user.ExtractRecordService;
@@ -123,6 +124,9 @@
   @Resource
   private UserAccountBindingHistoryService userAccountBindingHistoryService;
   @Resource
   private UserMoneyDebtService userMoneyDebtService;
   @Transactional
   public Integer addExtract(Extract extract) {
@@ -237,7 +241,7 @@
            .getLatestHistory(extract.getUserInfo().getId(), UserAccountBindingHistory.TYPE_PHONE);
      // 手机号更换绑定的7天内不能提现
      if (history != null && !history.getFirst()
            && (System.currentTimeMillis() - history.getCreateTime().getTime()) > 1000 * 60 * 60 * 24 * 7L)
            && (System.currentTimeMillis() - history.getCreateTime().getTime()) < 1000 * 60 * 60 * 24 * 7L)
         return 111;
      final String autoExtract = configService.get("extract_way"); // 是否自动转账
@@ -250,10 +254,17 @@
         return 3;
      }
      // 有借贷关系
      boolean isHaveToReplay = userMoneyDebtService.isHaveDebtToRepay(extract.getUserInfo().getId());
      if (isHaveToReplay) {
         return 110;
      }
      Integer type = setExtractRecord(extract, maxCount, maxMoney);
      if (type != 0) {
         return type;
      }
      extractMapper.insertSelective(extract);
      ExtractAuditRecord auditRecord = new ExtractAuditRecord();
@@ -283,7 +294,8 @@
      if ("是".equals(autoExtract)) {
         LogHelper.userInfo("uid=" + user.getId() + ",提交转账申请!");
      } else {// 暂时不自动提现
         transfer(extract, null);
         // transfer(extract, null);
         ;
      }
      return null;
   }
@@ -366,15 +378,15 @@
            Constant.alipayConfig.getAppId(), privateKey, "json", "gbk", null, "RSA2");
      AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
      String uuid = UUID.randomUUID().toString().replace("-", "");
      String appName = systemConfigService.get("appName", extract.getSystem());
      String appName = Constant.systemCommonConfig.getProjectChineseName();
      JSONObject json = new JSONObject();
      json.put("out_biz_no", uuid);
      json.put("payee_type", "ALIPAY_LOGONID");
      json.put("payee_account", extract.getAccount());
      json.put("amount", extract.getMoney());
      json.put("payer_show_name", appName + "提现");
      json.put("payer_show_name", appName + "App" + "提现");
      json.put("payee_real_name", extract.getName());
      json.put("remark", "来自" + appName + "的提现");
      json.put("remark", "来自" + appName + "App" + "的提现");
      request.setBizContent(json.toString());
      AlipayFundTransToaccountTransferResponse response = null;
      try {
@@ -506,6 +518,10 @@
      Long count = hongBaoV2Mapper.countByUidAndState(uid, HongBao.STATE_YILINGQU);
      if (count == null || count == 0)
         throw new ExtractException(1, "没有已到账的红包");
      // 查询是否有欠账
      boolean isDebt = userMoneyDebtService.isHaveDebtToRepay(uid);
      if (isDebt)
         throw new ExtractException(3, "有欠账未还");
      // 获取所有收入所得
      BigDecimal hongBaoMoney = hongBaoV2Service.computeMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU);