获取用户当前培训班最低价格
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -55,7 +56,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
public BigDecimal getVipDiscountAmount(ShopProduct shopProduct) {
|
||||
BigDecimal p = new BigDecimal(0);
|
||||
if (userVipService.isVip()&&shopProduct.getIsVipPrice()==1){
|
||||
if (userVipService.is4569SVip()||userVipService.is78SVip()){
|
||||
if (userVipService.is4569SVip(ShiroUtils.getUId())||userVipService.is78SVip(ShiroUtils.getUId())){
|
||||
p = shopProduct.getPrice().multiply(new BigDecimal(0.8));
|
||||
}else if (userVipService.isVip()){
|
||||
p = shopProduct.getPrice().multiply(new BigDecimal(0.9));
|
||||
@@ -74,7 +75,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
@Override
|
||||
public BigDecimal getVipPrice(ShopProduct shopProduct) {
|
||||
BigDecimal b = new BigDecimal(0);
|
||||
if (userVipService.is4569SVip()||userVipService.is78SVip()){
|
||||
if (userVipService.is4569SVip(ShiroUtils.getUId())||userVipService.is78SVip(ShiroUtils.getUId())){
|
||||
b = shopProduct.getPrice().multiply(new BigDecimal(0.8)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
}else if (userVipService.isVip()){
|
||||
b = shopProduct.getPrice().multiply(new BigDecimal(0.9)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
@@ -47,6 +47,13 @@ public class TrainingClassController {
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
//获取用户当前培训班最低价格
|
||||
@RequestMapping("/getFinalPriceByUser")
|
||||
public R getFinalPriceByUser(@RequestBody Map<String,Object> params) {
|
||||
Map<String,Object> info = trainingClassService.getFinalPriceByUser((int)params.get("classId"),(int)params.get("userId"));
|
||||
return R.ok().put("info",info);
|
||||
}
|
||||
|
||||
//培训班列表
|
||||
@RequestMapping("/trainingClassList")
|
||||
public R trainingClassList(@RequestBody Map<String,Object> params) {
|
||||
|
||||
@@ -20,11 +20,11 @@ public class TrainingToUser {
|
||||
|
||||
private Integer trainingId;
|
||||
|
||||
private String payMethod;
|
||||
|
||||
private String orderSn;
|
||||
|
||||
private BigDecimal money;
|
||||
private String identity;
|
||||
|
||||
private String payMethod;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.TrainingClass;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TrainingClassService extends IService<TrainingClass> {
|
||||
|
||||
Map<String,Object> getFinalPriceByUser(int classId, int userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ public interface UserVipService extends IService<UserVip> {
|
||||
boolean isVip();
|
||||
boolean isVip(int uid);
|
||||
boolean noMedicalVip();
|
||||
boolean isMedicalVip();
|
||||
boolean isChineseWesternVip();
|
||||
boolean isAcupunctureVip();
|
||||
boolean istumorVip();
|
||||
boolean isSociologyVip();
|
||||
boolean isPsycheVip();
|
||||
boolean is4569SVip();
|
||||
boolean is78SVip();
|
||||
boolean isMedicalVip(int uid);
|
||||
boolean isChineseWesternVip(int uid);
|
||||
boolean isAcupunctureVip(int uid);
|
||||
boolean istumorVip(int uid);
|
||||
boolean isSociologyVip(int uid);
|
||||
boolean isPsycheVip(int uid);
|
||||
boolean is4569SVip(int uid);
|
||||
boolean is78SVip(int uid);
|
||||
|
||||
//是否是这门课的vip
|
||||
UserVip ownCourseCatalogueByVip(int courseId);
|
||||
|
||||
@@ -1,13 +1,101 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.modules.common.dao.TrainingClassDao;
|
||||
import com.peanut.modules.common.dao.UserVipDao;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.TrainingClass;
|
||||
import com.peanut.modules.common.entity.UserContribution;
|
||||
import com.peanut.modules.common.entity.UserVip;
|
||||
import com.peanut.modules.common.service.TrainingClassService;
|
||||
import com.peanut.modules.common.service.UserContributionService;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonTrainingClassService")
|
||||
public class TrainingClassServiceImpl extends ServiceImpl<TrainingClassDao, TrainingClass> implements TrainingClassService {
|
||||
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private UserContributionService userContributionService;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> getFinalPriceByUser(int classId,int userId) {
|
||||
TrainingClass trainingClass = this.getById(classId);
|
||||
BigDecimal fee = trainingClass.getFee();
|
||||
String identity ="原价";
|
||||
if (trainingClass!=null){
|
||||
if (StringUtils.isNotEmpty(trainingClass.getVipType())){
|
||||
String[] vipTypes = trainingClass.getVipType().split(",");
|
||||
for (String vipType : vipTypes) {
|
||||
int count = userVipService.count(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId,userId).eq(UserVip::getType,vipType).eq(UserVip::getState,0));
|
||||
if (count>0){
|
||||
fee = trainingClass.getVipFee();
|
||||
identity = "vip";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(trainingClass.getSvipType())){
|
||||
String[] svipTypes = trainingClass.getSvipType().split(",");
|
||||
for (String svipType : svipTypes) {
|
||||
if ("1".equals(svipType)&&userVipService.is4569SVip(userId)){
|
||||
if (fee.compareTo(trainingClass.getSvipFee())>0){
|
||||
fee = trainingClass.getSvipFee();
|
||||
identity = "svip";
|
||||
}
|
||||
}else if ("2".equals(svipType)&&userVipService.is78SVip(userId)){
|
||||
if (fee.compareTo(trainingClass.getSvipFee())>0){
|
||||
fee = trainingClass.getSvipFee();
|
||||
identity = "svip";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trainingClass.getThreeHuFee().compareTo(BigDecimal.ZERO)>0){
|
||||
MPJLambdaWrapper<UserContribution> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(UserContribution::getUserId,userId);
|
||||
wrapper.selectSum(UserContribution::getScore);
|
||||
Map<String,Object> map = userContributionService.getMap(wrapper);
|
||||
if (map != null&&map.containsKey("score")){
|
||||
if (new BigDecimal(map.get("score").toString()).compareTo(new BigDecimal(90))>=0){
|
||||
if (fee.compareTo(trainingClass.getThreeHuFee())>0){
|
||||
fee = trainingClass.getThreeHuFee();
|
||||
identity = "三星湖粉";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trainingClass.getFiveHuFee().compareTo(BigDecimal.ZERO)>0){
|
||||
MPJLambdaWrapper<UserContribution> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(UserContribution::getUserId,userId);
|
||||
wrapper.selectSum(UserContribution::getScore);
|
||||
Map<String,Object> map = userContributionService.getMap(wrapper);
|
||||
if (map != null&&map.containsKey("score")){
|
||||
if (new BigDecimal(map.get("score").toString()).compareTo(new BigDecimal(150))>=0){
|
||||
if (fee.compareTo(trainingClass.getFiveHuFee())>0){
|
||||
fee = trainingClass.getFiveHuFee();
|
||||
identity = "五星湖粉";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Map map = new HashMap<>();
|
||||
map.put("fee",fee);
|
||||
map.put("identity",identity);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,53 +69,52 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMedicalVip() {
|
||||
return isVipByType(4);
|
||||
public boolean isMedicalVip(int uid) {
|
||||
return isVipByType(4,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChineseWesternVip() {
|
||||
return isVipByType(9);
|
||||
public boolean isChineseWesternVip(int uid) {
|
||||
return isVipByType(9,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcupunctureVip() {
|
||||
return isVipByType(5);
|
||||
public boolean isAcupunctureVip(int uid) {
|
||||
return isVipByType(5,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean istumorVip() {
|
||||
return isVipByType(6);
|
||||
public boolean istumorVip(int uid) {
|
||||
return isVipByType(6,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSociologyVip() {
|
||||
return isVipByType(7);
|
||||
public boolean isSociologyVip(int uid) {
|
||||
return isVipByType(7,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPsycheVip() {
|
||||
return isVipByType(8);
|
||||
public boolean isPsycheVip(int uid) {
|
||||
return isVipByType(8,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is4569SVip() {
|
||||
if (isVipByType(4)&&isVipByType(9)&&isVipByType(5)&&isVipByType(6)){
|
||||
public boolean is4569SVip(int uid) {
|
||||
if (isVipByType(4,uid)&&isVipByType(9,uid)&&isVipByType(5,uid)&&isVipByType(6,uid)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is78SVip() {
|
||||
if (isVipByType(7)&&isVipByType(8)){
|
||||
public boolean is78SVip(int uid) {
|
||||
if (isVipByType(7,uid)&&isVipByType(8,uid)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVipByType(int type) {
|
||||
int uid = ShiroUtils.getUId();
|
||||
public boolean isVipByType(int type,int uid) {
|
||||
if (uid >= 10000) {
|
||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||
.eq(UserVip::getUserId, uid)
|
||||
|
||||
@@ -165,19 +165,19 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
wrapper.rightJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,CourseEntity::getId);
|
||||
//开通的会员下的课程
|
||||
List list = new ArrayList<>();//通过顶级标签获取最下层标签
|
||||
if (userVipService.isMedicalVip()){
|
||||
if (userVipService.isMedicalVip(ShiroUtils.getUId())){
|
||||
userVipService.bottomLabel(1,list);
|
||||
}
|
||||
if (userVipService.isChineseWesternVip()){
|
||||
if (userVipService.isChineseWesternVip(ShiroUtils.getUId())){
|
||||
userVipService.bottomLabel(74,list);
|
||||
}
|
||||
if (userVipService.isAcupunctureVip()){
|
||||
if (userVipService.isAcupunctureVip(ShiroUtils.getUId())){
|
||||
userVipService.bottomLabel(2,list);
|
||||
}
|
||||
if (userVipService.istumorVip()){
|
||||
if (userVipService.istumorVip(ShiroUtils.getUId())){
|
||||
userVipService.bottomLabel(5,list);
|
||||
}
|
||||
if (userVipService.isPsycheVip()){
|
||||
if (userVipService.isPsycheVip(ShiroUtils.getUId())){
|
||||
userVipService.bottomLabel(4,list);
|
||||
}
|
||||
//购买的课程
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PsycheCourseController {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.distinct();
|
||||
wrapper.rightJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
|
||||
if (!userVipService.isPsycheVip()){
|
||||
if (!userVipService.isPsycheVip(ShiroUtils.getUId())){
|
||||
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class PsycheCourseController {
|
||||
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
||||
List<Map<String,Object>> list = courseService.listMaps(wrapper);
|
||||
for (Map<String,Object> courseEntity : list) {
|
||||
if (!userVipService.isPsycheVip()){
|
||||
if (!userVipService.isPsycheVip(ShiroUtils.getUId())){
|
||||
courseEntities.add(courseEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
||||
List<Map<String,Object>> courseList = this.getBaseMapper().selectMaps(wrapper);
|
||||
for (Map<String,Object> map:courseList){
|
||||
if (!userVipService.isSociologyVip()){
|
||||
if (!userVipService.isSociologyVip((int)param.get("userId"))){
|
||||
courseEntities.add(map);
|
||||
}
|
||||
}
|
||||
@@ -373,7 +373,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
}
|
||||
}
|
||||
List<CourseEntity> courseEntities = null;
|
||||
if (userVipService.isSociologyVip()){
|
||||
if (userVipService.isSociologyVip(user.getId())){
|
||||
MPJLambdaWrapper<CourseToSociologyEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseToSociologyEntity::getCourseId);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
|
||||
Reference in New Issue
Block a user