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); + } + + /** * 修改 */ 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/BookForumArticlesServiceController.java b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java index bfa1ce30..903884d5 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 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 138f8430..2b98138a 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; @@ -85,6 +86,9 @@ public class BuyOrderController { */ private static final String ORDER_STATUS_TO_BE_RECEIVED = "2"; + @Autowired + private ShopProudictBookService shopProudictBookService; + /** * 列表 */ @@ -263,6 +267,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..8dac1e31 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 @@ -92,7 +91,7 @@ public class ShopProductLabelController { /** - * + * 废除 * @param params * @return */ @@ -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 4793f84e..fc807303 100644 --- a/src/main/java/com/peanut/modules/book/service/UserEbookBuyService.java +++ b/src/main/java/com/peanut/modules/book/service/UserEbookBuyService.java @@ -22,8 +22,7 @@ public interface UserEbookBuyService extends IService { List getUserBookId(Integer userId); - - + 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 aac39f70..b8c0dfaa 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,5 +1,6 @@ package com.peanut.modules.book.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -11,6 +12,7 @@ import com.peanut.modules.book.service.UserEbookBuyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; import java.util.Map; @@ -52,4 +54,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 diff --git a/src/main/java/com/peanut/modules/pay/weChatPay/util/WxPayUtil.java b/src/main/java/com/peanut/modules/pay/weChatPay/util/WxPayUtil.java index 3be275e1..52212dd2 100644 --- a/src/main/java/com/peanut/modules/pay/weChatPay/util/WxPayUtil.java +++ b/src/main/java/com/peanut/modules/pay/weChatPay/util/WxPayUtil.java @@ -32,12 +32,12 @@ import java.util.Base64; public static final String apiV3Key = "4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF"; // apiV3秘钥 //商户私钥路径 - // public static final String privateKeyUrl = "/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem"; - public static final String privateKeyUrl = "C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem"; + public static final String privateKeyUrl = "/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem"; + //public static final String privateKeyUrl = "C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem"; //平台证书路径 - // public static final String wechatPayCertificateUrl = "/usr/local/hs/peanut_book/target/classes/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem"; - public static final String wechatPayCertificateUrl = "C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem"; + public static final String wechatPayCertificateUrl = "/usr/local/hs/peanut_book/target/classes/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem"; + //public static final String wechatPayCertificateUrl = "C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem"; //第一步申请完证书后,在API证书哪里点击管理证书就能看到 public static final String mchSerialNo = "679AECB2F7AC4183033F713828892BA640E4EEE3"; // 商户证书序列号 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 55f6a17d..9853eb73 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,10 +1,10 @@ + spring: datasource: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver -# url: jdbc:mysql://59.110.212.44:3306/e_book_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true - url: jdbc:mysql://59.110.212.44:3306/e_book?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true + url: jdbc:mysql://59.110.212.44:3306/e_book_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true username: root password: HSXY1234hsxy initial-size: 10 @@ -42,13 +42,6 @@ spring: username: admin password: 751019 virtualHost: / - - -# redis: -# host: 82.157.238.238 -# port: 6379 -# password: redis970104 - aliyun: oss: file: @@ -63,18 +56,5 @@ aliyun: templateCode: SMS_248840040 - -##多数据源的配置 -#dynamic: -# datasource: -# slave1: -# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver -# url: jdbc:sqlserver://localhost:1433;DatabaseName=renren_security -# username: sa -# password: 123456 -# slave2: -# driver-class-name: org.postgresql.Driver -# url: jdbc:postgresql://localhost:5432/renren_security -# username: renren - -# password: 123456 \ No newline at end of file +server: + port: 9200 \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index d8658679..2ceaca9a 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,10 +1,10 @@ + spring: datasource: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - # url: jdbc:mysql://59.110.212.44:3306/e_book?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - url: jdbc:mysql://59.110.212.44:3306/e_book_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://59.110.212.44:3306/e_book?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: HSXY1234hsxy initial-size: 10 @@ -55,16 +55,5 @@ aliyun: templateCode: SMS_248840040 -##多数据源的配置 -#dynamic: -# datasource: -# slave1: -# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver -# url: jdbc:sqlserver://localhost:1433;DatabaseName=renren_security -# username: sa -# password: 123456 -# slave2: -# driver-class-name: org.postgresql.Driver -# url: jdbc:postgresql://localhost:5432/renren_security -# username: renren -# password: 123456 \ No newline at end of file +server: + port: 9100 \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 667b4837..3cf6245a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,7 +4,6 @@ server: uri-encoding: UTF-8 max-threads: 1000 min-spare-threads: 30 - port: 9200 servlet: context-path: /pb @@ -12,7 +11,7 @@ connection-timeout: 6000000ms spring: # 环境 dev|test|prod profiles: - active: prod + active: dev # jackson时间格式化 jackson: time-zone: GMT+8 diff --git a/src/main/resources/weChatConfig.properties b/src/main/resources/weChatConfig.properties index fea1cb05..c9dcee5a 100644 --- a/src/main/resources/weChatConfig.properties +++ b/src/main/resources/weChatConfig.properties @@ -16,8 +16,8 @@ wxpay.notifyUrl: http://59.110.212.44:9100/pb/pay/payNotify wxpay.refundNotifyUrl: http://pjm6m9.natappfree.cc/pay/refundNotify # ???? /usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem -wxpay.keyPemPath:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem -#wxpay.keyPemPath:D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem +#wxpay.keyPemPath:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem +wxpay.keyPemPath:/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem #??????? wxpay.serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3 #???????