会员等级支持修改
This commit is contained in:
@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -18,6 +19,7 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Service
|
||||
@ApiModel(value = "YxUserLevel对象", description = "用户等级记录表")
|
||||
public class YxUserLevel extends BaseDomain {
|
||||
|
||||
|
||||
@@ -9,16 +9,23 @@
|
||||
package co.yixiang.modules.user.rest;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
||||
import co.yixiang.enums.ShopCommonEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.aop.ForbidSubmit;
|
||||
import co.yixiang.modules.shop.domain.YxSystemUserLevel;
|
||||
import co.yixiang.modules.user.domain.YxUser;
|
||||
import co.yixiang.modules.user.service.YxSystemUserLevelService;
|
||||
import co.yixiang.modules.user.service.YxUserLevelService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.service.dto.UserMoneyDto;
|
||||
import co.yixiang.modules.user.service.dto.YxUserQueryCriteria;
|
||||
import co.yixiang.modules.user.service.impl.YxUserLevelServiceImpl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -44,7 +51,14 @@ import java.math.BigDecimal;
|
||||
@RequestMapping("api")
|
||||
public class MemberController {
|
||||
|
||||
private final YxUserService yxUserService;
|
||||
@Autowired
|
||||
private YxUserService yxUserService;
|
||||
|
||||
@Autowired
|
||||
private YxUserLevelServiceImpl yxUserLevelServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private YxSystemUserLevelService yxSystemUserLevelService;
|
||||
|
||||
public MemberController(YxUserService yxUserService) {
|
||||
this.yxUserService = yxUserService;
|
||||
@@ -76,6 +90,18 @@ public class MemberController {
|
||||
// if (resources.getIntegral().compareTo(BigDecimal.valueOf(999999.99))>=0){
|
||||
// throw new YshopException("999999.99");
|
||||
// }
|
||||
//这里判断是否对会员等级进行了修改
|
||||
YxUser yxUser=yxUserService.getById(resources.getUid());
|
||||
//会员等级进行了修改
|
||||
if (yxUser.getLevel()!=resources.getLevel()){
|
||||
LambdaQueryWrapper<YxSystemUserLevel> wrapper=new LambdaQueryWrapper<>();
|
||||
wrapper.eq(YxSystemUserLevel::getGrade,resources.getLevel())
|
||||
.eq(YxSystemUserLevel::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||
.orderByAsc(YxSystemUserLevel::getGrade)
|
||||
.last("limit 1");
|
||||
int levelId=yxSystemUserLevelService.getOne(wrapper).getId();
|
||||
yxUserLevelServiceImpl.setUserLevel(resources.getUid(),levelId);
|
||||
}
|
||||
yxUserService.saveOrUpdate(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,15 @@
|
||||
*/
|
||||
package co.yixiang.modules.user.rest;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
||||
import co.yixiang.enums.ShopCommonEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.aop.ForbidSubmit;
|
||||
import co.yixiang.modules.shop.domain.YxSystemUserLevel;
|
||||
import co.yixiang.modules.user.service.YxSystemUserLevelService;
|
||||
import co.yixiang.modules.user.service.dto.YxSystemUserLevelQueryCriteria;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -55,6 +59,15 @@ public class SystemUserLevelController {
|
||||
@PostMapping(value = "/yxSystemUserLevel")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_CREATE')")
|
||||
public ResponseEntity create(@Validated @RequestBody YxSystemUserLevel resources){
|
||||
YxSystemUserLevel yxSystemUserLevel=yxSystemUserLevelService.lambdaQuery()
|
||||
.eq(YxSystemUserLevel::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||
.orderByAsc(YxSystemUserLevel::getGrade)
|
||||
.gt(YxSystemUserLevel::getGrade,resources.getGrade())
|
||||
.last("limit 1")
|
||||
.one();
|
||||
if (ObjectUtil.isNotEmpty(yxSystemUserLevel)){
|
||||
throw new YshopException("已有相同等级会员卡");
|
||||
}
|
||||
return new ResponseEntity<>(yxSystemUserLevelService.save(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -64,6 +77,15 @@ public class SystemUserLevelController {
|
||||
@PutMapping(value = "/yxSystemUserLevel")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody YxSystemUserLevel resources){
|
||||
YxSystemUserLevel yxSystemUserLevel=yxSystemUserLevelService.lambdaQuery()
|
||||
.eq(YxSystemUserLevel::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||
.orderByAsc(YxSystemUserLevel::getGrade)
|
||||
.gt(YxSystemUserLevel::getGrade,resources.getGrade())
|
||||
.last("limit 1")
|
||||
.one();
|
||||
if (ObjectUtil.isNotEmpty(yxSystemUserLevel)){
|
||||
throw new YshopException("已有相同等级会员卡");
|
||||
}
|
||||
yxSystemUserLevelService.saveOrUpdate(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,12 @@ import java.util.Map;
|
||||
*/
|
||||
public interface YxUserService extends BaseService<YxUser>{
|
||||
|
||||
/**
|
||||
* 更新会员等级
|
||||
* @return resources 会员信息
|
||||
*/
|
||||
void updateLevel(YxUser resources);
|
||||
|
||||
/**
|
||||
* 返回用户累计充值金额与消费金额
|
||||
* @param uid uid
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
|
||||
* @param uid 用户id
|
||||
* @param levelId 等级id
|
||||
*/
|
||||
private void setUserLevel(Long uid, int levelId){
|
||||
public void setUserLevel(Long uid, int levelId){
|
||||
YxSystemUserLevel systemUserLevelQueryVo = systemUserLevelService
|
||||
.getById(levelId);
|
||||
if(ObjectUtil.isNull(systemUserLevelQueryVo)) {
|
||||
|
||||
@@ -104,6 +104,25 @@ public class YxUserServiceImpl extends BaseServiceImpl<BxgUserMapper, YxUser> im
|
||||
@Autowired
|
||||
private YxStoreOrderCartInfoService storeOrderCartInfoService;
|
||||
|
||||
@Autowired
|
||||
private YxUserLevelService yxUserLevelService;
|
||||
@Autowired
|
||||
private YxUserLevel yxUserLevel;
|
||||
@Override
|
||||
public void updateLevel(YxUser resources) {
|
||||
LambdaQueryWrapper<YxUserLevel> wrapper=new LambdaQueryWrapper<>();
|
||||
wrapper.eq(YxUserLevel::getUid,resources.getUid());
|
||||
yxUserLevel.setLevelId(resources.getLevel())
|
||||
.setUid(resources.getUid())
|
||||
.setGrowth(resources.getGrowth());
|
||||
if (ObjectUtil.isNotEmpty(yxUserLevelService.getOne(wrapper))){
|
||||
yxUserLevelService.update(yxUserLevel,wrapper);
|
||||
}else {
|
||||
yxUserLevel.setId(null);
|
||||
yxUserLevelService.save(yxUserLevel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回用户累计充值金额与消费金额
|
||||
|
||||
Reference in New Issue
Block a user