Commit 09f5eafe authored by licc's avatar licc

代码优化

parent 5ea1c059
......@@ -3,6 +3,7 @@
<mapper namespace="cn.wisenergy.mapper.MonthAwardMapper">
<resultMap id="monthMap" type="cn.wisenergy.model.app.MonthAward">
<id column="id" property="id"/>
<result column="year_month" property="yearMonth"/>
<result column="month_manure_total" property="monthManureTotal"/>
<result column="month_award_pool" property="monthAwardPool"/>
<result column="month_manure_award" property="monthManureAward"/>
......@@ -24,16 +25,17 @@
</sql>
<sql id="cols_exclude_id">
month_manure_total,month_award_pool,month_manure_award,month_gold_award,month_farmer_award,
year_month,month_manure_total,month_award_pool,month_manure_award,month_gold_award,month_farmer_award,
month_forest_start_award,month_partner_award,create_time,update_time
</sql>
<sql id="vals">
#{monthManureTotal},#{monthAwardPool},#{monthManureAward},#{monthGoldAward},#{monthFarmerAward},
#{yearMonth},#{monthManureTotal},#{monthAwardPool},#{monthManureAward},#{monthGoldAward},#{monthFarmerAward},
#{monthForestStartAward}, #{monthPartnerAward},now(),now()
</sql>
<sql id="updateCondition">
<if test="yearMonth != null">year_month =#{yearMonth},</if>
<if test="monthManureTotal != null">month_manure_total = #{monthManureTotal},</if>
<if test="monthAwardPool != null">month_award_pool = #{monthAwardPool},</if>
<if test="monthManureAward != null">month_manure_award =#{monthManureAward},</if>
......@@ -46,6 +48,7 @@
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="yearMonth != null">and year_month =#{yearMonth}</if>
<if test="monthManureTotal != null">and month_manure_total = #{monthManureTotal}</if>
<if test="monthAwardPool != null">and month_award_pool = #{monthAwardPool}</if>
<if test="monthManureAward != null">and month_manure_award =#{monthManureAward}</if>
......
......@@ -25,6 +25,12 @@ public class MonthAward implements Serializable {
@ApiModelProperty(value = "主键id",name="id")
private Integer id;
/**
* 年月
*/
@ApiModelProperty(name = "yearMonth", value = "年月")
private Date yearMonth;
/**
* 本月月度肥料总额
*/
......
......@@ -31,7 +31,7 @@ public class TradeRecord implements Serializable {
private String userId;
/**
* 交易类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资
* 交易记录类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资奖励
*/
@ApiModelProperty(name = "tradeType", value = "交易类型 1:提现 2:订单返佣 3:订单下单 4:月度肥料 5:培育奖 6:工资")
private Integer tradeType;
......
package cn.wisenergy.model.enums;
/**
* @author 86187
* @ Description: 交易记录类型枚举
* @ Author : 86187
* @ Date : 2021/3/1 14:27
*/
public enum TradeRecordEnum {
/**
* 交易记录类型
*/
WITHDRAW_DEPOSIT(1, "提现"),
ORDER_REBATE(2, "订单返佣"),
PLACE_ORDER(3, "订单下单"),
MONTHLY_FERTILIZER(4, "月度肥料"),
CULTIVATING_PRIZE(5, "培育奖"),
SALARY_REWARD(6, "工资奖励");
private Integer code;
private String desc;
TradeRecordEnum(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;
}
}
......@@ -21,11 +21,11 @@ public enum UserLevelEnum {
GOLD_TREE(4, "黄金树"),
FARMER(6, "农场主"),
FARMER(5, "农场主"),
FOREST_START(7, "森林之星"),
FOREST_START(6, "森林之星"),
PARTNER(8, "西田森合伙人");
PARTNER(7, "西田森合伙人");
private Integer code;
private String desc;
......
......@@ -6,6 +6,7 @@ import cn.wisenergy.mapper.TeamPerformanceMapper;
import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.RebateStatusEnum;
import cn.wisenergy.model.enums.TradeRecordEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -66,7 +67,7 @@ public class AccountManager {
//4、添加交易流水记录
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(orderInfo.getBuyerId());
tradeRecord.setTradeType(2);
tradeRecord.setTradeType(TradeRecordEnum.ORDER_REBATE.getCode());
tradeRecord.setTradeNo(orderInfo.getTid());
recordMapper.add(tradeRecord);
}
......
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.AccountMapper;
import cn.wisenergy.mapper.MemberPercentMapper;
import cn.wisenergy.mapper.TeamPerformanceMapper;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.MonthlyTaskStatus;
import cn.wisenergy.model.enums.RebateStatusEnum;
import cn.wisenergy.model.enums.TradeRecordEnum;
import cn.wisenergy.model.vo.TeamPerformanceSortVo;
import cn.wisenergy.service.Manager.PublicManager;
import cn.wisenergy.service.app.AccountService;
......@@ -46,6 +44,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
@Autowired
private PublicManager publicManager;
@Autowired
private TradeRecordMapper tradeRecordMapper;
@Autowired
private TeamPerformanceMapper teamPerformanceMapper;
......@@ -156,15 +157,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//4、更新账户月度绩效
accountManager.updateAccountPerformanceMonth(teamPerformances);
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser();
if (CollectionUtils.isEmpty(userList)) {
return R.ok(0, true);
}
for (User user : userList) {
monthlyIncome(totalMoney, user);
}
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser();
if (CollectionUtils.isEmpty(userList)) {
return R.ok(0, true);
}
for (User user : userList) {
monthlyIncome(totalMoney, user);
}
return R.ok(0, true);
......@@ -375,6 +375,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
if (count != 0) {
return true;
}
//5、添加交易流水记录
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(user.getUserId());
tradeRecord.setTradeType(TradeRecordEnum.ORDER_REBATE.getCode());
tradeRecord.setTradeNo(null);
int number = tradeRecordMapper.add(tradeRecord);
if (number == 0) {
return false;
}
}
}
......
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