Commit 8d85fa25 authored by licc's avatar licc

新增枚举类

parent f0958551
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.ProgressPrize;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @author 86187
*/
public interface ProgressPrizeMapper extends BaseMapper<ProgressPrize> {
int add(ProgressPrize progressPrize);
int edit(ProgressPrize progressPrize);
int delById(@Param("id") Integer id);
}
......@@ -6,10 +6,10 @@
<result column="user_id" property="userId"/>
<result column="user_level" property="userLevel"/>
<result column="extract_money" property="extractMoney"/>
<result column="performance_month" property="performanceMonth"/>
<result column="earnings_month" property="earningsMonth"/>
<result column="performance_team" property="performanceTeam"/>
<result column="frozen_money" property="frozenMoney"/>
<result column="performance_total" property="performanceTotal"/>
<result column="earnings_total" property="earningsTotal"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
......@@ -24,21 +24,22 @@
</sql>
<sql id="cols_exclude_id">
user_id,user_level,extract_money,performance_month,performance_team,frozen_money,performance_total,create_time,update_time
user_id,user_level,extract_money,earnings_month,performance_team,frozen_money,earnings_total,create_time,update_time
</sql>
<sql id="vals">
#{userId},#{userLevel},#{extractMoney},#{performanceMonth},#{performanceTeam},#{frozenMoney}, #{performanceTotal},now(),now()
#{userId},#{userLevel},#{extractMoney},#{earningsMonth},#{performanceTeam},#{frozenMoney},
#{earningsTotal},now(),now()
</sql>
<sql id="updateCondition">
<if test="userId != null">user_id = #{userId},</if>
<if test="userLevel != null">user_level = #{userLevel},</if>
<if test="extractMoney != null">extract_money =#{extractMoney},</if>
<if test="performanceMonth != null">performance_month =#{performanceMonth},</if>
<if test="earningsMonth != null">earnings_month =#{earningsMonth},</if>
<if test="performanceTeam != null">performance_team =#{performanceTeam},</if>
<if test="frozenMoney != null">frozen_money =#{frozenMoney},</if>
<if test="performanceTotal != null">performance_total =#{performanceTotal},</if>
<if test="earningsTotal != null">earnings_total =#{earningsTotal},</if>
update_time =now()
</sql>
......@@ -47,10 +48,10 @@
<if test="userId != null">and user_id = #{userId}</if>
<if test="userLevel != null">and user_level = #{userLevel}</if>
<if test="extractMoney != null">and extract_money =#{extractMoney}</if>
<if test="performanceMonth != null">and performance_month =#{performanceMonth}</if>
<if test="earningsMonth != null">and earnings_month =#{earningsMonth}</if>
<if test="performanceTeam != null">and performance_team =#{performanceTeam}</if>
<if test="frozenMoney != null">and frozen_money =#{frozenMoney}</if>
<if test="performanceTotal != null">performance_total =#{performanceTotal}</if>
<if test="earningsTotal != null">and earnings_total =#{earningsTotal}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.ProgressPrizeMapper">
<resultMap id="monthMap" type="cn.wisenergy.model.app.ProgressPrize">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="year_month" property="yearMonth"/>
<result column="growth_rate" property="growthRate"/>
<result column="award_money" property="awardMoney"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
month_award
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
user_id,year_month,growth_rate,award_money,create_time,update_time
</sql>
<sql id="vals">
#{userId},#{yearMonth},#{growthRate},#{awardMoney},now(),now()
</sql>
<sql id="updateCondition">
<if test="userId != null">user_id = #{userId},</if>
<if test="yearMonth != null">year_month = #{yearMonth},</if>
<if test="growthRate != null">growth_rate =#{growthRate},</if>
<if test="awardMoney != null">award_money =#{awardMoney},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="userId != null">and user_id = #{userId}</if>
<if test="yearMonth != null">and year_month = #{yearMonth}</if>
<if test="growthRate != null">and growth_rate =#{growthRate}</if>
<if test="awardMoney != null">and award_money =#{awardMoney}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.ProgressPrize" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="edit" parameterType="cn.wisenergy.model.app.ProgressPrize">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<delete id="delById" parameterType="java.lang.Integer">
delete from
<include refid="table"/>
where id = #{id}
</delete>
</mapper>
\ No newline at end of file
......@@ -44,10 +44,10 @@ public class AccountInfo implements Serializable {
private BigDecimal extractMoney;
/**
* 本月业绩
* 本月收益
*/
@ApiModelProperty(name = "performanceMonth", value = "本月业绩")
private BigDecimal performanceMonth;
@ApiModelProperty(name = "earningsMonth", value = "本月收益")
private BigDecimal earningsMonth;
/**
* 本月团队业绩
......@@ -62,10 +62,10 @@ public class AccountInfo implements Serializable {
private BigDecimal frozenMoney;
/**
* 累计业绩
* 累计收益
*/
@ApiModelProperty(name = "performanceTotal", value = "累计业绩")
private BigDecimal performanceTotal;
@ApiModelProperty(name = "earningsTotal", value = "累计收益")
private BigDecimal earningsTotal;
/**
* 创建时间
*/
......
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*@ Description: 每月进步奖实体类
*@ Author : 86187
*@ Date : 2021/3/1 9:31
* @author 86187
*/
@Data
public class ProgressPrize implements Serializable {
private static final long serialVersionUID = -1533799058729746392L;
/**
* 主键id
*/
@ApiModelProperty(value = "主键id",name = "id")
private Integer id;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id",name = "userId")
private String userId;
/**
* 年月
*/
@ApiModelProperty(value = "年月",name = "yearMonth")
private Date yearMonth;
/**
* 本月增长率
*/
@ApiModelProperty(value = "本月增长率",name = "growthRate")
private BigDecimal growthRate;
/**
* 进步奖奖金
*/
@ApiModelProperty(value = "进步奖奖金",name = "awardMoney")
private BigDecimal awardMoney;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间",name = "createTime")
private Date createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间",name = "updateTime")
private Date updateTime;
}
package cn.wisenergy.model.enums;
/**
*@ Description: 月订单处理状态枚举
*@ Author : 86187
*@ Date : 2021/3/1 11:28
* @author 86187
*/
public enum MonthOrderStatus {
/**
* 月订单处理状态
*/
NO_DEAL_WITH(0, "未处理"),
ALREADY_DEAL_WITH(1, "已处理");
MonthOrderStatus(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
private Integer code;
private String desc;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package cn.wisenergy.model.enums;
/**
* @author 86187
* @ Description: 月度任务状态枚举
* @ Author : 86187
* @ Date : 2021/3/1 11:38
*/
public enum MonthlyTaskStatus {
/**
* 月度任务状态
*/
NO_DEAL_WITH(0, "未处理"),
ALREADY_DEAL_WITH(1, "已处理");
MonthlyTaskStatus(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
private Integer code;
private String desc;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package cn.wisenergy.model.enums;
/**
* @author 86187
* @ Description: 订单返佣状态枚举
* @ Author : 86187
* @ Date : 2021/3/1 10:42
*/
public enum RebateStatusEnum {
/**
* 返佣状态
*/
NO_REBATE(0, "未返佣"),
ALREADY_REBATE(1, "已返佣");
RebateStatusEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
private Integer code;
private String desc;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package cn.wisenergy.model.enums;
/**
* @author 86187
* @ Description: 用户会员等级枚举类
* @ Author : 86187
* @ Date : 2021/3/1 11:14
*/
public enum UserLevelEnum {
/**
* 会员等级
*/
NORMAL_USER(0, "普通用户"),
SEEDLING(1, "幼苗"),
BRONZE_TREE(2, "青铜树"),
SILVER_TREE(3, "白银树"),
GOLD_TREE(4, "黄金树"),
FARMER(6, "农场主"),
FOREST_START(7, "森林之星"),
PARTNER(8, "西田森合伙人");
private Integer code;
private String desc;
UserLevelEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
......@@ -5,6 +5,7 @@ import cn.wisenergy.mapper.OrderMapper;
import cn.wisenergy.mapper.TeamPerformanceMapper;
import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.RebateStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -35,43 +36,39 @@ public class AccountManager {
@Autowired
private TeamPerformanceMapper teamPerformanceMapper;
/**
* 保存用户佣金
*
* @param orderInfo 订单信息
* @param accountInfo 账户信息
* @param memberPercent 会员等级百比分
*/
@Transactional(rollbackFor = Exception.class)
public Boolean updateOrderAddMoney(OrderInfo orderInfo, AccountInfo accountInfo, MemberPercent memberpercent) {
public void updateOrderAddMoney(OrderInfo orderInfo, AccountInfo accountInfo, MemberPercent memberPercent) {
//1、计算返佣金额
BigDecimal bigDecimal = orderInfo.getPayment().multiply(memberpercent.getPercent());
BigDecimal bigDecimal = orderInfo.getPayment().multiply(memberPercent.getPercent());
BigDecimal extractMoney = accountInfo.getExtractMoney().add(bigDecimal);
accountInfo.setExtractMoney(extractMoney);
BigDecimal performanceMonth = accountInfo.getPerformanceMonth().add(bigDecimal);
accountInfo.setPerformanceMonth(performanceMonth);
BigDecimal performanceMonth = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceMonth);
BigDecimal performanceTotal = accountInfo.getPerformanceTotal().add(bigDecimal);
accountInfo.setPerformanceMonth(performanceTotal);
BigDecimal performanceTotal = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceTotal);
//2、修改订单返佣状态:已返佣 1
orderInfo.setRebateStatus(1);
orderInfo.setRebateStatus(RebateStatusEnum.ALREADY_REBATE.getCode());
int count = orderMapper.updateById(orderInfo);
if (count == 0) {
return false;
}
orderMapper.updateById(orderInfo);
//3、增加账户可用金额
int sum = accountMapper.updateById(accountInfo);
if(sum ==0){
return false;
}
accountMapper.updateById(accountInfo);
//4、添加交易流水记录
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(orderInfo.getBuyerId());
tradeRecord.setTradeType(2);
tradeRecord.setTradeNo(orderInfo.getTid());
int number = recordMapper.add(tradeRecord);
if (number == 0) {
return false;
}
return true;
recordMapper.add(tradeRecord);
}
@Transactional(rollbackFor = Exception.class)
......
......@@ -6,6 +6,8 @@ import cn.wisenergy.mapper.MemberPercentMapper;
import cn.wisenergy.mapper.TeamPerformanceMapper;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.MonthlyTaskStatus;
import cn.wisenergy.model.enums.RebateStatusEnum;
import cn.wisenergy.model.vo.TeamPerformanceSortVo;
import cn.wisenergy.service.Manager.PublicManager;
import cn.wisenergy.service.app.AccountService;
......@@ -56,12 +58,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
return R.ok(0, true);
}
//遍历订单,返佣
//1、遍历订单,订单状态是未返佣,完成时间小于当前时间 --返佣
for (OrderInfo orderInfo : list) {
//订单状态是未返佣,完成时间小于当前时间
long successTime = orderInfo.getSuccessTime().getTime();
long time = System.currentTimeMillis();
if (orderInfo.getRebateStatus() == 0 && successTime <= time) {
if (RebateStatusEnum.NO_REBATE.getCode().equals(orderInfo.getRebateStatus()) && successTime <= time) {
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
......@@ -103,18 +104,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//计算当月所有订单成交额
BigDecimal totalMoney = new BigDecimal(0);
for (OrderInfo orderInfo : list) {
//判断是否是本月
boolean bool = publicManager.isThisMonth(orderInfo.getCreateTime(), PATTERN);
if (bool && orderInfo.getMonthlyTaskStatus() == 0) {
totalMoney = totalMoney.add(orderInfo.getPayment());
}
}
//遍历订单
//遍历订单 订单状态创建时间,小于当前时间 订单当月处理状态 :未处理
for (OrderInfo orderInfo : list) {
//订单状态创建时间,小于当前时间 订单当月处理状态 :未处理
long createTime = orderInfo.getCreated().getTime();
long time = System.currentTimeMillis();
if (orderInfo.getMonthlyTaskStatus() == 0 && createTime <= time) {
if (MonthlyTaskStatus.NO_DEAL_WITH.getCode().equals(orderInfo.getMonthlyTaskStatus()) && createTime <= time) {
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
......@@ -142,7 +143,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
for (User userInfo : userList) {
//3、统计当前用户上级月度绩效
TeamPerformance team = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), new Date());
TeamPerformance team = teamPerformanceMapper.getByUserIdAndTime(userInfo.getUserId(), new Date());
if (null == team) {
continue;
}
......@@ -215,7 +216,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
accountInfo.setPerformanceMonth(new BigDecimal(income));
accountInfo.setEarningsMonth(new BigDecimal(income));
//更新用户账户表
accountMapper.updateById(accountInfo);
......@@ -292,7 +293,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(userId);
accountInfo.setPerformanceMonth(new BigDecimal(income));
accountInfo.setEarningsMonth(new BigDecimal(income));
//更新用户账户表
accountMapper.updateById(accountInfo);
......@@ -314,7 +315,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(userId);
accountInfo.setPerformanceMonth(new BigDecimal(income));
accountInfo.setEarningsMonth(new BigDecimal(income));
//更新用户账户表
accountMapper.updateById(accountInfo);
......@@ -332,6 +333,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
}
/**
* 如果会员等级是黄金以上,计算月度收益
*
* @param totalMoney
* @param user
* @return
*/
private boolean monthlyIncome(BigDecimal totalMoney, User user) {
double total = totalMoney.doubleValue();
BigDecimal money;
......@@ -355,11 +363,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
BigDecimal bigDecimal = new BigDecimal(income);
BigDecimal performanceMonth = accountInfo.getPerformanceMonth().add(bigDecimal);
accountInfo.setPerformanceMonth(performanceMonth);
BigDecimal performanceMonth = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceMonth);
BigDecimal performanceTotal = accountInfo.getPerformanceTotal().add(bigDecimal);
accountInfo.setPerformanceMonth(performanceTotal);
BigDecimal performanceTotal = accountInfo.getEarningsMonth().add(bigDecimal);
accountInfo.setEarningsMonth(performanceTotal);
//更新月收益
int count = accountMapper.updateById(accountInfo);
......
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