This commit is contained in:
yc13649764453
2023-09-18 09:41:19 +08:00
parent 8d3c128f3b
commit 9ada233eb7
60 changed files with 8255 additions and 655 deletions

View File

@@ -1,10 +1,11 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BookCategoryEntity;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.BookCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -55,6 +56,9 @@ public class BookCategoryController {
@RequestMapping("/save")
public R save(@RequestBody BookCategoryEntity bookCategoryEntity){
bookCategoryEntity.setDelFlag(0);
Integer bookCid = bookCategoryEntity.getBookCid();
bookCategoryService.save(bookCategoryEntity);
return R.ok();
@@ -74,29 +78,23 @@ public class BookCategoryController {
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
bookCategoryService.removeByIds(Arrays.asList(ids));
public R delete(@RequestParam Integer id){
// bookCategoryService.removeByIds(id);
bookCategoryService.removeById(id);
return R.ok();
}
/**
* 删除前检查
*/
@RequestMapping("/deleteCheck")
public R deleteCheck(@RequestBody String[] oids){
bookCategoryService.removeCheckByIds(Arrays.asList(oids));
return R.ok();
}
/**
* 获取图书 一级分类
*/
@RequestMapping("/getOneLevel")
public R getOneLevel(){
List<BookCategoryEntity> list = bookCategoryService.getOneLevel();
return R.ok().put("list",list);
List<BookCategoryEntity> book_cid = bookCategoryService.getBaseMapper().selectList(new QueryWrapper<BookCategoryEntity>().eq("book_cid", 0));
return R.ok().put("bookCategoryEntity",book_cid);
}

View File

@@ -80,25 +80,22 @@ public class BookController {
@PathVariable("userId") Integer userId) {
// 判断用户是否够买书籍
BookEntity book = bookService.getById(id);
book.setIsBuy(0);
Boolean canListen = book.getCanListen();
// Integer isVip = book.getIsVip(); // 0-免费 1-会免 2-付费
book.setIsBuy(true);
boolean b = myUserService.bookAuthenticate(id, userId);
boolean b = myUserService.bookAuthen(id, userId);
if (!b) {
// 无权限
book.setIsBuy(0);
book.setIsBuy(false);
}
//书籍详情返回,购买状态,免费章节数
// if (canListen==false) {
// // 无权限
// return R.error("该图书暂未开通听书功能");
// }
String authorName = "";
@@ -163,8 +160,7 @@ public class BookController {
book.setAuthorName(authorName);
book.setPublisherName(publisherName);
book.setFlag(flag);
return R.ok().put("book", book).put("canListen",canListen);
return R.ok().put("book", book);
}
/**
@@ -333,8 +329,68 @@ public class BookController {
/**
* 对外图标列表
* app 电子书目录
*/
@RequestMapping("/getCatalogue")
public R getCatalogue(@RequestParam("bookid") Integer id
) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity == null) {
return R.error("当前图书不存在或已删除");
}
String images = bookEntity.getImages() ;
Integer number=null;
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
List<HashMap<Object, Object>> chapterList = new ArrayList<>();
for (BookChapterEntity bookEntitys : bookChapterEntities) {
number = bookEntitys.getNumber();
HashMap<Object, Object> map = new HashMap<>();
map.put("bookid",id);
map.put("number", bookEntitys.getNumber());
map.put("chapterId", bookEntitys.getId());
map.put("chapterName", bookEntitys.getChapter());
//freeChapterCount
map.put("images",images);
chapterList.add(map);
}
if (number==null) {
return R.error("当前电子书目录为空");
}else{
return R.ok().put("BookCatalogue",chapterList);
}
}
//书籍详情返回,购买状态,免费章节数
/**
* app 获取免费章节数
*/
@RequestMapping("/getfreeChapter")
public R getfreeChapter(@RequestParam("bookid") Integer id
) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity == null) {
return R.error("当前图书不存在或已删除");
}
Integer freeChapterCount = bookEntity.getFreeChapterCount();
if (freeChapterCount == null) {
return R.error("当前电子书目录为空");
} else {
return R.ok().put("freeChapterCount", freeChapterCount);
}
}
/**
* 对外图标列表
*/
@RequestMapping("/listForWebsite")
// @RequiresPermissions("book:book:list")
public R listForWebsite(@RequestParam Map<String, Object> params) {

View File

@@ -148,9 +148,20 @@ public class BuyOrderController {
BuyOrderDetailEntity buyOrderDetailEntity = new BuyOrderDetailEntity();
Integer productId = buyOrderDetail.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
BigDecimal price = product.getPrice();
BigDecimal activityPrice = product.getActivityPrice();
BigDecimal big = new BigDecimal(0);
BigDecimal price=null;
//activityPrice等于0则原价
if (activityPrice == big) {
price = product.getPrice();
}else {
price = product.getActivityPrice();
}
Integer quantity = buyOrderDetail.getQuantity();
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
System.out.println("bigDecimal=================bigDecimal======================"+bigDecimal);
bigDecimal1 = bigDecimal1.add(bigDecimal);
if (product.getProductStock() - buyOrderDetail.getQuantity() < 0 ){
@@ -295,10 +306,23 @@ public class BuyOrderController {
BuyOrderDetailEntity buyOrderDetailEntity = new BuyOrderDetailEntity();
Integer productId = buyOrderDetail.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
BigDecimal price = product.getPrice();
// BigDecimal price = product.getPrice();
Integer quantity = buyOrderDetail.getQuantity();
BigDecimal activityPrice = product.getActivityPrice();
BigDecimal big = new BigDecimal(0);
BigDecimal price=null;
//activityPrice等于0则原价
if (activityPrice == big) {
price = product.getPrice();
}else {
price = product.getActivityPrice();
}
//价格*数量 = 单价*购买数量赋值给bigDecimal1
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
System.out.println("bigDecimal========bigDecimal=========bigDecimal======================"+bigDecimal);
bigDecimal1 = bigDecimal1.add(bigDecimal);
if (product.getProductStock() - buyOrderDetail.getQuantity() < 0) {

View File

@@ -62,6 +62,7 @@ public class OrderCartController {
@RequestMapping("/save")
// @RequiresPermissions("book:ordercart:save")
public R save(@RequestBody OrderCartEntity orderCart){
orderCartService.save(orderCart);
return R.ok();

View File

@@ -1,14 +1,11 @@
package com.peanut.modules.book.controller;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.BuyOrderDetailService;
import com.peanut.modules.book.service.ShopCategoryService;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.book.vo.ShopProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
@@ -16,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.service.ShopProductService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
@@ -42,8 +37,8 @@ public class ShopProductController {
@Autowired
private BookService bookService;
// 商品销量 productSalesVolume
@Autowired
private ShopProudictBookService shopProudictBookService;
@@ -158,31 +153,27 @@ public class ShopProductController {
@RequestMapping("/bookinfo/{productId}")
public R bookinfo(@PathVariable("productId") Integer productId){
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("book_ids", productId));
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
Integer poid = shopProductEntity.getProductPid();
List<Integer> poids = shopCategoryService.findPoid(poid);
Integer productId1 = shopProductEntity.getProductId();
shopProductEntity.setPoids(poids);
ArrayList<String> list = new ArrayList<>();
String bookId = shopProductEntity.getBookId();
list.add(bookId);
shopProductEntity.setBookids(list);
String bookId1 = shopProductEntity.getBookId();
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
List<Object> list = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
for(String s : bookId1.split(",")){
if(null != s && !"".equals(s)){
BookEntity book = this.bookService.getById(s);
Map<String, String> urlMap = new HashMap<String, String>();
// urlMap.put("",s,book.getImages());
urlMap.put("id",s);
urlMap.put("images",book.getImages());
urlMap.put("name",book.getName());
imagesUrl.add(urlMap)
;
}
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
booklist.add(String.valueOf(bookId));
list.add(byId);
}
shopProductEntity.setBookidsimages(imagesUrl);
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
return R.ok().put("shopProduct", shopProductEntity);
}
@@ -200,45 +191,34 @@ public class ShopProductController {
public R info(@PathVariable("productId") Integer productId){
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
ArrayList<Map<String, String>> imagesUrls = new ArrayList<Map<String,String>>();
Integer poid = shopProductEntity.getProductPid();
String bookids = shopProductEntity.getBookId();
Integer productId1 = shopProductEntity.getProductId();
System.out.println("productId1=============================="+productId1);
List<Integer> poids = shopCategoryService.findPoid(poid);
shopProductEntity.setPoids(poids);
ArrayList<String> list = new ArrayList<>();
String bookId = shopProductEntity.getBookId();
list.add(bookId);
shopProductEntity.setBookids(list);
//TODO 判定
if (shopProductEntity.getBookId() != null) {
String bookId1 = shopProductEntity.getBookId();
for(String s : bookId1.split(",")){
if(null != s && !"".equals(s)){
BookEntity book = this.bookService.getById(s);
String canListen1 =String.valueOf(book.getCanListen()) ;
Map<String, String> urlMap = new HashMap<String, String>();
urlMap.put("id",s);
//如果图书删除了,商品页面会报错
urlMap.put("images",book.getImages());
urlMap.put("name",book.getName());
urlMap.put("canListen",canListen1);
imagesUrl.add(urlMap)
;
}
}
List<Object> list = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
}else {
ShopProductEntity shopProduct = shopProductService.getById(productId);
return R.ok().put("shopProduct", shopProduct);
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
booklist.add(String.valueOf(bookId));
list.add(byId);
}
Boolean canListen=null;
shopProductEntity.setBookidsimages(imagesUrl);
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
return R.ok().put("shopProduct", shopProductEntity);
}
@@ -248,47 +228,62 @@ public class ShopProductController {
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopProductEntity shopProduct){
public R save(@RequestBody ShopProductEntity shopProduct) {
shopProduct.setCreateTime(new Date());
//用list集合接收数组转String类型字符串
String bkids = "";
for(String s : shopProduct.getBookids()){
bkids += s+",";
// //用list集合接收数组转String类型字符串
// String bkids = "";
// for(String s : shopProduct.getBookids()){
// bkids += s+",";
// }
// if (bkids!=null &&!bkids.isEmpty()){
// String substring = bkids.substring(0, bkids.length() - 1);
// shopProduct.setBookId(substring);
// }else {
// shopProduct.setBookId("");
// }
shopProductService.save(shopProduct);
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
for (String s : shopProduct.getBookids()) {
String bookidlist = s;
if (bookidlist != null) {
Integer proudict = shopProduct.getProductId();
shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
shopProudictBookService.save(shopProudictBookEntity);
}
}
if (bkids!=null &&!bkids.isEmpty()){
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
}else {
shopProduct.setBookId("");
}
shopProduct.setCreateTime(new Date());
shopProductService.save(shopProduct);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProductEntity shopProduct){
String bkids = "";
for(String s : shopProduct.getBookids()){
bkids += s+",";
}
if (bkids!=null &&!bkids.isEmpty()){
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
}else {
shopProduct.setBookId("");
}
public R update(@RequestBody ShopProductEntity shopProduct) {
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
shopProductService.updateById(shopProduct);
return R.ok();
}
shopProductService.updateById(shopProduct);
return R.ok();
}
/**
* 删除
*/

View File

@@ -0,0 +1,108 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.service.ShopProudictBookService;
import com.peanut.modules.book.vo.ProudictBookqueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("book/shopProudictBook")
public class ShopProudictBookController {
@Autowired
private ShopProudictBookService shopProudictBookService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params ){
PageUtils page = shopProudictBookService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 图书与商品信息
*/
@RequestMapping("/proudictBooklist")
public R proudictBooklist(@RequestParam Integer proudictId){
List<ProudictBookqueryVO> cartList = shopProudictBookService.getCartList(proudictId);
return R.ok().put("cartList", cartList);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopProudictBookEntity shopProudictBookEntity){
for(Integer s : shopProudictBookEntity.getBookidlist()){
Integer bookidlist = s;
if (bookidlist!=null){
Integer proudict = shopProudictBookEntity.getProudictId();
shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(bookidlist);
shopProudictBookService.save(shopProudictBookEntity);
}
}
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProudictBookEntity shopProudictBookEntity){
shopProudictBookService.updateById(shopProudictBookEntity);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestParam Integer id){
shopProudictBookService.removeById(id);
return R.ok();
}
}

View File

@@ -33,6 +33,7 @@ public class UserRecordController {
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params ){
PageUtils page = userRecordService.queryPage(params);
return R.ok().put("page", page);
}
@@ -187,8 +188,8 @@ public class UserRecordController {
userRecordEntity.setBookid(bookid);
userRecordEntity.setUserid(userid);
userRecordEntity.setOrderSn(orderSn);
userRecordEntity.setOrderCode(userRecordEntity.getOrderCode());
userRecordEntity.setDelflag(0);
userRecordEntity.setProudictId(bookid);
userRecordService.saveOrUpdate(userRecordEntity);
return R.ok("成功").put("userRecordEntity",userRecordEntity);
}