From 880c412b193258397ed39e48a9f3640b1f75d1cc Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sat, 7 Oct 2023 10:56:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/controller/BookController.java | 17 ++++++++++ .../book/controller/BuyOrderController.java | 12 +++++++ .../ShopProductLabelController.java | 2 +- .../book/service/UserEbookBuyService.java | 3 ++ .../service/impl/UserEbookBuyServiceImpl.java | 34 ++++++++----------- 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/BookController.java b/src/main/java/com/peanut/modules/book/controller/BookController.java index a13e945e..a708c582 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -59,6 +59,8 @@ public class BookController { private ShopProductService shopProductService; @Autowired private ShopProudictBookService shopProudictBookService; + @Autowired + private ShopProductToLabelService shopProductToLabelService; final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10); /** @@ -82,6 +84,21 @@ public class BookController { return R.ok().put("page", page); } + /** + * 获取精品图书 + * @return + */ + @RequestMapping("/getJPBooks") + public R getJPBooks(){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ShopProductToLabelEntity::getSplId,5);//精选图书 + wrapper.eq(ShopProductToLabelEntity::getDelFlag,0); + List pIds = shopProductToLabelService.getBaseMapper().selectList(wrapper).stream().map(ShopProductToLabelEntity::getProductId).collect(Collectors.toList()); + + List shopProductEntities = shopProductService.getBaseMapper().selectList(new LambdaQueryWrapper().in(ShopProductEntity::getProductId, pIds)); + return R.ok().put("Products",shopProductEntities); + } + /** diff --git a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java index 02bc6ef7..6733f094 100644 --- a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java +++ b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java @@ -7,6 +7,7 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; @@ -71,6 +72,8 @@ public class BuyOrderController { private PayWechatOrderService payWechatOrderService; @Autowired private PayZfbOrderService payZfbOrderService; + @Autowired + private ShopProudictBookService shopProudictBookService; // @Autowired // private /** @@ -255,6 +258,15 @@ public class BuyOrderController { transactionDetailsEntity.setOrderType("购买健康超市用品!"); transactionDetailsService.save(transactionDetailsEntity); + //购买成功后,添加书到个人表中 + List pros = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList()); + for (Integer s : pros){ + List collect = shopProudictBookService.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(ShopProudictBookEntity::getProudictId, s) + .eq(ShopProudictBookEntity::getDelFlag, 0)).stream().map(ShopProudictBookEntity::getBookId).collect(Collectors.toList()); + userEbookBuyService.addBookForUser(buyOrder.getUserId(),collect); + } + }else{ return R.error("余额不足!"); } diff --git a/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java b/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java index 0f5e6403..25b17d29 100644 --- a/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java +++ b/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java @@ -29,7 +29,6 @@ public class ShopProductLabelController { @Autowired private ShopProductLabelService shopProductLabelService; - @Autowired private ShopProductToLabelService shopProductToLabelService; @Autowired @@ -113,6 +112,7 @@ public class ShopProductLabelController { MPJLambdaWrapper shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper(); shopProductEntityMPJLambdaWrapper.selectAll(ShopProductEntity.class); shopProductEntityMPJLambdaWrapper.leftJoin(ShopProductEntity.class,ShopProductEntity::getProductId,ShopProductToLabelEntity::getProductId); + shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId); shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0); shopProductEntityMPJLambdaWrapper.eq(ShopProductEntity::getDelFlag,0); Page shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page(page, limit), ShopProductEntity.class, shopProductEntityMPJLambdaWrapper); diff --git a/src/main/java/com/peanut/modules/book/service/UserEbookBuyService.java b/src/main/java/com/peanut/modules/book/service/UserEbookBuyService.java index 4ef1356b..aa0e2c17 100644 --- a/src/main/java/com/peanut/modules/book/service/UserEbookBuyService.java +++ b/src/main/java/com/peanut/modules/book/service/UserEbookBuyService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.peanut.common.utils.PageUtils; import com.peanut.modules.book.entity.UserEbookBuyEntity; +import java.util.List; import java.util.Map; /** @@ -19,6 +20,8 @@ public interface UserEbookBuyService extends IService { PageUtils queryPages(Map params); + void addBookForUser(Integer userId, List bookIds); + } diff --git a/src/main/java/com/peanut/modules/book/service/impl/UserEbookBuyServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/UserEbookBuyServiceImpl.java index 991322d1..19ed63e4 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/UserEbookBuyServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/UserEbookBuyServiceImpl.java @@ -1,8 +1,10 @@ package com.peanut.modules.book.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.peanut.modules.book.entity.BuyOrderEntity; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -45,23 +47,17 @@ public class UserEbookBuyServiceImpl extends ServiceImpl bookIds) { + for (Integer i:bookIds){ + List userEbookBuyEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper().eq(UserEbookBuyEntity::getUserId, userId).eq(UserEbookBuyEntity::getBookId, i)); + if(userEbookBuyEntities.size()==0){ + UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity(); + userEbookBuyEntity.setUserId(userId); + userEbookBuyEntity.setBookId(i); + userEbookBuyEntity.setPayTime(new Date()); + this.save(userEbookBuyEntity); + } + } + } } \ No newline at end of file From ca919c55cd2db044e566c0e266f961d43a432faa Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sat, 7 Oct 2023 14:36:14 +0800 Subject: [PATCH 2/4] 20231007 --- .../modules/book/controller/ShopProductLabelController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java b/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java index 25b17d29..8dac1e31 100644 --- a/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java +++ b/src/main/java/com/peanut/modules/book/controller/ShopProductLabelController.java @@ -91,7 +91,7 @@ public class ShopProductLabelController { /** - * + * 废除 * @param params * @return */ From 5de88ed184cc1b483e5a564fabbe7cdf3ae70af6 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sat, 7 Oct 2023 15:31:51 +0800 Subject: [PATCH 3/4] 20231007 --- .../BookClockinPunchController.java | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java b/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java index e969e07a..ef3a7871 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookClockinPunchController.java @@ -1,11 +1,12 @@ package com.peanut.modules.book.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.R; -import com.peanut.modules.book.entity.BookClockinCommentEntity; -import com.peanut.modules.book.entity.BookClockinPunchEntity; -import com.peanut.modules.book.entity.BookEntity; -import com.peanut.modules.book.entity.MyUserEntity; +import com.peanut.modules.book.dao.UserEbookBuyDao; +import com.peanut.modules.book.entity.*; import com.peanut.modules.book.service.BookClockinCommentService; import com.peanut.modules.book.service.BookClockinPunchService; import com.peanut.modules.book.service.BookService; @@ -25,6 +26,8 @@ private BookService bookService; private MyUserService myUserService; @Autowired private BookClockinCommentService bookClockinCommentService; +@Autowired +private UserEbookBuyDao userEbookBuyDao; @@ -136,6 +139,42 @@ private BookClockinCommentService bookClockinCommentService; } + /** + * 获取用户打卡已购图书 + * @param userId + * @return + */ + @RequestMapping("/myClockBooks") + public R myClockBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(BookEntity.class); + wrapper.leftJoin(BookEntity.class,BookEntity::getId,UserEbookBuyEntity::getBookId); + wrapper.eq(UserEbookBuyEntity::getUserId,userId); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.eq(BookEntity::getClockIn,1); + Page userBookEntityPage = userEbookBuyDao.selectJoinPage(new Page(page, limit), BookEntity.class, wrapper); + return R.ok().put("page",userBookEntityPage); + } + + /** + * 获取打卡推荐图书 + * @param userId + * @param limit + * @param page + * @return + */ + @RequestMapping("/getBestClockBooks") + public R getBestClockBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ + String not_ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId; + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.eq(BookEntity::getClockIn,1); + wrapper.notExists(not_ex_sql); + Page bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); + return R.ok().put("page",bookEntityPage); + } + + /** * 修改 */ From a17d2fc8403441af96ee4807b333981508912e9c Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sat, 7 Oct 2023 18:10:50 +0800 Subject: [PATCH 4/4] 20231007 --- .../BookForumArticlesServiceController.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java index e7e54b4e..898a7604 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java @@ -138,6 +138,56 @@ public class BookForumArticlesServiceController { return R.ok().put("page",bookEntityPage); } + /** + * 书集----已购图书 + * @param userId + * @param limit + * @param page + * @return + */ + @RequestMapping("/getHasForumsAndBook") + public R getHasForumsAndBook(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ + String ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId; + String existSql = "select 1 from book_forum_articles where book.id = bookid"; + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.exists(ex_sql); + wrapper.exists(existSql); + Page bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); + for (BookEntity b : bookEntityPage.getRecords()){ + b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); + b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); + } + + return R.ok().put("page",bookEntityPage); + } + + /** + * 书集----推荐图书 + * @param userId + * @param limit + * @param page + * @return + */ + @RequestMapping("/getBestForumsAndBook") + public R getBestForumsAndBook(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ + String ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId; + String existSql = "select 1 from book_forum_articles where book.id = bookid"; + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.notExists(ex_sql); + wrapper.exists(existSql); + Page bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); + for (BookEntity b : bookEntityPage.getRecords()){ + b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); + b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); + } + + return R.ok().put("page",bookEntityPage); + } + /** * 点赞书评帖子 * @param forum_id