Browse Source

会员等级支持修改

sj
sj 2 years ago
parent
commit
0b33a011a2
  1. 2
      zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserLevel.java
  2. 28
      zsw-bxg/src/main/java/co/yixiang/modules/user/rest/MemberController.java
  3. 22
      zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserLevelController.java
  4. 6
      zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserService.java
  5. 2
      zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserLevelServiceImpl.java
  6. 19
      zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserServiceImpl.java

2
zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserLevel.java

@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springframework.stereotype.Service;
/** /**
* <p> * <p>
@ -18,6 +19,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Service
@ApiModel(value = "YxUserLevel对象", description = "用户等级记录表") @ApiModel(value = "YxUserLevel对象", description = "用户等级记录表")
public class YxUserLevel extends BaseDomain { public class YxUserLevel extends BaseDomain {

28
zsw-bxg/src/main/java/co/yixiang/modules/user/rest/MemberController.java

@ -9,16 +9,23 @@
package co.yixiang.modules.user.rest; package co.yixiang.modules.user.rest;
import cn.iocoder.yudao.framework.common.exception.YshopException; import cn.iocoder.yudao.framework.common.exception.YshopException;
import co.yixiang.enums.ShopCommonEnum;
import co.yixiang.logging.aop.log.Log; import co.yixiang.logging.aop.log.Log;
import co.yixiang.modules.aop.ForbidSubmit; 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.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.YxUserService;
import co.yixiang.modules.user.service.dto.UserMoneyDto; import co.yixiang.modules.user.service.dto.UserMoneyDto;
import co.yixiang.modules.user.service.dto.YxUserQueryCriteria; 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.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -44,7 +51,14 @@ import java.math.BigDecimal;
@RequestMapping("api") @RequestMapping("api")
public class MemberController { public class MemberController {
private final YxUserService yxUserService; @Autowired
private YxUserService yxUserService;
@Autowired
private YxUserLevelServiceImpl yxUserLevelServiceImpl;
@Autowired
private YxSystemUserLevelService yxSystemUserLevelService;
public MemberController(YxUserService yxUserService) { public MemberController(YxUserService yxUserService) {
this.yxUserService = yxUserService; this.yxUserService = yxUserService;
@ -76,6 +90,18 @@ public class MemberController {
// if (resources.getIntegral().compareTo(BigDecimal.valueOf(999999.99))>=0){ // if (resources.getIntegral().compareTo(BigDecimal.valueOf(999999.99))>=0){
// throw new YshopException("999999.99"); // 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); yxUserService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

22
zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserLevelController.java

@ -5,11 +5,15 @@
*/ */
package co.yixiang.modules.user.rest; 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.logging.aop.log.Log;
import co.yixiang.modules.aop.ForbidSubmit; import co.yixiang.modules.aop.ForbidSubmit;
import co.yixiang.modules.shop.domain.YxSystemUserLevel; import co.yixiang.modules.shop.domain.YxSystemUserLevel;
import co.yixiang.modules.user.service.YxSystemUserLevelService; import co.yixiang.modules.user.service.YxSystemUserLevelService;
import co.yixiang.modules.user.service.dto.YxSystemUserLevelQueryCriteria; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -55,6 +59,15 @@ public class SystemUserLevelController {
@PostMapping(value = "/yxSystemUserLevel") @PostMapping(value = "/yxSystemUserLevel")
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_CREATE')") @PreAuthorize("@ss.hasAnyPermissions('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_CREATE')")
public ResponseEntity create(@Validated @RequestBody YxSystemUserLevel resources){ 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); return new ResponseEntity<>(yxSystemUserLevelService.save(resources),HttpStatus.CREATED);
} }
@ -64,6 +77,15 @@ public class SystemUserLevelController {
@PutMapping(value = "/yxSystemUserLevel") @PutMapping(value = "/yxSystemUserLevel")
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_EDIT')") @PreAuthorize("@ss.hasAnyPermissions('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxSystemUserLevel resources){ 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); yxSystemUserLevelService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }

6
zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserService.java

@ -30,6 +30,12 @@ import java.util.Map;
*/ */
public interface YxUserService extends BaseService<YxUser>{ public interface YxUserService extends BaseService<YxUser>{
/**
* 更新会员等级
* @return resources 会员信息
*/
void updateLevel(YxUser resources);
/** /**
* 返回用户累计充值金额与消费金额 * 返回用户累计充值金额与消费金额
* @param uid uid * @param uid uid

2
zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserLevelServiceImpl.java

@ -141,7 +141,7 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
* @param uid 用户id * @param uid 用户id
* @param levelId 等级id * @param levelId 等级id
*/ */
private void setUserLevel(Long uid, int levelId){ public void setUserLevel(Long uid, int levelId){
YxSystemUserLevel systemUserLevelQueryVo = systemUserLevelService YxSystemUserLevel systemUserLevelQueryVo = systemUserLevelService
.getById(levelId); .getById(levelId);
if(ObjectUtil.isNull(systemUserLevelQueryVo)) { if(ObjectUtil.isNull(systemUserLevelQueryVo)) {

19
zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserServiceImpl.java

@ -104,6 +104,25 @@ public class YxUserServiceImpl extends BaseServiceImpl<BxgUserMapper, YxUser> im
@Autowired @Autowired
private YxStoreOrderCartInfoService storeOrderCartInfoService; 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);
}
}
/** /**
* 返回用户累计充值金额与消费金额 * 返回用户累计充值金额与消费金额

Loading…
Cancel
Save