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);
......
package com.lanren.huhu.partner.manager;
import com.lanren.huhu.partner.domain.PartnerAccount;
import com.lanren.huhu.partner.domain.UserAgent;
import com.lanren.huhu.partner.model.*;
import com.lanren.huhu.partner.model.User;
import com.lanren.huhu.partner.result.Result;
import com.lanren.huhu.partner.service.UserService;
import org.slf4j.Logger;
......@@ -11,11 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import static com.lanren.huhu.partner.constants.Constants.PARENT_COLUMN_NAME_CENGJI;
import static com.lanren.huhu.partner.constants.Constants.PARENT_COLUMN_NAME_PINGTUI;
/**
* @author houseme
*/
......@@ -43,226 +37,226 @@ public class UserManager {
return result;
}
/**
* 根据输入的userId, 完成递归查找
* @param userId
*/
@Async
public Result<String> purgeRelation(Integer userId) {
Result<String> result = new Result<String>();
try{
logger.info("start purgeRelation for userId: {} ...", userId);
PartnerAccount partnerAccount = userService.getPartnerAccountByUserId(userId);
if (partnerAccount == null) {
result.setCode(413);
}
int partnerLevel = partnerAccount.getIsSuperPartner() == 1 ? 30 : partnerAccount.getPartnerLevel();
/**
* 合伙人按邀请关系
*/
PartnerTree root = new PartnerTree();
root.setUserId(partnerAccount.getUserId());
root.setLevel(partnerLevel);
root.setParentList(new ArrayList<ParentPartner>());
recursiveSet(root);
/**
* 如果这个用户还是代理商身份, 也要处理他的代理商下级(层级下级 和 平推下级)
*/
UserAgent agent = userService.getUserAgentByUserId(partnerAccount.getUserId());
if (null != agent) {
AgentTree agentRoot = new AgentTree();
agentRoot.setUserId(partnerAccount.getUserId());
agentRoot.setAgentId(agent.getAgentId());
agentRoot.setLevel(partnerLevel);
agentRoot.setParentList(new ArrayList<ParentAgent>());
recursiveSet(agentRoot, PARENT_COLUMN_NAME_CENGJI);
recursiveSet(agentRoot, PARENT_COLUMN_NAME_PINGTUI);
}
logger.info("done purgeRelation for userId: {}", userId);
result.setData("用户刷新成功");
} catch (Exception e) {
logger.error(e.getMessage(), e);
result.setCode(500);
}
return result;
}
// /**
// * 根据输入的userId, 完成递归查找
// * @param userId
// */
// @Async
// public Result<String> purgeRelation(Integer userId) {
// Result<String> result = new Result<String>();
// try{
// logger.info("start purgeRelation for userId: {} ...", userId);
// PartnerAccount partnerAccount = userService.getPartnerAccountByUserId(userId);
// if (partnerAccount == null) {
// result.setCode(413);
// }
// int partnerLevel = partnerAccount.getIsSuperPartner() == 1 ? 30 : partnerAccount.getPartnerLevel();
// /**
// * 合伙人按邀请关系
// */
// PartnerTree root = new PartnerTree();
// root.setUserId(partnerAccount.getUserId());
// root.setLevel(partnerLevel);
// root.setParentList(new ArrayList<ParentPartner>());
// recursiveSet(root);
// /**
// * 如果这个用户还是代理商身份, 也要处理他的代理商下级(层级下级 和 平推下级)
// */
// UserAgent agent = userService.getUserAgentByUserId(partnerAccount.getUserId());
// if (null != agent) {
// AgentTree agentRoot = new AgentTree();
// agentRoot.setUserId(partnerAccount.getUserId());
// agentRoot.setAgentId(agent.getAgentId());
// agentRoot.setLevel(partnerLevel);
// agentRoot.setParentList(new ArrayList<ParentAgent>());
// recursiveSet(agentRoot, PARENT_COLUMN_NAME_CENGJI);
// recursiveSet(agentRoot, PARENT_COLUMN_NAME_PINGTUI);
// }
// logger.info("done purgeRelation for userId: {}", userId);
// result.setData("用户刷新成功");
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// result.setCode(500);
// }
// return result;
// }
/**
* ****************************************分割线****合伙人***************************************************************
*/
/**
* 递归查找, 完成输入的tree的所有下级查找
* @param tree
*/
private void recursiveSet(PartnerTree tree) {
logger.info("do recursiveSet for userId: {}", tree.getUserId());
if (logger.isDebugEnabled()) {
logger.info("do recursiveSet for userId: {}", tree.getUserId());
}
/**
* 先找到直接下级
*/
setChildList(tree);
ArrayList<PartnerTree> children = tree.getChildList();
/**
* 如果没有下级了 那么直接输出结果
*/
if (children.size() == 0) {
outputTree(tree);
} else {
/**
* 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
*/
for (PartnerTree child : children) {
recursiveSet(child);
/**
* 当完成 对每个下级再执行recursiveSet 之后
* 判断一下, 每个下级是否有直接下级
* 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
* 所以要在这里执行一次, 把他们自己输出
*/
if (child.getChildList().size() > 0) {
outputTree(child);
}
}
/**
* 最后输出自己
*/
outputTree(tree);
}
}
// /**
// * 递归查找, 完成输入的tree的所有下级查找
// * @param tree
// */
// private void recursiveSet(PartnerTree tree) {
// logger.info("do recursiveSet for userId: {}", tree.getUserId());
// if (logger.isDebugEnabled()) {
// logger.info("do recursiveSet for userId: {}", tree.getUserId());
// }
// /**
// * 先找到直接下级
// */
// setChildList(tree);
// ArrayList<PartnerTree> children = tree.getChildList();
// /**
// * 如果没有下级了 那么直接输出结果
// */
// if (children.size() == 0) {
// outputTree(tree);
// } else {
// /**
// * 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
// */
// for (PartnerTree child : children) {
// recursiveSet(child);
// /**
// * 当完成 对每个下级再执行recursiveSet 之后
// * 判断一下, 每个下级是否有直接下级
// * 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
// * 所以要在这里执行一次, 把他们自己输出
// */
// if (child.getChildList().size() > 0) {
// outputTree(child);
// }
// }
// /**
// * 最后输出自己
// */
// outputTree(tree);
// }
// }
/**
* 完成刷新用户缓存数据
* @param tree
*/
private void outputTree(PartnerTree tree) {
StringBuilder sb = new StringBuilder();
ArrayList<ParentPartner> list = tree.getParentList();
for (ParentPartner p : list) {
sb.append(p.getUserId()).append(",");
}
if (logger.isDebugEnabled()) {
logger.info("begin to clean cache......");
logger.info("userId: {}, parent is: {}", tree.getUserId(), sb.toString());
}
deleteRalationByUserId(tree.getUserId());
/**
* 加快接口返回速度 不再为每一个叶子做刷新
* 只做清楚缓存的操作
*/
// getRelationByUserId(tree.getUserId());
}
// /**
// * 完成刷新用户缓存数据
// * @param tree
// */
// private void outputTree(PartnerTree tree) {
// StringBuilder sb = new StringBuilder();
// ArrayList<ParentPartner> list = tree.getParentList();
// for (ParentPartner p : list) {
// sb.append(p.getUserId()).append(",");
// }
// if (logger.isDebugEnabled()) {
// logger.info("begin to clean cache......");
// logger.info("userId: {}, parent is: {}", tree.getUserId(), sb.toString());
// }
// deleteRalationByUserId(tree.getUserId());
// /**
// * 加快接口返回速度 不再为每一个叶子做刷新
// * 只做清楚缓存的操作
// */
//// getRelationByUserId(tree.getUserId());
// }
/**
* 无递归操作, 只往下查找一级
* 把下级的数据, 设置到输入的tree中的childrenList
* @param tree
*/
private void setChildList(PartnerTree tree) {
ArrayList<PartnerAccount> partnerAccountArrayList = (ArrayList<PartnerAccount>) userService.getPartnerAccountChildListByUserId(tree.getUserId());
for (PartnerAccount partnerAccount : partnerAccountArrayList) {
Integer childId = partnerAccount.getUserId();
Integer childLevel = partnerAccount.getIsSuperPartner() == 1 ? 30 : partnerAccount.getPartnerLevel();
if (!tree.getParentList().contains(childId)) {
ArrayList<ParentPartner> parentList4Child = tree.cloneParent();
parentList4Child.add(new ParentPartner(tree.getUserId(), tree.getLevel()));
PartnerTree oneChild = new PartnerTree();
oneChild.setUserId(childId);
oneChild.setLevel(childLevel);
oneChild.setParentList(parentList4Child);
tree.getChildList().add(oneChild);
}
}
}
// /**
// * 无递归操作, 只往下查找一级
// * 把下级的数据, 设置到输入的tree中的childrenList
// * @param tree
// */
// private void setChildList(PartnerTree tree) {
// ArrayList<PartnerAccount> partnerAccountArrayList = (ArrayList<PartnerAccount>) userService.getPartnerAccountChildListByUserId(tree.getUserId());
// for (PartnerAccount partnerAccount : partnerAccountArrayList) {
// Integer childId = partnerAccount.getUserId();
// Integer childLevel = partnerAccount.getIsSuperPartner() == 1 ? 30 : partnerAccount.getPartnerLevel();
// if (!tree.getParentList().contains(childId)) {
// ArrayList<ParentPartner> parentList4Child = tree.cloneParent();
// parentList4Child.add(new ParentPartner(tree.getUserId(), tree.getLevel()));
// PartnerTree oneChild = new PartnerTree();
// oneChild.setUserId(childId);
// oneChild.setLevel(childLevel);
// oneChild.setParentList(parentList4Child);
// tree.getChildList().add(oneChild);
// }
// }
// }
/**
* ****************************************分割线****代理商***************************************************************
*/
/**
* 递归查找, 完成输入的tree的所有下级查找
* @param tree
*/
private void recursiveSet(AgentTree tree, String parentColumnName) {
logger.info("do recursiveSet for userId: {}", tree.getUserId());
if (logger.isDebugEnabled()) {
logger.info("do recursiveSet for userId: {}", tree.getUserId());
}
/**
* 先找到直接下级
*/
setChildList(tree, parentColumnName);
ArrayList<AgentTree> children = tree.getChildList();
/**
* 如果没有下级了 那么直接输出结果
*/
if (children.size() == 0) {
outputTree(tree);
} else {
/**
* 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
*/
for (AgentTree child : children) {
recursiveSet(child, parentColumnName);
/**
* 当完成 对每个下级再执行recursiveSet 之后
* 判断一下, 每个下级是否有直接下级
* 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
* 所以要在这里执行一次, 把他们自己输出
*/
if (child.getChildList().size() > 0) {
outputTree(child);
}
}
/**
* 最后输出自己
*/
outputTree(tree);
}
}
// /**
// * 递归查找, 完成输入的tree的所有下级查找
// * @param tree
// */
// private void recursiveSet(AgentTree tree, String parentColumnName) {
// logger.info("do recursiveSet for userId: {}", tree.getUserId());
// if (logger.isDebugEnabled()) {
// logger.info("do recursiveSet for userId: {}", tree.getUserId());
// }
// /**
// * 先找到直接下级
// */
// setChildList(tree, parentColumnName);
// ArrayList<AgentTree> children = tree.getChildList();
// /**
// * 如果没有下级了 那么直接输出结果
// */
// if (children.size() == 0) {
// outputTree(tree);
// } else {
// /**
// * 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
// */
// for (AgentTree child : children) {
// recursiveSet(child, parentColumnName);
// /**
// * 当完成 对每个下级再执行recursiveSet 之后
// * 判断一下, 每个下级是否有直接下级
// * 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
// * 所以要在这里执行一次, 把他们自己输出
// */
// if (child.getChildList().size() > 0) {
// outputTree(child);
// }
// }
// /**
// * 最后输出自己
// */
// outputTree(tree);
// }
// }
/**
* 完成刷新用户缓存数据
* @param tree
*/
private void outputTree(AgentTree tree) {
StringBuilder sb = new StringBuilder();
ArrayList<ParentAgent> list = tree.getParentList();
for (ParentAgent p : list) {
sb.append(p.getUserId()).append(",");
}
if (logger.isDebugEnabled()) {
logger.info("begin to clean cache......");
logger.info("userId: {}, parent is: {}", tree.getUserId(), sb.toString());
}
deleteRalationByUserId(tree.getUserId());
}
// /**
// * 完成刷新用户缓存数据
// * @param tree
// */
// private void outputTree(AgentTree tree) {
// StringBuilder sb = new StringBuilder();
// ArrayList<ParentAgent> list = tree.getParentList();
// for (ParentAgent p : list) {
// sb.append(p.getUserId()).append(",");
// }
// if (logger.isDebugEnabled()) {
// logger.info("begin to clean cache......");
// logger.info("userId: {}, parent is: {}", tree.getUserId(), sb.toString());
// }
// deleteRalationByUserId(tree.getUserId());
// }
/**
* 无递归操作, 只往下查找一级
* 把下级的数据, 设置到输入的tree中的childrenList
* @param tree
*/
private void setChildList(AgentTree tree, String parentColumnName) {
ArrayList<UserAgent> partnerAccountArrayList = (ArrayList<UserAgent>) userService.getUserAgentChildListByUserId(tree.getUserId(), parentColumnName);
for (UserAgent userAgent : partnerAccountArrayList) {
Integer childId = userAgent.getUserId();
Integer agentId = userAgent.getAgentId();
Integer childLevel = userAgent.getAgentLevel();
if (!tree.getParentList().contains(childId)) {
ArrayList<ParentAgent> parentList4Child = tree.cloneParent();
parentList4Child.add(new ParentAgent(tree.getUserId(), tree.getAgentId(), tree.getLevel()));
AgentTree oneChild = new AgentTree();
oneChild.setUserId(childId);
oneChild.setAgentId(agentId);
oneChild.setLevel(childLevel);
oneChild.setParentList(parentList4Child);
tree.getChildList().add(oneChild);
}
}
}
// * 无递归操作, 只往下查找一级
// * 把下级的数据, 设置到输入的tree中的childrenList
// * @param tree
// */
// private void setChildList(AgentTree tree, String parentColumnName) {
// ArrayList<UserAgent> partnerAccountArrayList = (ArrayList<UserAgent>) userService.getUserAgentChildListByUserId(tree.getUserId(), parentColumnName);
// for (UserAgent userAgent : partnerAccountArrayList) {
// Integer childId = userAgent.getUserId();
// Integer agentId = userAgent.getAgentId();
// Integer childLevel = userAgent.getAgentLevel();
// if (!tree.getParentList().contains(childId)) {
// ArrayList<ParentAgent> parentList4Child = tree.cloneParent();
// parentList4Child.add(new ParentAgent(tree.getUserId(), tree.getAgentId(), tree.getLevel(), 0));
// AgentTree oneChild = new AgentTree();
// oneChild.setUserId(childId);
// oneChild.setAgentId(agentId);
// oneChild.setLevel(childLevel);
// oneChild.setParentList(parentList4Child);
// tree.getChildList().add(oneChild);
// }
// }
// }
/**
* 变更 代理商 或 用户的 上级
......@@ -284,7 +278,8 @@ public class UserManager {
logger.info("更新合伙人推荐关系, 将{}的上级改为{},更新{}行数据", from, to, cnt);
}
PartnerAccount partnerAccount = userService.getPartnerAccountByPhone(from);
return purgeRelation(partnerAccount.getUserId());
// return purgeRelation(partnerAccount.getUserId());
return new Result<String>();
}
private int updatePartnerRelation(String from, String to) {
......
......@@ -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