Merge branch 'master' of https://gitee.com/wjl2008_admin/nuttyreading-java
This commit is contained in:
@@ -1,144 +0,0 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookClockinCommentEntity;
|
||||
import com.peanut.modules.book.entity.BookClockInEntity;
|
||||
import com.peanut.modules.book.entity.BookClockinPunchEntity;
|
||||
import com.peanut.modules.book.service.BookClockinCommentService;
|
||||
import com.peanut.modules.book.service.BookClockinPunchService;
|
||||
import com.peanut.modules.book.service.BookClockInService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 签到信息用户评论
|
||||
*
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("clockin/comment")
|
||||
public class BookClockinCommentController {
|
||||
|
||||
@Autowired
|
||||
private BookClockinCommentService bookClockinCommentService;
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
@Autowired
|
||||
private BookClockInService bookClockinService;
|
||||
|
||||
/**
|
||||
* 列表 倒叙
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookClockinCommentService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookClockinCommentEntity commentEntity = bookClockinCommentService.getById(id);
|
||||
|
||||
return R.ok().put("commentEntity", commentEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookClockinCommentEntity clockinComment){
|
||||
Integer bookid1 = clockinComment.getBookId();
|
||||
Integer userId = clockinComment.getUserId();
|
||||
Integer taskId = clockinComment.getTaskId();
|
||||
|
||||
|
||||
BookClockinCommentEntity bookClockinCommentEntity = bookClockinCommentService.getBaseMapper().selectOne(new QueryWrapper<BookClockinCommentEntity>()
|
||||
.eq("book_id", bookid1)
|
||||
.eq("user_id", userId)
|
||||
.eq("task_id", taskId)
|
||||
|
||||
);
|
||||
BookClockinPunchEntity ClockinCommen = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id", bookid1)
|
||||
.eq("user_id", userId)
|
||||
.eq("t_id", taskId)
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (bookClockinCommentEntity !=null) {
|
||||
return R.error("该信息允许发布一条内容,请勿重复发布");
|
||||
}
|
||||
|
||||
if (ClockinCommen!=null) {
|
||||
clockinComment.setPid(1);
|
||||
}
|
||||
|
||||
bookClockinCommentService.save(clockinComment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/replysave")
|
||||
public R replysave(@RequestBody BookClockinCommentEntity clockinComment) {
|
||||
Integer bookid = clockinComment.getBookId();
|
||||
Integer userId = clockinComment.getUserId();
|
||||
Integer pid = clockinComment.getPid();
|
||||
BookClockInEntity bookClockinEntity = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("id",pid)
|
||||
);
|
||||
clockinComment.setDelFlag(0);
|
||||
bookClockinCommentService.save(clockinComment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookClockinCommentEntity clockinComment){
|
||||
|
||||
bookClockinCommentService.updateById(clockinComment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookClockinCommentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,350 +0,0 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.*;
|
||||
/**
|
||||
* 签到内容信息
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/clockin")
|
||||
public class BookClockinController {
|
||||
@Autowired
|
||||
private BookClockInService bookClockinService;
|
||||
@Autowired
|
||||
private BookTaskService bookTaskService;
|
||||
@Autowired
|
||||
private BookClockinCommentService bookClockinCommentService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
/**
|
||||
* 列表 app post请求
|
||||
*/
|
||||
@RequestMapping("/applistSS")
|
||||
public R applist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookClockinService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看全部评价
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam("bookid") String bookid,
|
||||
@RequestParam("taskid") String taskid) {
|
||||
|
||||
List<BookClockInEntity> bookClockinEntityList = bookClockinService.getBaseMapper().selectList(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("book_id", bookid).eq("task_id", taskid));
|
||||
List list = new ArrayList<>();
|
||||
for (BookClockInEntity bookClockinEntity : bookClockinEntityList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String name = "";
|
||||
String avatar="";
|
||||
Integer id2 =null;
|
||||
Integer userId = bookClockinEntity.getUserId();
|
||||
Integer taskId = bookClockinEntity.getTaskId();
|
||||
Integer bookId = bookClockinEntity.getBookId();
|
||||
String conTent = bookClockinEntity.getContent();
|
||||
Integer id1 = bookClockinEntity.getId();
|
||||
String images = (String)bookClockinEntity.getImages();
|
||||
Date createTime = bookClockinEntity.getCreateTime();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : id) {
|
||||
name = user.getNickname();
|
||||
id2 = user.getId();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
|
||||
//评论信息
|
||||
map.put("userid", id2);
|
||||
map.put("name", name);
|
||||
map.put("avatar", avatar);
|
||||
map.put("bookid", bookId);
|
||||
map.put("taskId", taskId);
|
||||
map.put("content", conTent);
|
||||
map.put("images", images);
|
||||
map.put("createdate", createTime);
|
||||
list.add(map);
|
||||
}
|
||||
Collections.reverse(list);
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表 后台get请求
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookClockinService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
BookClockInEntity bookClockinEntity = bookClockinService.getById(id);
|
||||
return R.ok().put("bookBuyConfig", bookClockinEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookClockInEntity bookClockinEntity) {
|
||||
|
||||
Integer bookId = bookClockinEntity.getBookId();
|
||||
Integer userId = bookClockinEntity.getUserId();
|
||||
Integer taskId = bookClockinEntity.getTaskId();
|
||||
Integer dayId = bookClockinEntity.getDayId();
|
||||
BookClockinPunchEntity bookClockinPunchEntity = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.eq("t_id", taskId)
|
||||
.eq("days", dayId)
|
||||
.eq("user_id", userId)
|
||||
);
|
||||
if (bookClockinPunchEntity==null) {
|
||||
return R.error("当天打卡内容未发布");
|
||||
}
|
||||
BookClockInEntity bookClockin = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.eq("task_id", taskId)
|
||||
.eq("day_id", dayId)
|
||||
.eq("user_id", userId)
|
||||
);
|
||||
if (bookClockin!=null) {
|
||||
return R.error("您已参与第"+dayId+"天签到评论");
|
||||
}
|
||||
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) bookClockinEntity.getImageeStrings();
|
||||
String imageStr = "";
|
||||
for (Map m : imageList) {
|
||||
imageStr += m.get("url") + ",";
|
||||
|
||||
}
|
||||
|
||||
if (imageStr!=null &&!imageStr.isEmpty()){
|
||||
String substring = imageStr.substring(0, imageStr.length() - 1);
|
||||
bookClockinEntity.setImages(substring);
|
||||
}else {
|
||||
bookClockinEntity.setImages("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bookClockinEntity.setDelFlag(0);
|
||||
bookClockinService.save(bookClockinEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookClockInEntity bookClockinEntity) {
|
||||
bookClockinService.updateById(bookClockinEntity);
|
||||
return R.ok("提交成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookClockinService.removeByIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 全部评价
|
||||
*
|
||||
* @param bookId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("commentAll")
|
||||
public R commentAll(@RequestParam("bookId") Integer bookId) {
|
||||
List applist = new ArrayList<>();
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
//根据bookid查找出签到表中签到的用户数据
|
||||
List<BookClockInEntity> bookid = bookClockinService.getBaseMapper().selectList(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.orderByDesc("create_time"));
|
||||
|
||||
for (BookClockInEntity book : bookid) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
|
||||
Integer bookid1 = book.getBookId();
|
||||
//BookClockinEntity获取点赞总数
|
||||
String likes = book.getLikeSum();
|
||||
|
||||
Integer userid1 = book.getUserId();
|
||||
Integer taskId = book.getTaskId();
|
||||
Integer id1 = book.getId();
|
||||
applist.add(taskId);
|
||||
//根据id和bookid查询出对应的签到下评论的全部数据
|
||||
|
||||
productMap.put("bookid",bookid1);
|
||||
productMap.put("userid",userid1);
|
||||
}
|
||||
PageUtils pages = bookClockinService.queryPage(productMap);
|
||||
return R.ok().put("days",applist).put("pages",pages);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 我的 :我的签到记录
|
||||
* @param id
|
||||
* @param bookId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myinfo")
|
||||
public R myinfo(@RequestParam("userid") Integer id,
|
||||
@RequestParam("bookid") Integer bookId) {
|
||||
|
||||
|
||||
List<BookClockInEntity> bookClockinEntityList = bookClockinService.getBaseMapper().selectList(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("user_id",id) .eq("book_id",bookId).orderByDesc("create_time"));
|
||||
List list = new ArrayList<>();
|
||||
|
||||
for (BookClockInEntity bookClockinEntity : bookClockinEntityList) {
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
Integer userId = bookClockinEntity.getUserId();
|
||||
Integer dayId = bookClockinEntity.getDayId();
|
||||
Integer bookIds = bookClockinEntity.getBookId();
|
||||
Integer typeId = bookClockinEntity.getTaskId();
|
||||
String content = bookClockinEntity.getContent();
|
||||
Object images = bookClockinEntity.getImages();
|
||||
Date createTime = bookClockinEntity.getCreateTime();
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
String name = byId.getName();
|
||||
String images1 = byId.getImages();
|
||||
BookTaskEntity bookTaskEntity = bookTaskService.getById(typeId);
|
||||
String heading = bookTaskEntity.getHeading();
|
||||
|
||||
|
||||
String myUsername = "";
|
||||
String avatar="";
|
||||
List<MyUserEntity> myUserid = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : myUserid) {
|
||||
myUsername = user.getNickname();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
|
||||
productMap.put("myUseravatar",avatar);
|
||||
productMap.put("myUsername",myUsername);
|
||||
|
||||
productMap.put("dayId",dayId);
|
||||
productMap.put("userId",userId);
|
||||
productMap.put("taskId",typeId);
|
||||
productMap.put("content",content);
|
||||
productMap.put("clockinimages",images);
|
||||
productMap.put("createTime",createTime);
|
||||
productMap.put("bookId",bookIds);
|
||||
productMap.put("bookname",name);
|
||||
productMap.put("bookimages",images1);
|
||||
productMap.put("TaskHeading",heading);
|
||||
list.add(productMap);
|
||||
|
||||
}
|
||||
// Collections.sort(list);
|
||||
// Collections.reverse(list);
|
||||
return R.ok().put("ClockinList", list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 详情页我的签到评论
|
||||
* @param id
|
||||
* @param taskid
|
||||
* @param bookId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myinfolist")
|
||||
public R myinfolist(@RequestParam("userid") Integer id,
|
||||
@RequestParam("taskid") Integer taskid,
|
||||
@RequestParam("bookid") Integer bookId
|
||||
) {
|
||||
List list = new ArrayList<>();
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
BookClockInEntity bookClockin = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("user_id",id)
|
||||
.eq("task_id",taskid)
|
||||
.eq("book_id",bookId)
|
||||
);
|
||||
BookClockinPunchEntity bookClockinPunchEntity = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("user_id",id)
|
||||
.eq("t_id",taskid)
|
||||
.eq("book_id",bookId)
|
||||
);
|
||||
|
||||
|
||||
if (bookClockin == null ) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
Integer userId = bookClockin.getUserId();
|
||||
Integer bookIds = bookClockin.getBookId();
|
||||
Integer taskId = bookClockin.getTaskId();
|
||||
Integer dayId = bookClockin.getDayId();
|
||||
String content = bookClockin.getContent();
|
||||
Object images = bookClockin.getImages();
|
||||
Date createTime = bookClockin.getCreateTime();
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
String name = byId.getName();
|
||||
String images1 = byId.getImages();
|
||||
BookTaskEntity bookTaskEntity = bookTaskService.getById(taskId);
|
||||
String heading = bookTaskEntity.getHeading();
|
||||
|
||||
|
||||
|
||||
String myUsername = "";
|
||||
String avatar="";
|
||||
List<MyUserEntity> myUserid = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : myUserid) {
|
||||
myUsername = user.getNickname();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
|
||||
productMap.put("myUseravatar",avatar);
|
||||
productMap.put("myUsername",myUsername);
|
||||
|
||||
|
||||
|
||||
productMap.put("userId",userId);
|
||||
productMap.put("taskId",taskId);
|
||||
productMap.put("dayId",dayId);
|
||||
|
||||
productMap.put("content",content);
|
||||
productMap.put("clockinimages",images);
|
||||
productMap.put("createTime",createTime);
|
||||
productMap.put("bookId",bookIds);
|
||||
productMap.put("bookname",name);
|
||||
productMap.put("bookimages",images1);
|
||||
productMap.put("TaskHeading",heading);
|
||||
list.add(productMap);
|
||||
|
||||
Collections.reverse(list);
|
||||
return R.ok().put("productlist", list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.dao.UserEbookBuyDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("book/clockinPunch")
|
||||
public class BookClockinPunchController {
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BookClockinCommentService bookClockinCommentService;
|
||||
@Autowired
|
||||
private UserEbookBuyDao userEbookBuyDao;
|
||||
@Autowired
|
||||
UserBookClockService userBookClockService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表 app post请求 /applistSS
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookClockinPunchService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
BookClockinPunchEntity bookClockinPunchEntity = bookClockinPunchService.getById(id);
|
||||
|
||||
return R.ok().put("bookClockinPunchEntity", bookClockinPunchEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
|
||||
Integer bookid1 = bookClockinPunchEntity.getBookId();
|
||||
Integer userId = bookClockinPunchEntity.getUserId();
|
||||
Integer taskId = bookClockinPunchEntity.getTId();
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid1);
|
||||
Boolean canListen = bookEntity.getCanListen();
|
||||
BookClockinPunchEntity bookClock = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id", bookid1)
|
||||
.eq("user_id", userId)
|
||||
.eq("t_id", taskId)
|
||||
|
||||
|
||||
);
|
||||
if (bookClock != null) {
|
||||
return R.error("您已经签到,请勿重复签到");
|
||||
}
|
||||
|
||||
|
||||
if (canListen == true) {
|
||||
boolean b = myUserService.bookAuthen(bookid1, userId);
|
||||
if (b) {
|
||||
bookClockinPunchEntity.setDelFlag(0);
|
||||
bookClockinPunchService.save(bookClockinPunchEntity);
|
||||
return R.ok("签到成功");
|
||||
} else {
|
||||
return R.error("您还未购买此书,购买后即可签到");
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
return R.error("该书暂未开放打卡权限");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户打卡已购图书
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myClockBooks")
|
||||
public R myClockBooks(@RequestParam Integer userId, @RequestParam Integer limit, @RequestParam Integer page) {
|
||||
MPJLambdaWrapper<UserEbookBuyEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(BookEntity.class);
|
||||
wrapper.leftJoin(BookEntity.class, BookEntity::getId, UserEbookBuyEntity::getBookId);
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId, userId);
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.eq(BookEntity::getClockIn, 1);
|
||||
Page<BookEntity> userBookEntityPage = userEbookBuyDao.selectJoinPage(new Page<BookEntity>(page, limit), BookEntity.class, wrapper);
|
||||
return R.ok().put("page", userBookEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打卡推荐图书
|
||||
*
|
||||
* @param userId
|
||||
* @param limit
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBestClockBooks")
|
||||
public R getBestClockBooks(@RequestParam Integer userId, @RequestParam Integer limit, @RequestParam Integer page) {
|
||||
String not_ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = " + userId;
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.eq(BookEntity::getClockIn, 1);
|
||||
wrapper.notExists(not_ex_sql);
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
return R.ok().put("page", bookEntityPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
|
||||
bookClockinPunchService.updateById(bookClockinPunchEntity);
|
||||
return R.ok("提交成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookClockinPunchService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论
|
||||
*
|
||||
* @param bookClockinPunchEntity
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/punchcoments")
|
||||
public R punchcoments(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
|
||||
//图书Id
|
||||
Integer bookId = bookClockinPunchEntity.getBookId();
|
||||
//用户id
|
||||
Integer userId = bookClockinPunchEntity.getUserId();
|
||||
//天数
|
||||
Integer days = bookClockinPunchEntity.getDays();
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
List<BookClockinCommentEntity> bookClockinCommentEntities = bookClockinCommentService.getBaseMapper().selectList(new QueryWrapper<BookClockinCommentEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookId)
|
||||
.eq("task_id", days)
|
||||
//pid等于1时为一级评论
|
||||
// .eq("pid",1)
|
||||
);
|
||||
for (BookClockinCommentEntity bookClockinCommentEntity : bookClockinCommentEntities) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
String name = "";
|
||||
String avatar = "";
|
||||
|
||||
Integer userId1 = bookClockinCommentEntity.getUserId();
|
||||
Integer bookId1 = bookClockinCommentEntity.getBookId();
|
||||
String content = bookClockinCommentEntity.getContent();
|
||||
String images = bookClockinCommentEntity.getImages();
|
||||
Date createTime = bookClockinCommentEntity.getCreateTime();
|
||||
|
||||
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : id) {
|
||||
name = user.getNickname();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
map.put("userid", userId1);
|
||||
map.put("name", name);
|
||||
map.put("avatar", avatar);
|
||||
map.put("bookid", bookId1);
|
||||
map.put("content", content);
|
||||
map.put("images", images);
|
||||
map.put("createdate", createTime);
|
||||
list.add(map);
|
||||
|
||||
}
|
||||
|
||||
Collections.reverse(list);
|
||||
return R.ok().put("list", list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -747,18 +747,18 @@ public class BookController {
|
||||
@RequestMapping("/file")
|
||||
public String getFile() {
|
||||
String filePath = "C:\\Users\\Administrator\\IdeaProjects\\peanut_book\\2020年8月中华人民共和国县以上行政区划代码.json";
|
||||
List<ProvinceEntity> provinceList = ReadProvinceUtil.getFile(filePath);
|
||||
List<Province> provinceList = ReadProvinceUtil.getFile(filePath);
|
||||
// System.out.println(provinceList);
|
||||
if (provinceList != null && provinceList.size() > 0) {
|
||||
for (ProvinceEntity province : provinceList) {
|
||||
for (Province province : provinceList) {
|
||||
// ProvinceEntity provinceEntity = new ProvinceEntity();
|
||||
// provinceEntity.setProvName(province.getProvName());
|
||||
// provinceEntity.setCreateDate(province.getCreateDate());
|
||||
// provinceEntity.setRegionCode(province.getRegionCode());
|
||||
provinceService.save(province);
|
||||
List<CityEntity> cityList = province.getCityList();
|
||||
List<City> cityList = province.getCityList();
|
||||
if (cityList != null && cityList.size() > 0) {
|
||||
for (CityEntity city : cityList) {
|
||||
for (City city : cityList) {
|
||||
// CityEntity cityEntity = new CityEntity();
|
||||
// cityEntity.setCreateDate(city.getCreateDate());
|
||||
// cityEntity.setCityName(city.getCityName());
|
||||
@@ -766,9 +766,9 @@ public class BookController {
|
||||
// city.setProvId(province.getProvId());
|
||||
city.setProvId(province.getProvId());
|
||||
cityService.save(city);
|
||||
List<CountyEntity> countyList = city.getCountyList();
|
||||
List<County> countyList = city.getCountyList();
|
||||
if (countyList != null && countyList.size() > 0) {
|
||||
for (CountyEntity county : countyList) {
|
||||
for (County county : countyList) {
|
||||
// CountyEntity countyEntity = new CountyEntity();
|
||||
county.setCityId(city.getCityId());
|
||||
// countyEntity.setCountyName(county.getCountyName());
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookClockinPunchEntity;
|
||||
import com.peanut.modules.book.entity.BookTaskEntity;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 发布签到任务
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/task")
|
||||
public class BookTaskController {
|
||||
|
||||
@Autowired
|
||||
private BookTaskService bookTaskService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookClockInService bookClockinService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
|
||||
/**
|
||||
* 列表后台
|
||||
*
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookTaskService.queryPage(params);
|
||||
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表app根据days查询
|
||||
*
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookTaskService.queryPageServi(params);
|
||||
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
|
||||
//根据id找到详细数据信息
|
||||
BookTaskEntity bookTaskEntity = bookTaskService.getById(id);
|
||||
Integer ids = bookTaskEntity.getId();
|
||||
Integer bookid = bookTaskEntity.getBookid();
|
||||
List<BookClockinPunchEntity> bookClockinPunchEntity = bookClockinPunchService.getBaseMapper().selectList(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("user_id", ids)
|
||||
.eq("book_id", bookid));
|
||||
|
||||
// 遍历 bookClockinEntityList 中的每个 bookClockinEntity,查询 BookClockinEntity 表中对应的总数
|
||||
int total = 0;
|
||||
for ( BookClockinPunchEntity bookClockin : bookClockinPunchEntity) {
|
||||
|
||||
Integer id1 = bookClockin.getId();
|
||||
// BookClockinEntity byId = bookClockinService.getById(id1);
|
||||
//++获取到总条数
|
||||
total ++;
|
||||
}
|
||||
//返回总条数
|
||||
|
||||
return R.ok().put("bookTaskEntity", bookTaskEntity).put("totalCont",total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookTaskEntity bookTaskEntity) {
|
||||
|
||||
bookTaskEntity.setDelFlag(0);
|
||||
bookTaskService.save(bookTaskEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookTaskEntity bookTaskEntity) {
|
||||
|
||||
bookTaskService.updateById(bookTaskEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookTaskService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
@RequestMapping("/totalsum")
|
||||
public R totalsum(@RequestBody BookTaskEntity bookTaskEntity) {
|
||||
|
||||
// 获取 BookTaskEntity 表中所有的 bookid和id
|
||||
String days = bookTaskEntity.getDays();
|
||||
Integer bookid = bookTaskEntity.getBookid();
|
||||
List<BookClockinPunchEntity> books = bookClockinPunchService.getBaseMapper().selectList(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("days", days)
|
||||
.eq("book_id", bookid));
|
||||
|
||||
|
||||
|
||||
// 遍历 bookClockinEntityList 中的每个 bookClockinEntity,查询 BookClockinEntity 表中对应的总数
|
||||
int total = 0;
|
||||
for ( BookClockinPunchEntity book : books) {
|
||||
// 使用 bookClockinEntity 进行匹配查询
|
||||
Integer id1 = book.getId();
|
||||
BookClockinPunchEntity byId = bookClockinPunchService.getById(id1);
|
||||
//++获取到总条数
|
||||
total ++;
|
||||
}
|
||||
//返回总条数
|
||||
return R.ok().put("totalSum",total);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
@@ -11,8 +10,15 @@ import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.request.ProductRequestVo;
|
||||
import com.peanut.modules.book.vo.request.ProductTransportVo;
|
||||
import com.peanut.modules.book.vo.response.ExpressQueryResponseVo;
|
||||
import com.peanut.modules.book.vo.ShippingAddressRequestVo;
|
||||
import com.peanut.modules.book.vo.UserAddressVo;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||
import com.peanut.modules.sys.service.SysConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@@ -22,6 +28,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -35,7 +43,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("book/buyorder")
|
||||
@RequestMapping("book/buyOrder")
|
||||
public class BuyOrderController {
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@@ -56,14 +64,19 @@ public class BuyOrderController {
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private UserRecordService userRecordService;
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
@Autowired
|
||||
private ExpressFeeService expressFeeService;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -78,33 +91,6 @@ public class BuyOrderController {
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param params
|
||||
* @return 听书未购买页面展示
|
||||
* (销量最多的书,最先放最前面展示。最新上线的书,预售的书,放最前面展示
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/lists")
|
||||
public R lists(@RequestParam Map<String, Object> params) throws Exception {
|
||||
|
||||
if ("all".equals(params.get("orderStatus"))) {
|
||||
params.remove("orderStatus");
|
||||
}
|
||||
PageUtils page = buyOrderService.queryPages(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{orderId}")
|
||||
public R info(@PathVariable("orderId") Integer orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
return R.ok().put("buyOrder", buyOrder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*
|
||||
@@ -113,13 +99,13 @@ public class BuyOrderController {
|
||||
*/
|
||||
@RequestMapping("/buySave")
|
||||
@Transactional
|
||||
public R buySave(@RequestBody BuyOrderEntity buyOrder) throws IOException {
|
||||
public R buySave(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||
// 获取订单详情
|
||||
List<BuyOrderDetailEntity> products = buyOrder.getProducts();
|
||||
List<BuyOrderDetail> buyOrderDetails = buyOrder.getProducts();
|
||||
// 订单总金额
|
||||
BigDecimal totalPrice = new BigDecimal(0);
|
||||
// 遍历商品总价计算
|
||||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
|
||||
Integer productId = buyOrderDetail.getProductId();
|
||||
int quantity = buyOrderDetail.getQuantity();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
@@ -130,7 +116,11 @@ public class BuyOrderController {
|
||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
||||
buyOrderDetail.setProductName(product.getProductName());
|
||||
buyOrderDetail.setProductPrice(product.getPrice());
|
||||
buyOrderDetail.setAddressId(buyOrder.getAddressId());
|
||||
int originWeight = product.getWeight();
|
||||
int originWeightIntValue = originWeight / 100;
|
||||
int originWeightDecimalValue = originWeightIntValue % 100;
|
||||
buyOrderDetail.setWeight(BigDecimal.valueOf(originWeightIntValue).add(BigDecimal.valueOf(originWeightDecimalValue).divide(new BigDecimal(100),
|
||||
MathContext.DECIMAL64)));
|
||||
buyOrderDetail.setProductUrl(product.getProductImages());
|
||||
buyOrderDetail.setOrderStatus(Constants.ORDER_STATUS_TO_BE_PAID);
|
||||
}
|
||||
@@ -140,16 +130,24 @@ public class BuyOrderController {
|
||||
String orderSn = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(orderSn);
|
||||
buyOrder.setPaymentDate(new Date());
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", buyOrder.getAddressId());
|
||||
UserAddress userAddress = userAddressService.getOne(queryWrapper);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
buyOrder.setProvince(vo.getProvince());
|
||||
buyOrder.setCity(vo.getCity());
|
||||
buyOrder.setDistrict(vo.getCity());
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
|
||||
buyOrderDetail.setOrderId(buyOrder.getOrderId());
|
||||
buyOrderDetail.setUserId(buyOrder.getUserId());
|
||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||
handleBuyCart(buyOrder, buyOrderDetail);
|
||||
}
|
||||
}
|
||||
buyOrderDetailService.saveBatch(products);
|
||||
buyOrderDetailService.saveBatch(buyOrderDetails);
|
||||
// 1. 虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||||
@@ -158,7 +156,7 @@ public class BuyOrderController {
|
||||
// 更新订单状态
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "0");
|
||||
recordTransaction(buyOrder, user, totalPrice);
|
||||
addEbookToUser(products, buyOrder);
|
||||
addEbookToUser(buyOrderDetails, buyOrder);
|
||||
} else {
|
||||
return R.error(500, "花生币余额不足!");
|
||||
}
|
||||
@@ -183,12 +181,39 @@ public class BuyOrderController {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/calculateTransportPrice", method = RequestMethod.POST)
|
||||
public R getTransportPrice(@RequestBody ProductTransportVo vo) {
|
||||
String regionCode = vo.getRegionCode();
|
||||
List<ProductRequestVo> products = vo.getProducts();
|
||||
BigDecimal totalWeight = new BigDecimal(0);
|
||||
for (ProductRequestVo product : products) {
|
||||
ShopProductEntity shopProduct = shopProductService.getById(product.getProductId());
|
||||
BigDecimal weight = BigDecimal.valueOf(Double.valueOf(shopProduct.getWeight()) / 1000.0);
|
||||
totalWeight = totalWeight.add(weight.multiply(new BigDecimal(product.getQuantity())));
|
||||
}
|
||||
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
|
||||
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
|
||||
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
|
||||
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
|
||||
return R.ok().put("result", expressFee);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/getMyOrderList")
|
||||
public R getMyOrderList(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderService.queryPage1(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BuyOrderEntity buyOrder) {
|
||||
public R update(@RequestBody BuyOrder buyOrder) {
|
||||
buyOrderService.updateById(buyOrder);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -202,15 +227,6 @@ public class BuyOrderController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/appUserGetlist")
|
||||
public R appUserGetlist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderService.queryPage1(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* app 端 取消订单
|
||||
@@ -220,7 +236,7 @@ public class BuyOrderController {
|
||||
public R appDelete(@RequestParam("orderId") Integer orderId) {
|
||||
|
||||
//1. 判断订单状态
|
||||
BuyOrderEntity byId = buyOrderService.getById(orderId);
|
||||
BuyOrder byId = buyOrderService.getById(orderId);
|
||||
if (byId != null) {
|
||||
//2. 判断当前订单是否存在优惠券 进行 回显
|
||||
Integer couponId = byId.getCouponId();
|
||||
@@ -231,9 +247,9 @@ public class BuyOrderController {
|
||||
couponHistoryService.updateById(byId1);
|
||||
}
|
||||
// 库存回滚
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", byId.getOrderId()));
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
Integer productId = buyOrderDetailEntity.getProductId();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
|
||||
@@ -244,23 +260,18 @@ public class BuyOrderController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/randomOrderCode")
|
||||
@Transactional
|
||||
public R randomOrderCode(@RequestBody BuyOrderEntity buyOrder) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值专用订单生成接口
|
||||
*/
|
||||
@RequestMapping("/rechargeSave")
|
||||
@Transactional
|
||||
public R rechargeSave(@RequestBody BuyOrderEntity buyOrder) throws IOException {
|
||||
public R rechargeSave(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrderService.save(buyOrder);
|
||||
//下单微信支付预付款订单
|
||||
BuyOrderEntity buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrderEntity>().eq(BuyOrderEntity::getOrderSn, timeId));
|
||||
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, timeId));
|
||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
|
||||
paymentInfo.setBuyOrderId(Integer.valueOf(buyOrderEntity.getProductId()));
|
||||
@@ -271,121 +282,84 @@ public class BuyOrderController {
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getOrderDetail")
|
||||
public R getOrderDetail(@RequestParam Integer orderId){
|
||||
LambdaQueryWrapper<BuyOrderEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrderEntity::getOrderId,orderId);
|
||||
BuyOrderEntity one = buyOrderService.getOne(wrapper);
|
||||
if(one.equals(null)){
|
||||
public R getOrderDetail(@RequestParam Integer orderId) {
|
||||
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrder::getOrderId, orderId);
|
||||
BuyOrder one = buyOrderService.getOne(wrapper);
|
||||
if (one.equals(null)) {
|
||||
return R.error("order error:order is null");
|
||||
}
|
||||
//添加用户信息
|
||||
one.setUser(myUserService.getById(one.getUserId()));
|
||||
//添加商品信息
|
||||
LambdaQueryWrapper<BuyOrderDetailEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(BuyOrderDetailEntity::getOrderId,orderId);
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(wrapper1);
|
||||
LambdaQueryWrapper<BuyOrderDetail> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(BuyOrderDetail::getOrderId, orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(wrapper1);
|
||||
one.setProducts(buyOrderDetailEntities);
|
||||
|
||||
return R.ok().put("detail",one);
|
||||
return R.ok().put("detail", one);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* 获取订单详情
|
||||
*
|
||||
* @param orderId 订单 ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/appGetOrderInfo/{type}")
|
||||
public R appGetOrderInfo(@PathVariable String type, @RequestParam("orderId") Integer orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime()/1000);
|
||||
List<BuyOrderDetailEntity> orderDetail = null;
|
||||
if ("1".equals(type)) {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", orderId));
|
||||
} else {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", orderId));
|
||||
}
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||||
@RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET)
|
||||
public R appGetOrderInfo(@RequestParam("orderId") Integer orderId) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(orderId);
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
|
||||
ShopProductEntity prod = shopProductService.getById(buyOrderDetailEntity.getProductId());
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
ShopProductEntity prod = shopProductService.getById(buyOrderDetail.getProductId());
|
||||
if (prod != null) {
|
||||
buyOrderDetailEntity.setImage(prod.getProductImages());
|
||||
buyOrderDetail.setImage(prod.getProductImages());
|
||||
}
|
||||
}
|
||||
|
||||
List<BuyOrderDetailEntity> resultOrder = new ArrayList<BuyOrderDetailEntity>();
|
||||
Set<String> sn_no = new HashSet<String>();
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||||
resultOrder.add(buyOrderDetailEntity);
|
||||
sn_no.add(buyOrderDetailEntity.getShippingSn());
|
||||
}
|
||||
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||||
.eq("orderSn", buyOrder.getOrderSn())
|
||||
.eq("userid", buyOrder.getUserId())
|
||||
.eq("orderdid", buyOrder.getOrderId())
|
||||
.last("LIMIT 1"));
|
||||
Integer id = null;
|
||||
if (userRecordEntity != null) {
|
||||
id = userRecordEntity.getId();
|
||||
}
|
||||
buyOrder.setProducts(resultOrder);
|
||||
Date createDate = buyOrder.getCreateTime();
|
||||
return R.ok().put("buyOrder", buyOrder).put("CreateTime", createDate).put("userRecordid", id);
|
||||
return R.ok().put("result", buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算快递费用
|
||||
*/
|
||||
@RequestMapping("/getTransPrice/{area}")
|
||||
public R getTransPrice(@PathVariable String area, @RequestParam Map<String, Object> productMap) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("kdCode", "YD");
|
||||
params.put("area", area);
|
||||
int price = this.buyOrderService.getProductGoodsType(params, productMap);
|
||||
return R.ok().put("price", price);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 后台发货按钮
|
||||
*
|
||||
* @Param shipperCode 快递公司编码
|
||||
* @Param sendType 0:订单列表发货 1:商品列表发货
|
||||
* @Param type 合并发货/拆分发货
|
||||
* @Param ids 订单id串
|
||||
*/
|
||||
@RequestMapping("/delivery/{shipperCode}")
|
||||
public R delivery(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] ids) {
|
||||
|
||||
buyOrderService.sendFMS(ids, shipperCode, shipperName);
|
||||
|
||||
@RequestMapping(value = "/modifyOrderAddress", method = RequestMethod.POST)
|
||||
public R modifyOrderAddress(@RequestBody ShippingAddressRequestVo addressRequestVo) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(addressRequestVo.getOrderId());
|
||||
buyOrder.setProvince(addressRequestVo.getProvince());
|
||||
buyOrder.setCity(addressRequestVo.getCity());
|
||||
buyOrder.setDistrict(addressRequestVo.getCounty());
|
||||
buyOrder.setShippingUser(addressRequestVo.getName());
|
||||
buyOrder.setUserPhone(addressRequestVo.getMobile());
|
||||
buyOrderService.updateById(buyOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
* 查询订单快递
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/queryFMS")
|
||||
public R queryFMS(@RequestParam Map<String, String> params) {
|
||||
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
|
||||
List<JSONObject> jsonList = new ArrayList<>();
|
||||
JSONObject jsonObj = null;
|
||||
for (BuyOrderDetailEntity detail : detailList) {
|
||||
jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
|
||||
if (Objects.isNull(jsonObj)) {
|
||||
return R.ok("暂未查到物流信息!");
|
||||
}
|
||||
jsonObj.put("ShipperName", detail.getShipperName());
|
||||
jsonList.add(jsonObj);
|
||||
|
||||
@RequestMapping(value = "/queryExpress", method = RequestMethod.GET)
|
||||
public R queryExpress(@RequestParam("orderId") Integer orderId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
List<ExpressQueryResponseVo> result = new ArrayList<>();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
|
||||
vo.setOrderDetailId(buyOrderDetail.getId());
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(buyOrderDetail.getExpressCompanyCode(), buyOrderDetail.getExpressBillNo());
|
||||
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
|
||||
vo.setTraces(expressQueryResponse.getTraces());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("rntStr", jsonList);
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,44 +386,20 @@ public class BuyOrderController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发货功能
|
||||
* 分包发货
|
||||
*
|
||||
* @param orderDetailIds 订单详情
|
||||
* @return
|
||||
* @param expressCompanyCode 快递公司编码
|
||||
* @param buyOrderDetailId 订单详情列表
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/blendSendFMS/{shipperCode}")
|
||||
public R blendSendFMS(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] orderDetailIds) {
|
||||
|
||||
|
||||
buyOrderService.blendSendFMS(orderDetailIds, shipperCode, shipperName);
|
||||
@RequestMapping(value = "/createSplitPackages", method = RequestMethod.POST)
|
||||
public R createSplitPackageOrder(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
|
||||
buyOrderService.createSplitPackageOrder(expressCompanyCode, buyOrderDetailId);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台取消订单接口
|
||||
*/
|
||||
@RequestMapping("/cancelFMS")
|
||||
public R cancelFMS(@RequestParam Map<String, Object> params) {
|
||||
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
|
||||
params.get("expNo").toString());
|
||||
return R.ok().put("paramsTEXT", params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去重查询可打印面单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querySheetPage")
|
||||
public R querySheetPage(@RequestParam Map<String, Object> params) {
|
||||
|
||||
PageUtils page = buyOrderDetailService.querySheet(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品实际价格
|
||||
*
|
||||
@@ -468,7 +418,7 @@ public class BuyOrderController {
|
||||
* @param product
|
||||
* @return
|
||||
*/
|
||||
private boolean handleStock(BuyOrderDetailEntity buyOrderDetail, ShopProductEntity product) {
|
||||
private boolean handleStock(BuyOrderDetail buyOrderDetail, ShopProductEntity product) {
|
||||
int quantity = buyOrderDetail.getQuantity();
|
||||
if (product.getProductStock() - quantity < 0) {
|
||||
return false;
|
||||
@@ -485,7 +435,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal useCouponAmount(BuyOrderEntity buyOrder) {
|
||||
private BigDecimal useCouponAmount(BuyOrder buyOrder) {
|
||||
Integer couponId = buyOrder.getCouponId();
|
||||
if (couponId != null) {
|
||||
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
||||
@@ -506,7 +456,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal getShoppingAmount(BuyOrderEntity buyOrder) {
|
||||
private BigDecimal getShoppingAmount(BuyOrder buyOrder) {
|
||||
return buyOrder.getOrderMoney() == null ? BigDecimal.ZERO : buyOrder.getShippingMoney();
|
||||
}
|
||||
|
||||
@@ -533,7 +483,7 @@ public class BuyOrderController {
|
||||
* @param user
|
||||
* @param totalPrice
|
||||
*/
|
||||
private void recordTransaction(BuyOrderEntity buyOrder, MyUserEntity user, BigDecimal totalPrice) {
|
||||
private void recordTransaction(BuyOrder buyOrder, MyUserEntity user, BigDecimal totalPrice) {
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setRemark("订单编号为 - " + buyOrder.getOrderSn());
|
||||
transactionDetailsEntity.setUserId(user.getId());
|
||||
@@ -551,8 +501,8 @@ public class BuyOrderController {
|
||||
* @param products
|
||||
* @param buyOrder
|
||||
*/
|
||||
private void addEbookToUser(List<BuyOrderDetailEntity> products, BuyOrderEntity buyOrder) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList());
|
||||
private void addEbookToUser(List<BuyOrderDetail> products, BuyOrder buyOrder) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderDetail::getProductId).collect(Collectors.toList());
|
||||
for (Integer productId : productIds) {
|
||||
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
.eq(ShopProductBookEntity::getProductId, productId)
|
||||
@@ -567,7 +517,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @param buyOrderDetail
|
||||
*/
|
||||
private void handleBuyCart(BuyOrderEntity buyOrder, BuyOrderDetailEntity buyOrderDetail) {
|
||||
private void handleBuyCart(BuyOrder buyOrder, BuyOrderDetail buyOrderDetail) {
|
||||
List<OrderCartEntity> orderCartList = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
|
||||
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderDetail.getProductId()));
|
||||
if (orderCartList.size() > 0) {
|
||||
@@ -579,7 +529,7 @@ public class BuyOrderController {
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30*60*1000));
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
|
||||
return message;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetail;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
@@ -32,32 +23,27 @@ public class BuyOrderDetailController {
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:buyorderdetail:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderDetailService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已购买书籍
|
||||
* 查询已购买书籍
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querybuy")
|
||||
public R querybuy(@RequestParam Map<String, Object> params){
|
||||
public R querybuy(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderDetailService.querybuy(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去重查询可打印面单
|
||||
*
|
||||
@@ -65,10 +51,8 @@ public class BuyOrderDetailController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querySheetPage")
|
||||
public R querySheetPage(@RequestParam Map<String, Object> params){
|
||||
|
||||
public R querySheetPage(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderDetailService.querySheet(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
@@ -76,9 +60,8 @@ public class BuyOrderDetailController {
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{allOrderId}")
|
||||
public R info(@PathVariable("allOrderId") Long allOrderId){
|
||||
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
|
||||
public R info(@PathVariable("allOrderId") Long allOrderId) {
|
||||
BuyOrderDetail buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
return R.ok().put("buyOrderDetail", buyOrderDetail);
|
||||
}
|
||||
|
||||
@@ -86,10 +69,8 @@ public class BuyOrderDetailController {
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:buyorderdetail:save")
|
||||
public R save(@RequestBody BuyOrderDetailEntity buyOrderDetail){
|
||||
buyOrderDetailService.save(buyOrderDetail);
|
||||
|
||||
public R save(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetailService.save(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -97,10 +78,8 @@ public class BuyOrderDetailController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:buyorderdetail:update")
|
||||
public R update(@RequestBody BuyOrderDetailEntity buyOrderDetail){
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
|
||||
public R update(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -108,15 +87,13 @@ public class BuyOrderDetailController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:buyorderdetail:delete")
|
||||
public R delete(@RequestBody Long[] allOrderIds){
|
||||
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
|
||||
|
||||
public R delete(@RequestBody Long[] allOrderIds) {
|
||||
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateOrderStatus")
|
||||
public R updateOrderStatus(@RequestBody BuyOrderDetailEntity buyOrderDetail){
|
||||
public R updateOrderStatus(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetail.setOrderStatus("2");
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
@@ -130,8 +107,7 @@ public class BuyOrderDetailController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/batchUpdateByShippingSns")
|
||||
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList){
|
||||
buyOrderDetailService.batchUpdateByShippingSns(shippingSnList);
|
||||
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.ExpressCompanyService;
|
||||
import com.peanut.modules.book.vo.ExpressCompanyVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 快递 Controller
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/express")
|
||||
public class ExpressController {
|
||||
|
||||
private final ExpressCompanyService expressCompanyService;
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getExpressCompanyList")
|
||||
public R getExpressCompanyList() {
|
||||
List<ExpressCompanyVo> expressCompanyList = expressCompanyService.getExpressCompanyList();
|
||||
return R.ok().put("result", expressCompanyList);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
ExpressController(ExpressCompanyService expressCompanyService) {
|
||||
this.expressCompanyService = expressCompanyService;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
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.entity.City;
|
||||
import com.peanut.modules.book.entity.County;
|
||||
import com.peanut.modules.book.entity.Province;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
import com.peanut.modules.book.service.ProvinceService;
|
||||
@@ -25,7 +25,6 @@ import java.util.Map;
|
||||
@RequestMapping("api/province")
|
||||
public class ProvinceController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
@@ -37,7 +36,7 @@ public class ProvinceController {
|
||||
|
||||
//获取地址
|
||||
@RequestMapping("/getProvince")
|
||||
public R getProvince(){
|
||||
public R getProvince() {
|
||||
|
||||
|
||||
//优化查询速度 目录放入redis中
|
||||
@@ -46,41 +45,36 @@ public class ProvinceController {
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Map <String,Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
listData.add(ret);
|
||||
}
|
||||
return R.ok().put("provinceEntity",listData);
|
||||
return R.ok().put("provinceEntity", listData);
|
||||
}
|
||||
List<ProvinceEntity> provinceEntityList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceEntityList));
|
||||
return R.ok().put("provinceEntity",provinceEntityList);
|
||||
List<Province> provinceList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceList));
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}
|
||||
|
||||
//获取省列表
|
||||
@RequestMapping("/getProvinceList")
|
||||
public R getProvinceList(){
|
||||
List<ProvinceEntity> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<ProvinceEntity>());
|
||||
public R getProvinceList() {
|
||||
List<Province> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<Province>());
|
||||
|
||||
return R.ok().put("provinceList",provinceList);
|
||||
return R.ok().put("provinceList", provinceList);
|
||||
}
|
||||
|
||||
//获取市列表
|
||||
@RequestMapping("/getCityList")
|
||||
public R getCityList(@RequestParam("provId") Integer provId){
|
||||
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
|
||||
public R getCityList(@RequestParam("provId") Integer provId) {
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", provId));
|
||||
|
||||
return R.ok().put("prov",prov);
|
||||
return R.ok().put("prov", prov);
|
||||
}
|
||||
|
||||
//获取区列表
|
||||
@RequestMapping("/getCountyList")
|
||||
public R getCountyList(@RequestParam("cityId") Integer cityId){
|
||||
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityId));
|
||||
|
||||
|
||||
return R.ok().put("countyList",countyList);
|
||||
public R getCountyList(@RequestParam("cityId") Integer cityId) {
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", cityId));
|
||||
return R.ok().put("countyList", countyList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.AuthorEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 出版商表
|
||||
@@ -39,10 +30,8 @@ public class PublisherController {
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:publisher:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = publisherService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
@@ -50,7 +39,6 @@ public class PublisherController {
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/publisherList")
|
||||
// @RequiresPermissions("book:publisher:list")
|
||||
public R publisherList(){
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>());
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
@@ -60,7 +48,6 @@ public class PublisherController {
|
||||
map.put("value",publisherEntitie.getPublisherName());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
@@ -68,10 +55,8 @@ public class PublisherController {
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:publisher:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
PublisherEntity publisher = publisherService.getById(id);
|
||||
|
||||
return R.ok().put("publisher", publisher);
|
||||
}
|
||||
|
||||
@@ -80,7 +65,6 @@ public class PublisherController {
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/appGetInfo/{id}/{limit}/{page}")
|
||||
// @RequiresPermissions("book:author:info")
|
||||
public R appGetInfo(@PathVariable("id") Integer id,
|
||||
@PathVariable("limit") String limit,
|
||||
@PathVariable("page") String page){
|
||||
@@ -103,7 +87,6 @@ public class PublisherController {
|
||||
public R save(@RequestBody PublisherEntity publisher){
|
||||
publisher.setDelFlag(0);
|
||||
publisherService.save(publisher);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -111,10 +94,8 @@ public class PublisherController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:publisher:update")
|
||||
public R update(@RequestBody PublisherEntity publisher){
|
||||
publisherService.updateById(publisher);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -122,11 +103,8 @@ public class PublisherController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:publisher:delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
publisherService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +31,6 @@ public class SeckillProdRelationController {
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:seckillprodrelation:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = seckillProdRelationService.queryPage(params);
|
||||
|
||||
@@ -50,7 +42,6 @@ public class SeckillProdRelationController {
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:seckillprodrelation:info")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
SeckillProdRelationEntity seckillProdRelation = seckillProdRelationService.getById(id);
|
||||
|
||||
@@ -61,26 +52,18 @@ public class SeckillProdRelationController {
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:seckillprodrelation:save")
|
||||
public R save(@RequestBody SeckillProdRelationEntity seckillProdRelation){
|
||||
|
||||
//判断当前场次 是否有相同商品
|
||||
|
||||
Integer prodId = seckillProdRelation.getProdId();
|
||||
|
||||
Integer promotionSeckillId = seckillProdRelation.getPromotionSeckillId();
|
||||
|
||||
List<SeckillProdRelationEntity> list = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", promotionSeckillId));
|
||||
|
||||
for (SeckillProdRelationEntity seckillProdRelationEntity : list) {
|
||||
Integer prodId1 = seckillProdRelationEntity.getProdId();
|
||||
if (prodId1 == prodId){
|
||||
return R.error("商品已存在");
|
||||
}
|
||||
}
|
||||
|
||||
seckillProdRelationService.save(seckillProdRelation);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -88,7 +71,6 @@ public class SeckillProdRelationController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:seckillprodrelation:update")
|
||||
public R update(@RequestBody SeckillProdRelationEntity seckillProdRelation){
|
||||
seckillProdRelationService.updateById(seckillProdRelation);
|
||||
|
||||
|
||||
@@ -98,17 +98,17 @@ public class ShopProductController {
|
||||
public R bookList(@RequestParam("userId") Integer userId
|
||||
) {
|
||||
//查询已购买的书籍
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("user_id", userId));
|
||||
//hashset不重复 且无序
|
||||
Set<String> purchasedProductIds = new HashSet<>();
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
map.put("ProductId", String.valueOf(buyOrderDetailEntity.getProductId()));
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailEntities) {
|
||||
map.put("ProductId", String.valueOf(buyOrderDetail.getProductId()));
|
||||
list.add(map);
|
||||
//去重取出以后买书籍的id
|
||||
purchasedProductIds.add(String.valueOf(buyOrderDetailEntity.getProductId()));
|
||||
purchasedProductIds.add(String.valueOf(buyOrderDetail.getProductId()));
|
||||
}
|
||||
//查询商品表并过滤已购买商品id,根据时间倒叙展示
|
||||
List<ShopProductEntity> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
|
||||
|
||||
@@ -78,7 +78,6 @@ public class ShopProductLabelController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getLabels")
|
||||
public R getLabels(){
|
||||
List<ShopProductLabelEntity> shopProductLabelEntities = shopProductLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductLabelEntity>()
|
||||
@@ -88,8 +87,6 @@ public class ShopProductLabelController {
|
||||
return R.ok().put("result",re);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 废除
|
||||
* @param params
|
||||
@@ -102,7 +99,6 @@ public class ShopProductLabelController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品列表通过标签
|
||||
* @return
|
||||
@@ -119,12 +115,4 @@ public class ShopProductLabelController {
|
||||
|
||||
return R.ok().put("page",shopProductEntityPage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 秒杀库存表
|
||||
@@ -34,10 +30,8 @@ public class ShopSeckillController {
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:shopseckill:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = shopSeckillService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
@@ -46,10 +40,8 @@ public class ShopSeckillController {
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{seckillId}")
|
||||
// @RequiresPermissions("book:shopseckill:info")
|
||||
public R info(@PathVariable("seckillId") Long seckillId){
|
||||
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
||||
|
||||
public R info(@PathVariable("seckillId") Long seckillId) {
|
||||
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
||||
return R.ok().put("shopSeckill", shopSeckill);
|
||||
}
|
||||
|
||||
@@ -57,10 +49,8 @@ public class ShopSeckillController {
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:shopseckill:save")
|
||||
public R save(@RequestBody ShopSeckillEntity shopSeckill){
|
||||
shopSeckillService.save(shopSeckill);
|
||||
|
||||
public R save(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||
shopSeckillService.save(shopSeckill);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -68,10 +58,8 @@ public class ShopSeckillController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:shopseckill:update")
|
||||
public R update(@RequestBody ShopSeckillEntity shopSeckill){
|
||||
shopSeckillService.updateById(shopSeckill);
|
||||
|
||||
public R update(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||
shopSeckillService.updateById(shopSeckill);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -79,28 +67,24 @@ public class ShopSeckillController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:shopseckill:delete")
|
||||
public R delete(@RequestBody Long[] seckillIds){
|
||||
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
||||
|
||||
public R delete(@RequestBody Long[] seckillIds) {
|
||||
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/getSeckillProd")
|
||||
public R getSeckillProd(){
|
||||
public R getSeckillProd() {
|
||||
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
|
||||
|
||||
return R.ok().put("list",list);
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
@GetMapping("/kill")
|
||||
public R kill(@RequestParam("killId") String killId,
|
||||
@RequestParam("key") String key,
|
||||
@RequestParam("num") Integer num,
|
||||
@RequestParam("userId") Integer userId){
|
||||
String orderId = shopSeckillService.kill(killId,key,num,userId);
|
||||
|
||||
return R.ok().put("orderId",orderId);
|
||||
@RequestParam("userId") Integer userId) {
|
||||
String orderId = shopSeckillService.kill(killId, key, num, userId);
|
||||
return R.ok().put("orderId", orderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,133 +1,95 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.UserAddressEntity;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.UserAddress;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
import com.peanut.modules.book.vo.UserAddressVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-31 11:20:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/useraddress")
|
||||
@RequestMapping("book/userAddress")
|
||||
public class UserAddressController {
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* 获取地址信息
|
||||
*
|
||||
* @param addressId address ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:useraddress:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = userAddressService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{addressid}")
|
||||
// @RequiresPermissions("book:useraddress:info")
|
||||
public R info(@PathVariable("addressid") Integer addressid){
|
||||
UserAddressEntity userAddress = userAddressService.getById(addressid);
|
||||
|
||||
return R.ok().put("userAddress", userAddress);
|
||||
@RequestMapping("/info/{addressId}")
|
||||
public R info(@PathVariable("addressId") Integer addressId) {
|
||||
UserAddress userAddress = userAddressService.getById(addressId);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
return R.ok().put("result", vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param userAddress 用户地址
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:useraddress:save")
|
||||
public R save(@RequestBody UserAddressEntity userAddress){
|
||||
Integer isdefault = userAddress.getIsdefault();
|
||||
if (isdefault == 1) {
|
||||
Integer userid = userAddress.getUserid();
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userid));
|
||||
for (UserAddressEntity userAddressEntity : list) {
|
||||
if (userAddressEntity.getIsdefault() == 1) {
|
||||
userAddressEntity.setIsdefault(0);
|
||||
}
|
||||
}
|
||||
userAddressService.updateBatchById(list);
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
// 判断是否已经有默认的地址了
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
userAddressService.save(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:useraddress:update")
|
||||
public R update(@RequestBody UserAddressEntity userAddress){
|
||||
|
||||
Integer isdefault = userAddress.getIsdefault();
|
||||
|
||||
if (isdefault == 1) {
|
||||
|
||||
Integer userid = userAddress.getUserid();
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userid));
|
||||
|
||||
for (UserAddressEntity userAddressEntity : list) {
|
||||
if (userAddressEntity.getIsdefault() == 1) {
|
||||
userAddressEntity.setIsdefault(0);
|
||||
userAddressService.updateById(userAddressEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public R update(@RequestBody UserAddress userAddress) {
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
|
||||
userAddressService.updateById(userAddress);
|
||||
|
||||
userAddressService.updateById(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 删除用户地址
|
||||
*
|
||||
* @param id address ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:useraddress:delete")
|
||||
public R delete(@RequestBody Integer[] addressids){
|
||||
userAddressService.removeByIds(Arrays.asList(addressids));
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
public R delete(@RequestParam("id") Integer id) {
|
||||
userAddressService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* app获取用户 收货地址
|
||||
* 获取用户收货地址列表
|
||||
*
|
||||
* @param userId 用户 ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/getUserAddress")
|
||||
// @RequiresPermissions("book:useraddress:delete")
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId){
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userId).orderByDesc("isDefault"));
|
||||
|
||||
return R.ok().put("list",list);
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.orderByDesc("is_default");
|
||||
List<UserAddress> userAddressList = userAddressService.list(queryWrapper);
|
||||
List<UserAddressVo> result = new ArrayList<>();
|
||||
for (UserAddress userAddress : userAddressList) {
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("list", result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ public class UserBookClockController {
|
||||
/**
|
||||
* 计算打卡天数
|
||||
*
|
||||
* @param bookId
|
||||
* @param userId
|
||||
* @return
|
||||
* @param bookId book ID
|
||||
* @param userId user ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/clockInDays", method = RequestMethod.GET)
|
||||
public R clockInDays(@RequestParam("bookId") Integer bookId,
|
||||
@@ -67,9 +67,9 @@ public class UserBookClockController {
|
||||
/**
|
||||
* 用户打卡
|
||||
*
|
||||
* @param bookId
|
||||
* @param userId
|
||||
* @return
|
||||
* @param bookId book ID
|
||||
* @param userId user ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/clockIn", method = RequestMethod.GET)
|
||||
public R clockIn(@RequestParam("bookId") Integer bookId,
|
||||
|
||||
@@ -5,10 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookClockEntryEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.service.BookClockEntryChatService;
|
||||
import com.peanut.modules.book.service.BookClockEntryService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.UserBookClockService;
|
||||
import com.peanut.modules.book.to.PageIdDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -20,13 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("book/clock")
|
||||
public class UserClockController {
|
||||
|
||||
@Autowired
|
||||
private UserBookClockService userBookClockService;
|
||||
@Autowired
|
||||
private BookClockEntryService bookClockEntryService;
|
||||
@Autowired
|
||||
private BookClockEntryChatService bookClockEntryChatService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import cn.com.marsoft.tool.ToolObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -118,15 +117,15 @@ public class UserFollowUpController {
|
||||
return R.error("请先评论再追评");
|
||||
}
|
||||
String orderSn = userRecord.getOrderSn();
|
||||
BuyOrderEntity buyOrderEntity =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>()
|
||||
BuyOrder buyOrder =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn",orderSn).last("LIMIT 1")
|
||||
);
|
||||
|
||||
Integer orderId = buyOrderEntity.getOrderId();
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
Integer bookid = userRecord.getBookid();
|
||||
Integer userid = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
BuyOrderDetailEntity detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("Order_id", orderId).eq("product_id",bookid));
|
||||
|
||||
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid",id1).last("LIMIT 1"));
|
||||
@@ -135,8 +134,8 @@ public class UserFollowUpController {
|
||||
// return R.error("您已评价过");
|
||||
// }
|
||||
|
||||
buyOrderEntity.setRecordId(2);
|
||||
buyOrderService.saveOrUpdate(buyOrderEntity);
|
||||
buyOrder.setRecordId(2);
|
||||
buyOrderService.saveOrUpdate(buyOrder);
|
||||
if (userFollowUpEntity.getImages()!=null) {
|
||||
|
||||
List<Map<String,String>> imageList = (ArrayList<Map<String,String>>)userFollowUpEntity.getImages();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class UserRecordController {
|
||||
public Object commodityComments(Integer userid, String orderSn, Integer bookid, String comment) {
|
||||
|
||||
|
||||
BuyOrderEntity buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>()
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", orderSn).last("LIMIT 1").eq("order_status", "3")
|
||||
//状态3为已收货
|
||||
// .eq("order_status","3")
|
||||
@@ -172,11 +172,11 @@ public class UserRecordController {
|
||||
UserRecordEntity userRecordEntity = new UserRecordEntity();
|
||||
|
||||
|
||||
if (!ToolObject.isNullOrEmpty(buyOrderEntity)) {
|
||||
if (!ToolObject.isNullOrEmpty(buyOrder)) {
|
||||
return error("您已评价过了,请勿重复评论");
|
||||
//
|
||||
} else {
|
||||
userRecordEntity.setId(buyOrderEntity.getOrderId());
|
||||
userRecordEntity.setId(buyOrder.getOrderId());
|
||||
userRecordEntity.setContent(comment);
|
||||
//商品评价
|
||||
userRecordEntity.setBookid(bookid);
|
||||
@@ -199,12 +199,12 @@ public class UserRecordController {
|
||||
@RequestMapping("/UserRecordcomment")
|
||||
public R commodity(@RequestBody UserRecordEntity recordEntity) {
|
||||
//todo 已收货限制字段,只可评价一次
|
||||
BuyOrderEntity buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>()
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", recordEntity.getOrderSn())
|
||||
);
|
||||
|
||||
Integer orderId = buyOrderEntity.getOrderId();
|
||||
BuyOrderDetailEntity detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetailEntity>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
|
||||
Integer orderId1 = detailEntity.getOrderId();
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user