From fe879975a3e8a0a1aa280fb839e02d159bfbcff8 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 27 八月 2019 18:04:38 +0800 Subject: [PATCH] 金币任务多次获取bug修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java | 116 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 66 insertions(+), 50 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java index 1a448a8..b538eb8 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java @@ -28,6 +28,7 @@ import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper; import com.yeshi.fanli.dto.HongBao; +import com.yeshi.fanli.dto.money.ExtractOrderStatisticDTO; import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo; import com.yeshi.fanli.entity.bus.user.Extract; import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord; @@ -47,19 +48,20 @@ 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.order.OrderUserStatisticService; import com.yeshi.fanli.service.inter.push.PushService; import com.yeshi.fanli.service.inter.user.ExtractRecordService; import com.yeshi.fanli.service.inter.user.ExtractService; import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserMoneyDetailService; -import com.yeshi.fanli.service.inter.user.UserNotificationService; +import com.yeshi.fanli.service.inter.user.UserMoneyService; 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; @@ -107,9 +109,6 @@ private PushService pushService; @Resource - private UserNotificationService userNotificationService; - - @Resource private UserMoneyDetailMapper userMoneyDetailMapper; @Resource @@ -123,6 +122,15 @@ @Resource private UserAccountBindingHistoryService userAccountBindingHistoryService; + + @Resource + private UserMoneyDebtService userMoneyDebtService; + + @Resource + private UserMoneyService userMoneyService; + + @Resource + private OrderUserStatisticService orderUserStatisticService; @Transactional public Integer addExtract(Extract extract) { @@ -165,8 +173,15 @@ UserInfo user = find.getUserInfo(); - userInfoMapper.addHongBaoByUid(user.getId(), find.getMoney()); + UserMoneyDetail userMoneyDetail = null; + try { + userMoneyDetail = UserMoneyDetailFactory.createExtractReject(find); + } catch (UserMoneyDetailException e1) { + e1.printStackTrace(); + } + // 澧炲姞璧勯噾 + userMoneyService.addUserMoney(user.getId(), find.getMoney(), userMoneyDetail); // 鏇存柊鍘熸潵鐨勭姸鎬� Extract updateExtract = new Extract(); updateExtract.setId(id); @@ -203,23 +218,6 @@ // 鏇存柊鎻愮幇璁板綍瀹℃牳琛� extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord); // 鏂扮増璧勯噾璇︽儏 - try { - UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractReject(find); - userMoneyDetailMapper.insert(userMoneyDetail); - } catch (UserMoneyDetailException e2) { - try { - LogHelper.errorDetailInfo(e2); - } catch (Exception e3) { - e3.printStackTrace(); - } - } - - try { - userNotificationService.extractWrong(user.getId(), find, - TimeUtil.getGernalTime(find.getExtractTime(), "yyyy-MM-dd HH:mm")); - } catch (Exception e) { - e.printStackTrace(); - } // 鏂扮増閫氱煡 userMoneyMsgNotificationService.extractFail(find, reason); @@ -250,24 +248,38 @@ 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(); auditRecord.setBeforeMoney(user.getMyHongBao()); auditRecord.setExtract(extract); + + Date minTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 180L); + // 缁熻鏁版嵁 + 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); - // 鍑忓幓璐︽埛璧勯噾 - userInfoMapper.subHongBaoByUid(extract.getUserInfo().getId(), extract.getMoney()); - // 鏂扮増璧勯噾璇︽儏 + UserMoneyDetail userMoneyDetail = null; try { - UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtract(extract); - userMoneyDetailMapper.insert(userMoneyDetail); + userMoneyDetail = UserMoneyDetailFactory.createExtract(extract); } catch (UserMoneyDetailException e2) { try { LogHelper.errorDetailInfo(e2); @@ -276,14 +288,17 @@ } } - userNotificationService.extractApply(extract.getUserInfo().getId()); + // 鍑忓幓璐︽埛璧勯噾 + userMoneyService.subUserMoney(extract.getUserInfo().getId(), extract.getMoney(), userMoneyDetail); + // 娣诲姞鏂扮増閫氱煡 userMoneyMsgNotificationService.extractApplay(extract); if ("鏄�".equals(autoExtract)) { LogHelper.userInfo("uid=" + user.getId() + ",鎻愪氦杞处鐢宠!"); } else {// 鏆傛椂涓嶈嚜鍔ㄦ彁鐜� - transfer(extract, null); + // transfer(extract, null); + ; } return null; } @@ -361,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"); @@ -379,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("鏀粯瀹濇彁鐜癈MQ寮傚父锛�" + new Gson().toJson(response) + ",鎻愮幇淇℃伅" + GsonUtil.toJson(extract)); + LogHelper.userErrorInfo("鎻愮幇:鏀粯瀹濇彁鐜癈MQ寮傚父锛�" + new Gson().toJson(response) + ",鎻愮幇淇℃伅" + GsonUtil.toJson(extract)); } } @@ -424,12 +442,10 @@ updateExtract.setReason(msg); extractMapper.updateByPrimaryKeySelective(updateExtract); - userInfoMapper.addHongBaoByUid(user.getId(), extract.getMoney()); - + UserMoneyDetail userMoneyDetail = null; // 鏂扮増璧勯噾璇︽儏 try { - UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractReject(extract); - userMoneyDetailMapper.insert(userMoneyDetail); + userMoneyDetail = UserMoneyDetailFactory.createExtractReject(extract); } catch (UserMoneyDetailException e2) { try { LogHelper.errorDetailInfo(e2); @@ -437,12 +453,10 @@ e1.printStackTrace(); } } + // 澧炲姞璧勯噾 + 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() + "]"); @@ -480,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) { @@ -503,9 +514,18 @@ @Transactional @Override public void checkExtract(Long uid) throws ExtractException { + BigDecimal compensateMoney = extractMapper.computeCompensateByUid(uid); + if (compensateMoney == null) + compensateMoney = new BigDecimal(0); + // 涓嶅垽瀹氬埌璐︾孩鍖呴棶棰� Long count = hongBaoV2Mapper.countByUidAndState(uid, HongBao.STATE_YILINGQU); - if (count == null || count == 0) + if ((count == null || count == 0) && compensateMoney.compareTo(new BigDecimal(0)) == 0) { throw new ExtractException(1, "娌℃湁宸插埌璐︾殑绾㈠寘"); + } + // 鏌ヨ鏄惁鏈夋瑺璐� + boolean isDebt = userMoneyDebtService.isHaveDebtToRepay(uid); + if (isDebt) + throw new ExtractException(3, "鏈夋瑺璐︽湭杩�"); // 鑾峰彇鎵�鏈夋敹鍏ユ墍寰� BigDecimal hongBaoMoney = hongBaoV2Service.computeMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU); @@ -530,10 +550,6 @@ weiqaunMoney = weiqaunMoney.abs(); BigDecimal balance = userInfoService.selectByPKey(uid).getMyHongBao(); - - BigDecimal compensateMoney = extractMapper.computeCompensateByUid(uid); - if (compensateMoney == null) - compensateMoney = new BigDecimal(0); BigDecimal after = hongBaoMoney.subtract(extractMoney.add(weiqaunMoney).add(balance).add(compensateMoney)); @@ -701,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); } } -- Gitblit v1.8.0