Browse Source

商家端新增会员权益增删改查接口业务功能

multiwx
dy-hu 7 months ago
parent
commit
b63e17ce5e
  1. 119
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/MemberShipController.java
  2. 7
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/member/CerePlatformMembershipDAO.java
  3. 63
      cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MemberLevelSaveParam.java
  4. 69
      cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MemberLevelUpdateParam.java
  5. 25
      cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MemberLevelgetByIdParam.java
  6. 25
      cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MembershipGetByIdParam.java
  7. 47
      cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MembershipSaveParam.java
  8. 49
      cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MembershipUpdateParam.java
  9. 18
      cereshop-business/src/main/java/com/shop/cereshop/business/service/member/CerePlatformMembershipService.java
  10. 79
      cereshop-business/src/main/java/com/shop/cereshop/business/service/member/impl/CerePlatformMembershipServiceImpl.java
  11. 14
      cereshop-business/src/main/resources/mybatis/mapper/member/CerePlatformMembershipDAO.xml
  12. 6
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/member/CerePlatformMembership.java
  13. 4
      doc/3.0/update.sql

119
cereshop-business/src/main/java/com/shop/cereshop/business/controller/MemberShipController.java

@ -0,0 +1,119 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.controller;
import com.shop.cereshop.business.annotation.NoRepeatSubmit;
import com.shop.cereshop.business.annotation.NoRepeatWebLog;
import com.shop.cereshop.business.param.member.MembershipGetByIdParam;
import com.shop.cereshop.business.param.member.MembershipSaveParam;
import com.shop.cereshop.business.param.member.MembershipUpdateParam;
import com.shop.cereshop.business.service.member.CerePlatformMembershipService;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.member.CerePlatformMembership;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.commons.utils.GsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* 会员权益
*/
@RestController
@RequestMapping("membership")
/**
* 注解方式生成日志对象指定topic生成对象类名
*/
@Slf4j(topic = "MemberShipController")
@Api(value = "会员模块", tags = "会员模块")
public class MemberShipController {
@Autowired
private CerePlatformMembershipService cerePlatformMembershipService;
/**
* 添加会员权益
* @param param
* @return
*/
@PostMapping(value = "save")
@NoRepeatSubmit
@ApiOperation(value = "添加会员权益")
@NoRepeatWebLog
public Result save(@RequestBody @Validated MembershipSaveParam param, HttpServletRequest request) throws CoBusinessException {
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
param.setBusinessId(user.getBusinessId());
cerePlatformMembershipService.save(param,user);
return new Result(user.getUsername(),"添加会员权益", GsonUtil.objectToGson(param));
}
/**
* 编辑会员权益
* @param param
* @return
*/
@PostMapping(value = "update")
@NoRepeatSubmit
@ApiOperation(value = "编辑会员权益")
@NoRepeatWebLog
public Result update(@RequestBody MembershipUpdateParam param, HttpServletRequest request) throws CoBusinessException {
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
cerePlatformMembershipService.update(param,user);
return new Result(user.getUsername(),"编辑会员权益", GsonUtil.objectToGson(param));
}
/**
* 删除会员权益
* @param param
* @return
*/
@PostMapping(value = "delete")
@NoRepeatSubmit
@ApiOperation(value = "删除会员权益")
@NoRepeatWebLog
public Result delete(@RequestBody MembershipGetByIdParam param, HttpServletRequest request) throws CoBusinessException {
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
cerePlatformMembershipService.delete(param,user);
return new Result(user.getUsername(),"删除会员权益", GsonUtil.objectToGson(param));
}
/**
* 会员权益详情查询
* @param param
* @return
*/
@PostMapping(value = "getById")
@ApiOperation(value = "会员权益详情查询")
public Result<CerePlatformMembership> getById(@RequestBody MembershipGetByIdParam param) throws CoBusinessException {
CerePlatformMembership membership=cerePlatformMembershipService.getById(param);
return new Result(membership);
}
/**
* 会员权益列表查询
* @return
*/
@PostMapping(value = "getAll")
@ApiOperation(value = "会员权益列表查询")
public Result<Page<CerePlatformMembership>> getAll(@RequestBody PageParam param) throws CoBusinessException {
Page page=cerePlatformMembershipService.getAll(param);
return new Result(page);
}
}

7
cereshop-business/src/main/java/com/shop/cereshop/business/dao/member/CerePlatformMembershipDAO.java

@ -8,6 +8,9 @@ package com.shop.cereshop.business.dao.member;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.member.CerePlatformMembership;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CerePlatformMembershipDAO extends BaseMapper<CerePlatformMembership> {
@ -20,4 +23,8 @@ public interface CerePlatformMembershipDAO extends BaseMapper<CerePlatformMember
int updateByPrimaryKeySelective(CerePlatformMembership record);
int updateByPrimaryKey(CerePlatformMembership record);
CerePlatformMembership check(@Param("memberId") Long memberId);
List<CerePlatformMembership> getAll();
}

63
cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MemberLevelSaveParam.java

@ -0,0 +1,63 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.member;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 添加会员等级请求
*/
@Data
@ApiModel(value = "MemberLevelSaveParam", description = "添加会员等级请求")
public class MemberLevelSaveParam {
/**
* 等级名称
*/
@ApiModelProperty(value = "等级名称")
@NotBlank(message = "等级名称不能为空")
private String memberLevelName;
/**
* 图标
*/
@ApiModelProperty(value = "图标")
@NotBlank(message = "图标不能为空")
private String memberLevelIcon;
/**
* 背景图
*/
@ApiModelProperty(value = "背景图")
@NotBlank(message = "背景图不能为空")
private String memberLevelBackground;
/**
* 成长值
*/
@ApiModelProperty(value = "成长值")
@NotNull(message = "成长值不能为空")
private Integer growth;
/**
* 会员权益id数组
*/
@ApiModelProperty(value = "会员权益id数组")
private List<String> ids;
/**
* 等级说明
*/
@ApiModelProperty(value = "等级说明")
private String memberLevelReason;
}

69
cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MemberLevelUpdateParam.java

@ -0,0 +1,69 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.member;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 编辑会员等级请求
*/
@Data
@ApiModel(value = "MemberLevelUpdateParam", description = "编辑会员等级请求")
public class MemberLevelUpdateParam {
/**
* 会员等级id
*/
@ApiModelProperty(value = "会员等级id")
private Long memberLevelId;
/**
* 等级名称
*/
@ApiModelProperty(value = "等级名称")
@NotBlank(message = "等级名称不能为空")
private String memberLevelName;
/**
* 图标
*/
@ApiModelProperty(value = "图标")
@NotBlank(message = "图标不能为空")
private String memberLevelIcon;
/**
* 背景图
*/
@ApiModelProperty(value = "背景图")
@NotBlank(message = "背景图不能为空")
private String memberLevelBackground;
/**
* 成长值
*/
@ApiModelProperty(value = "成长值")
@NotNull(message = "成长值不能为空")
private Integer growth;
/**
* 会员权益id数组
*/
@ApiModelProperty(value = "会员权益id数组")
private List<String> ids;
/**
* 等级说明
*/
@ApiModelProperty(value = "等级说明")
private String memberLevelReason;
}

25
cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MemberLevelgetByIdParam.java

@ -0,0 +1,25 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.member;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 编辑会员等级请求
*/
@Data
@ApiModel(value = "MemberLevelUpdateParam", description = "编辑会员等级请求")
public class MemberLevelgetByIdParam {
/**
* 会员等级id
*/
@ApiModelProperty(value = "会员等级id")
private Long memberLevelId;
}

25
cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MembershipGetByIdParam.java

@ -0,0 +1,25 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.member;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 会员权益详情请求
*/
@Data
@ApiModel(value = "MembershipGetByIdParam", description = "会员权益详情请求")
public class MembershipGetByIdParam {
/**
* 权益id
*/
@ApiModelProperty(value = "权益id")
private Long memberId;
}

47
cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MembershipSaveParam.java

@ -0,0 +1,47 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.member;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 添加会员权益请求
*/
@Data
@ApiModel(value = "MembershipSaveParam", description = "添加会员权益请求")
public class MembershipSaveParam {
/**
* 商家id
*/
@ApiModelProperty(value = "商家id")
private Long businessId;
/**
* 权益名称
*/
@ApiModelProperty(value = "权益名称")
@NotBlank(message = "权益名称名称不能为空")
private String memberName;
/**
* 权益图标
*/
@ApiModelProperty(value = "权益图标")
@NotBlank(message = "权益图标不能为空")
private String memberIcon;
/**
* 权益说明
*/
@ApiModelProperty(value = "权益说明")
private String memberReason;
}

49
cereshop-business/src/main/java/com/shop/cereshop/business/param/member/MembershipUpdateParam.java

@ -0,0 +1,49 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.member;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 编辑会员权益请求
*/
@Data
@ApiModel(value = "MembershipUpdateParam", description = "编辑会员权益请求")
public class MembershipUpdateParam {
/**
* 权益id
*/
@ApiModelProperty(value = "权益id")
private Long memberId;
/**
* 商家id
*/
@ApiModelProperty(value = "商家id")
private Long businessId;
/**
* 权益名称
*/
@ApiModelProperty(value = "权益名称")
private String memberName;
/**
* 权益图标
*/
@ApiModelProperty(value = "权益图标")
private String memberIcon;
/**
* 权益说明
*/
@ApiModelProperty(value = "权益说明")
private String memberReason;
}

18
cereshop-business/src/main/java/com/shop/cereshop/business/service/member/CerePlatformMembershipService.java

@ -5,5 +5,23 @@
*/
package com.shop.cereshop.business.service.member;
import com.shop.cereshop.business.param.member.MembershipGetByIdParam;
import com.shop.cereshop.business.param.member.MembershipSaveParam;
import com.shop.cereshop.business.param.member.MembershipUpdateParam;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.member.CerePlatformMembership;
import com.shop.cereshop.commons.exception.CoBusinessException;
public interface CerePlatformMembershipService {
void save(MembershipSaveParam param, CerePlatformBusinessUser user) throws CoBusinessException;
void update(MembershipUpdateParam param, CerePlatformBusinessUser user) throws CoBusinessException;
CerePlatformMembership getById(MembershipGetByIdParam param) throws CoBusinessException;
void delete(MembershipGetByIdParam param, CerePlatformBusinessUser user) throws CoBusinessException;
Page getAll(PageParam param) throws CoBusinessException;
}

79
cereshop-business/src/main/java/com/shop/cereshop/business/service/member/impl/CerePlatformMembershipServiceImpl.java

@ -5,14 +5,93 @@
*/
package com.shop.cereshop.business.service.member.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.member.CerePlatformMembershipDAO;
import com.shop.cereshop.business.param.member.MembershipGetByIdParam;
import com.shop.cereshop.business.param.member.MembershipSaveParam;
import com.shop.cereshop.business.param.member.MembershipUpdateParam;
import com.shop.cereshop.business.service.log.CerePlatformLogService;
import com.shop.cereshop.business.service.member.CerePlatformMembershipService;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.member.CerePlatformMembership;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class CerePlatformMembershipServiceImpl implements CerePlatformMembershipService {
@Autowired
private CerePlatformMembershipDAO cerePlatformMembershipDAO;
@Autowired
private CerePlatformLogService cerePlatformLogService;
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void save(MembershipSaveParam param, CerePlatformBusinessUser user) throws CoBusinessException {
String time= TimeUtils.yyMMddHHmmss();
CerePlatformMembership membership=new CerePlatformMembership();
membership.setBusinessId(param.getBusinessId());
membership.setMemberName(param.getMemberName());
membership.setMemberIcon(param.getMemberIcon());
membership.setMemberReason(param.getMemberReason());
membership.setCreateTime(time);
cerePlatformMembershipDAO.insert(membership);
//新增日志
cerePlatformLogService.addLog(user,"会员管理","商家端操作","添加会员权益",membership.getMemberId(),time);
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void update(MembershipUpdateParam param, CerePlatformBusinessUser user) throws CoBusinessException {
String time= TimeUtils.yyMMddHHmmss();
CerePlatformMembership membership=new CerePlatformMembership();
membership.setMemberId(param.getMemberId());
membership.setBusinessId(param.getBusinessId());
membership.setMemberName(param.getMemberName());
membership.setMemberIcon(param.getMemberIcon());
membership.setMemberReason(param.getMemberReason());
membership.setUpdateTime(time);
cerePlatformMembershipDAO.updateByPrimaryKeySelective(membership);
//新增日志
cerePlatformLogService.addLog(user,"会员管理","商家端操作","编辑会员权益",membership.getMemberId(),time);
}
@Override
public CerePlatformMembership getById(MembershipGetByIdParam param) throws CoBusinessException {
return cerePlatformMembershipDAO.selectByPrimaryKey(param.getMemberId());
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void delete(MembershipGetByIdParam param, CerePlatformBusinessUser user) throws CoBusinessException {
//校验该会员权益是否关联会员等级
CerePlatformMembership membership=cerePlatformMembershipDAO.check(param.getMemberId());
if(membership!=null){
throw new CoBusinessException(CoReturnFormat.MEMBER_SHIP_NOT_DELETE);
}
cerePlatformMembershipDAO.deleteByPrimaryKey(param.getMemberId());
//新增日志
cerePlatformLogService.addLog(user,"会员管理","商家端操作","删除会员权益", param.getMemberId(),TimeUtils.yyMMddHHmmss());
}
@Override
public Page getAll(PageParam param) throws CoBusinessException {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<CerePlatformMembership> list=cerePlatformMembershipDAO.getAll();
PageInfo<CerePlatformMembership> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
}

14
cereshop-business/src/main/resources/mybatis/mapper/member/CerePlatformMembershipDAO.xml

@ -62,6 +62,9 @@
<update id="updateByPrimaryKeySelective" parameterType="com.shop.cereshop.commons.domain.member.CerePlatformMembership">
update cere_platform_membership
<set>
<if test="businessId != null">
business_id = #{businessId,jdbcType=BIGINT},
</if>
<if test="memberName != null">
member_name = #{memberName,jdbcType=VARCHAR},
</if>
@ -89,4 +92,15 @@
update_time = #{updateTime,jdbcType=VARCHAR}
where member_id = #{memberId,jdbcType=BIGINT}
</update>
<select id="check" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.member.CerePlatformMembership">
SELECT b.* FROM cere_platform_member_level a
LEFT JOIN cere_platform_membership b ON
a.member_ids=b.member_id OR a.member_ids LIKE CONCAT('%,',b.member_id,'%')
where b.member_id=#{memberId}
</select>
<select id="getAll" resultType="com.shop.cereshop.commons.domain.member.CerePlatformMembership">
SELECT * FROM cere_platform_membership
</select>
</mapper>

6
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/member/CerePlatformMembership.java

@ -26,6 +26,12 @@ public class CerePlatformMembership implements Serializable {
private Long memberId;
/**
* 商家id
*/
@ApiModelProperty(value = "商家id")
private Long businessId;
/**
* 权益名称
*/
@ApiModelProperty(value = "字典id")

4
doc/3.0/update.sql

@ -295,3 +295,7 @@ ALTER TABLE cere_shop_product ADD plat_shelve_state tinyint(1) DEFAULT 0 COMMENT
-- 会员标签表增加商家表关联Id
ALTER TABLE `cere_platform_label`
ADD COLUMN `business_id` bigint(20) DEFAULT 0 COMMENT '商家Id';
-- 会员权益表增加商家表关联Id
ALTER TABLE `cere_platform_membership`
ADD COLUMN `business_id` bigint(20) DEFAULT 0 COMMENT '商家Id';
Loading…
Cancel
Save