会员等级V0.1
This commit is contained in:
parent
839902e770
commit
57d65f3fd9
@ -0,0 +1,50 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
|
||||
import cn.lili.event.GoodsCommentCompleteEvent;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.ExperienceSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 会员经验值
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/16 11:16 下午
|
||||
*/
|
||||
@Service
|
||||
public class MemberExperienceExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent {
|
||||
|
||||
//配置
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
//会员
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Override
|
||||
public void memberRegister(Member member) {
|
||||
//获取经验值设置
|
||||
Setting setting = settingService.get(SettingEnum.EXPERIENCE_SETTING.name());
|
||||
ExperienceSetting experienceSetting = new Gson().fromJson(setting.getSettingValue(), ExperienceSetting.class);
|
||||
//赠送会员经验值
|
||||
memberService.updateMemberPoint(Long.valueOf(experienceSetting.getRegister().longValue()), 1, member.getId(), "会员注册,赠送经验值" + experienceSetting.getRegister());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goodsComment(MemberEvaluation memberEvaluation) {
|
||||
//获取签到经验值设置
|
||||
Setting setting = settingService.get(SettingEnum.EXPERIENCE_SETTING.name());
|
||||
ExperienceSetting experienceSetting = new Gson().fromJson(setting.getSettingValue(), ExperienceSetting.class);
|
||||
//赠送会员经验值
|
||||
memberService.updateMemberPoint(Long.valueOf(experienceSetting.getComment().longValue()), 1, memberEvaluation.getMemberId(), "会员评价,赠送经验值" + experienceSetting.getComment());
|
||||
}
|
||||
}
|
@ -6,13 +6,11 @@ import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.member.service.MemberWalletService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.PointSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -35,7 +33,7 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
|
||||
@Override
|
||||
public void memberRegister(Member member) {
|
||||
//获取签到积分赠送设置
|
||||
//获取积分设置
|
||||
Setting setting = settingService.get(SettingEnum.POINT_SETTING.name());
|
||||
PointSetting pointSetting = new Gson().fromJson(setting.getSettingValue(), PointSetting.class);
|
||||
//赠送会员积分
|
||||
|
@ -89,7 +89,8 @@ public enum ResultCode {
|
||||
USER_RECEIPT_NOT_EXIST(20014,"会员发票信息不存在"),
|
||||
USER_EDIT_ERROR(20015,"用户修改失败"),
|
||||
USER_OLD_PASSWORD_ERROR(20016, "旧密码不正确"),
|
||||
USER_COLLECTION_EXIST(2001,"无法重复收藏"),
|
||||
USER_COLLECTION_EXIST(20017,"无法重复收藏"),
|
||||
USER_GRADE_IS_DEFAULT(20018,"会员等级为默认会员等级"),
|
||||
|
||||
/**
|
||||
* 权限
|
||||
|
@ -85,6 +85,14 @@ public class Member extends BaseEntity {
|
||||
@ApiModelProperty(value = "最后一次登录时间")
|
||||
private Date lastLoginDate;
|
||||
|
||||
@ApiModelProperty(value = "会员等级ID")
|
||||
private String gradeId;
|
||||
|
||||
@Min(message = "必须为数字", value = 0)
|
||||
@ApiModelProperty(value = "经验值数量")
|
||||
private Long experience;
|
||||
|
||||
|
||||
public Member(String username, String password, String mobile) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
|
@ -0,0 +1,40 @@
|
||||
package cn.lili.modules.member.entity.dos;
|
||||
|
||||
import cn.lili.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 会员等级
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date 2021/5/14 5:43 下午
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "li_member_grade")
|
||||
@TableName("li_member_grade")
|
||||
@ApiModel(value = "会员等级")
|
||||
public class MemberGrade extends BaseEntity {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "等级名称")
|
||||
private String gradeName;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "等级图片")
|
||||
private String gradeImage;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "所需经验值")
|
||||
private Integer experienceValue;
|
||||
|
||||
@ApiModelProperty(value = "是否为默认等级")
|
||||
private Boolean isDefault;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.lili.modules.member.mapper;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.MemberGrade;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 会员等级数据层
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/14 5:57 下午
|
||||
*/
|
||||
public interface MemberGradeMapper extends BaseMapper<MemberGrade> {
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.lili.modules.member.service;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.MemberGrade;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 会员等级业务层
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/14 5:57 下午
|
||||
*
|
||||
*/
|
||||
public interface MemberGradeService extends IService<MemberGrade> {
|
||||
|
||||
|
||||
}
|
@ -183,6 +183,17 @@ public interface MemberService extends IService<Member> {
|
||||
*/
|
||||
Boolean updateMemberPoint(Long point, Integer type, String memberId, String content);
|
||||
|
||||
/**
|
||||
* 会员积分变动
|
||||
*
|
||||
* @param experience 变动经验值
|
||||
* @param type 变动类型 1为增加 0为消费
|
||||
* @param memberId 会员id
|
||||
* @param content 变动详细
|
||||
* @return 操作结果
|
||||
*/
|
||||
Boolean updateMemberExperience(Long experience, Integer type, String memberId, String content);
|
||||
|
||||
/**
|
||||
* 修改会员状态
|
||||
*
|
||||
|
@ -0,0 +1,18 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.MemberGrade;
|
||||
import cn.lili.modules.member.mapper.MemberGradeMapper;
|
||||
import cn.lili.modules.member.service.MemberGradeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 会员等级业务层实现
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/14 5:58 下午
|
||||
*/
|
||||
@Service
|
||||
public class MemberGradeServiceImpl extends ServiceImpl<MemberGradeMapper, MemberGrade> implements MemberGradeService {
|
||||
|
||||
}
|
@ -383,6 +383,24 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateMemberExperience(Long experience, Integer type, String memberId, String content) {
|
||||
//获取当前会员信息
|
||||
Member member = this.getById(memberId);
|
||||
if (member != null) {
|
||||
//积分变动后的会员积分
|
||||
long currentExperience;
|
||||
if (type == 1) {
|
||||
currentExperience = CurrencyUtil.add(member.getPoint(), experience).longValue();
|
||||
} else {
|
||||
currentExperience = CurrencyUtil.sub(member.getPoint(), experience) < 0 ? 0 : new Double(CurrencyUtil.sub(member.getExperience(), experience)).longValue();
|
||||
}
|
||||
member.setExperience(currentExperience);
|
||||
return this.updateById(member);
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean updateMemberStatus(List<String> memberIds, Boolean status) {
|
||||
|
@ -3,10 +3,10 @@ package cn.lili.modules.order.order.service;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
|
||||
/**
|
||||
* @author liushuai(liushuai711 @ gmail.com)
|
||||
* @version v4.1
|
||||
* @Description:
|
||||
* @since 2021/4/28 3:47 下午
|
||||
* 订单价格
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/17 7:36 下午
|
||||
*/
|
||||
public interface OrderPriceService {
|
||||
|
||||
|
@ -28,10 +28,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liushuai(liushuai711 @ gmail.com)
|
||||
* @version v4.1
|
||||
* @Description:
|
||||
* @since 2021/4/28 3:48 下午
|
||||
* 订单价格业务层实现
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/17 7:36 下午
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -0,0 +1,33 @@
|
||||
package cn.lili.modules.system.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 经验值设置
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/16 11:10 下午
|
||||
*/
|
||||
@Data
|
||||
public class ExperienceSetting implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4261856614779031745L;
|
||||
@ApiModelProperty(value = "注册")
|
||||
private Integer register;
|
||||
|
||||
@ApiModelProperty(value = "每日签到经验值")
|
||||
private Integer signIn;
|
||||
|
||||
@ApiModelProperty(value = "订单评价赠送经验值")
|
||||
private Integer comment;
|
||||
|
||||
@ApiModelProperty(value = "分享获取经验值")
|
||||
private Integer share;
|
||||
|
||||
@ApiModelProperty(value = "购物获取经验值,一元*经验值")
|
||||
private Integer money;
|
||||
|
||||
}
|
@ -27,6 +27,8 @@ public enum SettingEnum {
|
||||
SMS_SETTING,
|
||||
//积分设置
|
||||
POINT_SETTING,
|
||||
//经验值设置
|
||||
EXPERIENCE_SETTING,
|
||||
|
||||
//微信 联合登陆设置
|
||||
WECHAT_CONNECT,
|
||||
|
@ -0,0 +1,70 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.MemberGrade;
|
||||
import cn.lili.modules.member.service.MemberGradeService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 管理端,会员等级接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2021/5/16 11:29 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "管理端,会员等级接口")
|
||||
@RequestMapping("/manager/memberGrade")
|
||||
public class MemberGradeManagerController {
|
||||
|
||||
@Autowired
|
||||
private MemberGradeService memberGradeService;
|
||||
|
||||
@ApiOperation(value = "通过id获取会员等级")
|
||||
@ApiImplicitParam(name = "id", value = "会员等级ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping(value = "/get/{id}")
|
||||
public ResultMessage<MemberGrade> get(@PathVariable String id) {
|
||||
|
||||
return ResultUtil.data(memberGradeService.getById(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取会员等级分页")
|
||||
@GetMapping(value = "/getByPage")
|
||||
public ResultMessage<IPage<MemberGrade>> getByPage(PageVO page) {
|
||||
|
||||
return ResultUtil.data(memberGradeService.page(PageUtil.initPage(page)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改会员等级")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "会员等级ID", required = true, paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/update/{id}")
|
||||
public ResultMessage<Object> update(@PathVariable String id,MemberGrade memberGrade) {
|
||||
if (memberGradeService.updateById(memberGrade)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除会员等级")
|
||||
@ApiImplicitParam(name = "id", value = "会员等级ID", required = true, dataType = "String", paramType = "path")
|
||||
@PutMapping(value = "/delete/{id}")
|
||||
public ResultMessage<IPage<Object>> delete(@PathVariable String id) {
|
||||
if(memberGradeService.getById(id).getIsDefault()){
|
||||
return ResultUtil.error(ResultCode.USER_GRADE_IS_DEFAULT);
|
||||
}else if(memberGradeService.removeById(id)){
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user