Commit feef15d7 authored by licc's avatar licc

月度奖金 定数任务接口提交

parent 8f8a972a
......@@ -2,6 +2,7 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.MonthManure;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @author 86187
......@@ -22,4 +23,12 @@ public interface MonthManureMapper extends BaseMapper<MonthManure> {
* @return 1
*/
int edit(MonthManure monthManure);
/**
* 通过年月获取月度肥料剩余奖金信息
*
* @param yearMonth 年月
* @return 月度肥料剩余奖金信息
*/
MonthManure queryByTime(@Param("yearMonth") String yearMonth);
}
......@@ -81,4 +81,29 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
*/
Double queryMonthAward(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
/**
* 获取本月新增奖金(月度肥料)
*
* @param yearMonth 时间
* @return 本月新增奖金
*/
Double queryMonthGrow(@Param("yearMonth") Date yearMonth);
/**
* 获取历史累计奖金 -时间小于yearMonth (月度肥料)
*
* @param yearMonth 时间
* @return 本月新增奖金
*/
Double queryAllAward(@Param("yearMonth") Date yearMonth);
/**
* 获取用户等级 月奖金---时间小于yearMonth (月度肥料)
*
* @param userLevel 用户等级
* @param yearMonth 时间
* @return 用户等级 月奖金
*/
Double queryByUserLevel(@Param("userLevel") Integer userLevel, @Param("yearMonth") Date yearMonth);
}
......@@ -60,5 +60,17 @@
</where>
</update>
<select id="queryByTime" resultType="cn.wisenergy.model.app.MonthManure">
SELECT
<include refid="cols_all"/>
FROM
<include refid="table"/>
<where>
<if test="yearMonth != null and yearMonth != ''">
year_month=#{yearMonth}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -141,14 +141,62 @@
from
<include refid="table"/>
<where>
(trade_type=2 or status=0)
(trade_type=4 or trade_type=7)
and status=0
<if test="userId">
and user_id=#{userId}
</if>
<if test="yearMonth != null">
AND(
YEAR(update_time) = YEAR(#{yearMonth})
AND MONTH(update_time) = MONTH(#{yearMonth}))
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth}))
</if>
</where>
</select>
<select id="queryMonthGrow" resultType="java.lang.Double">
select sum(money)
from
<include refid="table"/>
<where>
(trade_type=4 or trade_type=7)
and status=0
<if test="yearMonth != null">
AND(
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth}))
</if>
</where>
</select>
<select id="queryAllAward" resultType="java.lang.Double">
select sum(money)
from
<include refid="table"/>
<where>
(trade_type=4 or trade_type=7)
and status=0
<if test="yearMonth != null">
and create_time &lt; #{yearMonth}
</if>
</where>
</select>
<select id="queryByUserLevel" resultType="java.lang.Double">
select sum(t.money)
from trade_record t,user_info u
<where>
(t.trade_type=4 or t.trade_type=7)
and t.status=0
and t.user_id=u.user_id
<if test="yearMonth != null">
and t.create_time &lt; #{yearMonth}
AND(
YEAR(t.create_time) = YEAR(#{yearMonth})
AND MONTH(t.create_time) = MONTH(#{yearMonth}))
</if>
<if test="userLevel != null">
and u.user_level=#{userLevel}
</if>
</where>
</select>
......
......@@ -29,50 +29,50 @@ public class MonthAward implements Serializable {
* 与上一次比较的增长奖金
*/
@ApiModelProperty(name = "growthAward", value = "与上一次比较的增长额度")
private BigDecimal growthAward;
private Double growthAward;
/**
* 历史奖金总额
*/
@ApiModelProperty(value = "历史奖金总额",name="awardTotal")
private BigDecimal awardTotal;
private Double awardTotal;
/**
* 本月累计奖金总额(本月新增+上月没有分出去的月度肥料奖金)
*/
@ApiModelProperty(value = "本月累计奖金总额",name="monthAwardTotal")
private BigDecimal monthAwardTotal;
private Double monthAwardTotal;
/**
* 本月新增
*/
@ApiModelProperty(value = "本月新增",name="monthIncreased")
private BigDecimal monthIncreased;
private Double monthIncreased;
/**
* 黄金树月奖励总额
*/
@ApiModelProperty(value = "黄金树月奖励总额",name="goldAward")
private BigDecimal goldAward;
private Double goldAward;
/**
* 农场主月奖励总额
*/
@ApiModelProperty(value = "农场主月奖励总额",name="farmerAward")
private BigDecimal farmerAward;
private Double farmerAward;
/**
* 森林之星月奖励总额
*/
@ApiModelProperty(value = "森林之星月奖励总额",name="forestStartAward")
private BigDecimal forestStartAward;
private Double forestStartAward;
/**
* 森田合伙人月奖励总额
*/
@ApiModelProperty(value = "森田合伙人月奖励总额",name="partnerAward")
private BigDecimal partnerAward;
private Double partnerAward;
private Date createTime;
......
......@@ -32,9 +32,9 @@ public class TradeRecord implements Serializable {
private String userId;
/**
* 交易记录类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资奖励
* 交易记录类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资奖励 7:进步奖
*/
@ApiModelProperty(name = "tradeType", value = "交易类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资")
@ApiModelProperty(name = "tradeType", value = "交易类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资 7:进步奖")
private Integer tradeType;
/**
......
package cn.wisenergy.service.app;
/**
*@ Description: 月定时任务接口定义
*@ Author : 86187
*@ Date : 2021/3/10 10:22
* @author 86187
*/
public interface MonthTaskService {
}
......@@ -4,5 +4,10 @@ package cn.wisenergy.service.app;
* @author 86187
*/
public interface TradeRecordService {
/**
* 月度奖金统计- 数据写入月度奖金实体类
*
* @return true or false
*/
Boolean monthAwardCount();
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.service.app.MonthTaskService;
/**
* @author 86187
*/
public class MonthTaskServiceImpl implements MonthTaskService {
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.MonthAwardMapper;
import cn.wisenergy.mapper.MonthManureMapper;
import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.MonthAward;
import cn.wisenergy.model.app.MonthManure;
import cn.wisenergy.model.app.TradeRecord;
import cn.wisenergy.model.enums.UserLevelEnum;
import cn.wisenergy.service.app.TradeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author 86187
*/
@Service
@Slf4j
public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, TradeRecord> implements TradeRecordService {
@Autowired
private MonthManureMapper monthManureMapper;
@Autowired
private MonthAwardMapper monthAwardMapper;
@Override
public Boolean monthAwardCount() {
MonthAward result = new MonthAward();
//1、获取本月新增奖金
Double monthGrow = baseMapper.queryMonthGrow(new Date());
result.setMonthIncreased(monthGrow);
//2、获取历史奖金金额
Double awardTotal = baseMapper.queryAllAward(new Date());
result.setAwardTotal(awardTotal);
//3、本月累计奖金 =本月新增奖金+上月剩余月度肥料奖金
//获取上月剩余月度肥料奖金
Double monthAwardTotal;
Date date = DateUtil.getLastMonth(new Date());
String yearMonth = DateUtil.convertDateToStr(date, "yyyy-MM");
MonthManure monthManure = monthManureMapper.queryByTime(yearMonth);
if (null == monthManure) {
monthAwardTotal = monthGrow;
} else {
monthAwardTotal = monthGrow + monthManure.getManureAward();
}
result.setMonthAwardTotal(monthAwardTotal);
//4、较上月增长奖金 本月累计奖金-上月累计奖金
//获取上月 累计奖金
Double growthAward;
MonthAward monthAward = monthAwardMapper.getByTime(date);
if (null == monthAward) {
growthAward = monthAwardTotal;
} else {
growthAward = monthAwardTotal - monthAward.getMonthAwardTotal();
}
result.setGrowthAward(growthAward);
//5、获取黄金树本月奖金
Double goldAward = baseMapper.queryByUserLevel(UserLevelEnum.GOLD_TREE.getCode(), new Date());
result.setGoldAward(goldAward);
//6、获取农场主本月奖金
Double farmerAward = baseMapper.queryByUserLevel(UserLevelEnum.FARMER.getCode(), new Date());
result.setFarmerAward(farmerAward);
//7、森林之星月奖金
Double startAward = baseMapper.queryByUserLevel(UserLevelEnum.FOREST_START.getCode(), new Date());
result.setForestStartAward(startAward);
//8、森田合伙人月奖金
Double partnerAward = baseMapper.queryByUserLevel(UserLevelEnum.PARTNER.getCode(), new Date());
result.setPartnerAward(partnerAward);
//9、 判断是否有本月奖金这条数据,没有,新增,有更新值
MonthAward currentMonth = monthAwardMapper.getByTime(new Date());
if (null == currentMonth) {
int count = monthAwardMapper.add(result);
return count != 0;
} else {
int count = monthAwardMapper.edit(result);
return count != 0;
}
}
}
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