Commit f7f3b1fe by guanchen

更新奖励类型790

接口返回代理商关系时 剔除失效
parent 48c284ed
......@@ -19,10 +19,10 @@ public class Constants {
*/
public static final int AGENT_REWARD_TYPE_YEAR_VIP = 710;
public static final String AGENT_REWARD_TYPE_YEAR_VIP_REMARK = "推荐奖励-年VIP";
// public static final int AGENT_REWARD_TYPE_HALF_YEAR_VIP = 720;
// public static final String AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK = "城市代理商所得的购买半年-VIP";
// public static final int AGENT_REWARD_TYPE_SVIP = 730;
// public static final String AGENT_REWARD_TYPE_SVIP_REMARK = "城市代理商所得的购买超级VIP收益";
public static final int AGENT_REWARD_TYPE_HALF_YEAR_VIP = 720;
public static final String AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK = "城市代理商所得的购买半年-VIP";
public static final int AGENT_REWARD_TYPE_SVIP = 730;
public static final String AGENT_REWARD_TYPE_SVIP_REMARK = "城市代理商所得的购买超级VIP收益";
public static final int AGENT_REWARD_TYPE_REDPACK = 740;
public static final String AGENT_REWARD_TYPE_REDPACK_REMARK = "推荐奖励-普通用户购买红包";
public static final int AGENT_REWARD_TYPE_SELF_ORDER = 750;
......@@ -31,6 +31,8 @@ public class Constants {
public static final String AGENT_REWARD_TYPE_SHARE_ORDER_REMARK = "推荐奖励-分享赚";
public static final int AGENT_REWARD_TYPE_VIP_PACKAGE = 780;
public static final String AGENT_REWARD_TYPE_VIP_PACKAGE_REMARK = "推荐奖励-VIP礼包";
public static final int AGENT_REWARD_TYPE_PACKAGE_WITH_VIP = 790;
public static final String AGENT_REWARD_TYPE_PACKAGE_WITH_VIP_REMARK = "推荐奖励-购买礼包(送VIP会员)";
public static final int JD_OFFSET = 1000; //用于查找京东的平推奖励比例
public static final int MT_OFFSET = 2000; //用于查找美团的平推奖励比例
public static final int TN_OFFSET = 3000; //用于查找途牛的平推奖励比例
......@@ -60,6 +62,7 @@ public class Constants {
public static final int AGENT_REVOKE_TYPE_SHARE_ORDER = 400;
public static final String AGENT_REVOKE_TYPE_SHARE_ORDER_REMARK = "分享赚奖励扣回";
public static Map<Integer, String> AGENT_REVOKE_TYPE_MAP = new HashMap<Integer, String>();
/**
* 回扣状态
*/
......@@ -90,9 +93,10 @@ public class Constants {
* 代理商平推奖励比例配置
*/
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_YEAR_VIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_HALF_YEAR_VIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SVIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_VIP_PACKAGE, new HashMap<Integer, BigDecimal>());
// AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_HALF_YEAR_VIP, new HashMap<Integer, BigDecimal>());
// AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SVIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_PACKAGE_WITH_VIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_REDPACK, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SELF_ORDER, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SHARE_ORDER, new HashMap<Integer, BigDecimal>());
......@@ -103,10 +107,16 @@ public class Constants {
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SELF_ORDER + MTJD_OFFSET, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SELF_ORDER + ELM_OFFSET, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(0, new BigDecimal("0.02512563"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(1, new BigDecimal("0.01507538"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_VIP_PACKAGE).put(0, new BigDecimal("0.02512563"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_VIP_PACKAGE).put(1, new BigDecimal("0.01507538"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(0, new BigDecimal("0.03015076"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(1, new BigDecimal("0.0201005"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(0, new BigDecimal("0.03015076"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(1, new BigDecimal("0.0201005"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(0, new BigDecimal("0.03015076"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(1, new BigDecimal("0.0201005"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_VIP_PACKAGE).put(0, new BigDecimal("0.03015076"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_VIP_PACKAGE).put(1, new BigDecimal("0.0201005"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_PACKAGE_WITH_VIP).put(0, new BigDecimal("0.03015076"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_PACKAGE_WITH_VIP).put(1, new BigDecimal("0.0201005"));
/**
* 红包
......@@ -137,9 +147,10 @@ public class Constants {
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER + JD_OFFSET).put(1, new BigDecimal("0.0087"));
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_YEAR_VIP, AGENT_REWARD_TYPE_YEAR_VIP_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_HALF_YEAR_VIP, AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SVIP, AGENT_REWARD_TYPE_SVIP_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_VIP_PACKAGE, AGENT_REWARD_TYPE_VIP_PACKAGE_REMARK);
// AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_HALF_YEAR_VIP, AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK);
// AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SVIP, AGENT_REWARD_TYPE_SVIP_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_PACKAGE_WITH_VIP, AGENT_REWARD_TYPE_PACKAGE_WITH_VIP_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_REDPACK, AGENT_REWARD_TYPE_REDPACK_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SELF_ORDER, AGENT_REWARD_TYPE_SELF_ORDER_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SHARE_ORDER, AGENT_REWARD_TYPE_SHARE_ORDER_REMARK);
......
......@@ -3,8 +3,6 @@ package com.lanren.huhu.partner.model;
import com.lanren.huhu.partner.model.base.BaseModel;
import lombok.Data;
import java.util.ArrayList;
/**
* @author chen
* @title: AgentTree
......@@ -14,19 +12,20 @@ import java.util.ArrayList;
* @date 2019-07-02 20:15
*/
@Data
@Deprecated
public class AgentTree extends BaseModel {
Integer userId;
Integer agentId;
Integer level;
ArrayList<ParentAgent> parentList;
ArrayList<AgentTree> childList = new ArrayList<AgentTree>();
public ArrayList<ParentAgent> cloneParent() {
ArrayList<ParentAgent> copyList = new ArrayList<ParentAgent>();
for (ParentAgent parentAgent : this.getParentList()) {
ParentAgent one = new ParentAgent(parentAgent.getUserId(), parentAgent.getAgentId(), parentAgent.getLevel());
copyList.add(one);
}
return copyList;
}
// Integer userId;
// Integer agentId;
// Integer level;
// ArrayList<ParentAgent> parentList;
// ArrayList<AgentTree> childList = new ArrayList<AgentTree>();
//
// public ArrayList<ParentAgent> cloneParent() {
// ArrayList<ParentAgent> copyList = new ArrayList<ParentAgent>();
// for (ParentAgent parentAgent : this.getParentList()) {
// ParentAgent one = new ParentAgent(parentAgent.getUserId(), parentAgent.getAgentId(), parentAgent.getLevel());
// copyList.add(one);
// }
// return copyList;
// }
}
package com.lanren.huhu.partner.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.lanren.huhu.partner.model.base.BaseModel;
import lombok.Data;
import java.util.Objects;
/**
* @author chen
* @title: ParentAgent
......@@ -16,42 +19,30 @@ public class ParentAgent extends BaseModel {
int userId;
int agentId;
int level;
@JSONField(serialize=false)
int agentState;
public ParentAgent(int userId, int agentId, int level) {
public ParentAgent(int userId, int agentId, int level, int agentState) {
this.userId = userId;
this.agentId = agentId;
this.level = level;
this.agentState = agentState;
}
@Override
public boolean equals(Object obj) {
if(obj==null) {
return false;
}
if(this==obj) {
public boolean equals(Object o) {
if (this == o) {
return true;
}
if(obj instanceof ParentAgent){
ParentAgent parentAgent = (ParentAgent) obj;
if(parentAgent.agentId == this.agentId) {
return true;
} else {
if (!(o instanceof ParentAgent)) {
return false;
}
}
return false;
ParentAgent that = (ParentAgent) o;
return agentId == that.agentId;
}
@Override
public int hashCode() {
StringBuilder sb = new StringBuilder();
sb.append(agentId);
char[] charArr = sb.toString().toCharArray();
int hash = 0;
for(char c : charArr) {
hash = hash * 131 + c;
}
return hash;
return Objects.hash(agentId);
}
}
......@@ -22,6 +22,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
......@@ -63,7 +64,7 @@ public class AgentRewardQueueTask {
@Autowired
TransactionDefinition transactionDefinition;
// @Scheduled(fixedDelay = 5000L)
@Scheduled(fixedDelay = 5000L)
public void runScheduledTask() {
logger.info("run AgentRewardQueueTask");
runConsume();
......@@ -320,6 +321,7 @@ public class AgentRewardQueueTask {
agentReward.setCreatedAt(System.currentTimeMillis() / 1000L);
agentReward.setCommissionRate(commissionRate);
agentReward.setRewardTypeChild(message.getRewardTypeChild() == null ? "" : message.getRewardTypeChild());
agentReward.setRewardStatus(100);
/**
* agent_reward里:
* money 面额(message里, 需要上供的代理商自己获得的奖励)
......@@ -329,8 +331,8 @@ public class AgentRewardQueueTask {
* cash_code 支付金额
*/
BigDecimal rewardBasement;
// if (rewardType == AGENT_REWARD_TYPE_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_HALF_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_SVIP) {
if (rewardType == AGENT_REWARD_TYPE_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_REDPACK || rewardType == AGENT_REWARD_TYPE_VIP_PACKAGE) {
if (rewardType == AGENT_REWARD_TYPE_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_HALF_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_SVIP
|| rewardType == AGENT_REWARD_TYPE_REDPACK || rewardType == AGENT_REWARD_TYPE_VIP_PACKAGE || rewardType == AGENT_REWARD_TYPE_PACKAGE_WITH_VIP) {
rewardBasement = message.getSourceUserPayment();
} else {
/**
......
......@@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
......@@ -41,7 +42,7 @@ public class RevokeAgentRewardTask {
@Autowired
TransactionDefinition transactionDefinition;
// @Scheduled(fixedDelay = 5000L)
@Scheduled(fixedDelay = 5000L)
public void runScheduledTask() {
logger.info("run RevokeAgentRewardTask");
runConsume();
......@@ -117,6 +118,7 @@ public class RevokeAgentRewardTask {
agentReward.setAmount(agentReward.getAmount().negate());
agentReward.setCommission(agentReward.getAmount().negate());
agentReward.setSettleTime(new Date());
agentReward.setRewardStatus(100);
insertList.add(agentReward);
} else if (agentReward.getSettleState() == SETTLE_STATE_ON_THE_WAY || agentReward.getSettleState() == SETTLE_STATE_PRE) {
agentReward.setAmount(new BigDecimal(0));
......
......@@ -234,7 +234,7 @@ public class UserServiceImpl implements UserService {
ParentAgent parentAgent = null;
if (null != userAgent) {
int agentLevel = userAgent.getAgentLevel();
parentAgent = new ParentAgent(userAgent.getUserId(), userAgent.getAgentId(), agentLevel);
parentAgent = new ParentAgent(userAgent.getUserId(), userAgent.getAgentId(), agentLevel, userAgent.getAgentState());
}
return parentAgent;
}
......@@ -337,7 +337,7 @@ public class UserServiceImpl implements UserService {
/**
* 添加代理到list时 都需要加个判断 如果找到总代 就不再找了
*/
agentList.add(new ParentAgent(firstAgent.getUserId(), firstAgent.getAgentId(), firstAgent.getAgentLevel()));
agentList.add(new ParentAgent(firstAgent.getUserId(), firstAgent.getAgentId(), firstAgent.getAgentLevel(), firstAgent.getAgentState()));
if (firstAgent.getAgentLevel() != AGENT_LEVEL_1) {
loopTimes = 0;
if (logger.isDebugEnabled()) {
......@@ -361,7 +361,7 @@ public class UserServiceImpl implements UserService {
/**
* 添加代理到list时 都需要加个判断 如果找到总代 就不再找了
*/
agentList.add(new ParentAgent(loopUserAgent.getUserId(), loopUserAgent.getAgentId(), loopUserAgent.getLevel()));
agentList.add(new ParentAgent(loopUserAgent.getUserId(), loopUserAgent.getAgentId(), loopUserAgent.getLevel(), loopUserAgent.getAgentState()));
if (loopUserAgent.getLevel() == AGENT_LEVEL_1) {
break;
}
......@@ -398,6 +398,16 @@ public class UserServiceImpl implements UserService {
if (logger.isInfoEnabled()) {
logger.info("setAgentList {} for user: {} end", parentColumnName, userId);
}
return agentList;
return filterInvalid(agentList);
}
private List<ParentAgent> filterInvalid(ArrayList<ParentAgent> agentList) {
List<ParentAgent> resultList = new ArrayList<ParentAgent>();
for (ParentAgent parentAgent : agentList) {
if (parentAgent.getAgentState() == 1) {
resultList.add(parentAgent);
}
}
return resultList;
}
}
\ No newline at end of file
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