Commit 3425faaf authored by zhaobiyan's avatar zhaobiyan

会员积分总览接口

parent bdfc06c2
package cn.iocoder.yudao.module.member.api.memberUserScore;
package cn.iocoder.yudao.module.member.controller.admin.memberUserScore;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
......@@ -12,9 +12,7 @@ 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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
......@@ -30,10 +28,10 @@ public class MemberUserScoreController {
@Resource
private MemberUserScoreService userScoreService;
@GetMapping("/page")
@PostMapping("/page")
@ApiOperation("获得会员积分分页")
@PreAuthorize("@ss.hasPermission('member:user-score:query')")
public CommonResult<PageResult<MemberUserScoreBackVO>> getUserScorePage(@Valid MemberUserScoreQueryVO query, PageVO page) {
public CommonResult<PageResult<MemberUserScoreBackVO>> getUserScorePage(@Valid @RequestBody MemberUserScoreQueryVO query, PageVO page) {
PageResult<MemberUserScoreBackVO> pageResult = userScoreService.getUserScorePage(query, page);
return success(pageResult);
}
......
......@@ -2,7 +2,12 @@ package cn.iocoder.yudao.module.member.dal.mysql.memberUserScore;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.member.dal.dataobject.memberUserScore.MemberUserScoreDO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 会员积分 Mapper
......@@ -11,4 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MemberUserScoreMapper extends AbstractMapper<MemberUserScoreDO> {
List<MemberUserScoreBackVO> getUserScoreList(@Param("start") int start,@Param("size") int size,@Param("query") MemberUserScoreQueryVO query);
int countUserScore(@Param("query") MemberUserScoreQueryVO query);
}
......@@ -2,11 +2,13 @@ package cn.iocoder.yudao.module.member.service.memberUserScore;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.mysql.memberUserScore.MemberUserScoreMapper;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
......@@ -44,8 +46,15 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
@Override
public PageResult<MemberUserScoreBackVO> getUserScorePage(MemberUserScoreQueryVO query, PageVO page) {
PageResult<MemberUserScoreBackVO> pageResult = new PageResult<>();
return pageResult;
IPage<MemberUserScoreBackVO> mpPage = MyBatisUtils.buildPage(page);
page.setPage(query.getPageNo());
page.setRows(query.getPageSize());
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
List<MemberUserScoreBackVO> list = userScoreMapper.getUserScoreList(start, size, query);
int total = userScoreMapper.countUserScore(query);
return new PageResult<>(list, total, mpPage.getSize(), page.getPage(), (total + mpPage.getSize() - 1) / mpPage.getSize());
}
@Override
......
......@@ -17,9 +17,13 @@ public class MemberUserScoreBackVO {
@ApiModelProperty(value = "会员昵称")
private String nickname;
@ApiModelProperty(value = "联系方式")
private String areaCodeMobile;
@ApiModelProperty(value = "国家")
private String countryName;
private String areaCode;
@ApiModelProperty(value = "手机号")
private String mobile;
@ApiModelProperty(value = "国家(中文)")
private String countryNameZh;
@ApiModelProperty(value = "国家(英文)")
private String countryNameEn;
@ApiModelProperty(value = "当前积分")
private Integer holdScore;
@ApiModelProperty(value = "已兑换积分")
......
package cn.iocoder.yudao.module.member.vo.memberUserScore;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -14,11 +15,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
*/
@Data
@ApiModel("管理后台 - 会员积分查询 VO")
public class MemberUserScoreQueryVO {
public class MemberUserScoreQueryVO extends PageParam {
@ApiModelProperty(value = "关键词")
private String key;
@ApiModelProperty(value = "国家")
private String country;
private Integer country;
@ApiModelProperty(value = "当前积分")
private Integer holdScore;
@ApiModelProperty(value = "当前积分操作")
......
<?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.memberUserScore.MemberUserScoreMapper">
<select id="getUserScoreList"
resultType="cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO">
select
mu.id,
mu.nickname,
mu.area_code as areaCode,
mu.mobile,
re.title_zh as countryNameZh,
re.title_en as countryNameEn,
mus.hold_score as holdScore,
mus.used_score as usedScore,
mu.create_time as createTime
from member_user mu
left join member_user_score mus on mus.member_id = mu.id
left join ecw_region re on re.id = mu.country
where 1 = 1
<include refid="scoreCondition"/>
order by mu.id
limit #{start}, #{size}
</select>
<select id="countUserScore" resultType="java.lang.Integer">
select
count(*)
from member_user mu
left join member_user_score mus on mus.member_id = mu.id
left join ecw_region re on re.id = mu.country
where 1 = 1
<include refid="scoreCondition"/>
</select>
<sql id="scoreCondition">
<if test="query.key != null and query.key != ''">
and (mu.nickname like '%${query.key}%' or mu.mobile like '%${query.key}%')
</if>
<if test="query.country != null">
and mu.country = #{query.country}
</if>
<if test="query.memberCreateTimeStart != null ">
and mu.create_time &gt;= #{query.memberCreateTimeStart}
</if>
<if test="query.memberCreateTimeStart != null ">
and mu.create_time &lt;= #{query.memberCreateTimeEnd}
</if>
<if test="query.usedScore != null and query.usedScoreOperate != null">
<!--1:大于 2:等于 3:小于-->
<if test="query.usedScoreOperate == 1">
and mus.used_score &gt; #{query.usedScore}
</if>
<if test="query.usedScoreOperate == 2">
and mus.used_score = #{query.usedScore}
</if>
<if test="query.usedScoreOperate == 3">
and mus.used_score &lt; #{query.usedScore}
</if>
</if>
<if test="query.holdScore != null and query.holdScoreOperate != null">
<!--1:大于 2:等于 3:小于-->
<if test="query.holdScoreOperate == 1">
and mus.hold_score &gt; #{query.holdScore}
</if>
<if test="query.holdScoreOperate == 2">
and mus.hold_score = #{query.holdScore}
</if>
<if test="query.holdScoreOperate == 3">
and mus.hold_score &lt; #{query.holdScore}
</if>
</if>
</sql>
</mapper>
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