merge master

This commit is contained in:
Cauchy
2023-10-18 17:16:45 +08:00
32 changed files with 216 additions and 259 deletions

View File

@@ -9,22 +9,13 @@
package com.peanut.modules.app.controller; package com.peanut.modules.app.controller;
import com.peanut.common.utils.R;
import com.peanut.common.validator.ValidatorUtils;
import com.peanut.modules.app.form.LoginForm;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.app.utils.JwtUtils; import com.peanut.modules.app.utils.JwtUtils;
import com.peanut.modules.book.service.MyUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/** /**
* APP登录授权 * APP登录授权
* *
@@ -35,7 +26,7 @@ import java.util.Map;
@Api("APP登录接口") @Api("APP登录接口")
public class AppLoginController { public class AppLoginController {
@Autowired @Autowired
private UserService userService; private MyUserService userService;
@Autowired @Autowired
private JwtUtils jwtUtils; private JwtUtils jwtUtils;

View File

@@ -9,21 +9,12 @@
package com.peanut.modules.app.controller; package com.peanut.modules.app.controller;
import com.peanut.common.utils.R; import com.peanut.modules.book.service.MyUserService;
import com.peanut.common.validator.ValidatorUtils;
import com.peanut.modules.app.form.RegisterForm;
import com.peanut.modules.app.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/** /**
* 注册 * 注册
* *
@@ -34,7 +25,7 @@ import java.util.Date;
@Api("APP注册接口") @Api("APP注册接口")
public class AppRegisterController { public class AppRegisterController {
@Autowired @Autowired
private UserService userService; private MyUserService userService;
// @PostMapping("register") // @PostMapping("register")
// @ApiOperation("注册") // @ApiOperation("注册")

View File

@@ -12,7 +12,7 @@ package com.peanut.modules.app.controller;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.app.annotation.Login; import com.peanut.modules.app.annotation.Login;
import com.peanut.modules.app.annotation.LoginUser; import com.peanut.modules.app.annotation.LoginUser;
import com.peanut.modules.book.entity.UserEntity; import com.peanut.modules.book.entity.MyUserEntity;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@@ -33,7 +33,7 @@ public class AppTestController {
@Login @Login
@GetMapping("userInfo") @GetMapping("userInfo")
@ApiOperation("获取用户信息") @ApiOperation("获取用户信息")
public R userInfo(@LoginUser UserEntity user){ public R userInfo(@LoginUser MyUserEntity user){
return R.ok().put("user", user); return R.ok().put("user", user);
} }

View File

@@ -8,10 +8,10 @@
package com.peanut.modules.app.resolver; package com.peanut.modules.app.resolver;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.app.annotation.LoginUser; import com.peanut.modules.app.annotation.LoginUser;
import com.peanut.modules.app.interceptor.AuthorizationInterceptor; import com.peanut.modules.app.interceptor.AuthorizationInterceptor;
import com.peanut.modules.book.entity.UserEntity; import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.service.MyUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -29,11 +29,11 @@ import org.springframework.web.method.support.ModelAndViewContainer;
@Component @Component
public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Autowired @Autowired
private UserService userService; private MyUserService userService;
@Override @Override
public boolean supportsParameter(MethodParameter parameter) { public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class); return parameter.getParameterType().isAssignableFrom(MyUserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
} }
@Override @Override
@@ -46,7 +46,7 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu
} }
//获取用户信息 //获取用户信息
UserEntity user = userService.getById((Long)object); MyUserEntity user = userService.getById((Long)object);
return user; return user;
} }

View File

@@ -1,31 +0,0 @@
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package com.peanut.modules.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.app.form.LoginForm;
import com.peanut.modules.book.entity.UserEntity;
/**
* 用户
*
* @author Mark sunlightcs@gmail.com
*/
public interface UserService extends IService<UserEntity> {
// UserEntity queryByMobile(String mobile);
//
// /**
// * 用户登录
// * @param form 登录表单
// * @return 返回用户ID
// */
// long login(LoginForm form);
}

View File

@@ -1,44 +0,0 @@
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package com.peanut.modules.app.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.exception.RRException;
import com.peanut.common.validator.Assert;
import com.peanut.modules.book.dao.UserDao;
import com.peanut.modules.app.form.LoginForm;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.entity.UserEntity;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {
// public UserEntity queryByMobile(String mobile) {
// return baseMapper.selectOne(new QueryWrapper<UserEntity>().eq("mobile", mobile));
// }
// public long login(LoginForm form) {
// UserEntity user = queryByMobile(form.getMobile());
// Assert.isNull(user, "手机号或密码错误");
//
// //密码错误
// if(!user.getPassword().equals(DigestUtils.sha256Hex(form.getPassword()))){
// throw new RRException("手机号或密码错误");
// }
//
// return user.getUserId();
// }
}

View File

@@ -5,12 +5,12 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.entity.BookClockEntryEntity; import com.peanut.modules.book.entity.BookClockEntryEntity;
import com.peanut.modules.book.entity.BookClockInChatEntity; import com.peanut.modules.book.entity.BookClockEntryChatEntity;
import com.peanut.modules.book.entity.UserEntity; import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.service.BookClockEntryChatService; import com.peanut.modules.book.service.BookClockEntryChatService;
import com.peanut.modules.book.service.BookClockEntryService; import com.peanut.modules.book.service.BookClockEntryService;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.vo.ClockInCommentVo; import com.peanut.modules.book.vo.ClockInCommentVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -36,7 +36,7 @@ public class BookClockForumController {
private BookClockEntryService bookClockEntryService; private BookClockEntryService bookClockEntryService;
@Autowired @Autowired
private UserService userService; private MyUserService userService;
/** /**
* 获取论坛内容 * 获取论坛内容
@@ -66,7 +66,7 @@ public class BookClockForumController {
@RequestMapping(path = "/getChatList", method = RequestMethod.GET) @RequestMapping(path = "/getChatList", method = RequestMethod.GET)
public R getChatList(@RequestParam("entryId") Integer entryId, public R getChatList(@RequestParam("entryId") Integer entryId,
@RequestParam(value = "userId", required = false) Integer userId) { @RequestParam(value = "userId", required = false) Integer userId) {
QueryWrapper<BookClockInChatEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<BookClockEntryChatEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("entry_id", entryId); queryWrapper.eq("entry_id", entryId);
queryWrapper.eq("fid", 0); queryWrapper.eq("fid", 0);
if (userId != null) { if (userId != null) {
@@ -74,25 +74,25 @@ public class BookClockForumController {
} }
queryWrapper.orderByAsc("fid", "create_time"); queryWrapper.orderByAsc("fid", "create_time");
List<ClockInCommentVo> resultList = new ArrayList<>(); List<ClockInCommentVo> resultList = new ArrayList<>();
List<BookClockInChatEntity> chatEntityList = bookClockEntryChatService.list(queryWrapper); List<BookClockEntryChatEntity> chatEntityList = bookClockEntryChatService.list(queryWrapper);
for (BookClockInChatEntity entity : chatEntityList) { for (BookClockEntryChatEntity entity : chatEntityList) {
List<String> imageList = JSON.parseObject(entity.getImages(), new TypeReference<List<String>>() { List<String> imageList = JSON.parseObject(entity.getImages(), new TypeReference<List<String>>() {
}); });
entity.setImageList(imageList); entity.setImageList(imageList);
ClockInCommentVo vo = new ClockInCommentVo(); ClockInCommentVo vo = new ClockInCommentVo();
BeanUtil.copyProperties(entity, vo); BeanUtil.copyProperties(entity, vo);
UserEntity user = userService.getById(entity.getUserId()); MyUserEntity user = userService.getById(entity.getUserId());
vo.setNickName(user.getNickname()); vo.setNickName(user.getNickname());
vo.setAvatar(user.getAvatar()); vo.setAvatar(user.getAvatar());
QueryWrapper<BookClockInChatEntity> subQueryWrapper = new QueryWrapper<>(); QueryWrapper<BookClockEntryChatEntity> subQueryWrapper = new QueryWrapper<>();
subQueryWrapper.eq("fid", entity.getId()); subQueryWrapper.eq("fid", entity.getId());
List<BookClockInChatEntity> subClockInChatList = bookClockEntryChatService.list(subQueryWrapper); List<BookClockEntryChatEntity> subClockInChatList = bookClockEntryChatService.list(subQueryWrapper);
List<ClockInCommentVo> subCommentList = new ArrayList<>(); List<ClockInCommentVo> subCommentList = new ArrayList<>();
for (BookClockInChatEntity subChat : subClockInChatList) { for (BookClockEntryChatEntity subChat : subClockInChatList) {
ClockInCommentVo subVo = new ClockInCommentVo(); ClockInCommentVo subVo = new ClockInCommentVo();
BeanUtil.copyProperties(subChat, subVo); BeanUtil.copyProperties(subChat, subVo);
UserEntity subChatUser = userService.getById(subChat.getUserId()); MyUserEntity subChatUser = userService.getById(subChat.getUserId());
UserEntity pUser = userService.getById(subChat.getPuserId()); MyUserEntity pUser = userService.getById(subChat.getPuserId());
subVo.setPuserNickName(pUser.getNickname()); subVo.setPuserNickName(pUser.getNickname());
subVo.setPuserAvatar(pUser.getAvatar()); subVo.setPuserAvatar(pUser.getAvatar());
subVo.setAvatar(subChatUser.getAvatar()); subVo.setAvatar(subChatUser.getAvatar());
@@ -114,7 +114,7 @@ public class BookClockForumController {
* @return * @return
*/ */
@RequestMapping(path = "/addChat", method = RequestMethod.POST) @RequestMapping(path = "/addChat", method = RequestMethod.POST)
public R addChat(@RequestBody BookClockInChatEntity chat) { public R addChat(@RequestBody BookClockEntryChatEntity chat) {
List<String> imageList = chat.getImageList(); List<String> imageList = chat.getImageList();
if (imageList != null) { if (imageList != null) {
String images = JSON.toJSON(imageList).toString(); String images = JSON.toJSON(imageList).toString();

View File

@@ -685,7 +685,9 @@ public class BookController {
LambdaQueryWrapper<BookEntity> wrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BookEntity> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(BookEntity::getDelFlag,0); wrapper1.eq(BookEntity::getDelFlag,0);
wrapper1.in(BookEntity::getId,bookIds); if(bookIds.size()>0){
wrapper1.in(BookEntity::getId,bookIds);
}
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1); Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
return R.ok().put("page",bookEntityPage); return R.ok().put("page",bookEntityPage);

View File

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.dao.BookForumArticlesDao; import com.peanut.modules.book.dao.BookForumArticlesDao;
import com.peanut.modules.book.entity.*; import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*; import com.peanut.modules.book.service.*;
@@ -32,7 +31,7 @@ public class BookForumArticlesServiceController {
@Autowired @Autowired
private BookForumArticlesDao bookForumArticlesDao; private BookForumArticlesDao bookForumArticlesDao;
@Autowired @Autowired
private UserService userService; private MyUserService userService;
/** /**
* 列表 (开始时间倒叙) 后台get请求 * 列表 (开始时间倒叙) 后台get请求
@@ -71,6 +70,7 @@ public class BookForumArticlesServiceController {
wrapper.leftJoin(AuthorEntity.class,AuthorEntity::getId,BookEntity::getAuthorId); wrapper.leftJoin(AuthorEntity.class,AuthorEntity::getId,BookEntity::getAuthorId);
wrapper.eq(BookForumArticlesEntity::getDelflag,0); wrapper.eq(BookForumArticlesEntity::getDelflag,0);
wrapper.eq(BookEntity::getDelFlag,0); wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getState,0);
Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesDao.selectJoinPage(new Page<>(page, limit), BookForumArticlesEntity.class, wrapper); Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesDao.selectJoinPage(new Page<>(page, limit), BookForumArticlesEntity.class, wrapper);
for (BookForumArticlesEntity b : bookForumArticlesEntityPage.getRecords()){ for (BookForumArticlesEntity b : bookForumArticlesEntityPage.getRecords()){
@@ -102,6 +102,7 @@ public class BookForumArticlesServiceController {
wrapper.leftJoin(AuthorEntity.class,AuthorEntity::getId,BookEntity::getAuthorId); wrapper.leftJoin(AuthorEntity.class,AuthorEntity::getId,BookEntity::getAuthorId);
wrapper.eq(BookForumArticlesEntity::getDelflag,0); wrapper.eq(BookForumArticlesEntity::getDelflag,0);
wrapper.eq(BookEntity::getDelFlag,0); wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getState,0);
wrapper.orderByDesc(BookForumArticlesEntity::getContlike); wrapper.orderByDesc(BookForumArticlesEntity::getContlike);
Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesDao.selectJoinPage(new Page<>(page, limit), BookForumArticlesEntity.class, wrapper); Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesDao.selectJoinPage(new Page<>(page, limit), BookForumArticlesEntity.class, wrapper);
@@ -130,7 +131,7 @@ public class BookForumArticlesServiceController {
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (BookEntity b :bookEntityPage.getRecords()){ for (BookEntity b :bookEntityPage.getRecords()){
b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); b.setForums(userService.getForumsLimit(b.getId(), 4));
b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); b.setForumNum(bookForumArticlesService.getForumsCount(b.getId()));
} }
@@ -152,11 +153,12 @@ public class BookForumArticlesServiceController {
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookEntity::getDelFlag,0); wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getState,0);
wrapper.exists(ex_sql); wrapper.exists(ex_sql);
wrapper.exists(existSql); wrapper.exists(existSql);
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (BookEntity b : bookEntityPage.getRecords()){ for (BookEntity b : bookEntityPage.getRecords()){
b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); b.setForums(userService.getForumsLimit(b.getId(), 4));
b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); b.setForumNum(bookForumArticlesService.getForumsCount(b.getId()));
} }
@@ -173,15 +175,16 @@ public class BookForumArticlesServiceController {
@RequestMapping("/getBestForumsAndBook") @RequestMapping("/getBestForumsAndBook")
public R getBestForumsAndBook(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ public R getBestForumsAndBook(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
String ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId; String ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId;
String existSql = "select 1 from book_forum_articles where book.id = bookid"; String existSql = "select 1 from book_forum_articles where book.id = bookid and del_flag = 0";
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookEntity::getDelFlag,0); wrapper.eq(BookEntity::getDelFlag,0);
wrapper.eq(BookEntity::getState,0);
wrapper.notExists(ex_sql); wrapper.notExists(ex_sql);
wrapper.exists(existSql); wrapper.exists(existSql);
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (BookEntity b : bookEntityPage.getRecords()){ for (BookEntity b : bookEntityPage.getRecords()){
b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); b.setForums(userService.getForumsLimit(b.getId(), 4));
b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); b.setForumNum(bookForumArticlesService.getForumsCount(b.getId()));
} }
@@ -228,7 +231,7 @@ public class BookForumArticlesServiceController {
wrapper.orderByDesc(BookForumArticlesEntity::getCreateTime); wrapper.orderByDesc(BookForumArticlesEntity::getCreateTime);
Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (BookForumArticlesEntity b:bookForumArticlesEntityPage.getRecords()){ for (BookForumArticlesEntity b:bookForumArticlesEntityPage.getRecords()){
UserEntity byId = userService.getById(b.getUserid()); MyUserEntity byId = userService.getById(b.getUserid());
b.setUser(byId); b.setUser(byId);
b.setComment(bookForumCommenService.getCommentsLimit(b.getId(),3)); b.setComment(bookForumCommenService.getCommentsLimit(b.getId(),3));
} }

View File

@@ -227,6 +227,84 @@ public class BuyOrderController {
return R.ok(); return R.ok();
} }
/**
* app 端 取消订单
*/
@RequestMapping("/appDelete")
@Transactional
public R appDelete(@RequestParam("orderId") Integer orderId) {
//1. 判断订单状态
BuyOrder byId = buyOrderService.getById(orderId);
if (byId != null) {
//2. 判断当前订单是否存在优惠券 进行 回显
Integer couponId = byId.getCouponId();
if (couponId != null) {
CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
byId1.setUseStatus(0);
couponHistoryService.updateById(byId1);
}
// 库存回滚
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
.eq("order_id", byId.getOrderId()));
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
Integer productId = buyOrderDetailEntity.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
shopProductService.updateById(product);
}
buyOrderService.removeById(orderId);
}
return R.ok();
}
/**
* 充值专用订单生成接口
*/
@RequestMapping("/rechargeSave")
@Transactional
public R rechargeSave(@RequestBody BuyOrder buyOrder) throws IOException {
String timeId = IdWorker.getTimeId().substring(0, 32);
buyOrder.setOrderSn(timeId);
buyOrderService.save(buyOrder);
//下单微信支付预付款订单
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()));
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
wxpayService.prepay(paymentInfo);
return R.ok().put("orderSn", timeId);
}
/**
* 获取订单详情
*
* @param orderId
* @return
*/
@RequestMapping("/getOrderDetail")
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<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);
}
/** /**
* 获取订单详情 * 获取订单详情
* *

View File

@@ -9,10 +9,13 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.druid.util.StringUtils; import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.MD5Utils; import com.peanut.common.utils.MD5Utils;
import com.peanut.modules.book.entity.*; import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*; import com.peanut.modules.book.service.*;
import com.peanut.modules.book.to.PageIdDto;
import com.peanut.modules.sys.service.SysUserTokenService; import com.peanut.modules.sys.service.SysUserTokenService;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
@@ -71,6 +74,23 @@ public class MyUserController {
return R.ok().put("page", page); return R.ok().put("page", page);
} }
/**
* 获取用户列表
* @param p
* @return
*/
@RequestMapping("/getUserList")
public R getUserList(@RequestBody PageIdDto p){
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper<>();
if(!p.getKey().equals(null)){
wrapper.eq(MyUserEntity::getTel,p.getKey()).or().eq(MyUserEntity::getName,p.getKey());
}
wrapper.eq(MyUserEntity::getDelFlag,0);
Page<MyUserEntity> myUserEntityPage = userService.getBaseMapper().selectPage(new Page<MyUserEntity>(p.getPage(), p.getLimit()), wrapper);
return R.ok().put("user",myUserEntityPage);
}
/** /**
* 信息 * 信息

View File

@@ -1,9 +1,9 @@
package com.peanut.modules.book.dao; package com.peanut.modules.book.dao;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.BookClockInChatEntity; import com.peanut.modules.book.entity.BookClockEntryChatEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface BookClockEntryChatDao extends MPJBaseMapper<BookClockInChatEntity> { public interface BookClockEntryChatDao extends MPJBaseMapper<BookClockEntryChatEntity> {
} }

View File

@@ -1,24 +0,0 @@
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户
*
* @author Mark sunlightcs@gmail.com
*/
@Mapper
public interface UserDao extends MPJBaseMapper<UserEntity> {
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
@Data @Data
@TableName("book_clock_entry_chat") @TableName("book_clock_entry_chat")
public class BookClockInChatEntity implements Serializable { public class BookClockEntryChatEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId @TableId

View File

@@ -102,7 +102,7 @@ public class BookForumArticlesEntity {
//说话的人 //说话的人
@TableField(exist = false) @TableField(exist = false)
private UserEntity user; private MyUserEntity user;

View File

@@ -70,11 +70,11 @@ public class BookForumCommentEntity {
//发言者 //发言者
@TableField(exist = false) @TableField(exist = false)
private UserEntity user; private MyUserEntity user;
//对谁说 //对谁说
@TableField(exist = false) @TableField(exist = false)
private UserEntity puser; private MyUserEntity puser;
//子对话 //子对话
@TableField(exist = false) @TableField(exist = false)

View File

@@ -169,4 +169,7 @@ public class BuyOrder implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private Long timestamp; private Long timestamp;
@TableField(exist = false)
private MyUserEntity user;
} }

View File

@@ -1,65 +0,0 @@
package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@TableName("user")
public class UserEntity {
private static final long serialVersionUID = 1L;
@TableId
@TableField("id")
private Integer id;
private String name;
private Integer age;
private Integer sex;
private String avatar;
private String nickname;
private String tel;
private String password;
private String vip;
@TableField("vip_start_time")
private Date vipStartTime;
@TableField("vip_validtime")
private Date vipValidtime;
@TableField("peanut_coin")
private BigDecimal peanutCoin;
@TableField("read_time")
private Date readTime;
@TableField("last_login_time")
private Date lastLoginTime;
@TableField("yljk_oid")
private String yljkOid;
@TableField("create_time")
private Date createTime;
@TableField("update_time")
private Date updateTime;
@TableField("del_flag")
private Integer delFlag;
private String remark;
}

View File

@@ -1,7 +1,7 @@
package com.peanut.modules.book.service; package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.BookClockInChatEntity; import com.peanut.modules.book.entity.BookClockEntryChatEntity;
public interface BookClockEntryChatService extends IService<BookClockInChatEntity> { public interface BookClockEntryChatService extends IService<BookClockEntryChatEntity> {
} }

View File

@@ -13,8 +13,6 @@ public interface BookForumArticlesService extends IService<BookForumArticlesEn
PageUtils queryPages(Map<String, Object> params); PageUtils queryPages(Map<String, Object> params);
List<BookForumArticlesEntity> getForumsLimit(Integer book_id,Integer limit);
Integer getForumsCount(Integer book_id); Integer getForumsCount(Integer book_id);
} }

View File

@@ -3,11 +3,13 @@ package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BookForumArticlesEntity;
import com.peanut.modules.book.entity.MyUserEntity; import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.entity.UserAppAuthorEntity; import com.peanut.modules.book.entity.UserAppAuthorEntity;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import javax.persistence.Entity; import javax.persistence.Entity;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -30,6 +32,8 @@ public interface MyUserService extends IService<MyUserEntity> {
//电子书针对听书鉴权 //电子书针对听书鉴权
boolean bookAuthen(Integer bookId,Integer userId); boolean bookAuthen(Integer bookId,Integer userId);
List<BookForumArticlesEntity> getForumsLimit(Integer book_id, Integer limit);
//会员开通 电话 开通 期限 //会员开通 电话 开通 期限
boolean openMember(Integer customerId,Integer openMonth); boolean openMember(Integer customerId,Integer openMonth);

View File

@@ -18,5 +18,7 @@ public interface PayWechatOrderService extends IService<PayWechatOrderEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
void add(String orderSn,String prepayId); void add(String orderSn,String prepayId);
void addForPoint(String orderSn,String prepayId,Integer buyOrderId);
} }

View File

@@ -2,10 +2,10 @@ package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.BookClockEntryChatDao; import com.peanut.modules.book.dao.BookClockEntryChatDao;
import com.peanut.modules.book.entity.BookClockInChatEntity; import com.peanut.modules.book.entity.BookClockEntryChatEntity;
import com.peanut.modules.book.service.BookClockEntryChatService; import com.peanut.modules.book.service.BookClockEntryChatService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service("bookClockEntryChatService") @Service("bookClockEntryChatService")
public class BookClockEntryChatImpl extends ServiceImpl<BookClockEntryChatDao, BookClockInChatEntity> implements BookClockEntryChatService { public class BookClockEntryChatImpl extends ServiceImpl<BookClockEntryChatDao, BookClockEntryChatEntity> implements BookClockEntryChatService {
} }

View File

@@ -6,28 +6,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query; import com.peanut.common.utils.Query;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.dao.BookForumArticlesDao; import com.peanut.modules.book.dao.BookForumArticlesDao;
import com.peanut.modules.book.entity.AuthorEntity;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.BookForumArticlesEntity; import com.peanut.modules.book.entity.BookForumArticlesEntity;
import com.peanut.modules.book.entity.PublisherEntity;
import com.peanut.modules.book.service.AuthorService;
import com.peanut.modules.book.service.BookForumArticlesService; import com.peanut.modules.book.service.BookForumArticlesService;
import com.peanut.modules.book.service.BookService; import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.service.PublisherService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesDao, BookForumArticlesEntity> implements BookForumArticlesService { public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesDao, BookForumArticlesEntity> implements BookForumArticlesService {
@Autowired
UserService userService;
@Override @Override
@@ -61,20 +53,6 @@ public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesD
return new PageUtils(page); return new PageUtils(page);
} }
@Override
public List<BookForumArticlesEntity> getForumsLimit(Integer book_id,Integer limit) {
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
wrapper.eq(BookForumArticlesEntity::getBookid,book_id);
wrapper.orderByDesc(BookForumArticlesEntity::getCreateTime);
wrapper.last("limit "+limit);
List<BookForumArticlesEntity> bookForumArticlesEntities = this.getBaseMapper().selectList(wrapper);
//补充说话的人的用户信息
for (BookForumArticlesEntity b : bookForumArticlesEntities){
b.setUser(userService.getById(b.getUserid()));
}
return bookForumArticlesEntities;
}
@Override @Override
public Integer getForumsCount(Integer book_id) { public Integer getForumsCount(Integer book_id) {

View File

@@ -6,10 +6,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query; import com.peanut.common.utils.Query;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.dao.BookForumCommentDao; import com.peanut.modules.book.dao.BookForumCommentDao;
import com.peanut.modules.book.entity.BookForumCommentEntity; import com.peanut.modules.book.entity.BookForumCommentEntity;
import com.peanut.modules.book.service.BookForumCommenService; import com.peanut.modules.book.service.BookForumCommenService;
import com.peanut.modules.book.service.MyUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -20,7 +20,7 @@ import java.util.Map;
public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao, BookForumCommentEntity> implements BookForumCommenService { public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao, BookForumCommentEntity> implements BookForumCommenService {
@Autowired @Autowired
private UserService userService; private MyUserService userService;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {

View File

@@ -8,6 +8,7 @@ import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
import com.aliyun.tea.TeaException; import com.aliyun.tea.TeaException;
import com.aliyun.teautil.Common; import com.aliyun.teautil.Common;
import com.aliyun.teautil.models.RuntimeOptions; import com.aliyun.teautil.models.RuntimeOptions;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.peanut.common.utils.*; import com.peanut.common.utils.*;
@@ -55,6 +56,8 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
private CouponHistoryService couponHistoryService; private CouponHistoryService couponHistoryService;
@Autowired @Autowired
private MyUserDao myUserDao; private MyUserDao myUserDao;
@Autowired
private BookForumArticlesService bookForumArticlesService;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
@@ -145,6 +148,21 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
return true; return true;
} }
@Override
public List<BookForumArticlesEntity> getForumsLimit(Integer book_id,Integer limit) {
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
wrapper.eq(BookForumArticlesEntity::getBookid,book_id);
wrapper.orderByDesc(BookForumArticlesEntity::getCreateTime);
wrapper.last("limit "+limit);
List<BookForumArticlesEntity> bookForumArticlesEntities = bookForumArticlesService.getBaseMapper().selectList(wrapper);
//补充说话的人的用户信息
for (BookForumArticlesEntity b : bookForumArticlesEntities){
b.setUser(this.getById(b.getUserid()));
}
return bookForumArticlesEntities;
}

View File

@@ -50,4 +50,22 @@ public class PayWechatOrderServiceImpl extends ServiceImpl<PayWechatOrderDao, Pa
this.save(entity); this.save(entity);
} }
@Override
public void addForPoint(String orderSn, String prepayId, Integer buyOrderId) {
QueryWrapper<BuyOrderEntity> wrapper = new QueryWrapper<>();
wrapper.eq("order_sn", orderSn);
BuyOrderEntity buyOrder = buyOrderService.getOne(wrapper);
PayWechatOrderEntity entity = new PayWechatOrderEntity();
entity.setCustomerId(buyOrder.getUserId());
entity.setCreateTime(new Date());
entity.setOrderSn(buyOrder.getOrderSn());
entity.setPrepayId(prepayId);
entity.setTotalAmount(buyOrder.getRealMoney());
entity.setSystemLog("预支付完成");
entity.setPayType(buyOrder.getOrderType());
entity.setOrderId(buyOrder.getOrderSn());
entity.setBuyOrderId(buyOrderId);
this.save(entity);
}
} }

View File

@@ -9,6 +9,8 @@ public class PageIdDto implements Serializable {
private Integer id; private Integer id;
private String key;
private Integer limit; private Integer limit;
private Integer page; private Integer page;

View File

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper; import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.common.utils.PageUtils; import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query; import com.peanut.common.utils.Query;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.entity.BookBuyConfigEntity; import com.peanut.modules.book.entity.BookBuyConfigEntity;
import com.peanut.modules.book.entity.BuyOrder; import com.peanut.modules.book.entity.BuyOrder;
import com.peanut.modules.book.entity.MyUserEntity; import com.peanut.modules.book.entity.MyUserEntity;
@@ -37,7 +36,7 @@ public class OrderServiceImpl extends ServiceImpl<PayIOSOrderMapper,IosPayOrderE
@Autowired @Autowired
private BuyOrderService buyOrderService; private BuyOrderService buyOrderService;
@Autowired @Autowired
private UserService userService; private MyUserService userService;
@Autowired @Autowired
private MyUserService myUserService; private MyUserService myUserService;

View File

@@ -58,6 +58,11 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
log.info("请求参数:{}", paramMap); log.info("请求参数:{}", paramMap);
JSONObject responseJson = wxPayUtil.doPostWexinV3(wechatPayConfig.getPayUrl(), json.toJSONString()); JSONObject responseJson = wxPayUtil.doPostWexinV3(wechatPayConfig.getPayUrl(), json.toJSONString());
String prepayId = responseJson.getString("prepay_id"); String prepayId = responseJson.getString("prepay_id");
payWechatOrderService.add(paymentInfo.getOrderSn(), prepayId); if (paymentInfo.getBuyOrderId() == null) {
payWechatOrderService.add(paymentInfo.getOrderSn(), prepayId);
} else {
payWechatOrderService.addForPoint(paymentInfo.getOrderSn(), prepayId, paymentInfo.getBuyOrderId());
}
} }
} }

View File

@@ -3,7 +3,7 @@ spring:
redis: redis:
open: false # 是否开启redis缓存 true开启 false关闭 open: false # 是否开启redis缓存 true开启 false关闭
database: 0 database: 0
host: 59.110.212.44 host: 39.106.36.183
port: 6379 port: 6379
password: Jgll2015 # 密码(默认为空) password: Jgll2015 # 密码(默认为空)
timeout: 6000000ms # 连接超时时长(毫秒) timeout: 6000000ms # 连接超时时长(毫秒)
@@ -72,5 +72,5 @@ aliyun:
server: server:
port: 9200 port: 9200
redisAddress: redis://59.110.212.44:6379 redisAddress: redis://39.106.36.183:6379
redisPassword: Jgll2015 redisPassword: Jgll2015

View File

@@ -1,11 +1,12 @@
package com; package com;
import com.peanut.modules.pay.weChatPay.config.WechatPayConfig; import com.peanut.modules.pay.weChatPay.config.WechatPayConfig;
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.security.PrivateKey; import java.security.PrivateKey;
@SpringBootTest @SpringBootTest
public class VxApiTest { public class VxApiTest {
@@ -32,5 +33,13 @@ public class VxApiTest {
System.out.println(mchId); System.out.println(mchId);
} }
@Test
public void mytest(){
WechatPaymentInfo wechatPaymentInfo = new WechatPaymentInfo();
wechatPaymentInfo.setTotalAmount(new BigDecimal(56));
wechatPaymentInfo.setOrderSn("testtest");
System.out.println(wechatPaymentInfo.toString());
}
} }