--9.18
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
@@ -9,6 +11,7 @@ import com.peanut.modules.book.dao.BookCategoryDao;
|
||||
import com.peanut.modules.book.entity.BookCategoryEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.BookCategoryService;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -43,7 +46,7 @@ public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCa
|
||||
@Override
|
||||
public List<BookCategoryEntity> listTree() {
|
||||
List<BookCategoryEntity> entities = baseMapper.selectList(null);
|
||||
|
||||
//0为父菜单列表
|
||||
List<BookCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
|
||||
catalogueEntity.getBookCid() == 0
|
||||
|
||||
@@ -58,7 +61,7 @@ public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCa
|
||||
|
||||
|
||||
|
||||
|
||||
//子菜单列表
|
||||
private List<BookCategoryEntity> getChildrens(BookCategoryEntity root,List<BookCategoryEntity> all){
|
||||
|
||||
List<BookCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
|
||||
@@ -75,81 +75,75 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
@Override
|
||||
public boolean bookAuthenticate(Integer bookId, Integer userId) {
|
||||
|
||||
//查询书籍 类型
|
||||
BookEntity book = bookService.getById(bookId);
|
||||
Integer isVip = book.getIsVip(); // 0 - 免费 1- 会免 2 - 付费
|
||||
Boolean canListen = book.getCanListen();
|
||||
if (isVip == 1) {
|
||||
// 查询 用户是否为 vip 0 - 普通 1- 会员
|
||||
MyUserEntity myUserEntity = this.getBaseMapper().selectById(userId);
|
||||
String vip = myUserEntity.getVip();
|
||||
if (!"1".equals(vip)){
|
||||
|
||||
// 判断普通用 是否解锁书籍
|
||||
TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
.eq("relation_id", bookId));
|
||||
|
||||
if (transactionDetailsEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (isVip == 2) {
|
||||
|
||||
|
||||
// TODO 查询 购买表中是否有用户购买记录 ,
|
||||
TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
.eq("relation_id", bookId));
|
||||
|
||||
if (transactionDetailsEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//vip等于3为听书付费,
|
||||
if (isVip == 3){
|
||||
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id",bookId));
|
||||
|
||||
if (userid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (canListen == true){
|
||||
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id",bookId));
|
||||
|
||||
if (userid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
// //查询书籍 类型
|
||||
// BookEntity book = bookService.getById(bookId);
|
||||
// Integer isVip = book.getIsVip(); // 0 - 免费 1- 会免 2 - 付费
|
||||
// Boolean canListen = book.getCanListen();
|
||||
// if (isVip == 1) {
|
||||
// // 查询 用户是否为 vip 0 - 普通 1- 会员
|
||||
// MyUserEntity myUserEntity = this.getBaseMapper().selectById(userId);
|
||||
// String vip = myUserEntity.getVip();
|
||||
// if (!"1".equals(vip)){
|
||||
//
|
||||
// // 判断普通用 是否解锁书籍
|
||||
// TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
// .eq("relation_id", bookId));
|
||||
//
|
||||
// if (transactionDetailsEntity == null) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if (isVip == 2) {
|
||||
//
|
||||
//
|
||||
// // TODO 查询 购买表中是否有用户购买记录 ,
|
||||
// TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
// .eq("relation_id", bookId));
|
||||
//
|
||||
// if (transactionDetailsEntity == null) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// //vip等于3为听书付费,
|
||||
// if (isVip == 3){
|
||||
// UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
// .eq("user_id", userId)
|
||||
// .eq("book_id",bookId));
|
||||
//
|
||||
// if (userid == null) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (canListen == true){
|
||||
// UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
// .eq("user_id", userId)
|
||||
// .eq("book_id",bookId));
|
||||
//
|
||||
// if (userid == null) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bookAuthenti(Integer bookId, Integer userId) {
|
||||
public boolean bookAuthen(Integer bookId, Integer userId) {
|
||||
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookId));
|
||||
|
||||
//查询书籍 类型
|
||||
BookEntity book = bookService.getById(bookId);
|
||||
Integer isVip = book.getIsVip(); // 0 - 免费 1- 会免 2 - 付费
|
||||
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id",bookId));
|
||||
System.out.println("userid==========="+userid);
|
||||
|
||||
if (userid == null) {
|
||||
return false;
|
||||
}
|
||||
if (userid == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -289,7 +283,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
MyUserEntity user = this.getById(Integer.valueOf(userId));
|
||||
Double peanutCoin = user.getPeanutCoin().doubleValue() - salePrice.doubleValue();
|
||||
if (peanutCoin < 0) {
|
||||
return "当前书籍以购买,请勿重复购买!";
|
||||
return "当前书籍已购买,请勿重复购买!";
|
||||
}
|
||||
user.setPeanutCoin(new BigDecimal(peanutCoin));
|
||||
this.updateById(user);
|
||||
@@ -389,10 +383,6 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
return R.ok("sec");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bookEbookBuy(Integer bookid, Integer userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void sendCode(String phone,String code) throws Exception {
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -50,7 +51,6 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
|
||||
Integer productId = orderCartEntity.getProductId();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(productId);
|
||||
|
||||
ShopCartVo shopCartVo = new ShopCartVo();
|
||||
|
||||
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
|
||||
@@ -62,7 +62,19 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
|
||||
shopCartVo.setWeight(productEntity.getWeight().doubleValue());
|
||||
|
||||
shopCartVo.setProductStock(productEntity.getProductStock());
|
||||
shopCartVo.setProudictBook(Integer.valueOf(productEntity.getBookId()));
|
||||
|
||||
BigDecimal activityPrice = productEntity.getActivityPrice();
|
||||
BigDecimal big = new BigDecimal(0);
|
||||
BigDecimal price=null;
|
||||
//activityPrice等于0,则原价
|
||||
if (activityPrice == big) {
|
||||
price = productEntity.getPrice();
|
||||
|
||||
}else {
|
||||
price = productEntity.getActivityPrice();
|
||||
}
|
||||
shopCartVo.setActivityPrice(price);
|
||||
cartList.add(shopCartVo);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.ShopProudictBookDao;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.entity.ShopProudictBookEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.service.ShopProudictBookService;
|
||||
import com.peanut.modules.book.vo.ProudictBookqueryVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("shopProudictBookService")
|
||||
public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao,ShopProudictBookEntity> implements ShopProudictBookService {
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopProudictBookEntity> page = this.page(
|
||||
new Query<ShopProudictBookEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProudictBookEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils proudictBookqueryPage(Map<String, Object> params) {
|
||||
Object proudictId = params.get("proudictId");
|
||||
IPage<ShopProudictBookEntity> page = this.page(
|
||||
new Query<ShopProudictBookEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id",proudictId)
|
||||
);
|
||||
List<ShopProudictBookEntity> records = page.getRecords();
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProudictBookqueryVO> getCartList(Integer proudictId) {
|
||||
|
||||
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId));
|
||||
|
||||
List prList = new ArrayList<>();
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) {
|
||||
Integer proudictId1 = shopProudictBookEntity.getProudictId();
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
|
||||
System.out.println("proudictId1======="+proudictId1);
|
||||
System.out.println("bookId======="+bookId);
|
||||
BookEntity bookbyId = bookService.getById(bookId);
|
||||
ShopProductEntity shopProductbyId = shopProductService.getById(proudictId1);
|
||||
ProudictBookqueryVO queryVO = new ProudictBookqueryVO();
|
||||
queryVO.setBookId(bookbyId.getId());
|
||||
queryVO.setName(bookbyId.getName());
|
||||
queryVO.setCanListen(bookbyId.getCanListen());
|
||||
queryVO.setImages(bookbyId.getImages());
|
||||
queryVO.setClockIn(bookbyId.getClockIn());
|
||||
queryVO.setProudictId(shopProductbyId.getProductId());
|
||||
queryVO.setProductName(shopProductbyId.getProductName());
|
||||
queryVO.setPrice(shopProductbyId.getPrice());
|
||||
queryVO.setActivityPrice(shopProductbyId.getActivityPrice());
|
||||
queryVO.setSumSales(shopProductbyId.getSumSales());
|
||||
prList.add(queryVO);
|
||||
System.out.println("queryVO======="+queryVO);
|
||||
}
|
||||
|
||||
return prList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.modules.book.dao.UserRecordDao;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.modules.book.service.UserRecordService;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -20,7 +24,8 @@ import java.util.*;
|
||||
@Service("UserRecordServiceImpl")
|
||||
public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecordEntity> implements UserRecordService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -33,19 +38,29 @@ public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecor
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String orderSn = (String) params.get("orderSn");
|
||||
IPage<UserRecordEntity> page =page(
|
||||
new Query<UserRecordEntity>().getPage(params),
|
||||
new QueryWrapper<UserRecordEntity>()
|
||||
//订单号,开始时间
|
||||
.eq("orderSn",orderSn).orderByDesc("create_time")
|
||||
String proudictid = (String) params.get("proudictId");
|
||||
IPage<UserRecordEntity> page = page(
|
||||
new Query<UserRecordEntity>().getPage(params),
|
||||
new QueryWrapper<UserRecordEntity>()
|
||||
//订单号,开始时间
|
||||
.eq("bookid", proudictid).orderByDesc("create_date")
|
||||
// .eq("")
|
||||
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
for (UserRecordEntity userRecordEntity : page.getRecords()) {
|
||||
Integer userid = userRecordEntity.getUserid();
|
||||
MyUserEntity byId = myUserService.getById(userid);
|
||||
String avatar = byId.getAvatar();
|
||||
String nickname = byId.getNickname();
|
||||
userRecordEntity.setAvatar(avatar);
|
||||
userRecordEntity.setNickname(nickname);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) {
|
||||
|
||||
@@ -76,36 +91,6 @@ public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecor
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> uploadFiles(List<MultipartFile> files) {
|
||||
String endpoint = ConstantPropertiesUtils.END_POIND;
|
||||
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||
try {
|
||||
//创建oss实例
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (MultipartFile file : files) {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
String fileName = file.getOriginalFilename();
|
||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
fileName = uuid + fileName;
|
||||
String datePath = new DateTime().toString("yyyy/MM/dd");
|
||||
fileName = datePath + "/" + fileName;
|
||||
ossClient.putObject(bucketName, fileName, inputStream);
|
||||
urls.add("https://" + bucketName + "." + endpoint + "/" + fileName);
|
||||
}
|
||||
//关闭资源否则会导致OLD区逐渐的变大,直到内存泄漏
|
||||
ossClient.shutdown();
|
||||
return urls;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user