Commit 080b4735 authored by licc's avatar licc

新增月度奖金接口

parent c7438ca0
...@@ -2,6 +2,9 @@ package cn.wisenergy.mapper; ...@@ -2,6 +2,9 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.MonthAward; import cn.wisenergy.model.app.MonthAward;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/** /**
* @author 86187 * @author 86187
...@@ -31,4 +34,6 @@ public interface MonthAwardMapper extends BaseMapper<MonthAward> { ...@@ -31,4 +34,6 @@ public interface MonthAwardMapper extends BaseMapper<MonthAward> {
* @return 1 * @return 1
*/ */
int delById(Integer id); int delById(Integer id);
MonthAward getByTime(@Param("yearMonth")Date yearMonth);
} }
...@@ -16,6 +16,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> { ...@@ -16,6 +16,7 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/** /**
* 添加交易记录 * 添加交易记录
*
* @param tradeRecord 记录信息 * @param tradeRecord 记录信息
* @return 1 * @return 1
*/ */
...@@ -23,53 +24,61 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> { ...@@ -23,53 +24,61 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/** /**
* 编辑交易记录 * 编辑交易记录
*
* @param tradeRecord 记录信息 * @param tradeRecord 记录信息
* @return 1 * @return 1
*/ */
int edit(TradeRecord tradeRecord); int edit(TradeRecord tradeRecord);
/** /**
* 删除 * 删除
*
* @param id 主键 * @param id 主键
* @return 1 * @return 1
*/ */
int delById(@Param("id") Integer id); int delById(@Param("id") Integer id);
/** /**
* 根据用户id,获取用户交易列表 * 根据用户id,获取用户交易列表
*
* @param userId 用户id * @param userId 用户id
* @return 用户交易列表 * @return 用户交易列表
*/ */
List<TradeRecord> getByUserId(@Param("userId") String userId); List<TradeRecord> getByUserId(@Param("userId") String userId);
/** /**
* 根据用户id、年月 ,获取用户本月交易列表 * 根据用户id、年月 ,获取用户本月交易列表
*
* @param userId 用户id * @param userId 用户id
* @return 用户交易列表 * @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 * @param userId 用户id
* @return 累计收益 * @return 累计收益
*/ */
List<AccumulatedIncomeVo> getSixMonthIncome(@Param("userId") String userId); List<AccumulatedIncomeVo> getSixMonthIncome(@Param("userId") String userId);
/** /**
* 根据用户id 或 年月 ,获取用户本月交易提现列表 * 根据用户id 或 年月 ,获取用户本月交易提现列表
* @param userId 用户id *
* @param yearMonth 年月 * @param userId 用户id
* @param yearMonth 年月
* @return 交易列表 * @return 交易列表
*/ */
List<WithdrawalRecordVo> getWithdrawalRecord(@Param("userId") String userId, @Param("yearMonth") Date yearMonth); List<WithdrawalRecordVo> getWithdrawalRecord(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
/** /**
* 获取月 累计奖金 * 获取用户本月累计奖金
*
* @param userId 用户id
* @param yearMonth 年月 * @param yearMonth 年月
* @return * @return
*/ */
Double queryMonthAward(@Param("yearMonth") Date yearMonth); Double queryMonthAward(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
} }
...@@ -86,4 +86,20 @@ ...@@ -86,4 +86,20 @@
where id = #{id} where id = #{id}
</delete> </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> </mapper>
\ No newline at end of file
...@@ -137,17 +137,18 @@ ...@@ -137,17 +137,18 @@
</select> </select>
<select id="queryMonthAward" resultType="java.lang.Double"> <select id="queryMonthAward" resultType="java.lang.Double">
select select sum(money)
sum(money)
from from
<include refid="table"/> <include refid="table"/>
<where> <where>
(type=2 (type=2 or status=0)
or status=0) <if test="userId">
and user_id=#{userId}
</if>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( AND(
YEAR(create_time) = YEAR(#{yearMonth}) YEAR(update_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth})) AND MONTH(update_time) = MONTH(#{yearMonth}))
</if> </if>
</where> </where>
</select> </select>
......
...@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* @author 86187 * @author 86187
* @ Description: 月度奖金页面展示数据Vo * @ Description: 月度奖金页面展示数据Vo
...@@ -13,45 +16,65 @@ import lombok.Data; ...@@ -13,45 +16,65 @@ import lombok.Data;
@ApiModel("MonthAwardVo") @ApiModel("MonthAwardVo")
@Data @Data
public class MonthAwardVo { public class MonthAwardVo {
/**
* 与上一次比较的增长奖金
*/
@ApiModelProperty(name = "growthAward", value = "与上一次比较的增长额度")
private BigDecimal growthAward;
/** /**
* 历史累计奖金 * 历史奖金总额
*/ */
@ApiModelProperty(value = "历史累计奖金", name = "totalAward") @ApiModelProperty(value = "历史奖金总额",name="awardTotal")
private Double totalAward; private BigDecimal awardTotal;
/**
* 本月累计奖金总额(本月新增+上月没有分出去的月度肥料奖金)
*/
@ApiModelProperty(value = "本月累计奖金总额",name="monthAwardTotal")
private BigDecimal monthAwardTotal;
/** /**
* 本月新增 * 本月新增
*/ */
@ApiModelProperty(value = "本月新增", name = "monthIncreased") @ApiModelProperty(value = "本月新增",name="monthIncreased")
private Double monthIncreased; private BigDecimal monthIncreased;
/** /**
* 用户-份 * 黄金树月奖励总
*/ */
@ApiModelProperty(value = "用户-份额", name = "userMonthAward") @ApiModelProperty(value = "黄金树月奖励总额",name="goldAward")
private Double userMonthAward; private BigDecimal goldAward;
/** /**
* 黄金树等级奖金 * 农场主月奖励总额
*/ */
@ApiModelProperty(value = "黄金树等级奖金", name = "goldAward") @ApiModelProperty(value = "农场主月奖励总额",name="farmerAward")
private Double goldAward; private BigDecimal farmerAward;
/** /**
* 农场主等级 奖金 * 森林之星月奖励总额
*/ */
@ApiModelProperty(value = "农场主等级 奖金", name = "farmerAward") @ApiModelProperty(value = "森林之星月奖励总额",name="forestStartAward")
private Double farmerAward; private BigDecimal forestStartAward;
/** /**
* 森林之星等级奖金 * 森田合伙人月奖励总额
*/ */
@ApiModelProperty(value = "森林之星等级奖金", name = "forestStartAward") @ApiModelProperty(value = "森田合伙人月奖励总额",name="partnerAward")
private Double forestStartAward; private BigDecimal partnerAward;
/**
* 用户-份额
*/
@ApiModelProperty(value = "用户-份额", name = "userMonthAward")
private Double userMonthAward;
/** /**
* 西田森合伙人等级奖金 * 奖金入池时间
*/ */
@ApiModelProperty(value = "西田森合伙人等级奖金", name = "partnerAward") @ApiModelProperty(value = "奖金入池时间", name = "awardTime")
private Double partnerAward; 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; package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.MonthAwardVo;
/** /**
* @author 86187 * @author 86187
*/ */
public interface TradeRecordService { 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; package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.TradeRecordMapper; import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.TradeRecord; import cn.wisenergy.model.app.TradeRecord;
import cn.wisenergy.model.vo.MonthAwardVo;
import cn.wisenergy.service.app.TradeRecordService; import cn.wisenergy.service.app.TradeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
/** /**
* @author 86187 * @author 86187
*/ */
...@@ -19,24 +14,4 @@ import java.util.Date; ...@@ -19,24 +14,4 @@ import java.util.Date;
@Slf4j @Slf4j
public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, TradeRecord> implements TradeRecordService { 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; ...@@ -4,6 +4,7 @@ import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo; import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.User; import cn.wisenergy.model.app.User;
import cn.wisenergy.service.app.AccountService; import cn.wisenergy.service.app.AccountService;
import cn.wisenergy.web.common.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -22,7 +23,7 @@ import java.util.List; ...@@ -22,7 +23,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/account") @RequestMapping("/account")
@Slf4j @Slf4j
public class AccountController { public class AccountController extends BaseController {
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;
......
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R; 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.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -21,14 +23,18 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -21,14 +23,18 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/award") @RequestMapping("/award")
@Slf4j @Slf4j
public class TradeRecordController { public class MonthAwardController {
@Autowired @Autowired
private TradeRecordService tradeRecordService; private MonthAwardService monthAwardService;
@ApiOperation(value = "本月累计奖金", notes = "本月累计奖金", httpMethod = "GET") @ApiOperation(value = "本月累计奖金", notes = "本月累计奖金", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@GetMapping("/queryMonthAward") @GetMapping("/queryMonthAward")
public R<Double> queryMonthAward() { public R<MonthAwardVo> queryMonthAward(String userId) {
log.info("shop-mall[]TradeRecordController[]queryMonthAward[]input.method"); log.info("shop-mall[]MonthAwardController[]queryMonthAward[]input.param.userId:" + userId);
return tradeRecordService.queryMonthAward(); 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