yujian
2019-08-27 d8359ddb48dab5cc797a9d552e11fde571f4920c
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java
@@ -58,12 +58,10 @@
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
import com.yeshi.fanli.service.inter.user.UserMoneyService;
import com.yeshi.fanli.service.inter.user.UserNotificationService;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.GsonUtil;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import net.sf.json.JSONObject;
@@ -109,9 +107,6 @@
   @Resource
   private PushService pushService;
   @Resource
   private UserNotificationService userNotificationService;
   @Resource
   private UserMoneyDetailMapper userMoneyDetailMapper;
@@ -224,13 +219,6 @@
      extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord);
      // 新版资金详情
      try {
         userNotificationService.extractWrong(user.getId(), find,
               TimeUtil.getGernalTime(find.getExtractTime(), "yyyy-MM-dd HH:mm"));
      } catch (Exception e) {
         e.printStackTrace();
      }
      // 新版通知
      userMoneyMsgNotificationService.extractFail(find, reason);
   }
@@ -277,13 +265,15 @@
      auditRecord.setBeforeMoney(user.getMyHongBao());
      auditRecord.setExtract(extract);
      Date minTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 180L);
      // 统计数据
      int orderCount50More = orderUserStatisticService.countHongBaoOrderCount50MoreByUid(user.getId());
      BigDecimal weiQuanOrderFanAmount = orderUserStatisticService.sumWeiQuanOrderFanAmountByUid(user.getId());
      int weiQuanOrderCount = orderUserStatisticService.countWeiQuanOrderByUid(user.getId());
      int safeOrderCount = orderUserStatisticService.countSafeOrderByUid(user.getId());
      auditRecord.setExtraInfoStr(new Gson().toJson(new ExtractOrderStatisticDTO(orderCount50More, weiQuanOrderCount,
            weiQuanOrderFanAmount, safeOrderCount)));
      int orderCount50More = orderUserStatisticService.countOrderCount100MoreByUidAndMinTime(user.getId(), minTime);
      BigDecimal weiQuanOrderFanAmount = orderUserStatisticService.sumWeiQuanOrderFanAmountByUid(user.getId(),
            minTime);
      int weiQuanOrderCount = orderUserStatisticService.countWeiQuanOrderByUid(user.getId(), minTime);
      auditRecord.setExtraInfoStr(new Gson()
            .toJson(new ExtractOrderStatisticDTO(orderCount50More, weiQuanOrderCount, weiQuanOrderFanAmount, 0)));
      extractAuditRecordMapper.insertSelective(auditRecord);
      // 新版资金详情
@@ -301,7 +291,6 @@
      // 减去账户资金
      userMoneyService.subUserMoney(extract.getUserInfo().getId(), extract.getMoney(), userMoneyDetail);
      userNotificationService.extractApply(extract.getUserInfo().getId());
      // 添加新版通知
      userMoneyMsgNotificationService.extractApplay(extract);
@@ -387,6 +376,7 @@
    */
   @Transactional
   private void extractByZhiFuBao(Extract extract, AdminUser adminUser) {
      LogHelper.userErrorInfo("提现:开始通过提现-"+extract.getId());
      String privateKey = Constant.alipayConfig.getPrivateKey();
      AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
            Constant.alipayConfig.getAppId(), privateKey, "json", "gbk", null, "RSA2");
@@ -405,15 +395,17 @@
      AlipayFundTransToaccountTransferResponse response = null;
      try {
         response = alipayClient.execute(request);
         LogHelper.userErrorInfo("提现:支付宝通过提现成功-"+extract.getId());
      } catch (AlipayApiException e) {
         e.printStackTrace();
         LogHelper.userErrorInfo("支付宝提现异常:" + response + ",提现信息" + GsonUtil.toJson(extract));
         LogHelper.userErrorInfo("提现:支付宝提现异常:" + response + ",提现信息" + GsonUtil.toJson(extract));
      }
      try {
         CMQManager.getInstance().addExtractResultMsg(extract, response, adminUser);
         LogHelper.userErrorInfo("提现:添加处理队列成功-"+extract.getId());
      } catch (Exception e) {
         LogHelper.userErrorInfo("支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
         LogHelper.userErrorInfo("提现:支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
      }
   }
@@ -465,10 +457,6 @@
         userMoneyService.addUserMoney(user.getId(), extract.getMoney(), userMoneyDetail);
         try {
            userNotificationService.extractTransferFail(user.getId(),
                  TimeUtil.getGernalTime(extract.getExtractTime(), "yyyy-MM-dd HH:mm"));
            LogHelper.userInfo("支付宝转账失败:[提现IP:" + extract.getIp() + ",所转账号:" + extract.getAccount() + ",真实姓名:"
                  + extract.getName() + ",所转金额:" + extract.getMoney() + ",失败原因" + extract.getReason() + "]");
@@ -506,9 +494,6 @@
      extractMapper.updateByPrimaryKeySelective(updateExtract);
      try {
         userNotificationService.extractSuccess(extract.getUserInfo().getId(), extract,
               TimeUtil.getGernalTime(extract.getExtractTime(), "yyyy-MM-dd HH:mm"));
         LogHelper.userInfo("支付宝转账成功:[提现IP:" + extract.getIp() + ",所转账号:" + extract.getAccount() + ",真实姓名:"
               + extract.getName() + ",所转金额:" + extract.getMoney() + "]");
      } catch (Exception e) {
@@ -732,7 +717,7 @@
   }
   @Override
   public double countTodayMoney(Long uid) {
      return extractMapper.countTodayMoney(uid);
   public BigDecimal sumTodayApplyMoney(Long uid,String day) {
      return extractMapper.sumToadyApplyByUid(uid,day);
   }
}