Commit 04b40ea9 authored by zhaobiyan's avatar zhaobiyan

会员积分日志接口

parent 3425faaf
...@@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.member.controller.admin.memberUserScore; ...@@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.member.controller.admin.memberUserScore;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO; import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.convert.memberUserScore.MemberUserScoreConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScore.MemberUserScoreDO;
import cn.iocoder.yudao.module.member.service.memberUserScore.MemberUserScoreService; import cn.iocoder.yudao.module.member.service.memberUserScore.MemberUserScoreService;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO; import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO; import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO;
...@@ -12,7 +10,10 @@ import io.swagger.annotations.Api; ...@@ -12,7 +10,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; 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.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -31,8 +32,8 @@ public class MemberUserScoreController { ...@@ -31,8 +32,8 @@ public class MemberUserScoreController {
@PostMapping("/page") @PostMapping("/page")
@ApiOperation("获得会员积分分页") @ApiOperation("获得会员积分分页")
@PreAuthorize("@ss.hasPermission('member:user-score:query')") @PreAuthorize("@ss.hasPermission('member:user-score:query')")
public CommonResult<PageResult<MemberUserScoreBackVO>> getUserScorePage(@Valid @RequestBody MemberUserScoreQueryVO query, PageVO page) { public CommonResult<PageResult<MemberUserScoreBackVO>> getUserScorePage(@Valid @RequestBody MemberUserScoreQueryVO query) {
PageResult<MemberUserScoreBackVO> pageResult = userScoreService.getUserScorePage(query, page); PageResult<MemberUserScoreBackVO> pageResult = userScoreService.getUserScorePage(query);
return success(pageResult); return success(pageResult);
} }
} }
package cn.iocoder.yudao.module.member.controller.admin.memberUserScoreLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.service.memberUserScoreLog.MemberUserScoreLogService;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
@RestController
@Api(tags = "管理后台 - 会员积分记录")
@RequestMapping("/member/user-score-log")
public class MemberUserScoreLogController {
@Resource
private MemberUserScoreLogService memberUserScoreLogService;
@PostMapping("/page")
@ApiOperation("获得积分记录分页")
@PreAuthorize("@ss.hasPermission('member:user-score-log:query')")
public CommonResult<PageResult<MemberUserScoreLogBackVO>> page(@Valid @RequestBody MemberUserScoreLogQueryVO query) {
PageResult<MemberUserScoreLogBackVO> pageResult = memberUserScoreLogService.getPage(query);
return success(pageResult);
}
}
package cn.iocoder.yudao.module.member.convert.memberUserScoreLog;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 会员积分 Convert
* @author 系统管理员
*/
@Mapper
public interface MemberUserScoreLogConvert {
/*****转换MapStruct*****/
MemberUserScoreLogConvert INSTANCE = Mappers.getMapper(MemberUserScoreLogConvert.class);
}
package cn.iocoder.yudao.module.member.dal.dataobject.memberUserScoreLog;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("member_user_score_log")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberUserScoreLogDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 会员id
*/
private Long memberId;
private Integer scoreCount;
private Integer operateType;
private Integer sourceType;
private Long ruleId;
private String extParam = "{}";
}
package cn.iocoder.yudao.module.member.dal.mysql.memberUserScoreLog;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScoreLog.MemberUserScoreLogDO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 会员积分 Mapper
* @author 系统管理员
*/
@Mapper
public interface MemberUserScoreLogMapper extends AbstractMapper<MemberUserScoreLogDO> {
List<MemberUserScoreLogBackVO> getPageRecordList(@Param("start") int start, @Param("size") int size, @Param("query") MemberUserScoreLogQueryVO query);
int getPageCount(@Param("query") MemberUserScoreLogQueryVO query);
}
...@@ -37,11 +37,10 @@ public interface MemberUserScoreService extends IService<MemberUserScoreDO> { ...@@ -37,11 +37,10 @@ public interface MemberUserScoreService extends IService<MemberUserScoreDO> {
/** /**
* 获得会员积分分页 * 获得会员积分分页
* @param page 分页查询
* @param query 查询 * @param query 查询
* @return 会员积分分页 * @return 会员积分分页
*/ */
PageResult<MemberUserScoreBackVO> getUserScorePage(MemberUserScoreQueryVO query, PageVO page); PageResult<MemberUserScoreBackVO> getUserScorePage(MemberUserScoreQueryVO query);
/** /**
* 获得会员积分列表, 用于 Excel 导出 * 获得会员积分列表, 用于 Excel 导出
......
...@@ -2,13 +2,10 @@ package cn.iocoder.yudao.module.member.service.memberUserScore; ...@@ -2,13 +2,10 @@ package cn.iocoder.yudao.module.member.service.memberUserScore;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService; import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScore.MemberUserScoreDO; import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScore.MemberUserScoreDO;
import cn.iocoder.yudao.module.member.dal.mysql.memberUserScore.MemberUserScoreMapper; import cn.iocoder.yudao.module.member.dal.mysql.memberUserScore.MemberUserScoreMapper;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO; import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO; import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -45,16 +42,12 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM ...@@ -45,16 +42,12 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
} }
@Override @Override
public PageResult<MemberUserScoreBackVO> getUserScorePage(MemberUserScoreQueryVO query, PageVO page) { public PageResult<MemberUserScoreBackVO> getUserScorePage(MemberUserScoreQueryVO query) {
IPage<MemberUserScoreBackVO> mpPage = MyBatisUtils.buildPage(page); int start = (query.getPageNo() - 1) * query.getPageSize();
page.setPage(query.getPageNo()); int size = query.getPageSize();
page.setRows(query.getPageSize());
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
List<MemberUserScoreBackVO> list = userScoreMapper.getUserScoreList(start, size, query); List<MemberUserScoreBackVO> list = userScoreMapper.getUserScoreList(start, size, query);
int total = userScoreMapper.countUserScore(query); int total = userScoreMapper.countUserScore(query);
return new PageResult<>(list, total, mpPage.getSize(), page.getPage(), (total + mpPage.getSize() - 1) / mpPage.getSize()); return new PageResult<>(list, total, query.getPageSize(), query.getPageNo(), (total + query.getPageSize() - 1) / query.getPageSize());
} }
@Override @Override
......
package cn.iocoder.yudao.module.member.service.memberUserScoreLog;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScoreLog.MemberUserScoreLogDO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO;
/**
* 会员积分日志 Service 接口
*
* @author 系统管理员
*/
public interface MemberUserScoreLogService extends IService<MemberUserScoreLogDO> {
PageResult<MemberUserScoreLogBackVO> getPage(MemberUserScoreLogQueryVO query);
}
package cn.iocoder.yudao.module.member.service.memberUserScoreLog;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScoreLog.MemberUserScoreLogDO;
import cn.iocoder.yudao.module.member.dal.mysql.memberUserScoreLog.MemberUserScoreLogMapper;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO;
import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
/**
* 会员积分日志 Service 实现类
*
* @author 系统管理员
*/
@Service
@Validated
public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserScoreLogMapper, MemberUserScoreLogDO> implements MemberUserScoreLogService {
@Resource
private MemberUserScoreLogMapper userScoreLogMapper;
@Resource
private DictTypeService dictTypeService;
@Override
public PageResult<MemberUserScoreLogBackVO> getPage(MemberUserScoreLogQueryVO query) {
int start = (query.getPageNo() - 1) * query.getPageSize();
int size = query.getPageSize();
List<MemberUserScoreLogBackVO> list = userScoreLogMapper.getPageRecordList(start, size, query);
int total = userScoreLogMapper.getPageCount(query);
return new PageResult<>(list, total, query.getPageSize(), query.getPageNo(), (total + query.getPageSize() - 1) / query.getPageSize());
}
}
...@@ -4,12 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; ...@@ -4,12 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/** /**
* @author zhaobiyan * @author zhaobiyan
*/ */
...@@ -29,7 +26,7 @@ public class MemberUserScoreQueryVO extends PageParam { ...@@ -29,7 +26,7 @@ public class MemberUserScoreQueryVO extends PageParam {
@ApiModelProperty(value = "已使用积分操作") @ApiModelProperty(value = "已使用积分操作")
private Integer usedScoreOperate; private Integer usedScoreOperate;
@ApiModelProperty(value = "会员创建时间开始") @ApiModelProperty(value = "会员创建时间开始")
private Date memberCreateTimeStart; private Date startTime;
@ApiModelProperty(value = "会员创建时间结束") @ApiModelProperty(value = "会员创建时间结束")
private Date memberCreateTimeEnd; private Date endTime;
} }
package cn.iocoder.yudao.module.member.vo.memberUserScoreLog;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
/**
* @author zhaobiyan
*/
@Data
@ApiModel("管理后台 - 积分记录查询 VO")
public class MemberUserScoreLogBackVO {
@ApiModelProperty(value = "积分记录id")
private Long id;
@ApiModelProperty(value = "会员id")
private Long memberId;
@ApiModelProperty(value = "会员昵称")
private String memberName;
@ApiModelProperty(value = "积分数量")
private Integer scoreCount;
@ApiModelProperty(value = "操作类别")
private Integer operateType;
@ApiModelProperty(value = "积分来源")
private Integer sourceType;
@ApiModelProperty(value = "规则标题(中文)")
private String ruleTitleZh;
@ApiModelProperty(value = "规则标题(英文)")
private String ruleTitleEn;
@ApiModelProperty(value = "规则说明(中文)")
private String ruleDescZh;
@ApiModelProperty(value = "规则说明(英文)")
private String ruleDescEn;
@ApiModelProperty(value = "规则封面(中文)")
private String coverImageZh;
@ApiModelProperty(value = "规则封面(英文)")
private String coverImageEn;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "扩展参数")
private String extParam;
public JSONObject getExtParamJson() {
if (StringUtils.isBlank(extParam)) {
return new JSONObject();
}
return JSONUtil.parseObj(extParam);
}
}
package cn.iocoder.yudao.module.member.vo.memberUserScoreLog;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author zhaobiyan
*/
@Data
@ApiModel("管理后台 - 积分记录查询 VO")
public class MemberUserScoreLogQueryVO extends PageParam {
@ApiModelProperty(value = "关键词")
private String key;
@ApiModelProperty(value = "积分来源")
private Integer sourceType;
@ApiModelProperty(value = "规则标题")
private String ruleTitle;
@ApiModelProperty(value = "规则说明")
private String ruleDesc;
@ApiModelProperty(value = "积分数值")
private Integer scoreCount;
@ApiModelProperty(value = "积分数值操作")
private Integer scoreCountOperate;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.member.dal.mysql.memberUserScoreLog.MemberUserScoreLogMapper">
<select id="getPageRecordList"
resultType="cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO">
select
musl.id as id,
musl.member_id as memberId,
mu.nickname as memberName,
musl.score_count as scoreCount,
musl.operate_type as operateType,
musl.source_type as sourceType,
sr.title_zh as ruleTitleZh,
sr.title_en as ruleTitleEn,
sr.desc_zh as ruleDescZh,
sr.desc_en as ruleDescEn,
sr.cover_image_zh as coverImageZh,
sr.cover_image_en as coverImageEn,
musl.create_time as createTime,
musl.ext_param as extParam
from member_user_score_log musl
left join member_user mu on mu.id = musl.member_id
left join score_rule sr on sr.id = musl.rule_id
where 1=1
<include refid="pageCondition"/>
order by musl.create_time desc
limit #{start}, #{size}
</select>
<select id="getPageCount" resultType="java.lang.Integer">
select count(*)
from member_user_score_log musl
left join member_user mu on mu.id = musl.member_id
left join score_rule sr on sr.id = musl.rule_id
where 1=1
<include refid="pageCondition"/>
</select>
<sql id="pageCondition">
<if test="query.key !=null and query.key != ''">
and (mu.nickname like '%${query.key}%' or mu.mobile like '%${query.key}%')
</if>
<if test="query.sourceType !=null">
and musl.source_type = #{query.sourceType}
</if>
<if test="query.ruleTitle !=null and query.ruleTitle !=''">
and (sr.title_zh like '%${query.ruleTitle}%' or sr.title_en like '%${query.ruleTitle}%')
</if>
<if test="query.ruleDesc !=null and query.ruleDesc !=''">
and (sr.desc_zh like '%${query.ruleDesc}%' or sr.desc_en like '%${query.ruleDesc}%')
</if>
<if test="query.startTime != null ">
and musl.create_time &gt;= #{query.startTime}
</if>
<if test="query.endTime != null ">
and musl.create_time &lt;= #{query.endTime}
</if>
<if test="query.scoreCount != null and query.scoreCountOperate != null">
<!--1:大于 2:等于 3:小于-->
<if test="query.scoreCountOperate == 1">
and musl.score_count &gt; #{query.scoreCount}
</if>
<if test="query.scoreCountOperate == 2">
and musl.score_count = #{query.scoreCount}
</if>
<if test="query.scoreCountOperate == 3">
and musl.score_count &lt; #{query.scoreCount}
</if>
</if>
</sql>
</mapper>
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
<if test="query.country != null"> <if test="query.country != null">
and mu.country = #{query.country} and mu.country = #{query.country}
</if> </if>
<if test="query.memberCreateTimeStart != null "> <if test="query.startTime != null ">
and mu.create_time &gt;= #{query.memberCreateTimeStart} and mu.create_time &gt;= #{query.startTime}
</if> </if>
<if test="query.memberCreateTimeStart != null "> <if test="query.endTime != null ">
and mu.create_time &lt;= #{query.memberCreateTimeEnd} and mu.create_time &lt;= #{query.endTime}
</if> </if>
<if test="query.usedScore != null and query.usedScoreOperate != null"> <if test="query.usedScore != null and query.usedScoreOperate != null">
<!--1:大于 2:等于 3:小于--> <!--1:大于 2:等于 3:小于-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment