Merge remote-tracking branch 'origin/zcc'

This commit is contained in:
wangjinlei
2024-04-10 11:13:14 +08:00
16 changed files with 319 additions and 11 deletions

View File

@@ -53,10 +53,7 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
ShopProduct productEntity = shopProductService.getById(productId);
System.out.println("productEntity=============================="+productEntity);
// if (productEntity == null) {
// return null;
// } else {
// shopProductService.getBaseMapper().selectList()
if (productEntity != null) {
ShopCartVo shopCartVo = new ShopCartVo();
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
@@ -83,10 +80,7 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
shopCartVo.setActivityPrice(price);
cartList.add(shopCartVo);
}
// }
}
return cartList;
}

View File

@@ -0,0 +1,34 @@
package com.peanut.modules.common.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.UserVip;
import com.peanut.modules.common.service.UserVipService;
import lombok.extern.slf4j.Slf4j;
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;
/**
* 超V管理
*/
@Slf4j
@RestController("commonUserVip")
@RequestMapping("common/userVip")
public class UserVipController {
@Autowired
private UserVipService vipService;
@RequestMapping("/getMyVipHistory")
public R getMyVipHistory(String userId) {
LambdaQueryWrapper<UserVip> wrapper = new LambdaQueryWrapper();
wrapper.eq(UserVip::getUserId,userId);
wrapper.orderByAsc(UserVip::getState);
wrapper.orderByAsc(UserVip::getEndTime);
List<UserVip> userVips = vipService.list(wrapper);
return R.ok().put("result", userVips);
}
}

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peanut.modules.common.entity.UserVip;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserVipDao extends BaseMapper<UserVip> {
}

View File

@@ -72,6 +72,10 @@ public class MyUserEntity implements Serializable {
* 花生币
*/
private BigDecimal peanutCoin;
/**
* 积分
*/
private BigDecimal jf;
/**
* 阅读时间
*/

View File

@@ -0,0 +1,52 @@
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("user_vip")
public class UserVip implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 自增 ID
*/
@TableId
private int id;
/**
* 会员 ID
*/
private Integer userId;
/**
* 1超v2简易超v
*/
private Integer type;
/**
* 开始时间
*/
private Date startTime;
/**
* 失效时间
*/
private Date endTime;
/**
* 0有效1失效
*/
private Integer state;
/**
* 删除标识
*/
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private MyUserEntity user;
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.UserVip;
public interface UserVipService extends IService<UserVip> {
}

View File

@@ -17,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service("myUserService")
@Service("commonMyUserService")
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
@Autowired

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.UserVipDao;
import com.peanut.modules.common.entity.UserVip;
import com.peanut.modules.common.service.UserVipService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("commonUserVipService")
public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> implements UserVipService {
}

View File

@@ -0,0 +1,40 @@
package com.peanut.modules.job.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.modules.common.entity.MyUserEntity;
import com.peanut.modules.common.entity.UserVip;
import com.peanut.modules.common.service.MyUserService;
import com.peanut.modules.master.service.UserVipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component("userVipTask")
public class UserVipTask implements ITask{
@Autowired
private UserVipService vipService;
@Autowired
private MyUserService userService;
@Override
public void run(String params) {
LambdaQueryWrapper<UserVip> wrapper = new LambdaQueryWrapper();
wrapper.eq(UserVip::getState,0);
List<UserVip> list = vipService.list(wrapper);
if (list.size() > 0) {
for (UserVip userVip : list) {
if (userVip.getEndTime().getTime()<new Date().getTime()){
userVip.setState(1);
vipService.saveOrUpdate(userVip);
MyUserEntity user = userService.getById(userVip.getUserId());
user.setVip("0");
userService.saveOrUpdate(user);
}
}
}
}
}

View File

@@ -0,0 +1,115 @@
package com.peanut.modules.master.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.DateUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.MyUserEntity;
import com.peanut.modules.common.entity.UserVip;
import com.peanut.modules.master.service.MyUserService;
import com.peanut.modules.master.service.UserVipService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 超V管理
*/
@Slf4j
@RestController("masterUserVip")
@RequestMapping("master/userVip")
public class UserVipController {
@Autowired
private UserVipService vipService;
@Autowired
private MyUserService userService;
@RequestMapping("/listByPage")
public R listByPage(@RequestBody Map<String, Object> params) {
MPJLambdaWrapper<UserVip> wrapper = new MPJLambdaWrapper();
wrapper.selectAll(UserVip.class);
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId, UserVip::getUserId);
if (params.containsKey("userName")&& StringUtils.isNotEmpty(params.get("userName").toString())) {
wrapper.eq(MyUserEntity::getName,params.get("userName"));
}
if (params.containsKey("tel")&& StringUtils.isNotEmpty(params.get("tel").toString())) {
wrapper.eq(MyUserEntity::getTel,params.get("tel"));
}
if (params.containsKey("email")&& StringUtils.isNotEmpty(params.get("email").toString())) {
wrapper.eq(MyUserEntity::getEmail,params.get("email"));
}
if (params.containsKey("type")&& StringUtils.isNotEmpty(params.get("type").toString())) {
wrapper.eq(UserVip::getType,params.get("type"));
}
if (params.containsKey("state")&& StringUtils.isNotEmpty(params.get("state").toString())) {
wrapper.eq(UserVip::getState,params.get("state"));
}
wrapper.orderByAsc(UserVip::getEndTime);
Page<UserVip> page = vipService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
List<UserVip> userVips = page.getRecords();
if (userVips.size() > 0){
for (UserVip userVip : userVips) {
userVip.setUser(userService.getById(userVip.getUserId()));
}
}
return R.ok().put("result", page);
}
@RequestMapping("/saveUserVip")
@Transactional
public R saveUserVip(@RequestBody Map<String, Object> params) {
MyUserEntity user = userService.getById(params.get("userId").toString());
if (user.getPeanutCoin().compareTo(new BigDecimal(params.get("point").toString()))>=0){
if (user.getPeanutCoin().compareTo(new BigDecimal(params.get("jf").toString()))>=0){
UserVip userVip = new UserVip();
userVip.setUserId(Integer.parseInt(params.get("userId").toString()));
userVip.setType(Integer.parseInt(params.get("type").toString()));
userVip.setEndTime(DateUtils.addDateMonths(new Date(),Integer.parseInt(params.get("month").toString())));
vipService.save(userVip);
user.setPeanutCoin(user.getPeanutCoin().subtract(new BigDecimal(params.get("point").toString())));
user.setJf(user.getJf().subtract(new BigDecimal(params.get("jf").toString())));
user.setVip(params.get("type").toString());
userService.saveOrUpdate(user);
return R.ok();
}else {
return R.error("积分不足");
}
}else {
return R.error("花生币不足");
}
}
//延长过期时间month为延长月数
@RequestMapping("/extendUserVip")
public R extendUserVip(@RequestBody Map<String, Object> params) {
UserVip userVip = vipService.getById(params.get("userVipId").toString());
MyUserEntity user = userService.getById(userVip.getUserId());
if (user.getPeanutCoin().compareTo(new BigDecimal(params.get("point").toString()))>=0){
if (user.getPeanutCoin().compareTo(new BigDecimal(params.get("jf").toString()))>=0){
Date newEndTime = DateUtils.addDateMonths(userVip.getEndTime(),Integer.parseInt(params.get("month").toString()));
userVip.setEndTime(newEndTime);
vipService.saveOrUpdate(userVip);
user.setPeanutCoin(user.getPeanutCoin().subtract(new BigDecimal(params.get("point").toString())));
user.setJf(user.getJf().subtract(new BigDecimal(params.get("jf").toString())));
userService.saveOrUpdate(user);
return R.ok();
}else {
return R.error("积分不足");
}
}else {
return R.error("花生币不足");
}
}
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.MyUserEntity;
public interface MyUserService extends IService<MyUserEntity> {
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.UserVip;
public interface UserVipService extends IService<UserVip> {
}

View File

@@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.Map;
@Slf4j
@Service("buyConfigService")
@Service("masterBuyConfigService")
public class BuyConfigServiceImpl extends ServiceImpl<BookBuyConfigDao, BookBuyConfigEntity> implements BuyConfigService {
@Override

View File

@@ -8,6 +8,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("messageService")
@Service("masterMessageService")
public class MessageServiceImpl extends ServiceImpl<MessageDao, Message> implements MessageService {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.MyUserDao;
import com.peanut.modules.common.entity.MyUserEntity;
import com.peanut.modules.master.service.MyUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("masterMyUserService")
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.UserVipDao;
import com.peanut.modules.common.entity.UserVip;
import com.peanut.modules.master.service.UserVipService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("masterUserVipService")
public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> implements UserVipService {
}