From 8d85fa251604119b564297228ff468dfb5f25226 Mon Sep 17 00:00:00 2001
From: licc <lichuchuan@jtep.com.cn>
Date: Mon, 1 Mar 2021 13:51:24 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9E=9A=E4=B8=BE=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wisenergy/mapper/ProgressPrizeMapper.java | 17 +++++
 .../resources/mapper/AccountInfoMapper.xml    | 17 +++--
 .../resources/mapper/ProgressPrizeMapper.xml  | 75 +++++++++++++++++++
 .../cn/wisenergy/model/app/AccountInfo.java   | 12 +--
 .../cn/wisenergy/model/app/ProgressPrize.java | 62 +++++++++++++++
 .../model/enums/MonthOrderStatus.java         | 39 ++++++++++
 .../model/enums/MonthlyTaskStatus.java        | 40 ++++++++++
 .../model/enums/RebateStatusEnum.java         | 42 +++++++++++
 .../wisenergy/model/enums/UserLevelEnum.java  | 54 +++++++++++++
 .../service/Manager/AccountManager.java       | 39 +++++-----
 .../service/app/impl/AccountServiceImpl.java  | 36 +++++----
 11 files changed, 384 insertions(+), 49 deletions(-)
 create mode 100644 wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ProgressPrizeMapper.java
 create mode 100644 wisenergy-mapper/src/main/resources/mapper/ProgressPrizeMapper.xml
 create mode 100644 wisenergy-model/src/main/java/cn/wisenergy/model/app/ProgressPrize.java
 create mode 100644 wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthOrderStatus.java
 create mode 100644 wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthlyTaskStatus.java
 create mode 100644 wisenergy-model/src/main/java/cn/wisenergy/model/enums/RebateStatusEnum.java
 create mode 100644 wisenergy-model/src/main/java/cn/wisenergy/model/enums/UserLevelEnum.java

diff --git a/wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ProgressPrizeMapper.java b/wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ProgressPrizeMapper.java
new file mode 100644
index 0000000..fc99f67
--- /dev/null
+++ b/wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ProgressPrizeMapper.java
@@ -0,0 +1,17 @@
+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);
+}
diff --git a/wisenergy-mapper/src/main/resources/mapper/AccountInfoMapper.xml b/wisenergy-mapper/src/main/resources/mapper/AccountInfoMapper.xml
index 1fe07f0..9ca3c7b 100644
--- a/wisenergy-mapper/src/main/resources/mapper/AccountInfoMapper.xml
+++ b/wisenergy-mapper/src/main/resources/mapper/AccountInfoMapper.xml
@@ -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>
diff --git a/wisenergy-mapper/src/main/resources/mapper/ProgressPrizeMapper.xml b/wisenergy-mapper/src/main/resources/mapper/ProgressPrizeMapper.xml
new file mode 100644
index 0000000..f341b46
--- /dev/null
+++ b/wisenergy-mapper/src/main/resources/mapper/ProgressPrizeMapper.xml
@@ -0,0 +1,75 @@
+<?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
diff --git a/wisenergy-model/src/main/java/cn/wisenergy/model/app/AccountInfo.java b/wisenergy-model/src/main/java/cn/wisenergy/model/app/AccountInfo.java
index 7223d66..e937c92 100644
--- a/wisenergy-model/src/main/java/cn/wisenergy/model/app/AccountInfo.java
+++ b/wisenergy-model/src/main/java/cn/wisenergy/model/app/AccountInfo.java
@@ -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;
     /**
      * 创建时间
      */
diff --git a/wisenergy-model/src/main/java/cn/wisenergy/model/app/ProgressPrize.java b/wisenergy-model/src/main/java/cn/wisenergy/model/app/ProgressPrize.java
new file mode 100644
index 0000000..a9d9c1a
--- /dev/null
+++ b/wisenergy-model/src/main/java/cn/wisenergy/model/app/ProgressPrize.java
@@ -0,0 +1,62 @@
+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;
+
+}
diff --git a/wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthOrderStatus.java b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthOrderStatus.java
new file mode 100644
index 0000000..bc8a14b
--- /dev/null
+++ b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthOrderStatus.java
@@ -0,0 +1,39 @@
+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;
+    }
+}
diff --git a/wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthlyTaskStatus.java b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthlyTaskStatus.java
new file mode 100644
index 0000000..6c9a991
--- /dev/null
+++ b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/MonthlyTaskStatus.java
@@ -0,0 +1,40 @@
+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;
+    }
+}
diff --git a/wisenergy-model/src/main/java/cn/wisenergy/model/enums/RebateStatusEnum.java b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/RebateStatusEnum.java
new file mode 100644
index 0000000..98c99c0
--- /dev/null
+++ b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/RebateStatusEnum.java
@@ -0,0 +1,42 @@
+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;
+    }
+}
diff --git a/wisenergy-model/src/main/java/cn/wisenergy/model/enums/UserLevelEnum.java b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/UserLevelEnum.java
new file mode 100644
index 0000000..dec305f
--- /dev/null
+++ b/wisenergy-model/src/main/java/cn/wisenergy/model/enums/UserLevelEnum.java
@@ -0,0 +1,54 @@
+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;
+    }
+}
diff --git a/wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java b/wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
index 7c4e816..60b5030 100644
--- a/wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
+++ b/wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
@@ -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)
diff --git a/wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java b/wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
index 2dae9c3..14f12e8 100644
--- a/wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+++ b/wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
@@ -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);
-- 
2.18.1