From ce3420676d9ccf4a2bdf87aeb7ad1494b5e5d26c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 09 四月 2022 14:42:26 +0800
Subject: [PATCH] 图片上传与邀请图完善

---
 app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 46 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 1812f56..ba60441 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,6 +18,7 @@
 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.user.UserInfoService;
@@ -63,6 +64,9 @@
 
     @Resource
     private UserMoneyRecordService userMoneyRecordService;
+
+    @Resource
+    private UserExtractMoneyLimitService userExtractMoneyLimitService;
 
     @Override
     public List<Extract> list(ExtractQuery extractQuery, int page, int pageSize) {
@@ -111,15 +115,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 +145,34 @@
             throw new ExtractException(ExtractException.CODE_MONEY_LIMIT, String.format("鍗曟棩绱鏈�楂樻彁鐜版鏁颁负%s娆�", config.getMaxNumPerDay().toString()));
         }
 
+        //灏忛噾棰濇彁鐜伴檺鍒�
+        if (money.compareTo(new BigDecimal(1)) < 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, new BigDecimal(1), 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, 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")));
+        if (count < limit) {
+            return true;
+        }
+        return false;
     }
 
 
@@ -281,6 +309,16 @@
         }
     }
 
+    @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);
+    }
+
     /**
      * 鎻愮幇鍒版敮浠樺疂
      *

--
Gitblit v1.8.0