Commit 315f0fcf authored by licc's avatar licc

新增月度奖金实体类

parent 52b90143
...@@ -64,4 +64,12 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> { ...@@ -64,4 +64,12 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
*/ */
List<WithdrawalRecordVo> getWithdrawalRecord(@Param("userId") String userId, @Param("yearMonth") Date yearMonth); List<WithdrawalRecordVo> getWithdrawalRecord(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
/**
* 获取月 累计奖金
* @param yearMonth 年月
* @return
*/
Double queryMonthAward(@Param("yearMonth") Date yearMonth);
} }
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
<mapper namespace="cn.wisenergy.mapper.MonthAwardMapper"> <mapper namespace="cn.wisenergy.mapper.MonthAwardMapper">
<resultMap id="monthMap" type="cn.wisenergy.model.app.MonthAward"> <resultMap id="monthMap" type="cn.wisenergy.model.app.MonthAward">
<id column="id" property="id"/> <id column="id" property="id"/>
<result column="year_month" property="yearMonth"/> <result column="growth_award" property="growthAward"/>
<result column="month_manure_total" property="monthManureTotal"/> <result column="award_total" property="awardTotal"/>
<result column="month_award_pool" property="monthAwardPool"/> <result column="month_award_total" property="monthAwardTotal"/>
<result column="month_manure_award" property="monthManureAward"/> <result column="month_increased" property="monthIncreased"/>
<result column="month_gold_award" property="monthGoldAward"/> <result column="gold_award" property="goldAward"/>
<result column="month_farmer_award" property="monthFarmerAward"/> <result column="farmer_award" property="farmerAward"/>
<result column="month_forest_start_award" property="monthForestStartAward"/> <result column="forest_start_award" property="forestStartAward"/>
<result column="month_partner_award" property="monthPartnerAward"/> <result column="partner_award" property="partnerAward"/>
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
</resultMap> </resultMap>
...@@ -25,37 +25,37 @@ ...@@ -25,37 +25,37 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
year_month,month_manure_total,month_award_pool,month_manure_award,month_gold_award,month_farmer_award, growth_award,award_total,month_award_total,month_increased,gold_award,farmer_award, forest_start_award,
month_forest_start_award,month_partner_award,create_time,update_time partner_award,create_time,update_time
</sql> </sql>
<sql id="vals"> <sql id="vals">
#{yearMonth},#{monthManureTotal},#{monthAwardPool},#{monthManureAward},#{monthGoldAward},#{monthFarmerAward}, #{growthAward},#{awardTotal},#{monthAwardTotal},#{monthIncreased},#{goldAward},#{farmerAward},
#{monthForestStartAward}, #{monthPartnerAward},now(),now() #{forestStartAward}, #{partnerAward},now(),now()
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
<if test="yearMonth != null">year_month =#{yearMonth},</if> <if test="growthAward != null">growth_award =#{growthAward},</if>
<if test="monthManureTotal != null">month_manure_total = #{monthManureTotal},</if> <if test="awardTotal != null">award_total = #{awardTotal},</if>
<if test="monthAwardPool != null">month_award_pool = #{monthAwardPool},</if> <if test="monthAwardTotal != null">month_award_total = #{monthAwardTotal},</if>
<if test="monthManureAward != null">month_manure_award =#{monthManureAward},</if> <if test="monthIncreased != null">month_increased =#{monthIncreased},</if>
<if test="monthGoldAward != null">month_gold_award =#{monthGoldAward},</if> <if test="goldAward != null">gold_award =#{goldAward},</if>
<if test="monthFarmerAward != null">month_farmer_award =#{monthFarmerAward},</if> <if test="farmerAward != null">farmer_award =#{farmerAward},</if>
<if test="monthForestStartAward != null">month_forest_start_award =#{monthForestStartAward},</if> <if test="forestStartAward != null">forest_start_award =#{forestStartAward},</if>
<if test="monthPartnerAward != null">month_partner_award =#{monthPartnerAward},</if> <if test="partnerAward != null">partner_award =#{partnerAward},</if>
update_time =now() update_time =now()
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
<if test="id != null">id = #{id}</if> <if test="id != null">id = #{id}</if>
<if test="yearMonth != null">and year_month =#{yearMonth}</if> <if test="growthAward != null">and growth_award =#{growthAward}</if>
<if test="monthManureTotal != null">and month_manure_total = #{monthManureTotal}</if> <if test="awardTotal != null">and award_total = #{awardTotal}</if>
<if test="monthAwardPool != null">and month_award_pool = #{monthAwardPool}</if> <if test="monthAwardTotal != null">and month_award_total = #{monthAwardTotal}</if>
<if test="monthManureAward != null">and month_manure_award =#{monthManureAward}</if> <if test="monthIncreased != null">and month_increased =#{monthIncreased}</if>
<if test="monthGoldAward != null">and month_gold_award =#{monthGoldAward}</if> <if test="goldAward != null">and gold_award =#{goldAward}</if>
<if test="monthFarmerAward != null">and month_farmer_award =#{monthFarmerAward}</if> <if test="farmerAward != null">and farmer_award =#{farmerAward}</if>
<if test="monthForestStartAward != null">and month_forest_start_award =#{monthForestStartAward}</if> <if test="forestStartAward != null">and forest_start_award =#{forestStartAward}</if>
<if test="monthPartnerAward != null">and month_partner_award =#{monthPartnerAward}</if> <if test="partnerAward != null">and partner_award =#{partnerAward}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if> <if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if> <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql> </sql>
......
...@@ -136,4 +136,20 @@ ...@@ -136,4 +136,20 @@
</where> </where>
</select> </select>
<select id="queryMonthAward" resultType="java.lang.Double">
select
sum(money)
from
<include refid="table"/>
<where>
(type=2
or status=0)
<if test="yearMonth != null">
AND(
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth}))
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -26,54 +26,53 @@ public class MonthAward implements Serializable { ...@@ -26,54 +26,53 @@ public class MonthAward implements Serializable {
private Integer id; private Integer id;
/** /**
* 年月 * 与上一次比较的增长奖金
*/ */
@ApiModelProperty(name = "yearMonth", value = "年月") @ApiModelProperty(name = "growthAward", value = "与上一次比较的增长额度")
private String yearMonth; private BigDecimal growthAward;
/** /**
* 本月月度肥料总额 * 历史奖金总额
*/ */
@ApiModelProperty(value = "本月月度肥料总额",name="monthManureTotal") @ApiModelProperty(value = "历史奖金总额",name="awardTotal")
private BigDecimal monthManureTotal; private BigDecimal awardTotal;
/** /**
* 本月进步最大奖励池 * 本月累计奖金总额(本月新增+上月没有分出去的月度肥料奖金)
*/ */
@ApiModelProperty(value = "本月进步最大奖励池",name="monthAwardPool") @ApiModelProperty(value = "本月累计奖金总额",name="monthAwardTotal")
private BigDecimal monthAwardPool; private BigDecimal monthAwardTotal;
/** /**
* 月度肥料奖励 * 本月新增
*/ */
@ApiModelProperty(value = "月度肥料奖励",name="monthManureAward") @ApiModelProperty(value = "本月新增",name="monthIncreased")
private BigDecimal monthManureAward; private BigDecimal monthIncreased;
/** /**
* 黄金树月奖励总额 * 黄金树月奖励总额
*/ */
@ApiModelProperty(value = "黄金树月奖励总额",name="monthGoldAward") @ApiModelProperty(value = "黄金树月奖励总额",name="goldAward")
private BigDecimal monthGoldAward; private BigDecimal goldAward;
/** /**
* 农场主月奖励总额 * 农场主月奖励总额
*/ */
@ApiModelProperty(value = "农场主月奖励总额",name="monthFarmerAward") @ApiModelProperty(value = "农场主月奖励总额",name="farmerAward")
private BigDecimal monthFarmerAward; private BigDecimal farmerAward;
/** /**
* 森林之星月奖励总额 * 森林之星月奖励总额
*/ */
@ApiModelProperty(value = "森林之星月奖励总额",name="monthForestStartAward") @ApiModelProperty(value = "森林之星月奖励总额",name="forestStartAward")
private BigDecimal monthForestStartAward; private BigDecimal forestStartAward;
/** /**
* 森田合伙人月奖励总额 * 森田合伙人月奖励总额
*/ */
@ApiModelProperty(value = "森田合伙人月奖励总额",name="monthPartnerAward") @ApiModelProperty(value = "森田合伙人月奖励总额",name="partnerAward")
private BigDecimal monthPartnerAward; private BigDecimal partnerAward;
private Date createTime; private Date createTime;
......
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author 86187
* @ Description: 月度奖金页面展示数据Vo
* @ Author : 86187
* @ Date : 2021/3/9 11:09
*/
@ApiModel("MonthAwardVo")
@Data
public class MonthAwardVo {
/**
* 历史累计奖金
*/
@ApiModelProperty(value = "历史累计奖金", name = "totalAward")
private Double totalAward;
/**
* 本月新增
*/
@ApiModelProperty(value = "本月新增", name = "monthIncreased")
private Double monthIncreased;
/**
* 用户-份额
*/
@ApiModelProperty(value = "用户-份额", name = "userMonthAward")
private Double userMonthAward;
/**
* 黄金树等级奖金
*/
@ApiModelProperty(value = "黄金树等级奖金", name = "goldAward")
private Double goldAward;
/**
* 农场主等级 奖金
*/
@ApiModelProperty(value = "农场主等级 奖金", name = "farmerAward")
private Double farmerAward;
/**
* 森林之星等级奖金
*/
@ApiModelProperty(value = "森林之星等级奖金", name = "forestStartAward")
private Double forestStartAward;
/**
* 西田森合伙人等级奖金
*/
@ApiModelProperty(value = "西田森合伙人等级奖金", name = "partnerAward")
private Double partnerAward;
}
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.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
*/
@Service
@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;
}
}
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
/**
* @author 86187
* @ Description:
* @ Author : 86187
* @ Date : 2021/2/3 17:05
*/
@Api(tags = "图片上传")
@RestController
@RequestMapping("/pic")
@Slf4j
public class FileUploadController {
/**
* 请求 url 中的资源映射,不推荐写死在代码中,最好提供可配置,如 /upload_flowChart/**
*/
@Value("${uploadFile.resourceHandler}")
private String resourceHandler;
/**
* 上传文件保存的本地目录,使用@Value获取全局配置文件中配置的属性值,如 D:/java/upload_flowChart/
*/
@Value("${uploadFile.location}")
private String uploadImagesLocation;
/**
* 允许上传的格式
*/
private static final String[] IMAGE_TYPE = new String[]{".bmp", ".jpg", ".jpeg", ".gif", ".png"};
@ApiOperation(value = "文件上传", notes = "文件上传")
@PostMapping(value = "/upload", headers = "content-type=multipart/form-data")
public R file(
@ApiParam(required = true, value = "上传文件")
@RequestParam("file") MultipartFile file,
HttpServletRequest request) {
boolean isLegal = true;
if (file.isEmpty()) {
// 上传文件为空
return R.error("上传文件不能为空");
}
for (String type : IMAGE_TYPE) {
if (StringUtils.endsWithIgnoreCase(file.getOriginalFilename(), type)) {
isLegal = false;
break;
}
}
if (isLegal) {
return R.error("上传文件类型不符合");
}
File folder = new File(uploadImagesLocation);
if (!folder.exists()) {
folder.mkdirs();
}
String oldName = file.getOriginalFilename();
String newName = UUID.randomUUID().toString().substring(4,9) + oldName;
try {
file.transferTo(new File(folder, newName));
String url = "/upload_flowChart/" + newName;
return R.ok(200, url);
} catch (IOException e) {
e.printStackTrace();
}
return R.error("上传文件失败!");
}
}
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.service.app.TradeRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author 86187
* @ Description: 月度奖励
* @ Author : 86187
* @ Date : 2021/3/9 11:04
*/
@Api(tags = "月度奖励接口")
@RestController
@RequestMapping("/award")
@Slf4j
public class TradeRecordController {
@Autowired
private TradeRecordService tradeRecordService;
@ApiOperation(value = "本月累计奖金", notes = "本月累计奖金", httpMethod = "GET")
@GetMapping("/queryMonthAward")
public R<Double> queryMonthAward() {
log.info("shop-mall[]TradeRecordController[]queryMonthAward[]input.method");
return tradeRecordService.queryMonthAward();
}
}
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