Commit 080b4735 authored by licc's avatar licc

新增月度奖金接口

parent c7438ca0
......@@ -2,6 +2,9 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.MonthAward;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* @author 86187
......@@ -31,4 +34,6 @@ public interface MonthAwardMapper extends BaseMapper<MonthAward> {
* @return 1
*/
int delById(Integer id);
MonthAward getByTime(@Param("yearMonth")Date yearMonth);
}
......@@ -16,6 +16,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 添加交易记录
*
* @param tradeRecord 记录信息
* @return 1
*/
......@@ -23,6 +24,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 编辑交易记录
*
* @param tradeRecord 记录信息
* @return 1
*/
......@@ -30,6 +32,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 删除
*
* @param id 主键
* @return 1
*/
......@@ -37,6 +40,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 根据用户id,获取用户交易列表
*
* @param userId 用户id
* @return 用户交易列表
*/
......@@ -44,13 +48,15 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 根据用户id、年月 ,获取用户本月交易列表
*
* @param userId 用户id
* @return 用户交易列表
*/
List<TradeRecord> getByUserIdAndTime(@Param("userId") String userId,@Param("yearMonth") Date yearMonth);
List<TradeRecord> getByUserIdAndTime(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
/**
* 获取不包括本月的六个月的累计收益
*
* @param userId 用户id
* @return 累计收益
*/
......@@ -58,6 +64,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 根据用户id 或 年月 ,获取用户本月交易提现列表
*
* @param userId 用户id
* @param yearMonth 年月
* @return 交易列表
......@@ -66,10 +73,12 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 获取月 累计奖金
* 获取用户本月累计奖金
*
* @param userId 用户id
* @param yearMonth 年月
* @return
*/
Double queryMonthAward(@Param("yearMonth") Date yearMonth);
Double queryMonthAward(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
}
......@@ -86,4 +86,20 @@
where id = #{id}
</delete>
<select id="getByTime" resultType="cn.wisenergy.model.app.MonthAward">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="yearMonth != null">
AND(
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth}))
</if>
order by create_time desc
limit 1
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -137,17 +137,18 @@
</select>
<select id="queryMonthAward" resultType="java.lang.Double">
select
sum(money)
select sum(money)
from
<include refid="table"/>
<where>
(type=2
or status=0)
(type=2 or status=0)
<if test="userId">
and user_id=#{userId}
</if>
<if test="yearMonth != null">
AND(
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth}))
YEAR(update_time) = YEAR(#{yearMonth})
AND MONTH(update_time) = MONTH(#{yearMonth}))
</if>
</where>
</select>
......
......@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author 86187
* @ Description: 月度奖金页面展示数据Vo
......@@ -13,45 +16,65 @@ import lombok.Data;
@ApiModel("MonthAwardVo")
@Data
public class MonthAwardVo {
/**
* 与上一次比较的增长奖金
*/
@ApiModelProperty(name = "growthAward", value = "与上一次比较的增长额度")
private BigDecimal growthAward;
/**
* 历史累计奖金
* 历史奖金总额
*/
@ApiModelProperty(value = "历史累计奖金", name = "totalAward")
private Double totalAward;
@ApiModelProperty(value = "历史奖金总额",name="awardTotal")
private BigDecimal awardTotal;
/**
* 本月累计奖金总额(本月新增+上月没有分出去的月度肥料奖金)
*/
@ApiModelProperty(value = "本月累计奖金总额",name="monthAwardTotal")
private BigDecimal monthAwardTotal;
/**
* 本月新增
*/
@ApiModelProperty(value = "本月新增", name = "monthIncreased")
private Double monthIncreased;
@ApiModelProperty(value = "本月新增",name="monthIncreased")
private BigDecimal monthIncreased;
/**
* 用户-份
* 黄金树月奖励总
*/
@ApiModelProperty(value = "用户-份额", name = "userMonthAward")
private Double userMonthAward;
@ApiModelProperty(value = "黄金树月奖励总额",name="goldAward")
private BigDecimal goldAward;
/**
* 黄金树等级奖金
* 农场主月奖励总额
*/
@ApiModelProperty(value = "黄金树等级奖金", name = "goldAward")
private Double goldAward;
@ApiModelProperty(value = "农场主月奖励总额",name="farmerAward")
private BigDecimal farmerAward;
/**
* 农场主等级 奖金
* 森林之星月奖励总额
*/
@ApiModelProperty(value = "农场主等级 奖金", name = "farmerAward")
private Double farmerAward;
@ApiModelProperty(value = "森林之星月奖励总额",name="forestStartAward")
private BigDecimal forestStartAward;
/**
* 森林之星等级奖金
* 森田合伙人月奖励总额
*/
@ApiModelProperty(value = "森林之星等级奖金", name = "forestStartAward")
private Double forestStartAward;
@ApiModelProperty(value = "森田合伙人月奖励总额",name="partnerAward")
private BigDecimal partnerAward;
/**
* 用户-份额
*/
@ApiModelProperty(value = "用户-份额", name = "userMonthAward")
private Double userMonthAward;
/**
* 西田森合伙人等级奖金
* 奖金入池时间
*/
@ApiModelProperty(value = "西田森合伙人等级奖金", name = "partnerAward")
private Double partnerAward;
@ApiModelProperty(value = "奖金入池时间", name = "awardTime")
private Date awardTime;
}
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.MonthAwardVo;
/**
* @author 86187
* @ Description:
* @ Author : 86187
* @ Date : 2021/3/9 15:25
*/
public interface MonthAwardService {
/**
* 获取月度奖金
* @param userId 用户id
* @return 月度奖金
*/
R<MonthAwardVo> queryMonthAward(String userId);
}
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.MonthAwardVo;
/**
* @author 86187
*/
public interface TradeRecordService {
/**
* 查询本月累计奖金
*
* @return 本月累计奖金
*/
R<Double> queryMonthAward();
/**
* 查询各种月度奖金
*
* @param userId 用户id
* @return 各种月度奖金
*/
R<MonthAwardVo> queryAllAward(String userId);
}
package cn.wisenergy.service.app.impl;
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.vo.MonthAwardVo;
import cn.wisenergy.service.app.MonthAwardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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;
/**
* @author 86187
*/
@Slf4j
@Service
public class MonthAwardServiceImpl extends ServiceImpl<MonthAwardMapper, MonthAward> implements MonthAwardService {
@Autowired
private TradeRecordMapper tradeRecordMapper;
@Override
public R<MonthAwardVo> queryMonthAward(String userId) {
log.info("shop-mall[]MonthAwardServiceImpl[]queryMonthAward[]input.param.userId:" + userId);
if (StringUtils.isBlank(userId)) {
return R.error("入参为空!");
}
//获取本月最新的一条数据
MonthAwardVo monthAwardVo = new MonthAwardVo();
MonthAward monthAward = baseMapper.getByTime(new Date());
if (null == monthAward) {
return R.ok(monthAwardVo);
}
monthAwardVo.setAwardTime(monthAward.getCreateTime());
monthAwardVo.setAwardTotal(monthAward.getAwardTotal());
monthAwardVo.setFarmerAward(monthAward.getFarmerAward());
monthAwardVo.setForestStartAward(monthAward.getForestStartAward());
monthAwardVo.setGoldAward(monthAward.getGoldAward());
monthAwardVo.setGrowthAward(monthAward.getGrowthAward());
monthAwardVo.setMonthAwardTotal(monthAward.getMonthAwardTotal());
monthAwardVo.setMonthIncreased(monthAward.getMonthIncreased());
monthAwardVo.setPartnerAward(monthAward.getPartnerAward());
//获取用户本月奖金
Double sum = tradeRecordMapper.queryMonthAward(userId, new Date());
monthAwardVo.setUserMonthAward(sum);
return R.ok(monthAwardVo);
}
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.TradeRecord;
import cn.wisenergy.model.vo.MonthAwardVo;
import cn.wisenergy.service.app.TradeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author 86187
*/
......@@ -19,24 +14,4 @@ import java.util.Date;
@Slf4j
public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, TradeRecord> implements TradeRecordService {
@Override
public R<Double> queryMonthAward() {
log.info("shop-mall[]TradeRecordServiceImpl[]queryMonthAward[]input.method");
//获取本月累计奖金
Double award = baseMapper.queryMonthAward(new Date());
return R.ok(award);
}
@Override
public R<MonthAwardVo> queryAllAward(String userId) {
log.info("shop-mall[]TradeRecordServiceImpl[]queryAllAward[]input.param.userId:"+userId);
if(StringUtils.isBlank(userId)){
return R.error("入参为空!");
}
return null;
}
}
......@@ -4,6 +4,7 @@ import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.User;
import cn.wisenergy.service.app.AccountService;
import cn.wisenergy.web.common.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
......@@ -22,7 +23,7 @@ import java.util.List;
@RestController
@RequestMapping("/account")
@Slf4j
public class AccountController {
public class AccountController extends BaseController {
@Autowired
private AccountService accountService;
......
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.service.app.TradeRecordService;
import cn.wisenergy.model.vo.MonthAwardVo;
import cn.wisenergy.service.app.MonthAwardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -21,14 +23,18 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/award")
@Slf4j
public class TradeRecordController {
public class MonthAwardController {
@Autowired
private TradeRecordService tradeRecordService;
private MonthAwardService monthAwardService;
@ApiOperation(value = "本月累计奖金", notes = "本月累计奖金", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@GetMapping("/queryMonthAward")
public R<Double> queryMonthAward() {
log.info("shop-mall[]TradeRecordController[]queryMonthAward[]input.method");
return tradeRecordService.queryMonthAward();
public R<MonthAwardVo> queryMonthAward(String userId) {
log.info("shop-mall[]MonthAwardController[]queryMonthAward[]input.param.userId:" + userId);
if (StringUtils.isBlank(userId)) {
return R.error("入参为空!");
}
return monthAwardService.queryMonthAward(userId);
}
}
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