Commit 059c5b1f authored by licc's avatar licc

新增月度奖励列表接口

parent f952b3a3
......@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author 86187
......@@ -41,4 +43,9 @@ public interface MonthAwardMapper extends BaseMapper<MonthAward> {
* @return 月度奖金
*/
MonthAward getByTime(@Param("yearMonth") String yearMonth);
int count(Map<String,Object> map);
List<MonthAward> getList(Map<String,Object> map);
}
......@@ -103,4 +103,29 @@
limit 1
</select>
<select id="count" resultType="java.lang.Integer">
select count(1)
from
<include refid="table"/>
<where>
<if test="queryTime != null and queryTime != ''">
`year_month` = #{queryTime}
</if>
</where>
</select>
<select id="getList" resultType="cn.wisenergy.model.app.MonthAward">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="queryTime != null and queryTime != ''">
`year_month` = #{queryTime}
</if>
</where>
order by create_time desc
limit #{startNum},#{endNum}
</select>
</mapper>
\ No newline at end of file
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 月度奖励列表查询条件Dto
* @author 86187
*/
@Data
@ApiModel("MonthAwardQuery")
public class MonthAwardQuery {
/**
* 查询时间 格式(yyyy-MM)
*/
@ApiModelProperty(value = "查询时间 格式(yyyy-MM)", name = "queryTime")
private String queryTime;
/**
* 页码
*/
@ApiModelProperty(value = "页码", name = "pageNo")
private Integer pageNo;
/**
* 页条数
*/
@ApiModelProperty(value = "页条数", name = "pageSize")
private Integer pageSize;
private Integer startNum;
private Integer endNum;
}
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.MonthAward;
import cn.wisenergy.model.dto.MonthAwardQuery;
import cn.wisenergy.model.vo.MonthAwardVo;
import com.github.pagehelper.PageInfo;
/**
* @author 86187
......@@ -16,4 +19,11 @@ public interface MonthAwardService {
* @return 月度奖金
*/
R<MonthAwardVo> queryMonthAward(String userId);
/**
* 获取月度奖励列表
* @param monthAwardQuery 查询参数
* @return 月度奖励列表
*/
R<PageInfo<MonthAward>> getList(MonthAwardQuery monthAwardQuery);
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.constant.CommonAttributes;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.MonthAwardMapper;
import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.MonthAward;
import cn.wisenergy.model.app.TradeRecord;
import cn.wisenergy.model.dto.MonthAwardQuery;
import cn.wisenergy.model.dto.TradeRecordQuery;
import cn.wisenergy.model.vo.MonthAwardVo;
import cn.wisenergy.service.app.MonthAwardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author 86187
......@@ -60,4 +68,52 @@ public class MonthAwardServiceImpl extends ServiceImpl<MonthAwardMapper, MonthAw
}
return R.ok(monthAwardVo);
}
@Override
public R<PageInfo<MonthAward>> getList(MonthAwardQuery query) {
log.info("shop-mall[]MonthAwardServiceImpl[]getList[]input.param.query:" + query);
if (null == query) {
return R.error("入参为空!");
}
pageHandle(query);
Map<String, Object> map = new HashMap<>(8);
if (!StringUtils.isBlank(query.getQueryTime())) {
map.put("queryTime", query.getQueryTime());
}
int total = baseMapper.count(map);
map.put("startNum", query.getStartNum());
map.put("endNum", query.getEndNum());
List<MonthAward> list = baseMapper.getList(map);
PageInfo<MonthAward> info = new PageInfo<>();
info.setPageSize(query.getPageSize());
info.setPageNum(query.getPageNo());
info.setTotal(total);
info.setList(list);
return R.ok(info);
}
/**
* 分页处理方法
*
* @param schemeVo 参数
*/
private void pageHandle(MonthAwardQuery schemeVo) {
Integer pageNum = schemeVo.getPageNo();
Integer pageSize = schemeVo.getPageSize();
if (null == pageSize || pageSize == 0) {
pageSize = 10;
}
if (null == pageNum || pageNum == 0) {
pageNum = 1;
}
Integer endNum = pageSize;
Integer startNum = (pageNum - CommonAttributes.NUM_ONE) * pageSize;
schemeVo.setEndNum(endNum);
schemeVo.setStartNum(startNum);
schemeVo.setPageNo(pageNum);
schemeVo.setPageSize(pageSize);
}
}
......@@ -14,6 +14,7 @@ import cn.wisenergy.model.enums.UserLevelEnum;
import cn.wisenergy.service.app.TradeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -38,6 +39,7 @@ public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, Trade
@Autowired
private TradeRecordMapper tradeRecordMapper;
@XxlJob(value = "monthAwardCountTask")
@Override
public R<Boolean> monthAwardCount() {
MonthAward result = new MonthAward();
......
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