From 2922e51a7a8e657a8467c818ae16700e41ddac77 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 10 五月 2022 19:45:58 +0800 Subject: [PATCH] bug修复 --- app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java | 104 +++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 87 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java b/app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java index 1812f56..85f1812 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java +++ b/app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java @@ -18,12 +18,15 @@ import com.yeshi.makemoney.app.exception.money.UserMoneyBalanceException; import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; import com.yeshi.makemoney.app.service.inter.money.ExtractService; +import com.yeshi.makemoney.app.service.inter.money.UserExtractMoneyLimitService; import com.yeshi.makemoney.app.service.inter.money.UserMoneyRecordService; import com.yeshi.makemoney.app.service.inter.money.UserMoneyService; +import com.yeshi.makemoney.app.service.inter.msg.UserMsgNotifyService; import com.yeshi.makemoney.app.service.inter.user.UserInfoService; import com.yeshi.makemoney.app.service.query.money.ExtractQuery; import com.yeshi.makemoney.app.utils.Constant; import com.yeshi.makemoney.app.utils.factory.UserMoneyRecordFactory; +import com.yeshi.makemoney.app.utils.factory.msg.UserMsgFactory; import com.yeshi.makemoney.app.utils.mq.CMQManager; import com.yeshi.makemoney.app.utils.pay.AlipayUtil; import org.slf4j.Logger; @@ -64,10 +67,17 @@ @Resource private UserMoneyRecordService userMoneyRecordService; + @Resource + private UserExtractMoneyLimitService userExtractMoneyLimitService; + + @Resource + private UserMsgNotifyService userMsgNotifyService; + @Override public List<Extract> list(ExtractQuery extractQuery, int page, int pageSize) { DaoQuery daoQuery = new DaoQuery(); daoQuery.uid = extractQuery.getUid(); + daoQuery.state = extractQuery.getState(); daoQuery.minCreateTime = extractQuery.toStartTime(); daoQuery.maxCreateTime = extractQuery.toEndTime(); daoQuery.sortList = Arrays.asList(new String[]{"create_time desc"}); @@ -80,6 +90,7 @@ public long count(ExtractQuery extractQuery) { DaoQuery daoQuery = new DaoQuery(); daoQuery.uid = extractQuery.getUid(); + daoQuery.state = extractQuery.getState(); daoQuery.minCreateTime = extractQuery.toStartTime(); daoQuery.maxCreateTime = extractQuery.toEndTime(); return extractMapper.count(daoQuery); @@ -97,7 +108,8 @@ return extractMapper.count(daoQuery) < 1L; } - private ExtractConfig getExtractConfig(SystemEnum system) { + @Override + public ExtractConfig getExtractConfig(SystemEnum system) { String value = systemConfigService.getValueCache(system, SystemConfigKey.extractConfig); if (StringUtil.isNullOrEmpty(value)) { return null; @@ -111,15 +123,11 @@ throw new ExtractException(ExtractException.CODE_EXTRACT_CONFIG_ERROR, "鎻愮幇閰嶇疆閿欒"); } - if (isFirst(user.getId())) { - if (money.compareTo(config.getFirstMinMoney()) < 0) { - throw new ExtractException(ExtractException.CODE_MONEY_LIMIT, String.format("棣栨鎻愮幇鏈�浣庨噾棰濅负%s鍏�", config.getFirstMinMoney().toString())); - } - } else { - if (money.compareTo(config.getMinMoney()) < 0) { - throw new ExtractException(ExtractException.CODE_MONEY_LIMIT, String.format("鏈�浣庢彁鐜伴噾棰濅负%s鍏�", config.getMinMoney().toString())); - } + + if (money.compareTo(config.getMinMoney()) < 0) { + throw new ExtractException(ExtractException.CODE_MONEY_LIMIT, String.format("鏈�浣庢彁鐜伴噾棰濅负%s鍏�", config.getMinMoney().toString())); } + if (money.compareTo(config.getMaxMoney()) > 0) { throw new ExtractException(ExtractException.CODE_MONEY_LIMIT, String.format("鏈�楂樻彁鐜伴噾棰濅负%s鍏�", config.getMaxMoney().toString())); @@ -145,6 +153,44 @@ throw new ExtractException(ExtractException.CODE_MONEY_LIMIT, String.format("鍗曟棩绱鏈�楂樻彁鐜版鏁颁负%s娆�", config.getMaxNumPerDay().toString())); } + //灏忛噾棰濇彁鐜伴檺鍒� + if (money.compareTo(Constant.EXTRACT_LITTLE_MONEY_LIMIT) < 0) { + //鏄惁宸茬粡鐢ㄥ畬鏂扮敤鎴烽搴� + if (!canExtractLittleMoney(user.getId(), config.getNewerLittleMoneyNum(), new Date(currentTime))) { + throw new ExtractException(ExtractException.CODE_LITTLE_MONEY_LIMIT, "浠婃棩灏忎簬1鍏冩彁鐜版鏁板凡鐢ㄥ敖"); + } + } + + } + + @Override + public boolean canExtractLittleMoney(Long uid, int maxNewerCount, Date date) { + //鍒ゆ柇鏂颁汉 + long count = countByMaxMoney(uid, Constant.EXTRACT_LITTLE_MONEY_LIMIT, Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), null); + if (maxNewerCount > count) { + return true; + } + + //鍒ゆ柇婵�鍔卞垎閰� + int limit = userExtractMoneyLimitService.getLittleMoneyLimit(uid, date); + if (limit <= 0) { + return false; + } + count = countByMaxMoney(uid, Constant.EXTRACT_LITTLE_MONEY_LIMIT, Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyyMMdd"), "yyyyMMdd"))); + if (count < limit) { + return true; + } + return false; + } + + @Override + public BigDecimal getExtractingMoney(Long uid) { + DaoQuery daoQuery = new DaoQuery(); + daoQuery.uid = uid; + daoQuery.state = Extract.STATE_NOT_PROCESS; + BigDecimal money = extractMapper.sumMoney(daoQuery); + + return money == null ? new BigDecimal(0) : money; } @@ -191,7 +237,7 @@ @Transactional(rollbackFor = Exception.class) @Override - public void passExtract(Long id, Long adminId) throws ExtractException { + public void passExtract(Long id, String adminId) throws ExtractException { Extract extract = extractMapper.selectByPrimaryKeyForUpdate(id); if (extract == null) { throw new ExtractException(ExtractException.CODE_NOT_EXIST, "鎻愮幇璁板綍涓嶅瓨鍦�"); @@ -223,7 +269,7 @@ @Transactional(rollbackFor = Exception.class) @Override - public void rejectExtract(Long id, Long adminId, String reason) throws ExtractException, UserMoneyBalanceException, ParamsException { + public void rejectExtract(Long id, String adminId, String reason) throws ExtractException, UserMoneyBalanceException, ParamsException { Extract extract = extractMapper.selectByPrimaryKeyForUpdate(id); if (extract == null) { throw new ExtractException(ExtractException.CODE_NOT_EXIST, "鎻愮幇璁板綍涓嶅瓨鍦�"); @@ -242,7 +288,12 @@ updateExtract.setState(Extract.STATE_REJECT); updateExtract.setReason(reason); extractMapper.updateByPrimaryKeySelective(updateExtract); - //TODO 娑堟伅 + //娣诲姞娑堟伅閫氱煡 + try { + userMsgNotifyService.notify(UserMsgFactory.createExtractFail(extract.getUser().getId(), extract.getMoney(), reason)); + } catch (Exception e) { + e.printStackTrace(); + } } @Override @@ -281,13 +332,23 @@ } } + @Override + public long countByMaxMoney(Long uid, BigDecimal money, List<Integer> stateList, Date minCreateTime) { + DaoQuery daoQuery = new DaoQuery(); + daoQuery.uid = uid; + daoQuery.maxMoney = money; + daoQuery.stateList = stateList; + daoQuery.minCreateTime = minCreateTime; + return extractMapper.count(daoQuery); + } + /** * 鎻愮幇鍒版敮浠樺疂 * * @param extract * @param adminId */ - private void transferByAlipay(Extract extract, Long adminId) { + private void transferByAlipay(Extract extract, String adminId) { //鑾峰彇鐢ㄦ埛鐨勭郴缁� UserInfo user = userInfoService.get(extract.getUser().getId()); String appName = user.getSystem().getName(); @@ -311,7 +372,7 @@ } } - private void transferByWX(Extract extract, Long adminId, String wxAPPId) { + private void transferByWX(Extract extract, String adminId, String wxAPPId) { //鑾峰彇鐢ㄦ埛鐨勭郴缁� UserInfo user = userInfoService.get(extract.getUser().getId()); String appName = user.getSystem().getName(); @@ -358,7 +419,12 @@ userMoneyRecordService.update(update); } } - // TODO 閫氱煡杞处鎴愬姛 + //娣诲姞娑堟伅閫氱煡 + try { + userMsgNotifyService.notify(UserMsgFactory.createExtractSuccess(extract.getUser().getId(), extract.getMoney())); + } catch (Exception e) { + e.printStackTrace(); + } } @@ -386,8 +452,12 @@ } catch (Exception e) { e.printStackTrace(); } - // 鏂扮増鎻愮幇 - //TODO 閫氱煡杞处琚嫆缁� + //娣诲姞娑堟伅閫氱煡 + try { + userMsgNotifyService.notify(UserMsgFactory.createExtractFail(extract.getUser().getId(), extract.getMoney(), null)); + } catch (Exception e) { + e.printStackTrace(); + } } } -- Gitblit v1.8.0