From 15bedcc619b1edb6eb987f9288db7670e5b38c46 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 07 五月 2022 19:42:23 +0800
Subject: [PATCH] bug修复

---
 app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 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 ba60441..c72e872 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
@@ -21,10 +21,12 @@
 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;
@@ -68,6 +70,9 @@
     @Resource
     private UserExtractMoneyLimitService userExtractMoneyLimitService;
 
+    @Resource
+    private UserMsgNotifyService userMsgNotifyService;
+
     @Override
     public List<Extract> list(ExtractQuery extractQuery, int page, int pageSize) {
         DaoQuery daoQuery = new DaoQuery();
@@ -101,7 +106,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;
@@ -146,7 +152,7 @@
         }
 
         //灏忛噾棰濇彁鐜伴檺鍒�
-        if (money.compareTo(new BigDecimal(1)) < 0) {
+        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鍏冩彁鐜版鏁板凡鐢ㄥ敖");
@@ -158,7 +164,7 @@
     @Override
     public boolean canExtractLittleMoney(Long uid, int maxNewerCount, Date date) {
         //鍒ゆ柇鏂颁汉
-        long count = countByMaxMoney(uid, new BigDecimal(1), Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), null);
+        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;
         }
@@ -168,11 +174,21 @@
         if (limit <= 0) {
             return false;
         }
-        count = countByMaxMoney(uid, new BigDecimal(1), Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyyMMdd"), "yyyyMMdd")));
+        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;
     }
 
 
@@ -270,7 +286,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
@@ -396,7 +417,12 @@
                 userMoneyRecordService.update(update);
             }
         }
-        // TODO 閫氱煡杞处鎴愬姛
+        //娣诲姞娑堟伅閫氱煡
+        try {
+            userMsgNotifyService.notify(UserMsgFactory.createExtractSuccess(extract.getUser().getId(), extract.getMoney()));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
 
@@ -424,8 +450,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