From 28641bb94219076d93d9ea6d10b02ecec027a14d Mon Sep 17 00:00:00 2001 From: ronger Date: Sun, 13 Mar 2022 23:18:01 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BB=AA=E8=A1=A8=E7=9B=98?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=96=B0=E5=A2=9E=E6=96=87=E7=AB=A0/?= =?UTF-8?q?=E7=94=A8=E6=88=B7/=E9=93=B6=E8=A1=8C=E8=B4=A6=E6=88=B7?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forest/enumerate/TransactionEnum.java | 3 +- .../rymcu/forest/mapper/DashboardMapper.java | 25 +++- .../mapper/TransactionRecordMapper.java | 7 + .../forest/service/DashboardService.java | 21 +++ .../service/TransactionRecordService.java | 8 ++ .../service/impl/DashboardServiceImpl.java | 30 ++++- .../impl/TransactionRecordServiceImpl.java | 14 ++ .../web/api/admin/DashboardController.java | 48 +++++++ .../api/bank/TransactionRecordController.java | 6 + src/main/java/mapper/DashboardMapper.xml | 123 +++++++++++++++--- .../java/mapper/TransactionRecordMapper.xml | 27 +++- 11 files changed, 284 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/rymcu/forest/enumerate/TransactionEnum.java b/src/main/java/com/rymcu/forest/enumerate/TransactionEnum.java index fcfe846..6b6c8de 100644 --- a/src/main/java/com/rymcu/forest/enumerate/TransactionEnum.java +++ b/src/main/java/com/rymcu/forest/enumerate/TransactionEnum.java @@ -9,7 +9,8 @@ import java.util.Arrays; public enum TransactionEnum { ArticleSponsor("0", 20, "文章赞赏"), Answer("1", 30, "答题奖励"), - CorrectAnswer("2", 50, "答题奖励"); + CorrectAnswer("2", 50, "答题奖励"), + NewbieRewards("3", 200, "新手奖励"); private String dataType; diff --git a/src/main/java/com/rymcu/forest/mapper/DashboardMapper.java b/src/main/java/com/rymcu/forest/mapper/DashboardMapper.java index ce2a08e..40550d7 100644 --- a/src/main/java/com/rymcu/forest/mapper/DashboardMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/DashboardMapper.java @@ -1,5 +1,8 @@ package com.rymcu.forest.mapper; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.UserInfoDTO; import com.rymcu.forest.dto.admin.DashboardData; import java.util.List; @@ -63,18 +66,38 @@ public interface DashboardMapper { List selectLastThirtyDaysVisitData(); /** - * + * 获取历史 1 年文章数据 * @return */ List selectHistoryArticleData(); /** + * 获取历史 1 年用户数据 * @return */ List selectHistoryUserData(); /** + * 获取历史 1 年访问数据 * @return */ List selectHistoryVisitData(); + + /** + * 获取新增用户列表 + * @return + */ + List selectNewUsers(); + + /** + * 获取新增银行账号列表 + * @return + */ + List selectNewBankAccounts(); + + /** + * 获取新增文章列表 + * @return + */ + List selectNewArticles(); } diff --git a/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java b/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java index 065efe7..f35350f 100644 --- a/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java @@ -37,4 +37,11 @@ public interface TransactionRecordMapper extends Mapper { * @return */ Boolean existsWithBankAccountAndFunds(@Param("bankAccount") String bankAccount, @Param("funds") String funds); + + /** + * 查询是否已发放 + * @param bankAccount + * @return + */ + Boolean existsWithNewbieRewards(@Param("bankAccount") String bankAccount); } diff --git a/src/main/java/com/rymcu/forest/service/DashboardService.java b/src/main/java/com/rymcu/forest/service/DashboardService.java index 2a1639a..f65670f 100644 --- a/src/main/java/com/rymcu/forest/service/DashboardService.java +++ b/src/main/java/com/rymcu/forest/service/DashboardService.java @@ -1,7 +1,11 @@ package com.rymcu.forest.service; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.UserInfoDTO; import com.rymcu.forest.dto.admin.Dashboard; +import java.util.List; import java.util.Map; /** @@ -26,4 +30,21 @@ public interface DashboardService { * @return */ Map history(); + + /** + * 获取新增用户列表 + * @return + */ + List newUsers(); + + /**获取新增银行账号列表 + * @return + */ + List newBankAccounts(); + + /** + * 获取新增文章列表 + * @return + */ + List newArticles(); } diff --git a/src/main/java/com/rymcu/forest/service/TransactionRecordService.java b/src/main/java/com/rymcu/forest/service/TransactionRecordService.java index 28e406a..e5da803 100644 --- a/src/main/java/com/rymcu/forest/service/TransactionRecordService.java +++ b/src/main/java/com/rymcu/forest/service/TransactionRecordService.java @@ -46,4 +46,12 @@ public interface TransactionRecordService extends Service { * @throws Exception */ TransactionRecord bankTransfer(Integer idUser, TransactionEnum transactionType) throws Exception; + + /** + * 发放新手奖励 + * @param transactionRecord + * @return + * @throws Exception + */ + TransactionRecord newbieRewards(TransactionRecord transactionRecord) throws Exception; } diff --git a/src/main/java/com/rymcu/forest/service/impl/DashboardServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/DashboardServiceImpl.java index dd02b84..293e085 100644 --- a/src/main/java/com/rymcu/forest/service/impl/DashboardServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/DashboardServiceImpl.java @@ -1,7 +1,12 @@ package com.rymcu.forest.service.impl; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.dto.ArticleTagDTO; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.UserInfoDTO; import com.rymcu.forest.dto.admin.Dashboard; import com.rymcu.forest.dto.admin.DashboardData; +import com.rymcu.forest.mapper.ArticleMapper; import com.rymcu.forest.mapper.DashboardMapper; import com.rymcu.forest.service.DashboardService; import org.springframework.stereotype.Service; @@ -18,6 +23,8 @@ public class DashboardServiceImpl implements DashboardService { @Resource private DashboardMapper dashboardMapper; + @Resource + private ArticleMapper articleMapper; @Override public Dashboard dashboard() { @@ -46,7 +53,6 @@ public class DashboardServiceImpl implements DashboardService { while (now.isAfter(localDate)) { String date = localDate.toString(); dates.add(date); - articles.forEach(article->{ if (date.equals(article.getLabel())) { articleData.add(article.getValue()); @@ -88,7 +94,7 @@ public class DashboardServiceImpl implements DashboardService { @Override public Map history() { - Map map = new HashMap(4); + Map map = new HashMap(4); ArrayList dates = new ArrayList(30); ArrayList articleData = new ArrayList(30); ArrayList userData = new ArrayList(30); @@ -177,4 +183,24 @@ public class DashboardServiceImpl implements DashboardService { map.put("visits", visitData); return map; } + + @Override + public List newUsers() { + return dashboardMapper.selectNewUsers(); + } + + @Override + public List newBankAccounts() { + return dashboardMapper.selectNewBankAccounts(); + } + + @Override + public List newArticles() { + List list = dashboardMapper.selectNewArticles(); + list.forEach(article -> { + List tags = articleMapper.selectTags(article.getIdArticle()); + article.setTags(tags); + }); + return list; + } } diff --git a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java index 7298956..af8856f 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java @@ -106,6 +106,20 @@ public class TransactionRecordServiceImpl extends AbstractService list = dashboardService.newUsers(); + PageInfo pageInfo = new PageInfo<>(list); + Map map = new HashMap(2); + map.put("users", pageInfo.getList()); + Map pagination = Utils.getPagination(pageInfo); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + + @GetMapping("/new-bank-accounts") + public GlobalResult newBankAccounts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + PageHelper.startPage(page, rows); + List list = dashboardService.newBankAccounts(); + PageInfo pageInfo = new PageInfo(list); + Map map = new HashMap(2); + map.put("bankAccounts", pageInfo.getList()); + Map pagination = new HashMap(4); + pagination.put("pageSize", pageInfo.getPageSize()); + pagination.put("total", pageInfo.getTotal()); + pagination.put("currentPage", pageInfo.getPageNum()); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + + @GetMapping("/new-articles") + public GlobalResult newArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + PageHelper.startPage(page, rows); + List list = dashboardService.newArticles(); + PageInfo pageInfo = new PageInfo<>(list); + Map map = new HashMap<>(2); + map.put("articles", pageInfo.getList()); + Map pagination = Utils.getPagination(pageInfo); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } } diff --git a/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java b/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java index 2cc999b..c3a230a 100644 --- a/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java +++ b/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java @@ -27,4 +27,10 @@ public class TransactionRecordController { return GlobalResultGenerator.genSuccessResult(transactionRecord); } + @PostMapping("/newbie-rewards") + public GlobalResult newbieRewards(@RequestBody TransactionRecord transactionRecord) throws Exception { + transactionRecord = transactionRecordService.newbieRewards(transactionRecord); + return GlobalResultGenerator.genSuccessResult(transactionRecord); + } + } diff --git a/src/main/java/mapper/DashboardMapper.xml b/src/main/java/mapper/DashboardMapper.xml index 0be4881..e0da515 100644 --- a/src/main/java/mapper/DashboardMapper.xml +++ b/src/main/java/mapper/DashboardMapper.xml @@ -5,46 +5,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/mapper/TransactionRecordMapper.xml b/src/main/java/mapper/TransactionRecordMapper.xml index f0dd586..7a6b022 100644 --- a/src/main/java/mapper/TransactionRecordMapper.xml +++ b/src/main/java/mapper/TransactionRecordMapper.xml @@ -12,17 +12,32 @@ - update forest_bank_account set account_balance = account_balance - #{money} where bank_account = #{formBankAccount}; - update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount}; + update forest_bank_account + set account_balance = account_balance - #{money} + where bank_account = #{formBankAccount}; + update forest_bank_account + set account_balance = account_balance + #{money} + where bank_account = #{toBankAccount}; + \ No newline at end of file