Fixing .gitignore
This commit is contained in:
@@ -1,46 +1,46 @@
|
||||
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.core.toolkit.ObjectUtils;
|
||||
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.ActivityDao;
|
||||
import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.entity.ActivityEntity;
|
||||
import com.peanut.modules.book.service.ActivityService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("activityService")
|
||||
public class ActivityServiceImpl extends ServiceImpl<ActivityDao, ActivityEntity> implements ActivityService {
|
||||
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(ActivityServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
IPage<ActivityEntity> page = null;
|
||||
if ("0".equals(params.get("currentState"))) {
|
||||
page = this.page(
|
||||
new Query<ActivityEntity>().getPage(params),
|
||||
new QueryWrapper<ActivityEntity>()
|
||||
);
|
||||
} else {
|
||||
page = this.page(
|
||||
new Query<ActivityEntity>().getPage(params),
|
||||
new QueryWrapper<ActivityEntity>().eq("current_state", params.get("currentState"))
|
||||
);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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.core.toolkit.ObjectUtils;
|
||||
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.ActivityDao;
|
||||
import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.entity.ActivityEntity;
|
||||
import com.peanut.modules.book.service.ActivityService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("activityService")
|
||||
public class ActivityServiceImpl extends ServiceImpl<ActivityDao, ActivityEntity> implements ActivityService {
|
||||
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(ActivityServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
IPage<ActivityEntity> page = null;
|
||||
if ("0".equals(params.get("currentState"))) {
|
||||
page = this.page(
|
||||
new Query<ActivityEntity>().getPage(params),
|
||||
new QueryWrapper<ActivityEntity>()
|
||||
);
|
||||
} else {
|
||||
page = this.page(
|
||||
new Query<ActivityEntity>().getPage(params),
|
||||
new QueryWrapper<ActivityEntity>().eq("current_state", params.get("currentState"))
|
||||
);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.AuthorDao;
|
||||
import com.peanut.modules.book.entity.AuthorEntity;
|
||||
import com.peanut.modules.book.service.AuthorService;
|
||||
|
||||
|
||||
@Service("authorService")
|
||||
public class AuthorServiceImpl extends ServiceImpl<AuthorDao, AuthorEntity> implements AuthorService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<AuthorEntity> page = this.page(
|
||||
new Query<AuthorEntity>().getPage(params),
|
||||
new QueryWrapper<AuthorEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.AuthorDao;
|
||||
import com.peanut.modules.book.entity.AuthorEntity;
|
||||
import com.peanut.modules.book.service.AuthorService;
|
||||
|
||||
|
||||
@Service("authorService")
|
||||
public class AuthorServiceImpl extends ServiceImpl<AuthorDao, AuthorEntity> implements AuthorService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<AuthorEntity> page = this.page(
|
||||
new Query<AuthorEntity>().getPage(params),
|
||||
new QueryWrapper<AuthorEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookBrowseRecordsDao;
|
||||
import com.peanut.modules.book.entity.BookBrowseRecordsEntity;
|
||||
import com.peanut.modules.book.service.BookBrowseRecordsService;
|
||||
|
||||
|
||||
@Service("bookBrowseRecordsService")
|
||||
public class BookBrowseRecordsServiceImpl extends ServiceImpl<BookBrowseRecordsDao, BookBrowseRecordsEntity> implements BookBrowseRecordsService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
|
||||
IPage<BookBrowseRecordsEntity> page = this.page(
|
||||
new Query<BookBrowseRecordsEntity>().getPage(params),
|
||||
new QueryWrapper<BookBrowseRecordsEntity>()
|
||||
.eq("user_id",Integer.valueOf(userId)).orderByDesc("update_time")
|
||||
);
|
||||
List<BookBrowseRecordsEntity> records = page.getRecords();
|
||||
|
||||
for (BookBrowseRecordsEntity bookBrowseRecord: records) {
|
||||
Integer bookId = bookBrowseRecord.getBookId();
|
||||
BookEntity bookEntity = bookService.getById(bookId);
|
||||
BookReadRateEntity bookReadRate = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>().eq("book_id", bookId).eq("user_id", userId));
|
||||
if (bookReadRate != null) {
|
||||
Integer chapterId = bookReadRate.getChapterId();
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getById(chapterId);
|
||||
if (bookChapterEntity != null) {
|
||||
bookBrowseRecord.setChapterId(chapterId);
|
||||
bookBrowseRecord.setChapterName(bookChapterEntity.getChapter());
|
||||
bookBrowseRecord.setChapterNum(bookChapterEntity.getNumber());
|
||||
String images = bookEntity.getImages();
|
||||
bookBrowseRecord.setImages(images);
|
||||
}
|
||||
}
|
||||
// this.baseMapper.updateById(bookBrowseRecord);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookBrowseRecordsDao;
|
||||
import com.peanut.modules.book.entity.BookBrowseRecordsEntity;
|
||||
import com.peanut.modules.book.service.BookBrowseRecordsService;
|
||||
|
||||
|
||||
@Service("bookBrowseRecordsService")
|
||||
public class BookBrowseRecordsServiceImpl extends ServiceImpl<BookBrowseRecordsDao, BookBrowseRecordsEntity> implements BookBrowseRecordsService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
|
||||
IPage<BookBrowseRecordsEntity> page = this.page(
|
||||
new Query<BookBrowseRecordsEntity>().getPage(params),
|
||||
new QueryWrapper<BookBrowseRecordsEntity>()
|
||||
.eq("user_id",Integer.valueOf(userId)).orderByDesc("update_time")
|
||||
);
|
||||
List<BookBrowseRecordsEntity> records = page.getRecords();
|
||||
|
||||
for (BookBrowseRecordsEntity bookBrowseRecord: records) {
|
||||
Integer bookId = bookBrowseRecord.getBookId();
|
||||
BookEntity bookEntity = bookService.getById(bookId);
|
||||
BookReadRateEntity bookReadRate = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>().eq("book_id", bookId).eq("user_id", userId));
|
||||
if (bookReadRate != null) {
|
||||
Integer chapterId = bookReadRate.getChapterId();
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getById(chapterId);
|
||||
if (bookChapterEntity != null) {
|
||||
bookBrowseRecord.setChapterId(chapterId);
|
||||
bookBrowseRecord.setChapterName(bookChapterEntity.getChapter());
|
||||
bookBrowseRecord.setChapterNum(bookChapterEntity.getNumber());
|
||||
String images = bookEntity.getImages();
|
||||
bookBrowseRecord.setImages(images);
|
||||
}
|
||||
}
|
||||
// this.baseMapper.updateById(bookBrowseRecord);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.BookBuyConfigDao;
|
||||
import com.peanut.modules.book.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.book.service.BookBuyConfigService;
|
||||
|
||||
|
||||
@Service("bookBuyConfigService")
|
||||
public class BookBuyConfigServiceImpl extends ServiceImpl<BookBuyConfigDao, BookBuyConfigEntity> implements BookBuyConfigService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookBuyConfigEntity> page = this.page(
|
||||
new Query<BookBuyConfigEntity>().getPage(params),
|
||||
new QueryWrapper<BookBuyConfigEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.BookBuyConfigDao;
|
||||
import com.peanut.modules.book.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.book.service.BookBuyConfigService;
|
||||
|
||||
|
||||
@Service("bookBuyConfigService")
|
||||
public class BookBuyConfigServiceImpl extends ServiceImpl<BookBuyConfigDao, BookBuyConfigEntity> implements BookBuyConfigService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookBuyConfigEntity> page = this.page(
|
||||
new Query<BookBuyConfigEntity>().getPage(params),
|
||||
new QueryWrapper<BookBuyConfigEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +1,78 @@
|
||||
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;
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("bookCategoryService")
|
||||
public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCategoryEntity> implements BookCategoryService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
//分页
|
||||
IPage<BookCategoryEntity> page = this.page(
|
||||
new Query<BookCategoryEntity>().getPage(params),
|
||||
new QueryWrapper<BookCategoryEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCategoryEntity> getOneLevel() {
|
||||
//获取一级分类
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void removeCheckByIds(List<String> asList) {
|
||||
//删除前查看是否有子目录
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCategoryEntity> listTree() {
|
||||
List<BookCategoryEntity> entities = baseMapper.selectList(null);
|
||||
//0为父菜单列表
|
||||
List<BookCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
|
||||
catalogueEntity.getBookCid() == 0
|
||||
|
||||
).map((menu)->{
|
||||
menu.setChildren(getChildrens(menu,entities));
|
||||
return menu;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort() == null? 0 : menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return level1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//子菜单列表
|
||||
private List<BookCategoryEntity> getChildrens(BookCategoryEntity root,List<BookCategoryEntity> all){
|
||||
|
||||
List<BookCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
return root.getId().equals(catalogueEntity.getBookCid());
|
||||
}).map(catalogueEntity -> {
|
||||
catalogueEntity.setChildren(getChildrens(catalogueEntity, all));
|
||||
return catalogueEntity;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return children;
|
||||
}
|
||||
}
|
||||
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;
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("bookCategoryService")
|
||||
public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCategoryEntity> implements BookCategoryService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
//分页
|
||||
IPage<BookCategoryEntity> page = this.page(
|
||||
new Query<BookCategoryEntity>().getPage(params),
|
||||
new QueryWrapper<BookCategoryEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCategoryEntity> getOneLevel() {
|
||||
//获取一级分类
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void removeCheckByIds(List<String> asList) {
|
||||
//删除前查看是否有子目录
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCategoryEntity> listTree() {
|
||||
List<BookCategoryEntity> entities = baseMapper.selectList(null);
|
||||
//0为父菜单列表
|
||||
List<BookCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
|
||||
catalogueEntity.getBookCid() == 0
|
||||
|
||||
).map((menu)->{
|
||||
menu.setChildren(getChildrens(menu,entities));
|
||||
return menu;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort() == null? 0 : menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return level1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//子菜单列表
|
||||
private List<BookCategoryEntity> getChildrens(BookCategoryEntity root,List<BookCategoryEntity> all){
|
||||
|
||||
List<BookCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
return root.getId().equals(catalogueEntity.getBookCid());
|
||||
}).map(catalogueEntity -> {
|
||||
catalogueEntity.setChildren(getChildrens(catalogueEntity, all));
|
||||
return catalogueEntity;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,161 +1,161 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.common.utils.FileDownloadUtil;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.spire.doc.Document;
|
||||
import com.spire.doc.Section;
|
||||
import com.spire.doc.documents.Paragraph;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.io.InputStream;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookChapterContentDao;
|
||||
import com.peanut.modules.book.entity.BookChapterContentEntity;
|
||||
import com.peanut.modules.book.service.BookChapterContentService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Service("bookChapterContentService")
|
||||
public class BookChapterContentServiceImpl extends ServiceImpl<BookChapterContentDao, BookChapterContentEntity> implements BookChapterContentService {
|
||||
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object chapterid = params.get("chapterid");
|
||||
System.out.println(chapterid);
|
||||
IPage<BookChapterContentEntity> page = this.page(
|
||||
new Query<BookChapterContentEntity>().getPage(params),
|
||||
new QueryWrapper<BookChapterContentEntity>().eq("book_id",params.get("bookid"))
|
||||
.eq("book_chatper_id",params.get("chapterid"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBookVoices(Integer id) {
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
|
||||
List<BookChapterEntity> books = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||||
if(CollectionUtils.isEmpty(books)){
|
||||
bookEntity.setContentStatus("3");
|
||||
}else {
|
||||
for (BookChapterEntity book:books) {
|
||||
int count = 0;
|
||||
Integer bookId = book.getBookId();
|
||||
Integer chapterId = book.getId();
|
||||
String content = book.getContent();
|
||||
// String[] split = content.split("。");
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance();
|
||||
|
||||
iterator.setText(content);
|
||||
int start = iterator.first();
|
||||
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end,end = iterator.next()) {
|
||||
BookChapterContentEntity bcce = new BookChapterContentEntity();
|
||||
bcce.setBookId(bookId);
|
||||
bcce.setBookChatperId(chapterId);
|
||||
bcce.setContent(content.substring(start,end));
|
||||
bcce.setNumber(++count);
|
||||
save(bcce);
|
||||
System.out.println(content.substring(start,end));
|
||||
|
||||
}
|
||||
}
|
||||
bookEntity.setContentStatus("2");
|
||||
}
|
||||
|
||||
bookService.updateById(bookEntity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWordChapterParagraph(Integer bookId) {
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookId);
|
||||
String novel = bookEntity.getNovel();
|
||||
InputStream inputStream = FileDownloadUtil.getInputStream(novel);
|
||||
Document doc = new Document(inputStream);
|
||||
int num = 0;
|
||||
for (int i = 0; i < doc.getSections().getCount(); i++) {
|
||||
Section section = doc.getSections().get(i);
|
||||
//遍历Paragraph,每个小节下有若干段落
|
||||
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
|
||||
Paragraph paragraph = section.getParagraphs().get(j);
|
||||
//获取标题
|
||||
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText()))//段落样式为“标题1”的内容
|
||||
{
|
||||
//如果 是标题 1 为一级 目录
|
||||
|
||||
String level1 = paragraph.getText();
|
||||
|
||||
BookChapterEntity chapterEntity = bookChapterService.getOne(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("chapter", level1).eq("book_id", bookId));
|
||||
|
||||
Integer chapterId = chapterEntity.getId();
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
int num1 = 0;
|
||||
do {
|
||||
int cj = 0;
|
||||
|
||||
BookChapterContentEntity contentEntity = new BookChapterContentEntity();
|
||||
// builder.append(section.getParagraphs().get(j).getText() + "\n");
|
||||
String text = section.getParagraphs().get(j).getText();
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
num1++;
|
||||
//存放进数据库
|
||||
if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
|
||||
cj = 2;
|
||||
}
|
||||
if (section.getParagraphs().get(j).getStyleName().equals("Heading3")) {
|
||||
cj = 3;
|
||||
}
|
||||
if (section.getParagraphs().get(j).getStyleName().equals("Heading4")) {
|
||||
cj = 4;
|
||||
}
|
||||
|
||||
contentEntity.setContent(text);
|
||||
contentEntity.setLevel(cj);
|
||||
contentEntity.setBookChatperId(chapterId);
|
||||
contentEntity.setBookId(bookId);
|
||||
contentEntity.setNumber(num1);
|
||||
this.save(contentEntity);
|
||||
}
|
||||
|
||||
j++;
|
||||
|
||||
//防止index超出异常发生
|
||||
if (j >= section.getParagraphs().getCount()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// System.out.println(section.getParagraphs().get(j).getStyleName());
|
||||
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
|
||||
//获取段落标题内容
|
||||
// String text = builder.toString();
|
||||
j--; //由于do..while的特性,这里需要-1
|
||||
// System.out.println("标题1和内容: " + i + ":" + text + ":" + (j - 1) + "\r");
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.common.utils.FileDownloadUtil;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.spire.doc.Document;
|
||||
import com.spire.doc.Section;
|
||||
import com.spire.doc.documents.Paragraph;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.io.InputStream;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookChapterContentDao;
|
||||
import com.peanut.modules.book.entity.BookChapterContentEntity;
|
||||
import com.peanut.modules.book.service.BookChapterContentService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Service("bookChapterContentService")
|
||||
public class BookChapterContentServiceImpl extends ServiceImpl<BookChapterContentDao, BookChapterContentEntity> implements BookChapterContentService {
|
||||
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object chapterid = params.get("chapterid");
|
||||
System.out.println(chapterid);
|
||||
IPage<BookChapterContentEntity> page = this.page(
|
||||
new Query<BookChapterContentEntity>().getPage(params),
|
||||
new QueryWrapper<BookChapterContentEntity>().eq("book_id",params.get("bookid"))
|
||||
.eq("book_chatper_id",params.get("chapterid"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBookVoices(Integer id) {
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
|
||||
List<BookChapterEntity> books = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||||
if(CollectionUtils.isEmpty(books)){
|
||||
bookEntity.setContentStatus("3");
|
||||
}else {
|
||||
for (BookChapterEntity book:books) {
|
||||
int count = 0;
|
||||
Integer bookId = book.getBookId();
|
||||
Integer chapterId = book.getId();
|
||||
String content = book.getContent();
|
||||
// String[] split = content.split("。");
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance();
|
||||
|
||||
iterator.setText(content);
|
||||
int start = iterator.first();
|
||||
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end,end = iterator.next()) {
|
||||
BookChapterContentEntity bcce = new BookChapterContentEntity();
|
||||
bcce.setBookId(bookId);
|
||||
bcce.setBookChatperId(chapterId);
|
||||
bcce.setContent(content.substring(start,end));
|
||||
bcce.setNumber(++count);
|
||||
save(bcce);
|
||||
System.out.println(content.substring(start,end));
|
||||
|
||||
}
|
||||
}
|
||||
bookEntity.setContentStatus("2");
|
||||
}
|
||||
|
||||
bookService.updateById(bookEntity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWordChapterParagraph(Integer bookId) {
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookId);
|
||||
String novel = bookEntity.getNovel();
|
||||
InputStream inputStream = FileDownloadUtil.getInputStream(novel);
|
||||
Document doc = new Document(inputStream);
|
||||
int num = 0;
|
||||
for (int i = 0; i < doc.getSections().getCount(); i++) {
|
||||
Section section = doc.getSections().get(i);
|
||||
//遍历Paragraph,每个小节下有若干段落
|
||||
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
|
||||
Paragraph paragraph = section.getParagraphs().get(j);
|
||||
//获取标题
|
||||
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText()))//段落样式为“标题1”的内容
|
||||
{
|
||||
//如果 是标题 1 为一级 目录
|
||||
|
||||
String level1 = paragraph.getText();
|
||||
|
||||
BookChapterEntity chapterEntity = bookChapterService.getOne(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("chapter", level1).eq("book_id", bookId));
|
||||
|
||||
Integer chapterId = chapterEntity.getId();
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
int num1 = 0;
|
||||
do {
|
||||
int cj = 0;
|
||||
|
||||
BookChapterContentEntity contentEntity = new BookChapterContentEntity();
|
||||
// builder.append(section.getParagraphs().get(j).getText() + "\n");
|
||||
String text = section.getParagraphs().get(j).getText();
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
num1++;
|
||||
//存放进数据库
|
||||
if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
|
||||
cj = 2;
|
||||
}
|
||||
if (section.getParagraphs().get(j).getStyleName().equals("Heading3")) {
|
||||
cj = 3;
|
||||
}
|
||||
if (section.getParagraphs().get(j).getStyleName().equals("Heading4")) {
|
||||
cj = 4;
|
||||
}
|
||||
|
||||
contentEntity.setContent(text);
|
||||
contentEntity.setLevel(cj);
|
||||
contentEntity.setBookChatperId(chapterId);
|
||||
contentEntity.setBookId(bookId);
|
||||
contentEntity.setNumber(num1);
|
||||
this.save(contentEntity);
|
||||
}
|
||||
|
||||
j++;
|
||||
|
||||
//防止index超出异常发生
|
||||
if (j >= section.getParagraphs().getCount()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// System.out.println(section.getParagraphs().get(j).getStyleName());
|
||||
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
|
||||
//获取段落标题内容
|
||||
// String text = builder.toString();
|
||||
j--; //由于do..while的特性,这里需要-1
|
||||
// System.out.println("标题1和内容: " + i + ":" + text + ":" + (j - 1) + "\r");
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +1,69 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.vo.BookShelfVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookChapterDao;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
@Service("bookChapterService")
|
||||
public class BookChapterServiceImpl extends ServiceImpl<BookChapterDao, BookChapterEntity> implements BookChapterService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object bookid = params.get("bookid");
|
||||
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
//8.24修改根据number升序 排序
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByAsc("number")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage1(Map<String, Object> params) {
|
||||
Object chapterid = params.get("chapterid");
|
||||
System.out.println(chapterid);
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",params.get("bookid"))
|
||||
.eq("number",params.get("number"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookChapterEntity> getUserBookChapter(Integer userId) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.vo.BookShelfVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookChapterDao;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
@Service("bookChapterService")
|
||||
public class BookChapterServiceImpl extends ServiceImpl<BookChapterDao, BookChapterEntity> implements BookChapterService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object bookid = params.get("bookid");
|
||||
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
//8.24修改根据number升序 排序
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByAsc("number")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage1(Map<String, Object> params) {
|
||||
Object chapterid = params.get("chapterid");
|
||||
System.out.println(chapterid);
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",params.get("bookid"))
|
||||
.eq("number",params.get("number"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookChapterEntity> getUserBookChapter(Integer userId) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
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.BookClockinCommentDao;
|
||||
import com.peanut.modules.book.entity.BookClockinCommentEntity;
|
||||
import com.peanut.modules.book.entity.BookClockinEntity;
|
||||
import com.peanut.modules.book.service.BookClockinCommentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookClockinCommentServiceImpl extends ServiceImpl<BookClockinCommentDao,BookClockinCommentEntity> implements BookClockinCommentService{
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookClockinCommentEntity> page = this.page(
|
||||
new Query<BookClockinCommentEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinCommentEntity>().orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
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.BookClockinCommentDao;
|
||||
import com.peanut.modules.book.entity.BookClockinCommentEntity;
|
||||
import com.peanut.modules.book.entity.BookClockinEntity;
|
||||
import com.peanut.modules.book.service.BookClockinCommentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookClockinCommentServiceImpl extends ServiceImpl<BookClockinCommentDao,BookClockinCommentEntity> implements BookClockinCommentService{
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookClockinCommentEntity> page = this.page(
|
||||
new Query<BookClockinCommentEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinCommentEntity>().orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
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.BookClockinPunchDao;
|
||||
import com.peanut.modules.book.entity.BookClockinPunchEntity;
|
||||
import com.peanut.modules.book.service.BookClockinPunchService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookClockinPunchServiceImp extends ServiceImpl<BookClockinPunchDao, BookClockinPunchEntity> implements BookClockinPunchService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
Object book =params.get("bookid");
|
||||
Object days = params.get("days");
|
||||
IPage<BookClockinPunchEntity> page = this.page(
|
||||
new Query<BookClockinPunchEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id",book)
|
||||
.eq("days",days)
|
||||
.orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
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.BookClockinPunchDao;
|
||||
import com.peanut.modules.book.entity.BookClockinPunchEntity;
|
||||
import com.peanut.modules.book.service.BookClockinPunchService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookClockinPunchServiceImp extends ServiceImpl<BookClockinPunchDao, BookClockinPunchEntity> implements BookClockinPunchService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
Object book =params.get("bookid");
|
||||
Object days = params.get("days");
|
||||
IPage<BookClockinPunchEntity> page = this.page(
|
||||
new Query<BookClockinPunchEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id",book)
|
||||
.eq("days",days)
|
||||
.orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +1,45 @@
|
||||
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.BookClockinDao;
|
||||
import com.peanut.modules.book.entity.BookClockinEntity;
|
||||
import com.peanut.modules.book.service.BookClockinService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookClockinServiceImpl extends ServiceImpl<BookClockinDao, BookClockinEntity> implements BookClockinService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object book =params.get("bookid");
|
||||
Object taskid = params.get("taskid");
|
||||
IPage<BookClockinEntity> page = this.page(
|
||||
new Query<BookClockinEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinEntity>()
|
||||
.eq("book_id",book)
|
||||
.eq("task_id",taskid)
|
||||
.orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPagemylist(Map<String, Object> params) {
|
||||
IPage<BookClockinEntity> page = this.page(
|
||||
new Query<BookClockinEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinEntity>()
|
||||
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
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.BookClockinDao;
|
||||
import com.peanut.modules.book.entity.BookClockinEntity;
|
||||
import com.peanut.modules.book.service.BookClockinService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookClockinServiceImpl extends ServiceImpl<BookClockinDao, BookClockinEntity> implements BookClockinService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object book =params.get("bookid");
|
||||
Object taskid = params.get("taskid");
|
||||
IPage<BookClockinEntity> page = this.page(
|
||||
new Query<BookClockinEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinEntity>()
|
||||
.eq("book_id",book)
|
||||
.eq("task_id",taskid)
|
||||
.orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPagemylist(Map<String, Object> params) {
|
||||
IPage<BookClockinEntity> page = this.page(
|
||||
new Query<BookClockinEntity>().getPage(params),
|
||||
new QueryWrapper<BookClockinEntity>()
|
||||
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +1,61 @@
|
||||
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.BookForumArticlesDao;
|
||||
import com.peanut.modules.book.entity.AuthorEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.AuthorService;
|
||||
import com.peanut.modules.book.service.BookForumArticlesService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesDao, BookForumArticlesEntity> implements BookForumArticlesService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String bookid = (String) params.get("bookid");
|
||||
IPage<BookForumArticlesEntity> page = this.page(
|
||||
new Query<BookForumArticlesEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumArticlesEntity>().eq("bookid",bookid).orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPages(Map<String, Object> params) {
|
||||
String bookid = (String) params.get("bookid");
|
||||
|
||||
IPage<BookForumArticlesEntity> page = this.page(
|
||||
new Query<BookForumArticlesEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumArticlesEntity>().eq("bookid",bookid)
|
||||
|
||||
|
||||
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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.BookForumArticlesDao;
|
||||
import com.peanut.modules.book.entity.AuthorEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.AuthorService;
|
||||
import com.peanut.modules.book.service.BookForumArticlesService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesDao, BookForumArticlesEntity> implements BookForumArticlesService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String bookid = (String) params.get("bookid");
|
||||
IPage<BookForumArticlesEntity> page = this.page(
|
||||
new Query<BookForumArticlesEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumArticlesEntity>().eq("bookid",bookid).orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPages(Map<String, Object> params) {
|
||||
String bookid = (String) params.get("bookid");
|
||||
|
||||
IPage<BookForumArticlesEntity> page = this.page(
|
||||
new Query<BookForumArticlesEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumArticlesEntity>().eq("bookid",bookid)
|
||||
|
||||
|
||||
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||
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.BookForumCommentDao;
|
||||
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
||||
import com.peanut.modules.book.entity.BookForumCommentEntity;
|
||||
import com.peanut.modules.book.service.BookForumCommenService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao, BookForumCommentEntity> implements BookForumCommenService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String b = (String) params.get("bfa_id");
|
||||
IPage<BookForumCommentEntity> page = this.page(
|
||||
new Query<BookForumCommentEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumCommentEntity>().eq("bfa_id",b).orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils importlistqueryPages(Map<String, Object> params) {
|
||||
Object b = params.get("bfid");
|
||||
IPage<BookForumCommentEntity> page = this.page(
|
||||
new Query<BookForumCommentEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumCommentEntity>().eq("bfa_id",b).orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||
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.BookForumCommentDao;
|
||||
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
||||
import com.peanut.modules.book.entity.BookForumCommentEntity;
|
||||
import com.peanut.modules.book.service.BookForumCommenService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao, BookForumCommentEntity> implements BookForumCommenService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String b = (String) params.get("bfa_id");
|
||||
IPage<BookForumCommentEntity> page = this.page(
|
||||
new Query<BookForumCommentEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumCommentEntity>().eq("bfa_id",b).orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils importlistqueryPages(Map<String, Object> params) {
|
||||
Object b = params.get("bfid");
|
||||
IPage<BookForumCommentEntity> page = this.page(
|
||||
new Query<BookForumCommentEntity>().getPage(params),
|
||||
new QueryWrapper<BookForumCommentEntity>().eq("bfa_id",b).orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
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.BookListeningDao;
|
||||
import com.peanut.modules.book.entity.BookListeningEntity;
|
||||
import com.peanut.modules.book.service.BookListeningService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service("bookListeningService")
|
||||
public class BookListeningServiceImpl extends ServiceImpl<BookListeningDao,BookListeningEntity> implements BookListeningService{
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookListeningEntity> page = this.page(
|
||||
new Query<BookListeningEntity>().getPage(params),
|
||||
new QueryWrapper<BookListeningEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
|
||||
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.BookListeningDao;
|
||||
import com.peanut.modules.book.entity.BookListeningEntity;
|
||||
import com.peanut.modules.book.service.BookListeningService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service("bookListeningService")
|
||||
public class BookListeningServiceImpl extends ServiceImpl<BookListeningDao,BookListeningEntity> implements BookListeningService{
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookListeningEntity> page = this.page(
|
||||
new Query<BookListeningEntity>().getPage(params),
|
||||
new QueryWrapper<BookListeningEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.dao.BookListeningShelfDao;
|
||||
import com.peanut.modules.book.entity.BookListeningShelfEntity;
|
||||
import com.peanut.modules.book.service.BookListeningShelfService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookListeningShelfServiceImpl extends ServiceImpl<BookListeningShelfDao, BookListeningShelfEntity> implements BookListeningShelfService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.dao.BookListeningShelfDao;
|
||||
import com.peanut.modules.book.entity.BookListeningShelfEntity;
|
||||
import com.peanut.modules.book.service.BookListeningShelfService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookListeningShelfServiceImpl extends ServiceImpl<BookListeningShelfDao, BookListeningShelfEntity> implements BookListeningShelfService {
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.BookReadRateDao;
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
|
||||
|
||||
@Service("bookReadRateService")
|
||||
public class BookReadRateServiceImpl extends ServiceImpl<BookReadRateDao, BookReadRateEntity> implements BookReadRateService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookReadRateEntity> page = this.page(
|
||||
new Query<BookReadRateEntity>().getPage(params),
|
||||
new QueryWrapper<BookReadRateEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.BookReadRateDao;
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
|
||||
|
||||
@Service("bookReadRateService")
|
||||
public class BookReadRateServiceImpl extends ServiceImpl<BookReadRateDao, BookReadRateEntity> implements BookReadRateService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookReadRateEntity> page = this.page(
|
||||
new Query<BookReadRateEntity>().getPage(params),
|
||||
new QueryWrapper<BookReadRateEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,233 +1,233 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.BookShelfVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookShelfDao;
|
||||
|
||||
|
||||
@Service("bookShelfService")
|
||||
public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEntity> implements BookShelfService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookListeningService bookListeningService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookShelfEntity> page = this.page(
|
||||
new Query<BookShelfEntity>().getPage(params),
|
||||
new QueryWrapper<BookShelfEntity>().orderByDesc("update_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookShelfVo> getUserBookshelf(Integer userId) {
|
||||
|
||||
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
//1.获取 用户的 书架列表
|
||||
|
||||
List<BookShelfEntity> bookShelf = this.baseMapper.selectList(new QueryWrapper<BookShelfEntity>().eq("user_id", userId).orderByDesc("update_time"));
|
||||
//2. 遍历 获取书 的 详情
|
||||
for (BookShelfEntity bookShelfEntity : bookShelf) {
|
||||
String authorName = "";
|
||||
Integer bookid = bookShelfEntity.getBookId();
|
||||
BookShelfVo bookShelfVo = new BookShelfVo();
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
String name = bookEntity.getName();
|
||||
String images = bookEntity.getImages();
|
||||
String authorId = bookEntity.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
//3. 根据 userid bookid 查询书籍 阅读进度
|
||||
|
||||
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookid));
|
||||
// BookReadRateEntity bookReadRateEntity = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>()
|
||||
// .eq("user_id", userId)
|
||||
// .eq("book_id", bookid));
|
||||
String percent = "";
|
||||
if (bookReadRateEntity == null) {
|
||||
|
||||
percent = "0%";
|
||||
} else {
|
||||
Integer chapterId = bookReadRateEntity.getChapterId();
|
||||
String chapterName = bookReadRateEntity.getChapterName();
|
||||
//4. 根据 章节id 去书籍表查询
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(bookReadRateEntity.getContentId());
|
||||
if (bookChapterEntity == null) {
|
||||
percent = "0%";
|
||||
}else {
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
BookChapterEntity book_id = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
|
||||
.select("max(number) as number")
|
||||
.eq("book_id", bookid));
|
||||
|
||||
Integer idNumber = book_id.getNumber();
|
||||
if (idNumber == 0){
|
||||
percent = "0%";
|
||||
}else {
|
||||
|
||||
//todo 章节号等于3 idnumber章节数13 3除以13等于阅读进度
|
||||
float xx = (float)number / idNumber;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("##.00%");
|
||||
|
||||
if (Math.abs(xx) < 0.000000000001) {
|
||||
percent = "0.00%";
|
||||
} else {
|
||||
percent = df.format(xx);
|
||||
}
|
||||
bookShelfVo.setChapterNum(number);
|
||||
}
|
||||
}
|
||||
bookShelfVo.setChapterId(chapterId);
|
||||
bookShelfVo.setChapterName(chapterName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bookShelfVo.setBookShelfId(bookShelfEntity.getId());
|
||||
bookShelfVo.setBookid(bookid);
|
||||
bookShelfVo.setBookName(name);
|
||||
bookShelfVo.setAuthorName(authorName);
|
||||
bookShelfVo.setImage(images);
|
||||
bookShelfVo.setPrecent(percent);
|
||||
list.add(bookShelfVo);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookShelfVo> getUserBookChapterRead(Integer userId) {
|
||||
List list = new ArrayList();
|
||||
|
||||
//1.获取 用户的 书架列表
|
||||
|
||||
List<BookShelfEntity> bookShelf = this.baseMapper.selectList(new QueryWrapper<BookShelfEntity>().eq("user_id", userId).orderByDesc("update_time"));
|
||||
//2. 遍历 获取书 的 详情
|
||||
for (BookShelfEntity bookShelfEntity : bookShelf) {
|
||||
String authorName = "";
|
||||
Integer bookid = bookShelfEntity.getBookId();
|
||||
BookShelfVo bookShelfVo = new BookShelfVo();
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
String name = bookEntity.getName();
|
||||
String images = bookEntity.getImages();
|
||||
String authorId = bookEntity.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
//3. 根据 userid bookid 查询书籍 阅读进度
|
||||
|
||||
// BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
|
||||
// .eq("user_id", userId)
|
||||
// .eq("book_id", bookid));
|
||||
|
||||
BookListeningEntity bookListeningEntity = bookListeningService.getBaseMapper().selectOne(new QueryWrapper<BookListeningEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookid));
|
||||
|
||||
String percent = "";
|
||||
if (bookListeningEntity == null) {
|
||||
|
||||
percent = "0%";
|
||||
} else {
|
||||
Integer chapterId = bookListeningEntity.getChapterId();
|
||||
String chapterName = bookListeningEntity.getChapterName();
|
||||
//4. 根据 章节id 去书籍表查询
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(bookListeningEntity.getContentId());
|
||||
if (bookChapterEntity == null) {
|
||||
percent = "0%";
|
||||
}else {
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
BookChapterEntity book_id = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
|
||||
.select("max(number) as number")
|
||||
.eq("book_id", bookid));
|
||||
|
||||
Integer idNumber = book_id.getNumber();
|
||||
if (idNumber == 0){
|
||||
percent = "0%";
|
||||
}else {
|
||||
|
||||
//todo 章节号等于3 idnumber章节数13 3除以13等于阅读进度
|
||||
float xx = (float)number / idNumber;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("##.00%");
|
||||
|
||||
// float xx = (float) number / idNumber;
|
||||
// int df = (int) (xx * 3600); // 将百分比转换为秒数
|
||||
|
||||
if (Math.abs(xx) < 0.000000000001) {
|
||||
percent = "0.00%";
|
||||
} else {
|
||||
percent = df.format(xx);
|
||||
}
|
||||
bookShelfVo.setChapterNum(number);
|
||||
}
|
||||
}
|
||||
bookShelfVo.setChapterId(chapterId);
|
||||
bookShelfVo.setChapterName(chapterName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bookShelfVo.setBookShelfId(bookShelfEntity.getId());
|
||||
bookShelfVo.setBookid(bookid);
|
||||
bookShelfVo.setBookName(name);
|
||||
bookShelfVo.setAuthorName(authorName);
|
||||
bookShelfVo.setImage(images);
|
||||
bookShelfVo.setPrecent(percent);
|
||||
list.add(bookShelfVo);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.BookShelfVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BookShelfDao;
|
||||
|
||||
|
||||
@Service("bookShelfService")
|
||||
public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEntity> implements BookShelfService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookListeningService bookListeningService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookShelfEntity> page = this.page(
|
||||
new Query<BookShelfEntity>().getPage(params),
|
||||
new QueryWrapper<BookShelfEntity>().orderByDesc("update_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookShelfVo> getUserBookshelf(Integer userId) {
|
||||
|
||||
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
//1.获取 用户的 书架列表
|
||||
|
||||
List<BookShelfEntity> bookShelf = this.baseMapper.selectList(new QueryWrapper<BookShelfEntity>().eq("user_id", userId).orderByDesc("update_time"));
|
||||
//2. 遍历 获取书 的 详情
|
||||
for (BookShelfEntity bookShelfEntity : bookShelf) {
|
||||
String authorName = "";
|
||||
Integer bookid = bookShelfEntity.getBookId();
|
||||
BookShelfVo bookShelfVo = new BookShelfVo();
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
String name = bookEntity.getName();
|
||||
String images = bookEntity.getImages();
|
||||
String authorId = bookEntity.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
//3. 根据 userid bookid 查询书籍 阅读进度
|
||||
|
||||
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookid));
|
||||
// BookReadRateEntity bookReadRateEntity = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>()
|
||||
// .eq("user_id", userId)
|
||||
// .eq("book_id", bookid));
|
||||
String percent = "";
|
||||
if (bookReadRateEntity == null) {
|
||||
|
||||
percent = "0%";
|
||||
} else {
|
||||
Integer chapterId = bookReadRateEntity.getChapterId();
|
||||
String chapterName = bookReadRateEntity.getChapterName();
|
||||
//4. 根据 章节id 去书籍表查询
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(bookReadRateEntity.getContentId());
|
||||
if (bookChapterEntity == null) {
|
||||
percent = "0%";
|
||||
}else {
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
BookChapterEntity book_id = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
|
||||
.select("max(number) as number")
|
||||
.eq("book_id", bookid));
|
||||
|
||||
Integer idNumber = book_id.getNumber();
|
||||
if (idNumber == 0){
|
||||
percent = "0%";
|
||||
}else {
|
||||
|
||||
//todo 章节号等于3 idnumber章节数13 3除以13等于阅读进度
|
||||
float xx = (float)number / idNumber;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("##.00%");
|
||||
|
||||
if (Math.abs(xx) < 0.000000000001) {
|
||||
percent = "0.00%";
|
||||
} else {
|
||||
percent = df.format(xx);
|
||||
}
|
||||
bookShelfVo.setChapterNum(number);
|
||||
}
|
||||
}
|
||||
bookShelfVo.setChapterId(chapterId);
|
||||
bookShelfVo.setChapterName(chapterName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bookShelfVo.setBookShelfId(bookShelfEntity.getId());
|
||||
bookShelfVo.setBookid(bookid);
|
||||
bookShelfVo.setBookName(name);
|
||||
bookShelfVo.setAuthorName(authorName);
|
||||
bookShelfVo.setImage(images);
|
||||
bookShelfVo.setPrecent(percent);
|
||||
list.add(bookShelfVo);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookShelfVo> getUserBookChapterRead(Integer userId) {
|
||||
List list = new ArrayList();
|
||||
|
||||
//1.获取 用户的 书架列表
|
||||
|
||||
List<BookShelfEntity> bookShelf = this.baseMapper.selectList(new QueryWrapper<BookShelfEntity>().eq("user_id", userId).orderByDesc("update_time"));
|
||||
//2. 遍历 获取书 的 详情
|
||||
for (BookShelfEntity bookShelfEntity : bookShelf) {
|
||||
String authorName = "";
|
||||
Integer bookid = bookShelfEntity.getBookId();
|
||||
BookShelfVo bookShelfVo = new BookShelfVo();
|
||||
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
|
||||
String name = bookEntity.getName();
|
||||
String images = bookEntity.getImages();
|
||||
String authorId = bookEntity.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
//3. 根据 userid bookid 查询书籍 阅读进度
|
||||
|
||||
// BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
|
||||
// .eq("user_id", userId)
|
||||
// .eq("book_id", bookid));
|
||||
|
||||
BookListeningEntity bookListeningEntity = bookListeningService.getBaseMapper().selectOne(new QueryWrapper<BookListeningEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookid));
|
||||
|
||||
String percent = "";
|
||||
if (bookListeningEntity == null) {
|
||||
|
||||
percent = "0%";
|
||||
} else {
|
||||
Integer chapterId = bookListeningEntity.getChapterId();
|
||||
String chapterName = bookListeningEntity.getChapterName();
|
||||
//4. 根据 章节id 去书籍表查询
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(bookListeningEntity.getContentId());
|
||||
if (bookChapterEntity == null) {
|
||||
percent = "0%";
|
||||
}else {
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
BookChapterEntity book_id = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
|
||||
.select("max(number) as number")
|
||||
.eq("book_id", bookid));
|
||||
|
||||
Integer idNumber = book_id.getNumber();
|
||||
if (idNumber == 0){
|
||||
percent = "0%";
|
||||
}else {
|
||||
|
||||
//todo 章节号等于3 idnumber章节数13 3除以13等于阅读进度
|
||||
float xx = (float)number / idNumber;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("##.00%");
|
||||
|
||||
// float xx = (float) number / idNumber;
|
||||
// int df = (int) (xx * 3600); // 将百分比转换为秒数
|
||||
|
||||
if (Math.abs(xx) < 0.000000000001) {
|
||||
percent = "0.00%";
|
||||
} else {
|
||||
percent = df.format(xx);
|
||||
}
|
||||
bookShelfVo.setChapterNum(number);
|
||||
}
|
||||
}
|
||||
bookShelfVo.setChapterId(chapterId);
|
||||
bookShelfVo.setChapterName(chapterName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bookShelfVo.setBookShelfId(bookShelfEntity.getId());
|
||||
bookShelfVo.setBookid(bookid);
|
||||
bookShelfVo.setBookName(name);
|
||||
bookShelfVo.setAuthorName(authorName);
|
||||
bookShelfVo.setImage(images);
|
||||
bookShelfVo.setPrecent(percent);
|
||||
list.add(bookShelfVo);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,42 +1,42 @@
|
||||
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.BookTaskDao;
|
||||
import com.peanut.modules.book.entity.BookTaskEntity;
|
||||
import com.peanut.modules.book.service.BookTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookTaskServiceImpl extends ServiceImpl<BookTaskDao, BookTaskEntity> implements BookTaskService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object bookid = params.get("bookid");
|
||||
IPage<BookTaskEntity> page = this.page(
|
||||
new Query<BookTaskEntity>().getPage(params),
|
||||
new QueryWrapper<BookTaskEntity>().eq("book_id",bookid).orderByAsc("days")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageServi(Map<String, Object> params) {
|
||||
Object bookid = params.get("bookid");
|
||||
Object days = params.get("days");
|
||||
IPage<BookTaskEntity> page = this.page(
|
||||
new Query<BookTaskEntity>().getPage(params),
|
||||
new QueryWrapper<BookTaskEntity>().eq("book_id",bookid).orderByDesc("create_time").eq("days",days)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
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.BookTaskDao;
|
||||
import com.peanut.modules.book.entity.BookTaskEntity;
|
||||
import com.peanut.modules.book.service.BookTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class BookTaskServiceImpl extends ServiceImpl<BookTaskDao, BookTaskEntity> implements BookTaskService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object bookid = params.get("bookid");
|
||||
IPage<BookTaskEntity> page = this.page(
|
||||
new Query<BookTaskEntity>().getPage(params),
|
||||
new QueryWrapper<BookTaskEntity>().eq("book_id",bookid).orderByAsc("days")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageServi(Map<String, Object> params) {
|
||||
Object bookid = params.get("bookid");
|
||||
Object days = params.get("days");
|
||||
IPage<BookTaskEntity> page = this.page(
|
||||
new Query<BookTaskEntity>().getPage(params),
|
||||
new QueryWrapper<BookTaskEntity>().eq("book_id",bookid).orderByDesc("create_time").eq("days",days)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +1,98 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import jodd.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.awt.print.Book;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BuyOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
|
||||
|
||||
@Service("buyOrderDetailService")
|
||||
public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, BuyOrderDetailEntity> implements BuyOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Integer orderId = Integer.valueOf((String) params.get("orderId"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id",orderId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 去重查询未打印的面单信息
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageUtils querySheet(Map<String, Object> params) {
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>().eq("is_print","0")
|
||||
.groupBy("shipping_sn")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils querybuy(Map<String, Object> params) {
|
||||
Integer userid = Integer.valueOf((String) params.get("id"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("user_id",userid)
|
||||
|
||||
);
|
||||
System.out.println("=====querybuy=====userid================"+userid);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils querybuyss(Map<String, Object> params) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void batchUpdateByShippingSns(String[] shippingSnList) {
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntityList = this.list(new QueryWrapper<BuyOrderDetailEntity>());
|
||||
for(String sn : shippingSnList){
|
||||
for(BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntityList){
|
||||
if(StringUtil.isNotEmpty(buyOrderDetailEntity.getShippingSn()) && buyOrderDetailEntity.getShippingSn().equals(sn)){
|
||||
buyOrderDetailEntity.setIsPrint("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateBatchById(buyOrderDetailEntityList);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import jodd.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.awt.print.Book;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BuyOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
|
||||
|
||||
@Service("buyOrderDetailService")
|
||||
public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, BuyOrderDetailEntity> implements BuyOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Integer orderId = Integer.valueOf((String) params.get("orderId"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id",orderId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 去重查询未打印的面单信息
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageUtils querySheet(Map<String, Object> params) {
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>().eq("is_print","0")
|
||||
.groupBy("shipping_sn")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils querybuy(Map<String, Object> params) {
|
||||
Integer userid = Integer.valueOf((String) params.get("id"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("user_id",userid)
|
||||
|
||||
);
|
||||
System.out.println("=====querybuy=====userid================"+userid);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils querybuyss(Map<String, Object> params) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void batchUpdateByShippingSns(String[] shippingSnList) {
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntityList = this.list(new QueryWrapper<BuyOrderDetailEntity>());
|
||||
for(String sn : shippingSnList){
|
||||
for(BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntityList){
|
||||
if(StringUtil.isNotEmpty(buyOrderDetailEntity.getShippingSn()) && buyOrderDetailEntity.getShippingSn().equals(sn)){
|
||||
buyOrderDetailEntity.setIsPrint("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateBatchById(buyOrderDetailEntityList);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CityDao;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
|
||||
|
||||
@Service("cityService")
|
||||
public class CityServiceImpl extends ServiceImpl<CityDao, CityEntity> implements CityService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CityEntity> page = this.page(
|
||||
new Query<CityEntity>().getPage(params),
|
||||
new QueryWrapper<CityEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CityDao;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
|
||||
|
||||
@Service("cityService")
|
||||
public class CityServiceImpl extends ServiceImpl<CityDao, CityEntity> implements CityService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CityEntity> page = this.page(
|
||||
new Query<CityEntity>().getPage(params),
|
||||
new QueryWrapper<CityEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CountyDao;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
|
||||
|
||||
@Service("countyService")
|
||||
public class CountyServiceImpl extends ServiceImpl<CountyDao, CountyEntity> implements CountyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CountyEntity> page = this.page(
|
||||
new Query<CountyEntity>().getPage(params),
|
||||
new QueryWrapper<CountyEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CountyDao;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
|
||||
|
||||
@Service("countyService")
|
||||
public class CountyServiceImpl extends ServiceImpl<CountyDao, CountyEntity> implements CountyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CountyEntity> page = this.page(
|
||||
new Query<CountyEntity>().getPage(params),
|
||||
new QueryWrapper<CountyEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,244 +1,244 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.DateUtil;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
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.CouponHistoryDao;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Slf4j
|
||||
@Service("couponHistoryService")
|
||||
public class CouponHistoryServiceImpl extends ServiceImpl<CouponHistoryDao, CouponHistoryEntity> implements CouponHistoryService {
|
||||
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponProductCategoryRelationService categoryRelationService;
|
||||
@Autowired
|
||||
private CouponProductRelationService productRelationService;
|
||||
@Autowired
|
||||
private ShopProductServiceImpl shopProductService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
IPage<CouponHistoryEntity> page = this.page(
|
||||
new Query<CouponHistoryEntity>().getPage(params),
|
||||
new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq(StringUtils.isNotBlank(userId), "member_id", Integer.parseInt(userId))
|
||||
);
|
||||
List<CouponHistoryEntity> records = page.getRecords();
|
||||
for (CouponHistoryEntity record : records) {
|
||||
Long couponId = record.getCouponId();
|
||||
CouponEntity byId = couponService.getById(couponId);
|
||||
if(byId != null) {
|
||||
record.setCouponName(byId.getCouponName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void runCouponsUserStatusTimeOutToExpired() {
|
||||
log.info("runCouponsUserStatusTimeOutToExpired start.......time={}", System.currentTimeMillis());
|
||||
Long startTime01 = System.currentTimeMillis();
|
||||
//查找到所有用户已领取,但未使用的用户券列表
|
||||
List<CouponHistoryEntity> couponsUserList = findListByUseStatus();
|
||||
log.info("runCouponsUserStatusTimeOutToExpired couponsUserList.size={}", couponsUserList.size());
|
||||
if (couponsUserList.size() > 0) {
|
||||
List<CouponHistoryEntity> needCouponsUserList = new ArrayList<>();
|
||||
Date currentDate = new Date();
|
||||
for (int i = 0; i < couponsUserList.size(); i++) {
|
||||
CouponHistoryEntity couponsUser = couponsUserList.get(i);
|
||||
Long couponId = couponsUser.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
Date effDate = couponEntity.getTakeEffectDate();
|
||||
Date expDate = couponEntity.getExpirationDate();
|
||||
boolean isEffective = DateUtil.isEffectiveDate(currentDate, effDate, expDate);
|
||||
//券已失效 则修改用户券的状态为已过期
|
||||
if (!isEffective) {
|
||||
couponsUser.setUseStatus(2);
|
||||
needCouponsUserList.add(couponsUser); //需要更新状态的券
|
||||
couponEntity.setCurrentState("2");
|
||||
this.couponService.updateById(couponEntity);
|
||||
}
|
||||
}
|
||||
|
||||
if (needCouponsUserList.size() > 0) {
|
||||
log.info("runCouponsUserStatusTimeOutToExpired update needCouponsUserList.size={}", needCouponsUserList.size());
|
||||
saveOrUpdateBatch(needCouponsUserList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Long endTime02 = System.currentTimeMillis();
|
||||
log.info("runCouponsUserStatusTimeOutToExpired end second={},mills={}", (endTime02 - startTime01) / 1000, (endTime02 - startTime01) % 1000);
|
||||
}
|
||||
|
||||
private List<CouponHistoryEntity> findListByUseStatus() {
|
||||
List<CouponHistoryEntity> list = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>().eq("use_status", 0));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CouponEntity> appGetCoupon() {
|
||||
|
||||
//获取 当前时间 有效期内的优惠券
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
List<CouponEntity> list = new ArrayList<>();
|
||||
|
||||
List<CouponEntity> couponEntityList = couponService.list(new QueryWrapper<CouponEntity>());
|
||||
|
||||
for (CouponEntity couponEntity : couponEntityList) {
|
||||
Date endTime = couponEntity.getTakeEffectDate();
|
||||
Date enableTime = couponEntity.getTakeEffectDate();
|
||||
// 判断结束日期 是否大于 当前 时间 以及 领取日期 是否 小于当前日期
|
||||
if (endTime.getTime() - date.getTime() > 0 && enableTime.getTime() - date.getTime() <= 0) {
|
||||
list.add(couponEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCouponVo> appGetUserCoupon(Integer userId, String amount,String type) {
|
||||
|
||||
// 查询用户当前 拥有的优惠券
|
||||
// 商品 :0 ,电子书 :1
|
||||
List<CouponHistoryEntity> couponHistoryEntities = null;
|
||||
if("0".equals(type)){
|
||||
couponHistoryEntities = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", 0)
|
||||
.eq("coupon_pro_type","0")
|
||||
);
|
||||
}else{
|
||||
couponHistoryEntities = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", 0)
|
||||
.eq("coupon_pro_type","1")
|
||||
);
|
||||
}
|
||||
|
||||
// 可使用优惠券列表
|
||||
ArrayList<UserCouponVo> list = new ArrayList<>();
|
||||
|
||||
for (CouponHistoryEntity couponHistoryEntity : couponHistoryEntities) {
|
||||
Long couponId = couponHistoryEntity.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
// 判断当前优惠券是否过期
|
||||
Date startTime = couponEntity.getExpirationDate();
|
||||
// 判断结束日期 是否大于 当前 时间
|
||||
if (startTime.after(new Date())){
|
||||
if(Integer.parseInt(amount) >= couponEntity.getUseLevel()){
|
||||
UserCouponVo userCouponVo = new UserCouponVo();
|
||||
BeanUtils.copyProperties(couponHistoryEntity, userCouponVo);
|
||||
userCouponVo.setCoupons(couponEntity);
|
||||
list.add(userCouponVo);
|
||||
}
|
||||
// boolean result = couponCanUseCategory(products, couponId, String.valueOf(couponEntity.getCouponType()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
// 判断组合分类 是否 符合优惠券规则
|
||||
private boolean couponCanUseCategory(String products, Long couponId, String userType) {
|
||||
|
||||
List list1 = new ArrayList<>();
|
||||
|
||||
if (!userType.equals("0")) {
|
||||
|
||||
if (userType.equals("1")) {
|
||||
|
||||
List<CouponProductCategoryRelationEntity> couponC = categoryRelationService.getBaseMapper().selectList(new QueryWrapper<CouponProductCategoryRelationEntity>()
|
||||
.eq("coupon_id", couponId));
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
String[] split = products.split(",");
|
||||
for (CouponProductCategoryRelationEntity couponProductCategoryRelationEntity : couponC) {
|
||||
// platform 0 1.判断商品 是否为 同一分类下
|
||||
|
||||
for (String s : split) {
|
||||
// 多商品的 判断商品 是否为同一个分类 下
|
||||
ShopProductEntity spe = shopProductService.getById(Integer.parseInt(s));
|
||||
Integer productPid = spe.getProductPid();
|
||||
Long productCategoryId = couponProductCategoryRelationEntity.getProductCategoryId();
|
||||
if (productCategoryId.intValue() == productPid) {
|
||||
list.add(productCategoryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (split.length == list.size()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else if (userType.equals("2")) {
|
||||
|
||||
List<CouponProductRelationEntity> couponC = productRelationService.getBaseMapper().selectList(new QueryWrapper<CouponProductRelationEntity>()
|
||||
.eq("coupon_id", couponId));
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
String[] split = products.split(",");
|
||||
for (CouponProductRelationEntity couponProductCategoryRelationEntity : couponC) {
|
||||
// platform 0 1.判断商品 是否为 同一分类下
|
||||
for (String s : split) {
|
||||
// 多商品的 判断商品 是否为同一个分类 下
|
||||
// Long productId = couponProductCategoryRelationEntity.getProductId();
|
||||
Long productId = couponProductCategoryRelationEntity.getProductId();
|
||||
if (Long.parseLong(s) == productId) {
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (split.length == list.size()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.DateUtil;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
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.CouponHistoryDao;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Slf4j
|
||||
@Service("couponHistoryService")
|
||||
public class CouponHistoryServiceImpl extends ServiceImpl<CouponHistoryDao, CouponHistoryEntity> implements CouponHistoryService {
|
||||
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponProductCategoryRelationService categoryRelationService;
|
||||
@Autowired
|
||||
private CouponProductRelationService productRelationService;
|
||||
@Autowired
|
||||
private ShopProductServiceImpl shopProductService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
IPage<CouponHistoryEntity> page = this.page(
|
||||
new Query<CouponHistoryEntity>().getPage(params),
|
||||
new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq(StringUtils.isNotBlank(userId), "member_id", Integer.parseInt(userId))
|
||||
);
|
||||
List<CouponHistoryEntity> records = page.getRecords();
|
||||
for (CouponHistoryEntity record : records) {
|
||||
Long couponId = record.getCouponId();
|
||||
CouponEntity byId = couponService.getById(couponId);
|
||||
if(byId != null) {
|
||||
record.setCouponName(byId.getCouponName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void runCouponsUserStatusTimeOutToExpired() {
|
||||
log.info("runCouponsUserStatusTimeOutToExpired start.......time={}", System.currentTimeMillis());
|
||||
Long startTime01 = System.currentTimeMillis();
|
||||
//查找到所有用户已领取,但未使用的用户券列表
|
||||
List<CouponHistoryEntity> couponsUserList = findListByUseStatus();
|
||||
log.info("runCouponsUserStatusTimeOutToExpired couponsUserList.size={}", couponsUserList.size());
|
||||
if (couponsUserList.size() > 0) {
|
||||
List<CouponHistoryEntity> needCouponsUserList = new ArrayList<>();
|
||||
Date currentDate = new Date();
|
||||
for (int i = 0; i < couponsUserList.size(); i++) {
|
||||
CouponHistoryEntity couponsUser = couponsUserList.get(i);
|
||||
Long couponId = couponsUser.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
Date effDate = couponEntity.getTakeEffectDate();
|
||||
Date expDate = couponEntity.getExpirationDate();
|
||||
boolean isEffective = DateUtil.isEffectiveDate(currentDate, effDate, expDate);
|
||||
//券已失效 则修改用户券的状态为已过期
|
||||
if (!isEffective) {
|
||||
couponsUser.setUseStatus(2);
|
||||
needCouponsUserList.add(couponsUser); //需要更新状态的券
|
||||
couponEntity.setCurrentState("2");
|
||||
this.couponService.updateById(couponEntity);
|
||||
}
|
||||
}
|
||||
|
||||
if (needCouponsUserList.size() > 0) {
|
||||
log.info("runCouponsUserStatusTimeOutToExpired update needCouponsUserList.size={}", needCouponsUserList.size());
|
||||
saveOrUpdateBatch(needCouponsUserList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Long endTime02 = System.currentTimeMillis();
|
||||
log.info("runCouponsUserStatusTimeOutToExpired end second={},mills={}", (endTime02 - startTime01) / 1000, (endTime02 - startTime01) % 1000);
|
||||
}
|
||||
|
||||
private List<CouponHistoryEntity> findListByUseStatus() {
|
||||
List<CouponHistoryEntity> list = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>().eq("use_status", 0));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CouponEntity> appGetCoupon() {
|
||||
|
||||
//获取 当前时间 有效期内的优惠券
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
List<CouponEntity> list = new ArrayList<>();
|
||||
|
||||
List<CouponEntity> couponEntityList = couponService.list(new QueryWrapper<CouponEntity>());
|
||||
|
||||
for (CouponEntity couponEntity : couponEntityList) {
|
||||
Date endTime = couponEntity.getTakeEffectDate();
|
||||
Date enableTime = couponEntity.getTakeEffectDate();
|
||||
// 判断结束日期 是否大于 当前 时间 以及 领取日期 是否 小于当前日期
|
||||
if (endTime.getTime() - date.getTime() > 0 && enableTime.getTime() - date.getTime() <= 0) {
|
||||
list.add(couponEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCouponVo> appGetUserCoupon(Integer userId, String amount,String type) {
|
||||
|
||||
// 查询用户当前 拥有的优惠券
|
||||
// 商品 :0 ,电子书 :1
|
||||
List<CouponHistoryEntity> couponHistoryEntities = null;
|
||||
if("0".equals(type)){
|
||||
couponHistoryEntities = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", 0)
|
||||
.eq("coupon_pro_type","0")
|
||||
);
|
||||
}else{
|
||||
couponHistoryEntities = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", 0)
|
||||
.eq("coupon_pro_type","1")
|
||||
);
|
||||
}
|
||||
|
||||
// 可使用优惠券列表
|
||||
ArrayList<UserCouponVo> list = new ArrayList<>();
|
||||
|
||||
for (CouponHistoryEntity couponHistoryEntity : couponHistoryEntities) {
|
||||
Long couponId = couponHistoryEntity.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
// 判断当前优惠券是否过期
|
||||
Date startTime = couponEntity.getExpirationDate();
|
||||
// 判断结束日期 是否大于 当前 时间
|
||||
if (startTime.after(new Date())){
|
||||
if(Integer.parseInt(amount) >= couponEntity.getUseLevel()){
|
||||
UserCouponVo userCouponVo = new UserCouponVo();
|
||||
BeanUtils.copyProperties(couponHistoryEntity, userCouponVo);
|
||||
userCouponVo.setCoupons(couponEntity);
|
||||
list.add(userCouponVo);
|
||||
}
|
||||
// boolean result = couponCanUseCategory(products, couponId, String.valueOf(couponEntity.getCouponType()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
// 判断组合分类 是否 符合优惠券规则
|
||||
private boolean couponCanUseCategory(String products, Long couponId, String userType) {
|
||||
|
||||
List list1 = new ArrayList<>();
|
||||
|
||||
if (!userType.equals("0")) {
|
||||
|
||||
if (userType.equals("1")) {
|
||||
|
||||
List<CouponProductCategoryRelationEntity> couponC = categoryRelationService.getBaseMapper().selectList(new QueryWrapper<CouponProductCategoryRelationEntity>()
|
||||
.eq("coupon_id", couponId));
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
String[] split = products.split(",");
|
||||
for (CouponProductCategoryRelationEntity couponProductCategoryRelationEntity : couponC) {
|
||||
// platform 0 1.判断商品 是否为 同一分类下
|
||||
|
||||
for (String s : split) {
|
||||
// 多商品的 判断商品 是否为同一个分类 下
|
||||
ShopProductEntity spe = shopProductService.getById(Integer.parseInt(s));
|
||||
Integer productPid = spe.getProductPid();
|
||||
Long productCategoryId = couponProductCategoryRelationEntity.getProductCategoryId();
|
||||
if (productCategoryId.intValue() == productPid) {
|
||||
list.add(productCategoryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (split.length == list.size()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else if (userType.equals("2")) {
|
||||
|
||||
List<CouponProductRelationEntity> couponC = productRelationService.getBaseMapper().selectList(new QueryWrapper<CouponProductRelationEntity>()
|
||||
.eq("coupon_id", couponId));
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
String[] split = products.split(",");
|
||||
for (CouponProductRelationEntity couponProductCategoryRelationEntity : couponC) {
|
||||
// platform 0 1.判断商品 是否为 同一分类下
|
||||
for (String s : split) {
|
||||
// 多商品的 判断商品 是否为同一个分类 下
|
||||
// Long productId = couponProductCategoryRelationEntity.getProductId();
|
||||
Long productId = couponProductCategoryRelationEntity.getProductId();
|
||||
if (Long.parseLong(s) == productId) {
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (split.length == list.size()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CouponProductCategoryRelationDao;
|
||||
import com.peanut.modules.book.entity.CouponProductCategoryRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductCategoryRelationService;
|
||||
|
||||
|
||||
@Service("couponProductCategoryRelationService")
|
||||
public class CouponProductCategoryRelationServiceImpl extends ServiceImpl<CouponProductCategoryRelationDao, CouponProductCategoryRelationEntity> implements CouponProductCategoryRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String couponId = (String) params.get("couponId");
|
||||
IPage<CouponProductCategoryRelationEntity> page = this.page(
|
||||
new Query<CouponProductCategoryRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CouponProductCategoryRelationEntity>().eq("coupon_id",Integer.valueOf(couponId))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CouponProductCategoryRelationDao;
|
||||
import com.peanut.modules.book.entity.CouponProductCategoryRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductCategoryRelationService;
|
||||
|
||||
|
||||
@Service("couponProductCategoryRelationService")
|
||||
public class CouponProductCategoryRelationServiceImpl extends ServiceImpl<CouponProductCategoryRelationDao, CouponProductCategoryRelationEntity> implements CouponProductCategoryRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String couponId = (String) params.get("couponId");
|
||||
IPage<CouponProductCategoryRelationEntity> page = this.page(
|
||||
new Query<CouponProductCategoryRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CouponProductCategoryRelationEntity>().eq("coupon_id",Integer.valueOf(couponId))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CouponProductRelationDao;
|
||||
import com.peanut.modules.book.entity.CouponProductRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductRelationService;
|
||||
|
||||
|
||||
@Service("couponProductRelationService")
|
||||
public class CouponProductRelationServiceImpl extends ServiceImpl<CouponProductRelationDao, CouponProductRelationEntity> implements CouponProductRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String couponId = (String) params.get("couponId");
|
||||
IPage<CouponProductRelationEntity> page = this.page(
|
||||
new Query<CouponProductRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CouponProductRelationEntity>().eq("coupon_id",Integer.valueOf(couponId))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.CouponProductRelationDao;
|
||||
import com.peanut.modules.book.entity.CouponProductRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductRelationService;
|
||||
|
||||
|
||||
@Service("couponProductRelationService")
|
||||
public class CouponProductRelationServiceImpl extends ServiceImpl<CouponProductRelationDao, CouponProductRelationEntity> implements CouponProductRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String couponId = (String) params.get("couponId");
|
||||
IPage<CouponProductRelationEntity> page = this.page(
|
||||
new Query<CouponProductRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CouponProductRelationEntity>().eq("coupon_id",Integer.valueOf(couponId))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +1,45 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
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.CouponDao;
|
||||
import com.peanut.modules.book.entity.CouponEntity;
|
||||
import com.peanut.modules.book.service.CouponService;
|
||||
|
||||
|
||||
@Service("couponService")
|
||||
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CouponEntity> page = null;
|
||||
String cu = params.get("currentState").toString();
|
||||
if("0".equals(cu)){
|
||||
page = this.page(
|
||||
new Query<CouponEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<CouponEntity>().like("coupon_name",params.get("key"))
|
||||
);
|
||||
}else{
|
||||
page = this.page(
|
||||
new Query<CouponEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<CouponEntity>().eq("current_state",cu).like("coupon_name",params.get("key"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
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.CouponDao;
|
||||
import com.peanut.modules.book.entity.CouponEntity;
|
||||
import com.peanut.modules.book.service.CouponService;
|
||||
|
||||
|
||||
@Service("couponService")
|
||||
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CouponEntity> page = null;
|
||||
String cu = params.get("currentState").toString();
|
||||
if("0".equals(cu)){
|
||||
page = this.page(
|
||||
new Query<CouponEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<CouponEntity>().like("coupon_name",params.get("key"))
|
||||
);
|
||||
}else{
|
||||
page = this.page(
|
||||
new Query<CouponEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<CouponEntity>().eq("current_state",cu).like("coupon_name",params.get("key"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.dao.FMSOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.FMSOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.FMSOrderDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("fmsOrderService")
|
||||
public class FMSOrderDetailServiceImpl extends ServiceImpl<FMSOrderDetailDao, FMSOrderDetailEntity>
|
||||
implements FMSOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.dao.FMSOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.FMSOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.FMSOrderDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("fmsOrderService")
|
||||
public class FMSOrderDetailServiceImpl extends ServiceImpl<FMSOrderDetailDao, FMSOrderDetailEntity>
|
||||
implements FMSOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,412 +1,412 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.domain.Member;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.app.config.SMSConfig;
|
||||
import com.peanut.modules.app.config.Sample;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.mq.service.RabbitMqService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
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.modules.book.dao.MyUserDao;
|
||||
|
||||
@Slf4j
|
||||
@Service("myuserService")
|
||||
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private RabbitMqService rabbitMqService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private MyUserDao myUserDao;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<MyUserEntity> page = this.page(
|
||||
new Query<MyUserEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<MyUserEntity>().like("name",params.get("key")).or().eq("tel",params.get("key"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code) throws Exception {
|
||||
String scode = code.split("_")[0];
|
||||
sendCode(phone,scode);
|
||||
}
|
||||
|
||||
@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;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bookAuthen(Integer bookId, Integer userId) {
|
||||
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 openMember(Integer customerId,Integer openMonth) {
|
||||
|
||||
MyUserEntity user = this.getById(customerId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
long ttl = 0;
|
||||
Date validDate = new Date();
|
||||
Date date = new Date();
|
||||
if (user.getVip().equals("1")) {
|
||||
//如果当前已经是会员进行续期操作
|
||||
validDate = user.getVipValidtime();
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(validDate);
|
||||
|
||||
if (openMonth == 1){
|
||||
Integer openDays = 31;
|
||||
// 把日期往后增加一天,整数 往后推,负数往前移动
|
||||
calendar.add(Calendar.DAY_OF_YEAR, openDays);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}else {
|
||||
//月份
|
||||
calendar.add(Calendar.MONTH, openMonth);
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
//获取系统当前日期
|
||||
user.setVip("1");
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
|
||||
|
||||
if (openMonth == 1){
|
||||
Integer openDays = 31;
|
||||
// 把日期往后增加一天,整数 往后推,负数往前移动
|
||||
calendar.add(Calendar.DAY_OF_YEAR, openDays);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}else {
|
||||
//月份
|
||||
calendar.add(Calendar.MONTH, openMonth);
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}
|
||||
|
||||
}
|
||||
user.setVipStartTime(date);
|
||||
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
|
||||
//mq
|
||||
// 手动指定消息过期时间
|
||||
|
||||
Map<String, Object> msgMap = Maps.newHashMapWithExpectedSize(3);
|
||||
msgMap.put("msg", customerId);
|
||||
msgMap.put("time", LocalDateTime.now());
|
||||
msgMap.put("ttl", ttl);
|
||||
|
||||
// 注意这里发送的交换机是 延时交换机
|
||||
rabbitMqService.send(DelayQueueConfig.DELAY_EXCHANGE, DelayQueueConfig.DELAY_QUEUE_ROUTING_KEY, JSONObject.toJSONString(msgMap), ttl);
|
||||
log.info("消息发送成功:{}", JSONObject.toJSONString(msgMap));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rechargeHSPoint(Integer customerId,Integer HSPoint) {
|
||||
MyUserEntity user = this.getById(customerId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
BigDecimal hs = new BigDecimal(HSPoint);
|
||||
BigDecimal peanutCoin = user.getPeanutCoin();
|
||||
user.setPeanutCoin(peanutCoin.add(hs));
|
||||
this.updateById(user);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String buyEbook(String userId, String bookId,String couponId) {
|
||||
|
||||
String authorName = "";
|
||||
|
||||
//避免重复购买
|
||||
TransactionDetailsEntity entity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
.eq("relation_id", bookId));
|
||||
|
||||
if (entity != null) {
|
||||
return "余额不足,请充值!";
|
||||
}
|
||||
|
||||
CouponEntity coupon = this.couponService.getById(couponId);
|
||||
|
||||
BigDecimal salePrice = new BigDecimal(0);
|
||||
|
||||
|
||||
// 查询书籍 价格
|
||||
BookEntity book = bookService.getById(Integer.valueOf(bookId));
|
||||
|
||||
// 是否为秒杀
|
||||
|
||||
Integer isSale = book.getIsSale();
|
||||
|
||||
if(!ObjectUtils.isEmpty(coupon)){
|
||||
if (isSale == 1) {
|
||||
salePrice = book.getSalePrice().subtract(coupon.getCouponAmount());
|
||||
}else {
|
||||
salePrice = book.getPrice().subtract(coupon.getCouponAmount());
|
||||
}
|
||||
}else{
|
||||
if (isSale == 1) {
|
||||
salePrice = book.getSalePrice();
|
||||
}else {
|
||||
salePrice = book.getPrice();
|
||||
}
|
||||
}
|
||||
|
||||
//查询用户
|
||||
MyUserEntity user = this.getById(Integer.valueOf(userId));
|
||||
Double peanutCoin = user.getPeanutCoin().doubleValue() - salePrice.doubleValue();
|
||||
if (peanutCoin < 0) {
|
||||
return "当前书籍已购买,请勿重复购买!";
|
||||
}
|
||||
user.setPeanutCoin(new BigDecimal(peanutCoin));
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
TransactionDetailsEntity detailsEntity = new TransactionDetailsEntity();
|
||||
detailsEntity.setUserId(Integer.valueOf(userId));
|
||||
detailsEntity.setChangeAmount(salePrice.negate());
|
||||
detailsEntity.setUserBalance(user.getPeanutCoin());
|
||||
detailsEntity.setRemark("购买:"+book.getName());
|
||||
detailsEntity.setOrderType("购买电子书");
|
||||
detailsEntity.setRelationId(Integer.valueOf(bookId));
|
||||
detailsEntity.setUserName(user.getNickname());
|
||||
detailsEntity.setTel(user.getTel());
|
||||
transactionDetailsService.save(detailsEntity);
|
||||
|
||||
// 插入购买记录
|
||||
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
|
||||
userEbookBuyEntity.setUserId(Integer.valueOf(userId));
|
||||
userEbookBuyEntity.setBookId(Integer.valueOf(bookId));
|
||||
userEbookBuyEntity.setBookName(book.getName());
|
||||
String authorId = book.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
|
||||
|
||||
userEbookBuyEntity.setAuthor(authorName);
|
||||
userEbookBuyEntity.setImage(book.getImages());
|
||||
userEbookBuyEntity.setPayStatus("支付成功");
|
||||
userEbookBuyEntity.setPayType("point");
|
||||
userEbookBuyEntity.setPayTime(new Date());
|
||||
userEbookBuyService.save(userEbookBuyEntity);
|
||||
if(!ObjectUtils.isEmpty(coupon)){
|
||||
CouponHistoryEntity historyEntity = this.couponHistoryService.getOne(new QueryWrapper<CouponHistoryEntity>().eq("member_id", userId).eq("coupon_id", couponId));
|
||||
historyEntity.setUseStatus(1);
|
||||
this.couponHistoryService.updateById(historyEntity);
|
||||
}
|
||||
|
||||
|
||||
return "购买成功!";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
@Override
|
||||
public void update(MyUserEntity user) {
|
||||
myUserDao.update(user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信授权登录
|
||||
*
|
||||
* @param userAppAuthorEntity
|
||||
*/
|
||||
@Override
|
||||
public R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity) {
|
||||
|
||||
// todo CommConfig WeiXinParam 表未建
|
||||
try {
|
||||
Member member = new Member();
|
||||
BeanUtils.copyProperties(userAppAuthorEntity, member);
|
||||
|
||||
CommConfig commConfig = new CommConfig();
|
||||
//调用微信授权
|
||||
// WeixinLoginUtils appWeiXinUserInfo1 = weixinLoginUtils1.getAppWeiXinUserInfo(commConfig.);
|
||||
WeixinLoginUtils weixinLoginUtils = new WeixinLoginUtils();
|
||||
StringBuilder stringBuilder = weixinLoginUtils.getAccessTokenBycode(commConfig.getUserAppID(), commConfig.getUserAppSecret(), userAppAuthorEntity.getCode());
|
||||
if (stringBuilder != null) {
|
||||
if (stringBuilder.toString().trim().contains("errcode")) {
|
||||
return R.error();
|
||||
}
|
||||
JSONObject object = JSONObject.parseObject(stringBuilder.toString().trim());
|
||||
String accessToken = object.getString("access_token"); //接口调用凭证
|
||||
String openID = object.getString("openid"); //授权用户唯一标识
|
||||
//获取微信用户基本信息
|
||||
WeiXinParam appWeiXinUserInfo = weixinLoginUtils.getAppWeiXinUserInfo(accessToken, openID, WeiXinParam.class);
|
||||
// TODO 业务逻辑
|
||||
|
||||
return R.ok().put("member",member);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return R.ok("sec");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void sendCode(String phone,String code) throws Exception {
|
||||
com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret());
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||
.setSignName(smsConfig.getSingName())
|
||||
.setTemplateCode(smsConfig.getTemplateCode())
|
||||
.setPhoneNumbers(phone)
|
||||
.setTemplateParam("{\"code\":\""+ code +"\"}");
|
||||
RuntimeOptions runtime = new RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||
System.out.println(body.getMessage());
|
||||
|
||||
} catch (TeaException error) {
|
||||
// 如有需要,请打印 error
|
||||
Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 如有需要,请打印 error
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.domain.Member;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.app.config.SMSConfig;
|
||||
import com.peanut.modules.app.config.Sample;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.mq.service.RabbitMqService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
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.modules.book.dao.MyUserDao;
|
||||
|
||||
@Slf4j
|
||||
@Service("myuserService")
|
||||
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private RabbitMqService rabbitMqService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private MyUserDao myUserDao;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<MyUserEntity> page = this.page(
|
||||
new Query<MyUserEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<MyUserEntity>().like("name",params.get("key")).or().eq("tel",params.get("key"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code) throws Exception {
|
||||
String scode = code.split("_")[0];
|
||||
sendCode(phone,scode);
|
||||
}
|
||||
|
||||
@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;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bookAuthen(Integer bookId, Integer userId) {
|
||||
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 openMember(Integer customerId,Integer openMonth) {
|
||||
|
||||
MyUserEntity user = this.getById(customerId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
long ttl = 0;
|
||||
Date validDate = new Date();
|
||||
Date date = new Date();
|
||||
if (user.getVip().equals("1")) {
|
||||
//如果当前已经是会员进行续期操作
|
||||
validDate = user.getVipValidtime();
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(validDate);
|
||||
|
||||
if (openMonth == 1){
|
||||
Integer openDays = 31;
|
||||
// 把日期往后增加一天,整数 往后推,负数往前移动
|
||||
calendar.add(Calendar.DAY_OF_YEAR, openDays);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}else {
|
||||
//月份
|
||||
calendar.add(Calendar.MONTH, openMonth);
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
//获取系统当前日期
|
||||
user.setVip("1");
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
|
||||
|
||||
if (openMonth == 1){
|
||||
Integer openDays = 31;
|
||||
// 把日期往后增加一天,整数 往后推,负数往前移动
|
||||
calendar.add(Calendar.DAY_OF_YEAR, openDays);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}else {
|
||||
//月份
|
||||
calendar.add(Calendar.MONTH, openMonth);
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}
|
||||
|
||||
}
|
||||
user.setVipStartTime(date);
|
||||
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
|
||||
//mq
|
||||
// 手动指定消息过期时间
|
||||
|
||||
Map<String, Object> msgMap = Maps.newHashMapWithExpectedSize(3);
|
||||
msgMap.put("msg", customerId);
|
||||
msgMap.put("time", LocalDateTime.now());
|
||||
msgMap.put("ttl", ttl);
|
||||
|
||||
// 注意这里发送的交换机是 延时交换机
|
||||
rabbitMqService.send(DelayQueueConfig.DELAY_EXCHANGE, DelayQueueConfig.DELAY_QUEUE_ROUTING_KEY, JSONObject.toJSONString(msgMap), ttl);
|
||||
log.info("消息发送成功:{}", JSONObject.toJSONString(msgMap));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rechargeHSPoint(Integer customerId,Integer HSPoint) {
|
||||
MyUserEntity user = this.getById(customerId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
BigDecimal hs = new BigDecimal(HSPoint);
|
||||
BigDecimal peanutCoin = user.getPeanutCoin();
|
||||
user.setPeanutCoin(peanutCoin.add(hs));
|
||||
this.updateById(user);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String buyEbook(String userId, String bookId,String couponId) {
|
||||
|
||||
String authorName = "";
|
||||
|
||||
//避免重复购买
|
||||
TransactionDetailsEntity entity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
.eq("relation_id", bookId));
|
||||
|
||||
if (entity != null) {
|
||||
return "余额不足,请充值!";
|
||||
}
|
||||
|
||||
CouponEntity coupon = this.couponService.getById(couponId);
|
||||
|
||||
BigDecimal salePrice = new BigDecimal(0);
|
||||
|
||||
|
||||
// 查询书籍 价格
|
||||
BookEntity book = bookService.getById(Integer.valueOf(bookId));
|
||||
|
||||
// 是否为秒杀
|
||||
|
||||
Integer isSale = book.getIsSale();
|
||||
|
||||
if(!ObjectUtils.isEmpty(coupon)){
|
||||
if (isSale == 1) {
|
||||
salePrice = book.getSalePrice().subtract(coupon.getCouponAmount());
|
||||
}else {
|
||||
salePrice = book.getPrice().subtract(coupon.getCouponAmount());
|
||||
}
|
||||
}else{
|
||||
if (isSale == 1) {
|
||||
salePrice = book.getSalePrice();
|
||||
}else {
|
||||
salePrice = book.getPrice();
|
||||
}
|
||||
}
|
||||
|
||||
//查询用户
|
||||
MyUserEntity user = this.getById(Integer.valueOf(userId));
|
||||
Double peanutCoin = user.getPeanutCoin().doubleValue() - salePrice.doubleValue();
|
||||
if (peanutCoin < 0) {
|
||||
return "当前书籍已购买,请勿重复购买!";
|
||||
}
|
||||
user.setPeanutCoin(new BigDecimal(peanutCoin));
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
TransactionDetailsEntity detailsEntity = new TransactionDetailsEntity();
|
||||
detailsEntity.setUserId(Integer.valueOf(userId));
|
||||
detailsEntity.setChangeAmount(salePrice.negate());
|
||||
detailsEntity.setUserBalance(user.getPeanutCoin());
|
||||
detailsEntity.setRemark("购买:"+book.getName());
|
||||
detailsEntity.setOrderType("购买电子书");
|
||||
detailsEntity.setRelationId(Integer.valueOf(bookId));
|
||||
detailsEntity.setUserName(user.getNickname());
|
||||
detailsEntity.setTel(user.getTel());
|
||||
transactionDetailsService.save(detailsEntity);
|
||||
|
||||
// 插入购买记录
|
||||
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
|
||||
userEbookBuyEntity.setUserId(Integer.valueOf(userId));
|
||||
userEbookBuyEntity.setBookId(Integer.valueOf(bookId));
|
||||
userEbookBuyEntity.setBookName(book.getName());
|
||||
String authorId = book.getAuthorId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
|
||||
|
||||
userEbookBuyEntity.setAuthor(authorName);
|
||||
userEbookBuyEntity.setImage(book.getImages());
|
||||
userEbookBuyEntity.setPayStatus("支付成功");
|
||||
userEbookBuyEntity.setPayType("point");
|
||||
userEbookBuyEntity.setPayTime(new Date());
|
||||
userEbookBuyService.save(userEbookBuyEntity);
|
||||
if(!ObjectUtils.isEmpty(coupon)){
|
||||
CouponHistoryEntity historyEntity = this.couponHistoryService.getOne(new QueryWrapper<CouponHistoryEntity>().eq("member_id", userId).eq("coupon_id", couponId));
|
||||
historyEntity.setUseStatus(1);
|
||||
this.couponHistoryService.updateById(historyEntity);
|
||||
}
|
||||
|
||||
|
||||
return "购买成功!";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
@Override
|
||||
public void update(MyUserEntity user) {
|
||||
myUserDao.update(user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信授权登录
|
||||
*
|
||||
* @param userAppAuthorEntity
|
||||
*/
|
||||
@Override
|
||||
public R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity) {
|
||||
|
||||
// todo CommConfig WeiXinParam 表未建
|
||||
try {
|
||||
Member member = new Member();
|
||||
BeanUtils.copyProperties(userAppAuthorEntity, member);
|
||||
|
||||
CommConfig commConfig = new CommConfig();
|
||||
//调用微信授权
|
||||
// WeixinLoginUtils appWeiXinUserInfo1 = weixinLoginUtils1.getAppWeiXinUserInfo(commConfig.);
|
||||
WeixinLoginUtils weixinLoginUtils = new WeixinLoginUtils();
|
||||
StringBuilder stringBuilder = weixinLoginUtils.getAccessTokenBycode(commConfig.getUserAppID(), commConfig.getUserAppSecret(), userAppAuthorEntity.getCode());
|
||||
if (stringBuilder != null) {
|
||||
if (stringBuilder.toString().trim().contains("errcode")) {
|
||||
return R.error();
|
||||
}
|
||||
JSONObject object = JSONObject.parseObject(stringBuilder.toString().trim());
|
||||
String accessToken = object.getString("access_token"); //接口调用凭证
|
||||
String openID = object.getString("openid"); //授权用户唯一标识
|
||||
//获取微信用户基本信息
|
||||
WeiXinParam appWeiXinUserInfo = weixinLoginUtils.getAppWeiXinUserInfo(accessToken, openID, WeiXinParam.class);
|
||||
// TODO 业务逻辑
|
||||
|
||||
return R.ok().put("member",member);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return R.ok("sec");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void sendCode(String phone,String code) throws Exception {
|
||||
com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret());
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||
.setSignName(smsConfig.getSingName())
|
||||
.setTemplateCode(smsConfig.getTemplateCode())
|
||||
.setPhoneNumbers(phone)
|
||||
.setTemplateParam("{\"code\":\""+ code +"\"}");
|
||||
RuntimeOptions runtime = new RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||
System.out.println(body.getMessage());
|
||||
|
||||
} catch (TeaException error) {
|
||||
// 如有需要,请打印 error
|
||||
Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 如有需要,请打印 error
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,91 +1,91 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.vo.ShopCartVo;
|
||||
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;
|
||||
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.OrderCartDao;
|
||||
import com.peanut.modules.book.entity.OrderCartEntity;
|
||||
import com.peanut.modules.book.service.OrderCartService;
|
||||
|
||||
|
||||
@Service("orderCartService")
|
||||
public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEntity> implements OrderCartService {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<OrderCartEntity> page = this.page(
|
||||
new Query<OrderCartEntity>().getPage(params),
|
||||
new QueryWrapper<OrderCartEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCartVo> getCartList(Integer userId) {
|
||||
|
||||
List<OrderCartEntity> list = this.list(new QueryWrapper<OrderCartEntity>().eq("user_id", userId));
|
||||
|
||||
List cartList = new ArrayList<>();
|
||||
|
||||
for (OrderCartEntity orderCartEntity : list) {
|
||||
|
||||
Integer productId = orderCartEntity.getProductId();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(productId);
|
||||
// shopProductService.getBaseMapper().selectList()
|
||||
ShopCartVo shopCartVo = new ShopCartVo();
|
||||
|
||||
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
|
||||
|
||||
shopCartVo.setImage(productEntity.getProductImages());
|
||||
|
||||
shopCartVo.setProductName(productEntity.getProductName());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
return cartList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderCartEntity getDeteleOrderCarts(Integer userId, Integer productId) {
|
||||
return this.getBaseMapper().getDeteleOrderCart(userId,productId);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.vo.ShopCartVo;
|
||||
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;
|
||||
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.OrderCartDao;
|
||||
import com.peanut.modules.book.entity.OrderCartEntity;
|
||||
import com.peanut.modules.book.service.OrderCartService;
|
||||
|
||||
|
||||
@Service("orderCartService")
|
||||
public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEntity> implements OrderCartService {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<OrderCartEntity> page = this.page(
|
||||
new Query<OrderCartEntity>().getPage(params),
|
||||
new QueryWrapper<OrderCartEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCartVo> getCartList(Integer userId) {
|
||||
|
||||
List<OrderCartEntity> list = this.list(new QueryWrapper<OrderCartEntity>().eq("user_id", userId));
|
||||
|
||||
List cartList = new ArrayList<>();
|
||||
|
||||
for (OrderCartEntity orderCartEntity : list) {
|
||||
|
||||
Integer productId = orderCartEntity.getProductId();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(productId);
|
||||
// shopProductService.getBaseMapper().selectList()
|
||||
ShopCartVo shopCartVo = new ShopCartVo();
|
||||
|
||||
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
|
||||
|
||||
shopCartVo.setImage(productEntity.getProductImages());
|
||||
|
||||
shopCartVo.setProductName(productEntity.getProductName());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
return cartList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderCartEntity getDeteleOrderCarts(Integer userId, Integer productId) {
|
||||
return this.getBaseMapper().getDeteleOrderCart(userId,productId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +1,34 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.PayPaymentOrderDao;
|
||||
import com.peanut.modules.book.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.book.service.PayPaymentOrderService;
|
||||
|
||||
|
||||
@Service("payPaymentOrderService")
|
||||
public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao, PayPaymentOrderEntity> implements PayPaymentOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayPaymentOrderEntity> page = this.page(
|
||||
new Query<PayPaymentOrderEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<PayPaymentOrderEntity>()
|
||||
.eq("tel",params.get("key"))
|
||||
.or().like("user_name",params.get("key")).orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.PayPaymentOrderDao;
|
||||
import com.peanut.modules.book.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.book.service.PayPaymentOrderService;
|
||||
|
||||
|
||||
@Service("payPaymentOrderService")
|
||||
public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao, PayPaymentOrderEntity> implements PayPaymentOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayPaymentOrderEntity> page = this.page(
|
||||
new Query<PayPaymentOrderEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<PayPaymentOrderEntity>()
|
||||
.eq("tel",params.get("key"))
|
||||
.or().like("user_name",params.get("key")).orderByDesc("create_time")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
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.PayWechatOrderDao;
|
||||
import com.peanut.modules.book.entity.PayWechatOrderEntity;
|
||||
import com.peanut.modules.book.service.PayWechatOrderService;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("payWechatOrderService")
|
||||
public class PayWechatOrderServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOrderEntity> implements PayWechatOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayWechatOrderEntity> page = this.page(
|
||||
new Query<PayWechatOrderEntity>().getPage(params),
|
||||
new QueryWrapper<PayWechatOrderEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
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.PayWechatOrderDao;
|
||||
import com.peanut.modules.book.entity.PayWechatOrderEntity;
|
||||
import com.peanut.modules.book.service.PayWechatOrderService;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("payWechatOrderService")
|
||||
public class PayWechatOrderServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOrderEntity> implements PayWechatOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayWechatOrderEntity> page = this.page(
|
||||
new Query<PayWechatOrderEntity>().getPage(params),
|
||||
new QueryWrapper<PayWechatOrderEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.PayZfbOrderDao;
|
||||
import com.peanut.modules.book.entity.PayZfbOrderEntity;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
|
||||
|
||||
@Service("payZfbOrderService")
|
||||
public class PayZfbOrderServiceImpl extends ServiceImpl<PayZfbOrderDao, PayZfbOrderEntity> implements PayZfbOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayZfbOrderEntity> page = this.page(
|
||||
new Query<PayZfbOrderEntity>().getPage(params),
|
||||
new QueryWrapper<PayZfbOrderEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.PayZfbOrderDao;
|
||||
import com.peanut.modules.book.entity.PayZfbOrderEntity;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
|
||||
|
||||
@Service("payZfbOrderService")
|
||||
public class PayZfbOrderServiceImpl extends ServiceImpl<PayZfbOrderDao, PayZfbOrderEntity> implements PayZfbOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayZfbOrderEntity> page = this.page(
|
||||
new Query<PayZfbOrderEntity>().getPage(params),
|
||||
new QueryWrapper<PayZfbOrderEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +1,63 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.ProvinceDao;
|
||||
import com.peanut.modules.book.service.ProvinceService;
|
||||
|
||||
|
||||
@Service("provinceService")
|
||||
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, ProvinceEntity> implements ProvinceService {
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ProvinceEntity> page = this.page(
|
||||
new Query<ProvinceEntity>().getPage(params),
|
||||
new QueryWrapper<ProvinceEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProvinceEntity> getCity() {
|
||||
List<ProvinceEntity> provinceList = this.baseMapper.selectList(new QueryWrapper<ProvinceEntity>());
|
||||
for (ProvinceEntity province:provinceList){
|
||||
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
|
||||
.eq("prov_id", province.getProvId()));
|
||||
|
||||
if (prov.size() > 0) {
|
||||
for (CityEntity cityEntity : prov) {
|
||||
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityEntity.getCityId()));
|
||||
if (countyList != null) {
|
||||
cityEntity.setCountyList(countyList);
|
||||
}
|
||||
}
|
||||
province.setCityList(prov);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return provinceList;
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.ProvinceDao;
|
||||
import com.peanut.modules.book.service.ProvinceService;
|
||||
|
||||
|
||||
@Service("provinceService")
|
||||
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, ProvinceEntity> implements ProvinceService {
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ProvinceEntity> page = this.page(
|
||||
new Query<ProvinceEntity>().getPage(params),
|
||||
new QueryWrapper<ProvinceEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProvinceEntity> getCity() {
|
||||
List<ProvinceEntity> provinceList = this.baseMapper.selectList(new QueryWrapper<ProvinceEntity>());
|
||||
for (ProvinceEntity province:provinceList){
|
||||
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
|
||||
.eq("prov_id", province.getProvId()));
|
||||
|
||||
if (prov.size() > 0) {
|
||||
for (CityEntity cityEntity : prov) {
|
||||
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityEntity.getCityId()));
|
||||
if (countyList != null) {
|
||||
cityEntity.setCountyList(countyList);
|
||||
}
|
||||
}
|
||||
province.setCityList(prov);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return provinceList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.PublisherDao;
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
|
||||
|
||||
@Service("publisherService")
|
||||
public class PublisherServiceImpl extends ServiceImpl<PublisherDao, PublisherEntity> implements PublisherService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PublisherEntity> page = this.page(
|
||||
new Query<PublisherEntity>().getPage(params),
|
||||
new QueryWrapper<PublisherEntity>().orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.PublisherDao;
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
|
||||
|
||||
@Service("publisherService")
|
||||
public class PublisherServiceImpl extends ServiceImpl<PublisherDao, PublisherEntity> implements PublisherService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PublisherEntity> page = this.page(
|
||||
new Query<PublisherEntity>().getPage(params),
|
||||
new QueryWrapper<PublisherEntity>().orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.SeckillProdRelationDao;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
|
||||
|
||||
@Service("seckillProdRelationService")
|
||||
public class SeckillProdRelationServiceImpl extends ServiceImpl<SeckillProdRelationDao, SeckillProdRelationEntity> implements SeckillProdRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
String promotionSeckillId = (String) params.get("promotionSeckillId");
|
||||
|
||||
IPage<SeckillProdRelationEntity> page = this.page(
|
||||
new Query<SeckillProdRelationEntity>().getPage(params),
|
||||
new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id",promotionSeckillId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.SeckillProdRelationDao;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
|
||||
|
||||
@Service("seckillProdRelationService")
|
||||
public class SeckillProdRelationServiceImpl extends ServiceImpl<SeckillProdRelationDao, SeckillProdRelationEntity> implements SeckillProdRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
String promotionSeckillId = (String) params.get("promotionSeckillId");
|
||||
|
||||
IPage<SeckillProdRelationEntity> page = this.page(
|
||||
new Query<SeckillProdRelationEntity>().getPage(params),
|
||||
new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id",promotionSeckillId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,113 +1,113 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ShopCategoryDao;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.ShopCategoryService;
|
||||
|
||||
|
||||
@Service("shopCategoryService")
|
||||
public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCategoryEntity> implements ShopCategoryService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopCategoryEntity> page = this.page(
|
||||
new Query<ShopCategoryEntity>().getPage(params),
|
||||
new QueryWrapper<ShopCategoryEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> listTree() {
|
||||
List<ShopCategoryEntity> entities = baseMapper.selectList(null);
|
||||
//一级菜单
|
||||
List<ShopCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
|
||||
catalogueEntity.getParentCid() == 0
|
||||
|
||||
).map((menu)->{
|
||||
menu.setChildren(getChildrens(menu,entities));
|
||||
return menu;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort() == null? 0 : menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return level1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCheckByIds(List<String> asList) {
|
||||
|
||||
|
||||
this.baseMapper.deleteBatchIds(asList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getOneLevel() {
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
|
||||
System.out.println("list=================================="+list);
|
||||
|
||||
// List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("name", "医学视频").eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getTwoLevel(Integer catId) {
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", catId).eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findBookId(String bookId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> findPoid(Integer oid) {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
List<Integer> poidPList = findPoidPList(oid, list);
|
||||
Collections.reverse(poidPList);
|
||||
|
||||
return poidPList;
|
||||
}
|
||||
|
||||
private List<Integer> findPoidPList(Integer oid,List<Integer> list){
|
||||
list.add(oid);
|
||||
ShopCategoryEntity byId = this.getById(oid);
|
||||
if (byId.getParentCid() != 0){
|
||||
findPoidPList(byId.getParentCid().intValue(),list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<ShopCategoryEntity> getChildrens(ShopCategoryEntity root,List<ShopCategoryEntity> all){
|
||||
|
||||
List<ShopCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
return root.getCatId().equals(catalogueEntity.getParentCid());
|
||||
}).map(catalogueEntity -> {
|
||||
catalogueEntity.setChildren(getChildrens(catalogueEntity, all));
|
||||
return catalogueEntity;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ShopCategoryDao;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.ShopCategoryService;
|
||||
|
||||
|
||||
@Service("shopCategoryService")
|
||||
public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCategoryEntity> implements ShopCategoryService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopCategoryEntity> page = this.page(
|
||||
new Query<ShopCategoryEntity>().getPage(params),
|
||||
new QueryWrapper<ShopCategoryEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> listTree() {
|
||||
List<ShopCategoryEntity> entities = baseMapper.selectList(null);
|
||||
//一级菜单
|
||||
List<ShopCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
|
||||
catalogueEntity.getParentCid() == 0
|
||||
|
||||
).map((menu)->{
|
||||
menu.setChildren(getChildrens(menu,entities));
|
||||
return menu;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort() == null? 0 : menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return level1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCheckByIds(List<String> asList) {
|
||||
|
||||
|
||||
this.baseMapper.deleteBatchIds(asList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getOneLevel() {
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
|
||||
System.out.println("list=================================="+list);
|
||||
|
||||
// List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("name", "医学视频").eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getTwoLevel(Integer catId) {
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", catId).eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findBookId(String bookId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> findPoid(Integer oid) {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
List<Integer> poidPList = findPoidPList(oid, list);
|
||||
Collections.reverse(poidPList);
|
||||
|
||||
return poidPList;
|
||||
}
|
||||
|
||||
private List<Integer> findPoidPList(Integer oid,List<Integer> list){
|
||||
list.add(oid);
|
||||
ShopCategoryEntity byId = this.getById(oid);
|
||||
if (byId.getParentCid() != 0){
|
||||
findPoidPList(byId.getParentCid().intValue(),list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<ShopCategoryEntity> getChildrens(ShopCategoryEntity root,List<ShopCategoryEntity> all){
|
||||
|
||||
List<ShopCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
return root.getCatId().equals(catalogueEntity.getParentCid());
|
||||
}).map(catalogueEntity -> {
|
||||
catalogueEntity.setChildren(getChildrens(catalogueEntity, all));
|
||||
return catalogueEntity;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +1,88 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.ShopProductDao;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
|
||||
|
||||
@Service("shopProductService")
|
||||
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProductEntity> implements ShopProductService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userid = (String) params.get("userid");
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
|
||||
.notLike("book_ids",",").orderByDesc("sum_sales").eq("del_flag",0)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils appQueryPage(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopProductEntity> appGetCategoryList(Integer catId) {
|
||||
List<ShopProductEntity> list = this.getBaseMapper().appGetCategoryList(catId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils getNewBook(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils selectListqueryPage(Map<String, Object> params) {
|
||||
Object name = params.get("name");
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageproductSales(Map<String, Object> params) {
|
||||
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("sum_sales")
|
||||
);
|
||||
System.out.println("page"+page);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageactivityprice(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().ne("activity_price", "").ne("activity_price", 0)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.ShopProductDao;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
|
||||
|
||||
@Service("shopProductService")
|
||||
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProductEntity> implements ShopProductService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userid = (String) params.get("userid");
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
|
||||
.notLike("book_ids",",").orderByDesc("sum_sales").eq("del_flag",0)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils appQueryPage(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopProductEntity> appGetCategoryList(Integer catId) {
|
||||
List<ShopProductEntity> list = this.getBaseMapper().appGetCategoryList(catId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils getNewBook(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils selectListqueryPage(Map<String, Object> params) {
|
||||
Object name = params.get("name");
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageproductSales(Map<String, Object> params) {
|
||||
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().orderByDesc("sum_sales")
|
||||
);
|
||||
System.out.println("page"+page);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPageactivityprice(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>().ne("activity_price", "").ne("activity_price", 0)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +1,86 @@
|
||||
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.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.HashMap;
|
||||
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) {
|
||||
|
||||
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("proudict_id", proudictId));
|
||||
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId));
|
||||
List prList = new ArrayList<>();
|
||||
List prLists = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) {
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
List<ShopProudictBookEntity> booklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", bookId));
|
||||
for (ShopProudictBookEntity shopProudictBook : booklist) {
|
||||
Integer proudictId1 = shopProudictBook.getProudictId();
|
||||
Integer bookId1 = shopProudictBook.getBookId();
|
||||
BookEntity bookbyId = bookService.getById(bookId1);
|
||||
prList.add(bookbyId);
|
||||
ShopProductEntity shopProductbyId = shopProductService.getById(proudictId1);
|
||||
shopProductbyId.setBookidsimages(prList);
|
||||
}
|
||||
}
|
||||
shopProductEntity.setBookidsimages(prList);
|
||||
return prLists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBookidsByProductId(Integer productId) {
|
||||
List<ShopProudictBookEntity> spbs = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("del_flag",0).eq("proudict_id",productId));
|
||||
List<Integer> ids = new ArrayList();
|
||||
for (ShopProudictBookEntity s : spbs){
|
||||
ids.add(s.getBookId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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.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.HashMap;
|
||||
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) {
|
||||
|
||||
|
||||
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("proudict_id", proudictId));
|
||||
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId));
|
||||
List prList = new ArrayList<>();
|
||||
List prLists = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) {
|
||||
Integer bookId = shopProudictBookEntity.getBookId();
|
||||
List<ShopProudictBookEntity> booklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("book_id", bookId));
|
||||
for (ShopProudictBookEntity shopProudictBook : booklist) {
|
||||
Integer proudictId1 = shopProudictBook.getProudictId();
|
||||
Integer bookId1 = shopProudictBook.getBookId();
|
||||
BookEntity bookbyId = bookService.getById(bookId1);
|
||||
prList.add(bookbyId);
|
||||
ShopProductEntity shopProductbyId = shopProductService.getById(proudictId1);
|
||||
shopProductbyId.setBookidsimages(prList);
|
||||
}
|
||||
}
|
||||
shopProductEntity.setBookidsimages(prList);
|
||||
return prLists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBookidsByProductId(Integer productId) {
|
||||
List<ShopProudictBookEntity> spbs = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("del_flag",0).eq("proudict_id",productId));
|
||||
List<Integer> ids = new ArrayList();
|
||||
for (ShopProudictBookEntity s : spbs){
|
||||
ids.add(s.getBookId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,259 +1,259 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.ProdInfoVo;
|
||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.redisson.api.RSemaphore;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ShopSeckillDao;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
|
||||
@Slf4j
|
||||
@Service("shopSeckillService")
|
||||
public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
||||
|
||||
@Autowired
|
||||
private SeckillProdRelationService seckillProdRelationService;
|
||||
@Autowired
|
||||
StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
RedissonClient redissonClient;
|
||||
|
||||
private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
||||
private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
||||
private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopSeckillEntity> page = this.page(
|
||||
new Query<ShopSeckillEntity>().getPage(params),
|
||||
new QueryWrapper<ShopSeckillEntity>()
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSeckillEntity> getSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
||||
if (list != null && list.size() > 0) {
|
||||
list.stream().map(session -> {
|
||||
Long seckillId = session.getSeckillId();
|
||||
List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
||||
session.setRelationProd(seckillList);
|
||||
return session;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
||||
List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
||||
});
|
||||
saveSessionInfo(seckilProdVo);
|
||||
saveSessionProdInfo(seckilProdVo);
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
long time = new Date().getTime();
|
||||
for(String key : keys){
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
long endTime = Long.parseLong(s[1]);
|
||||
if(endTime <= time){
|
||||
stringRedisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SeckillRedisTo> getCurrentSeckillProd() {
|
||||
long time = new Date().getTime();
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
|
||||
for (String key : keys) {
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
long startTime = Long.parseLong(s[0]);
|
||||
long endTime = Long.parseLong(s[1]);
|
||||
|
||||
|
||||
if (time >= startTime && time <= endTime ) {
|
||||
|
||||
List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);
|
||||
BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
List<Object> objects = operations.multiGet(list);
|
||||
if (objects.size() > 0) {
|
||||
List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
||||
// seckillRedisTo.setRandomCode(null);
|
||||
return seckillRedisTo;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String kill(String killId, String key, Integer num , Integer userId) {
|
||||
|
||||
|
||||
BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
String o = hashOps.get(killId);
|
||||
if (StringUtils.isEmpty(o)){
|
||||
return null;
|
||||
}else {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
||||
Long startTime = seckillRedisTo.getStartTime();
|
||||
Long endTime = seckillRedisTo.getEndTime();
|
||||
|
||||
long time = new Date().getTime();
|
||||
|
||||
long ttl = endTime - time;
|
||||
if ( time >= startTime && time <= endTime){
|
||||
String randomCode = seckillRedisTo.getRandomCode();
|
||||
String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
||||
if( randomCode.equals(key) && killId.equals(prodId)){
|
||||
if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
||||
String redisKey = userId + "_" + prodId;
|
||||
Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
||||
if (aBoolean) {
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
||||
try {
|
||||
boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
||||
// 秒杀成功
|
||||
String timeId = IdWorker.getTimeId();
|
||||
return timeId;
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
||||
seckilProdVo.stream().forEach(session -> {
|
||||
long startTime = session.getStartTime().getTime();
|
||||
long endTime = session.getEndTime().getTime();
|
||||
String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
||||
|
||||
Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
||||
if (!aBoolean) {
|
||||
List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
||||
stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
||||
|
||||
seckilProdVos.stream().forEach(seckilProdVo -> {
|
||||
|
||||
BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
|
||||
seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
||||
String token = UUID.randomUUID().toString().replace("-", "");
|
||||
if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
||||
SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(seckilProd.getProdId());
|
||||
ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
||||
});
|
||||
seckillRedisTo.setProdInfo(prodInfoVo);
|
||||
BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
||||
|
||||
seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
||||
seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
||||
|
||||
seckillRedisTo.setRandomCode(token);
|
||||
|
||||
|
||||
String string = JSON.toJSONString(seckillRedisTo);
|
||||
ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
||||
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
||||
semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String startTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalTime min = LocalTime.MIN;
|
||||
LocalDateTime start = LocalDateTime.of(now, min);
|
||||
String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
|
||||
private String endTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate localDate = now.plusDays(2);
|
||||
LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
||||
String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.ProdInfoVo;
|
||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.redisson.api.RSemaphore;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ShopSeckillDao;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
|
||||
@Slf4j
|
||||
@Service("shopSeckillService")
|
||||
public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
||||
|
||||
@Autowired
|
||||
private SeckillProdRelationService seckillProdRelationService;
|
||||
@Autowired
|
||||
StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
RedissonClient redissonClient;
|
||||
|
||||
private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
||||
private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
||||
private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopSeckillEntity> page = this.page(
|
||||
new Query<ShopSeckillEntity>().getPage(params),
|
||||
new QueryWrapper<ShopSeckillEntity>()
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSeckillEntity> getSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
||||
if (list != null && list.size() > 0) {
|
||||
list.stream().map(session -> {
|
||||
Long seckillId = session.getSeckillId();
|
||||
List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
||||
session.setRelationProd(seckillList);
|
||||
return session;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
||||
List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
||||
});
|
||||
saveSessionInfo(seckilProdVo);
|
||||
saveSessionProdInfo(seckilProdVo);
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
long time = new Date().getTime();
|
||||
for(String key : keys){
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
long endTime = Long.parseLong(s[1]);
|
||||
if(endTime <= time){
|
||||
stringRedisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SeckillRedisTo> getCurrentSeckillProd() {
|
||||
long time = new Date().getTime();
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
|
||||
for (String key : keys) {
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
long startTime = Long.parseLong(s[0]);
|
||||
long endTime = Long.parseLong(s[1]);
|
||||
|
||||
|
||||
if (time >= startTime && time <= endTime ) {
|
||||
|
||||
List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);
|
||||
BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
List<Object> objects = operations.multiGet(list);
|
||||
if (objects.size() > 0) {
|
||||
List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
||||
// seckillRedisTo.setRandomCode(null);
|
||||
return seckillRedisTo;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String kill(String killId, String key, Integer num , Integer userId) {
|
||||
|
||||
|
||||
BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
String o = hashOps.get(killId);
|
||||
if (StringUtils.isEmpty(o)){
|
||||
return null;
|
||||
}else {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
||||
Long startTime = seckillRedisTo.getStartTime();
|
||||
Long endTime = seckillRedisTo.getEndTime();
|
||||
|
||||
long time = new Date().getTime();
|
||||
|
||||
long ttl = endTime - time;
|
||||
if ( time >= startTime && time <= endTime){
|
||||
String randomCode = seckillRedisTo.getRandomCode();
|
||||
String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
||||
if( randomCode.equals(key) && killId.equals(prodId)){
|
||||
if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
||||
String redisKey = userId + "_" + prodId;
|
||||
Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
||||
if (aBoolean) {
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
||||
try {
|
||||
boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
||||
// 秒杀成功
|
||||
String timeId = IdWorker.getTimeId();
|
||||
return timeId;
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
||||
seckilProdVo.stream().forEach(session -> {
|
||||
long startTime = session.getStartTime().getTime();
|
||||
long endTime = session.getEndTime().getTime();
|
||||
String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
||||
|
||||
Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
||||
if (!aBoolean) {
|
||||
List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
||||
stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
||||
|
||||
seckilProdVos.stream().forEach(seckilProdVo -> {
|
||||
|
||||
BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
|
||||
seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
||||
String token = UUID.randomUUID().toString().replace("-", "");
|
||||
if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
||||
SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(seckilProd.getProdId());
|
||||
ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
||||
});
|
||||
seckillRedisTo.setProdInfo(prodInfoVo);
|
||||
BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
||||
|
||||
seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
||||
seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
||||
|
||||
seckillRedisTo.setRandomCode(token);
|
||||
|
||||
|
||||
String string = JSON.toJSONString(seckillRedisTo);
|
||||
ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
||||
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
||||
semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String startTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalTime min = LocalTime.MIN;
|
||||
LocalDateTime start = LocalDateTime.of(now, min);
|
||||
String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
|
||||
private String endTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate localDate = now.plusDays(2);
|
||||
LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
||||
String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,41 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.TransactionDetailsDao;
|
||||
import com.peanut.modules.book.entity.TransactionDetailsEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("transactionDetailsService")
|
||||
public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetailsDao, TransactionDetailsEntity> implements TransactionDetailsService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
|
||||
IPage<TransactionDetailsEntity> page = this.page(
|
||||
new Query<TransactionDetailsEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<TransactionDetailsEntity>()
|
||||
.eq(StringUtils.isNotBlank(userId),"user_id",userId)
|
||||
.eq("tel",params.get("key")).or().like("user_name",params.get("key")).orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.TransactionDetailsDao;
|
||||
import com.peanut.modules.book.entity.TransactionDetailsEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("transactionDetailsService")
|
||||
public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetailsDao, TransactionDetailsEntity> implements TransactionDetailsService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
|
||||
IPage<TransactionDetailsEntity> page = this.page(
|
||||
new Query<TransactionDetailsEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<TransactionDetailsEntity>()
|
||||
.eq(StringUtils.isNotBlank(userId),"user_id",userId)
|
||||
.eq("tel",params.get("key")).or().like("user_name",params.get("key")).orderByDesc("create_time")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.UserAddressDao;
|
||||
import com.peanut.modules.book.entity.UserAddressEntity;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
|
||||
|
||||
@Service("userAddressService")
|
||||
public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddressEntity> implements UserAddressService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<UserAddressEntity> page = this.page(
|
||||
new Query<UserAddressEntity>().getPage(params),
|
||||
new QueryWrapper<UserAddressEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
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.UserAddressDao;
|
||||
import com.peanut.modules.book.entity.UserAddressEntity;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
|
||||
|
||||
@Service("userAddressService")
|
||||
public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddressEntity> implements UserAddressService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<UserAddressEntity> page = this.page(
|
||||
new Query<UserAddressEntity>().getPage(params),
|
||||
new QueryWrapper<UserAddressEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.UserEbookBuyDao;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
|
||||
|
||||
@Service("userEbookBuyService")
|
||||
public class UserEbookBuyServiceImpl extends ServiceImpl<UserEbookBuyDao, UserEbookBuyEntity> implements UserEbookBuyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
IPage<UserEbookBuyEntity> page = this.page(
|
||||
new Query<UserEbookBuyEntity>().getPage(params),
|
||||
new QueryWrapper<UserEbookBuyEntity>().eq("user_id",userId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPages(Map<String, Object> params) {
|
||||
Integer userid = Integer.valueOf((String) params.get("id"));
|
||||
IPage<UserEbookBuyEntity> page = this.page(
|
||||
new Query<UserEbookBuyEntity>().getPage(params),
|
||||
new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id",userid)
|
||||
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.UserEbookBuyDao;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
|
||||
|
||||
@Service("userEbookBuyService")
|
||||
public class UserEbookBuyServiceImpl extends ServiceImpl<UserEbookBuyDao, UserEbookBuyEntity> implements UserEbookBuyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
IPage<UserEbookBuyEntity> page = this.page(
|
||||
new Query<UserEbookBuyEntity>().getPage(params),
|
||||
new QueryWrapper<UserEbookBuyEntity>().eq("user_id",userId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPages(Map<String, Object> params) {
|
||||
Integer userid = Integer.valueOf((String) params.get("id"));
|
||||
IPage<UserEbookBuyEntity> page = this.page(
|
||||
new Query<UserEbookBuyEntity>().getPage(params),
|
||||
new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id",userid)
|
||||
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.UserFeedbackDao;
|
||||
import com.peanut.modules.book.entity.UserFeedbackEntity;
|
||||
import com.peanut.modules.book.service.UserFeedbackSerivce;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserFeedbackServiceImpl extends ServiceImpl<UserFeedbackDao, UserFeedbackEntity> implements UserFeedbackSerivce {
|
||||
}
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.UserFeedbackDao;
|
||||
import com.peanut.modules.book.entity.UserFeedbackEntity;
|
||||
import com.peanut.modules.book.service.UserFeedbackSerivce;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserFeedbackServiceImpl extends ServiceImpl<UserFeedbackDao, UserFeedbackEntity> implements UserFeedbackSerivce {
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
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.UserFollowUpDao;
|
||||
import com.peanut.modules.book.entity.UserFollowUpEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.service.UserFollowUpService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UserFollowUpServiceImpl extends ServiceImpl<UserFollowUpDao,UserFollowUpEntity> implements UserFollowUpService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String bookid = (String) params.get("bookid");
|
||||
IPage<UserFollowUpEntity> page =page(
|
||||
new Query<UserFollowUpEntity>().getPage(params),
|
||||
new QueryWrapper<UserFollowUpEntity>()
|
||||
//订单号,开始时间
|
||||
.eq("userid",bookid).orderByDesc("create_date")
|
||||
// .eq("")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
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.UserFollowUpDao;
|
||||
import com.peanut.modules.book.entity.UserFollowUpEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.service.UserFollowUpService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UserFollowUpServiceImpl extends ServiceImpl<UserFollowUpDao,UserFollowUpEntity> implements UserFollowUpService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String bookid = (String) params.get("bookid");
|
||||
IPage<UserFollowUpEntity> page =page(
|
||||
new Query<UserFollowUpEntity>().getPage(params),
|
||||
new QueryWrapper<UserFollowUpEntity>()
|
||||
//订单号,开始时间
|
||||
.eq("userid",bookid).orderByDesc("create_date")
|
||||
// .eq("")
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
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.*;
|
||||
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;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service("UserRecordServiceImpl")
|
||||
public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecordEntity> implements UserRecordService {
|
||||
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
|
||||
@Override
|
||||
public Object commodityComment(String userid, String orderSn, String starLevel, String comment) {
|
||||
|
||||
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) {
|
||||
|
||||
String endpoint = ConstantPropertiesUtils.END_POIND;
|
||||
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||
|
||||
try {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
|
||||
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);
|
||||
ossClient.shutdown();
|
||||
String url = "https://" + bucketName + "." + endpoint + "/" + fileName;
|
||||
return url;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
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.*;
|
||||
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;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service("UserRecordServiceImpl")
|
||||
public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecordEntity> implements UserRecordService {
|
||||
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
|
||||
@Override
|
||||
public Object commodityComment(String userid, String orderSn, String starLevel, String comment) {
|
||||
|
||||
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
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);
|
||||
}
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) {
|
||||
|
||||
String endpoint = ConstantPropertiesUtils.END_POIND;
|
||||
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||
|
||||
try {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
|
||||
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);
|
||||
ossClient.shutdown();
|
||||
String url = "https://" + bucketName + "." + endpoint + "/" + fileName;
|
||||
return url;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user