Commit 07c1474a by guanchen

v1.4.5上线

parent 42bf0f18
...@@ -18,17 +18,18 @@ public class Constants { ...@@ -18,17 +18,18 @@ public class Constants {
* 代理商奖励类型 * 代理商奖励类型
*/ */
public static final int AGENT_REWARD_TYPE_YEAR_VIP = 710; public static final int AGENT_REWARD_TYPE_YEAR_VIP = 710;
public static final String AGENT_REWARD_TYPE_YEAR_VIP_REMARK = "城市代理商所得的购买年-VIP"; 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 int AGENT_REWARD_TYPE_HALF_YEAR_VIP = 720;
public static final String AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK = "城市代理商所得的购买半年-VIP"; // public static final String AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK = "城市代理商所得的购买半年-VIP";
public static final int AGENT_REWARD_TYPE_SVIP = 730; // public static final int AGENT_REWARD_TYPE_SVIP = 730;
public static final String AGENT_REWARD_TYPE_SVIP_REMARK = "城市代理商所得的购买超级VIP收益"; // public static final String AGENT_REWARD_TYPE_SVIP_REMARK = "城市代理商所得的购买超级VIP收益";
public static final int AGENT_REWARD_TYPE_REDPACK = 740; public static final int AGENT_REWARD_TYPE_REDPACK = 740;
public static final String AGENT_REWARD_TYPE_REDPACK_REMARK = "城市代理商的红包收益"; public static final String AGENT_REWARD_TYPE_REDPACK_REMARK = "推荐奖励-普通用户购买红包";
public static final int AGENT_REWARD_TYPE_SELF_ORDER = 750; public static final int AGENT_REWARD_TYPE_SELF_ORDER = 750;
public static final String AGENT_REWARD_TYPE_SELF_ORDER_REMARK = "城市代理商的自购省收益"; public static final String AGENT_REWARD_TYPE_SELF_ORDER_REMARK = "推荐奖励-自购省";
public static final int AGENT_REWARD_TYPE_SHARE_ORDER = 760; public static final int AGENT_REWARD_TYPE_SHARE_ORDER = 760;
public static final String AGENT_REWARD_TYPE_SHARE_ORDER_REMARK = "城市代理商的分享赚收益"; public static final String AGENT_REWARD_TYPE_SHARE_ORDER_REMARK = "推荐奖励-分享赚";
public static final int JD_OFFSET = 1000; //用于查找京东的平推奖励比例
public static Map<Integer, Map<Integer, BigDecimal>> AGENT_RATE_MAP = new HashMap<Integer, Map<Integer, BigDecimal>>(); public static Map<Integer, Map<Integer, BigDecimal>> AGENT_RATE_MAP = new HashMap<Integer, Map<Integer, BigDecimal>>();
public static Map<Integer, String> AGENT_REWARD_REMARK = new HashMap<Integer, String>(); public static Map<Integer, String> AGENT_REWARD_REMARK = new HashMap<Integer, String>();
public static final int AGENT_LEVEL_1 = 1; public static final int AGENT_LEVEL_1 = 1;
...@@ -38,6 +39,7 @@ public class Constants { ...@@ -38,6 +39,7 @@ public class Constants {
public static final String DISTRIBUTE_REDIS_LOCK_KEY = "huhu:partner:distribute:redis:key"; public static final String DISTRIBUTE_REDIS_LOCK_KEY = "huhu:partner:distribute:redis:key";
public static final String PARENT_COLUMN_NAME_CENGJI = "parent_agent_id"; public static final String PARENT_COLUMN_NAME_CENGJI = "parent_agent_id";
public static final String PARENT_COLUMN_NAME_PINGTUI = "presenter_id"; public static final String PARENT_COLUMN_NAME_PINGTUI = "presenter_id";
public static final String ORDER_TYPE_JD = "jd";
/** /**
* 回扣类型 * 回扣类型
*/ */
...@@ -135,37 +137,39 @@ public class Constants { ...@@ -135,37 +137,39 @@ public class Constants {
* 代理商平推奖励比例配置 * 代理商平推奖励比例配置
*/ */
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_YEAR_VIP, new HashMap<Integer, BigDecimal>()); 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_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_SVIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_REDPACK, 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_SELF_ORDER, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SHARE_ORDER, new HashMap<Integer, BigDecimal>()); AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SHARE_ORDER, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SELF_ORDER + JD_OFFSET, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SHARE_ORDER + JD_OFFSET, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(0, new BigDecimal("0.03333333")); 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.01388889")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(1, new BigDecimal("0.01507538"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_YEAR_VIP).put(2, new BigDecimal("0.00833333"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(0, new BigDecimal("0.03015075")); // AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(0, new BigDecimal("0.03015075"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(1, new BigDecimal("0.01256281")); // AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(1, new BigDecimal("0.01256281"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(2, new BigDecimal("0.00753769")); // AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_HALF_YEAR_VIP).put(2, new BigDecimal("0.00753769"));
//
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(0, new BigDecimal("0.02500000")); // AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(0, new BigDecimal("0.02500000"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(1, new BigDecimal("0.01111111")); // AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(1, new BigDecimal("0.01111111"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(2, new BigDecimal("0.00555556")); // AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SVIP).put(2, new BigDecimal("0.00555556"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_REDPACK).put(0, new BigDecimal("0.03")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_REDPACK).put(0, new BigDecimal("0.03"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_REDPACK).put(1, new BigDecimal("0.02")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_REDPACK).put(1, new BigDecimal("0.02"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_REDPACK).put(2, new BigDecimal("0.01")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER).put(0, new BigDecimal("0.009"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER).put(0, new BigDecimal("0.03")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER).put(1, new BigDecimal("0.009"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER).put(1, new BigDecimal("0.02")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER + JD_OFFSET).put(0, new BigDecimal("0.0087"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER).put(2, new BigDecimal("0.01")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER + JD_OFFSET).put(1, new BigDecimal("0.0087"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER).put(0, new BigDecimal("0.03")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER).put(0, new BigDecimal("0.009"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER).put(1, new BigDecimal("0.02")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER).put(1, new BigDecimal("0.009"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER).put(2, new BigDecimal("0.01")); AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER + JD_OFFSET).put(0, new BigDecimal("0.0087"));
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_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_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_SVIP, AGENT_REWARD_TYPE_SVIP_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_REDPACK, AGENT_REWARD_TYPE_REDPACK_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_SELF_ORDER, AGENT_REWARD_TYPE_SELF_ORDER_REMARK);
AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SHARE_ORDER, AGENT_REWARD_TYPE_SHARE_ORDER_REMARK); AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SHARE_ORDER, AGENT_REWARD_TYPE_SHARE_ORDER_REMARK);
......
...@@ -36,7 +36,7 @@ public class UserController { ...@@ -36,7 +36,7 @@ public class UserController {
@RequestMapping(value = "/relation/nocache", method = RequestMethod.POST) @RequestMapping(value = "/relation/nocache", method = RequestMethod.POST)
public Result<User> getRelationNoCache(@RequestBody @Valid User user, @RequestHeader HttpHeaders headers) { public Result<User> getRelationNoCache(@RequestBody @Valid User user, @RequestHeader HttpHeaders headers) {
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
logger.info("getRelation userId:{},header:{},time:{}", user.getUserId(), headers.keySet().toArray(), LocalDateTime.now()); logger.info("getRelationNocache userId:{},header:{},time:{}", user.getUserId(), headers.keySet().toArray(), LocalDateTime.now());
} }
return userManager.getRelationNoCache(user.getUserId()); return userManager.getRelationNoCache(user.getUserId());
} }
......
...@@ -70,7 +70,7 @@ public class AgentManager { ...@@ -70,7 +70,7 @@ public class AgentManager {
agentRewardMessage.setSourceUserId(2328); agentRewardMessage.setSourceUserId(2328);
agentRewardMessage.setReferenceId("9999"); agentRewardMessage.setReferenceId("9999");
agentRewardMessage.setAgentId(33); agentRewardMessage.setAgentId(33);
agentRewardMessage.setAgentReward(new BigDecimal(5)); // agentRewardMessage.setAgentReward(new BigDecimal(0));
agentRewardMessage.setSourceUserPayment(new BigDecimal(5)); agentRewardMessage.setSourceUserPayment(new BigDecimal(5));
agentRewardMessage.setSettleState(-100); agentRewardMessage.setSettleState(-100);
agentRewardMessage.setOrderType("taobao"); agentRewardMessage.setOrderType("taobao");
......
...@@ -20,7 +20,7 @@ public class AgentRewardMessage extends BaseModel { ...@@ -20,7 +20,7 @@ public class AgentRewardMessage extends BaseModel {
int sourceUserId; int sourceUserId;
String referenceId; String referenceId;
int agentId; int agentId;
BigDecimal agentReward; // BigDecimal agentReward;
int settleState; int settleState;
String orderType; String orderType;
String orderSn; String orderSn;
...@@ -30,7 +30,7 @@ public class AgentRewardMessage extends BaseModel { ...@@ -30,7 +30,7 @@ public class AgentRewardMessage extends BaseModel {
String orderGoodsId; String orderGoodsId;
String orderTitle; String orderTitle;
String rewardTypeChild; String rewardTypeChild;
String orderRateArray; // String orderRateArray;
String sourceOrder; String sourceOrder;
@Override @Override
...@@ -41,7 +41,7 @@ public class AgentRewardMessage extends BaseModel { ...@@ -41,7 +41,7 @@ public class AgentRewardMessage extends BaseModel {
one.sourceUserId = this.sourceUserId; one.sourceUserId = this.sourceUserId;
one.referenceId = this.referenceId; one.referenceId = this.referenceId;
one.agentId = this.agentId; one.agentId = this.agentId;
one.agentReward = this.agentReward; // one.agentReward = this.agentReward;
one.settleState = this.settleState; one.settleState = this.settleState;
one.orderType = this.orderType; one.orderType = this.orderType;
one.orderSn = this.orderSn; one.orderSn = this.orderSn;
...@@ -51,7 +51,7 @@ public class AgentRewardMessage extends BaseModel { ...@@ -51,7 +51,7 @@ public class AgentRewardMessage extends BaseModel {
one.orderGoodsId = this.orderGoodsId; one.orderGoodsId = this.orderGoodsId;
one.orderTitle = this.orderTitle; one.orderTitle = this.orderTitle;
one.rewardTypeChild = this.rewardTypeChild; one.rewardTypeChild = this.rewardTypeChild;
one.orderRateArray = this.orderRateArray; // one.orderRateArray = this.orderRateArray;
one.sourceOrder = this.sourceOrder; one.sourceOrder = this.sourceOrder;
return one; return one;
} }
......
...@@ -108,35 +108,49 @@ public class AgentRewardQueueTask { ...@@ -108,35 +108,49 @@ public class AgentRewardQueueTask {
logger.info("未知的奖励类型 跳过不处理: {}", message); logger.info("未知的奖励类型 跳过不处理: {}", message);
return; return;
} else { } else {
rateMap = AGENT_RATE_MAP.get(rewardType); if ((rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER)
&& message.getOrderType().equals(ORDER_TYPE_JD) ) {
rateMap = AGENT_RATE_MAP.get(rewardType + JD_OFFSET);
} else {
rateMap = AGENT_RATE_MAP.get(rewardType);
}
} }
UserAgent userAgent = userAgentService.getOneByAgentId(message.getAgentId()); UserAgent userAgent = userAgentService.getOneByAgentId(message.getAgentId());
if (userAgent == null) { if (userAgent == null) {
logger.info("代理商id: {} 不存在, 跳过不处理", message); logger.info("代理商id: {} 不存在, 跳过不处理", message);
return; return;
} }
if (userAgent.getAgentLevel() != AGENT_LEVEL_4 && // if (userAgent.getAgentLevel() != AGENT_LEVEL_4 &&
(rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER || rewardType == AGENT_REWARD_TYPE_REDPACK) ) { // (rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER || rewardType == AGENT_REWARD_TYPE_REDPACK) ) {
logger.info("奖励类型{}, 代理商id: {} 不是城市代理, 跳过不处理", rewardType, message); // logger.info("奖励类型{}, 代理商id: {} 不是城市代理, 跳过不处理", rewardType, message);
// return;
// }
/**
* 直属层级代理 是总代 没有平推, 是授权公司 只奖励自购省和分享赚
*/
if (userAgent.getAgentLevel() == AGENT_LEVEL_1 ||
(userAgent.getAgentLevel() == AGENT_LEVEL_2 && (rewardType != AGENT_REWARD_TYPE_SELF_ORDER && rewardType != AGENT_REWARD_TYPE_SHARE_ORDER))) {
logger.info("奖励类型{}, 代理商id: {} , 不在奖励范围内, 跳过不处理", rewardType, message);
return; return;
} }
/** /**
* 这里的逻辑有问题, 不能用这个接口找上级, 因为会先找一次直接邀请人, * 这里的逻辑有问题, 不能用这个接口找上级, 因为会先找一次直接邀请人,
* 只能按message.getAgentId()的代理商id, 找user_agent表里的平推关系 * 只能按message.getAgentId()的代理商id, 找user_agent表里的平推关系
* 已修复
*/ */
ArrayList<ParentAgent> parentList = (ArrayList<ParentAgent>) userService.getAgentListByUserId(userAgent.getUserId(), PARENT_COLUMN_NAME_PINGTUI); ArrayList<ParentAgent> parentList = (ArrayList<ParentAgent>) userService.getAgentListByUserId(userAgent.getUserId(), PARENT_COLUMN_NAME_PINGTUI);
if (parentList.size() > 0) { if (parentList.size() > 0) {
/** /**
* 扫描agentlist中的平推城市代理 * 扫描agentlist中的平推城市代理
* 最多只需要找3 * 最多只需要找2
*/ */
int rewardCnt = 0; int rewardCnt = 0;
ArrayList<ParentAgent> rewardList = new ArrayList<ParentAgent>(); ArrayList<ParentAgent> rewardList = new ArrayList<ParentAgent>();
for (ParentAgent agent : parentList) { for (ParentAgent agent : parentList) {
/** /**
* 奖励次数不够3, 写到rewardList * 奖励次数不够2, 写到rewardList
*/ */
if (rewardCnt < 3){ if (rewardCnt < 2){
rewardList.add(agent); rewardList.add(agent);
rewardCnt++; rewardCnt++;
/** /**
...@@ -145,33 +159,47 @@ public class AgentRewardQueueTask { ...@@ -145,33 +159,47 @@ public class AgentRewardQueueTask {
if (agent.getLevel() == AGENT_LEVEL_1) { if (agent.getLevel() == AGENT_LEVEL_1) {
break; break;
} }
/**
* 如果是AGENT_LEVEL_2 奖励类型 750 或 760, 只奖励1个人 并且只拿1份
*/
if (userAgent.getAgentLevel() == AGENT_LEVEL_2 && (rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER)) {
break;
}
} else { } else {
break; break;
} }
} }
if (rewardList.size() > 3) { if (rewardList.size() > 2) {
logger.error("代理商推荐奖励处理异常 奖励人数超出3人, 奖励消息: {}", message); logger.error("代理商推荐奖励处理异常 奖励人数超出2人, 奖励消息: {}", message);
return; return;
} }
/** /**
* 如果上面检查通过, 证明代理商关系没问题, 后面处理只看rewardList的size * 如果上面检查通过, 证明代理商关系没问题, 后面处理只看rewardList的size
* 决定比例怎么分: 1个人-拿3份; 2个人-第二个拿后2份; 3个人-各1份 * 决定比例怎么分: 1个人-拿2份; 2个人-各1份
*/ */
List<BigDecimal> rateList = new ArrayList<BigDecimal>(); List<BigDecimal> rateList = new ArrayList<BigDecimal>();
if (rewardList.size() == 1) { if (rewardList.size() == 1) {
rateList.add(rateMap.get(0).add(rateMap.get(1)).add(rateMap.get(2))); /**
* 如果直属层级代理商是AGENT_LEVEL_2 奖励类型 750 或 760 只拿1份
*/
if (userAgent.getAgentLevel() == AGENT_LEVEL_2 &&
(rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER) ) {
rateList.add(rateMap.get(0));
} else {
rateList.add(rateMap.get(0).add(rateMap.get(1)));
}
} else if (rewardList.size() == 2) { } else if (rewardList.size() == 2) {
rateList.add(rateMap.get(0)); if (userAgent.getAgentLevel() == AGENT_LEVEL_2 &&
rateList.add(rateMap.get(1).add(rateMap.get(2))); (rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER) ) {
} else if (rewardList.size() == 3) { logger.error("代理商推荐奖励逻辑处理错误, 直属代理商id: {}, rewardList[1]: {}", userAgent.getAgentId(), rewardList.get(1));
}
rateList.add(rateMap.get(0)); rateList.add(rateMap.get(0));
rateList.add(rateMap.get(1)); rateList.add(rateMap.get(1));
rateList.add(rateMap.get(2));
} }
TransactionStatus transactionStatus = null; TransactionStatus transactionStatus = null;
List<AgentReward> pushList = new ArrayList<AgentReward>(); List<AgentReward> pushList = new ArrayList<AgentReward>();
List<AgentReward> pushRewardList = new ArrayList<AgentReward>(); // List<AgentReward> pushRewardList = new ArrayList<AgentReward>();
try { try {
/** /**
* 开启事务, 如果rewardList中的奖励 都插入成功, 才提交事务 * 开启事务, 如果rewardList中的奖励 都插入成功, 才提交事务
...@@ -185,12 +213,13 @@ public class AgentRewardQueueTask { ...@@ -185,12 +213,13 @@ public class AgentRewardQueueTask {
pushList.add(reward); pushList.add(reward);
/** /**
* 如果是城市代理获得的佣金 或 红包奖励 需要 再往上分 * 如果是城市代理获得的佣金 或 红包奖励 需要 再往上分
* 已废弃
*/ */
if (reward.getAgentLevel() == AGENT_LEVEL_4 && // if (reward.getAgentLevel() == AGENT_LEVEL_4 &&
(rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER || rewardType == AGENT_REWARD_TYPE_REDPACK) // (rewardType == AGENT_REWARD_TYPE_SELF_ORDER || rewardType == AGENT_REWARD_TYPE_SHARE_ORDER || rewardType == AGENT_REWARD_TYPE_REDPACK)
) { // ) {
pushRewardList.add(reward); // pushRewardList.add(reward);
} // }
} }
} }
/** /**
...@@ -203,9 +232,9 @@ public class AgentRewardQueueTask { ...@@ -203,9 +232,9 @@ public class AgentRewardQueueTask {
for (AgentReward reward : pushList) { for (AgentReward reward : pushList) {
doPush(reward); doPush(reward);
} }
for (AgentReward reward : pushRewardList) { // for (AgentReward reward : pushRewardList) {
pushRewardQueue(reward, message.clone()); // pushRewardQueue(reward, message.clone());
} // }
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
logger.error("插入代理商分成奖励失败, 奖励 {}", message); logger.error("插入代理商分成奖励失败, 奖励 {}", message);
...@@ -231,23 +260,23 @@ public class AgentRewardQueueTask { ...@@ -231,23 +260,23 @@ public class AgentRewardQueueTask {
} }
} }
private void pushRewardQueue(AgentReward reward, AgentRewardMessage message) { // private void pushRewardQueue(AgentReward reward, AgentRewardMessage message) {
logger.info("处理循环上供奖励......."); // logger.info("处理循环上供奖励.......");
logger.info("reward is :{}", reward); // logger.info("reward is :{}", reward);
logger.info("message is :{}", message); // logger.info("message is :{}", message);
message.setAgentId(reward.getAgentId()); // message.setAgentId(reward.getAgentId());
message.setAgentReward(reward.getAmount()); // message.setAgentReward(reward.getAmount());
String rateArray; // String rateArray;
if (StringUtils.isEmpty(reward.getRatioAll())) { // if (StringUtils.isEmpty(reward.getRatioAll())) {
rateArray = "[" + reward.getCommissionRate() + "]"; // rateArray = "[" + reward.getCommissionRate() + "]";
} else { // } else {
rateArray = reward.getRatioAll().replaceAll("\\]", ""); // rateArray = reward.getRatioAll().replaceAll("\\]", "");
rateArray = rateArray + reward.getCommissionRate() + "]"; // rateArray = rateArray + reward.getCommissionRate() + "]";
} // }
message.setOrderRateArray(rateArray); // message.setOrderRateArray(rateArray);
logger.info("推送循环上供奖励: {}", message); // logger.info("推送循环上供奖励: {}", message);
stringRedisTemplate.opsForList().leftPush(AGENT_REWARD_QUEUE_KEY, JSON.toJSONString(message)); // stringRedisTemplate.opsForList().leftPush(AGENT_REWARD_QUEUE_KEY, JSON.toJSONString(message));
} // }
private AgentReward doInsert(BigDecimal commissionRate, ParentAgent agent, AgentRewardMessage message) { private AgentReward doInsert(BigDecimal commissionRate, ParentAgent agent, AgentRewardMessage message) {
try { try {
...@@ -286,15 +315,16 @@ public class AgentRewardQueueTask { ...@@ -286,15 +315,16 @@ public class AgentRewardQueueTask {
* cash_code 支付金额 * cash_code 支付金额
*/ */
BigDecimal rewardBasement; 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_HALF_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_SVIP) {
if (rewardType == AGENT_REWARD_TYPE_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_REDPACK) {
rewardBasement = message.getSourceUserPayment(); rewardBasement = message.getSourceUserPayment();
} else { } else {
/** /**
* 订单相关, 还需要写入两个字段:all_money_ori 原始佣金, 继承下来的比例数组 * 订单相关, 还需要写入两个字段:all_money_ori 原始佣金, 继承下来的比例数组
*/ */
rewardBasement = message.getAgentReward(); rewardBasement = message.getOrderCommission();
agentReward.setAllMoneyOri(message.getOrderCommission()); agentReward.setAllMoneyOri(message.getOrderCommission());
agentReward.setRatioAll(message.getOrderRateArray()); agentReward.setRatioAll("");
} }
logger.info("rewardBasement is: {}", rewardBasement); logger.info("rewardBasement is: {}", rewardBasement);
logger.info("commissionRate is: {}", commissionRate); logger.info("commissionRate is: {}", commissionRate);
...@@ -311,7 +341,6 @@ public class AgentRewardQueueTask { ...@@ -311,7 +341,6 @@ public class AgentRewardQueueTask {
agentReward.setAmount(reward); agentReward.setAmount(reward);
agentReward.setCommission(reward); agentReward.setCommission(reward);
agentReward.setCashCode("0"); agentReward.setCashCode("0");
doPush(agentReward);
agentRewardService.save(agentReward); agentRewardService.save(agentReward);
return agentReward; return agentReward;
} }
...@@ -333,6 +362,7 @@ public class AgentRewardQueueTask { ...@@ -333,6 +362,7 @@ public class AgentRewardQueueTask {
message.setTime(agentReward.getCreatedAt()); message.setTime(agentReward.getCreatedAt());
message.setRewardType(agentReward.getRewardType()); message.setRewardType(agentReward.getRewardType());
redisTemplatePush.opsForList().leftPush(AGENT_REWARD_PUSH_KEY, message); redisTemplatePush.opsForList().leftPush(AGENT_REWARD_PUSH_KEY, message);
logger.info("推送奖励通知 {}", message);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
......
...@@ -57,12 +57,12 @@ public class UserServiceImpl implements UserService { ...@@ -57,12 +57,12 @@ public class UserServiceImpl implements UserService {
@Override @Override
@Cacheable @Cacheable
public User getRelationByUserId(Integer userId) { public User getRelationByUserId(Integer userId) {
logger.info("UserServiceImpl get user relation from database, userId: {}", userId);
return getRelationByUserIdRealtime(userId); return getRelationByUserIdRealtime(userId);
} }
@Override @Override
public User getRelationByUserIdRealtime(Integer userId) { public User getRelationByUserIdRealtime(Integer userId) {
logger.info("UserServiceImpl get user relation from database, userId: {}", userId);
User user = new User(); User user = new User();
user.setUserId(userId); user.setUserId(userId);
user.setPartnerList((ArrayList<ParentPartner>) getPartnerListByUserId(userId)); user.setPartnerList((ArrayList<ParentPartner>) getPartnerListByUserId(userId));
...@@ -267,15 +267,17 @@ public class UserServiceImpl implements UserService { ...@@ -267,15 +267,17 @@ public class UserServiceImpl implements UserService {
* 1. 层级关系 都包含自己 * 1. 层级关系 都包含自己
* 2. 推荐关系 只有当自己是总代时才包含自己 * 2. 推荐关系 只有当自己是总代时才包含自己
*/ */
if (null != selfAgent && (parentColumnName.equals(PARENT_COLUMN_NAME_CENGJI) ||
parentColumnName.equals(PARENT_COLUMN_NAME_PINGTUI) && selfAgent.getAgentLevel() == AGENT_LEVEL_1)) {
} else { /**
selfAgent = null; * 1.4.5更新: 平推奖励都不包含自己了
} */
int loopUserId = userId; int loopUserId = userId;
int loopTimes = 0; int loopTimes = 0;
UserAgent firstAgent = null; UserAgent firstAgent = null;
/**
* 自己不是代理商的话 按C端邀请关系找到第一个代理商
* 自己是代理商的话 按B端找, 如果是找平推, 最后都找完再剔除自己
*/
if (selfAgent == null) { if (selfAgent == null) {
/** /**
* 自己不是代理商时 按C端邀请关系查找代理商 * 自己不是代理商时 按C端邀请关系查找代理商
...@@ -382,7 +384,16 @@ public class UserServiceImpl implements UserService { ...@@ -382,7 +384,16 @@ public class UserServiceImpl implements UserService {
logger.info("已找到总代 不再往下找, 总代id: {}", firstAgent.getAgentId()); logger.info("已找到总代 不再往下找, 总代id: {}", firstAgent.getAgentId());
} }
} }
/**
* 如果是平推奖励 过滤掉自己
*/
if (parentColumnName.equals(PARENT_COLUMN_NAME_PINGTUI)
&& selfAgent != null
&& agentList.size() > 0) {
agentList.remove(0);
}
} }
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
logger.info("setAgentList for user: {} end", userId); logger.info("setAgentList for user: {} end", userId);
} }
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<property name="MaxFileSize" value="256MB"/><!--单个文件大小--> <property name="MaxFileSize" value="256MB"/><!--单个文件大小-->
<property name="totalSizeCap" value="256MB"/><!--单个文件大小--> <property name="totalSizeCap" value="256MB"/><!--单个文件大小-->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <!--<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">-->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!--<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">-->
<pattern>${pattern}</pattern> <!--<pattern>${pattern}</pattern>-->
</encoder> <!--</encoder>-->
</appender> <!--</appender>-->
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${log_file}-info.log</File> <File>${log_file}-info.log</File>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<pattern>${pattern}</pattern> <pattern>${pattern}</pattern>
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level> <level>DEBUG</level>
</filter> </filter>
</appender> </appender>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</appender> </appender>
<root level="info"> <root level="info">
<appender-ref ref="stdout"/> <!--<appender-ref ref="stdout"/>-->
<appender-ref ref="info"/> <appender-ref ref="info"/>
<appender-ref ref="error"/> <appender-ref ref="error"/>
</root> </root>
......
...@@ -55,4 +55,28 @@ select * from partner_income_summary where user_id=1648 and yeartime=2019 and mo ...@@ -55,4 +55,28 @@ select * from partner_income_summary where user_id=1648 and yeartime=2019 and mo
delete from partner_account_log where user_id=1648 and yeartime=2019 and monthtime=6; delete from partner_account_log where user_id=1648 and yeartime=2019 and monthtime=6;
update partner_reward set reward_status=100,settle_state=case when settle_state=300 then 200 else settle_state end where user_id=1648 and recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59' ; update partner_reward set reward_status=100,settle_state=case when settle_state=300 then 200 else settle_state end where user_id=1648 and recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59' ;
delete from partner_income_summary where user_id=1648 and yeartime=2019 and monthtime=6; delete from partner_income_summary where user_id=1648 and yeartime=2019 and monthtime=6;
\ No newline at end of file
更新自购省分享赚比例
update income_rate_config
set self_rate=0.522
where type in (20,40) and self_role=10;
update income_rate_config
set self_rate=0.783
where type in (20,40) and self_role=20;
update income_rate_config
set self_rate=0.8352
where type in (20,40) and self_role=30;
update income_rate_config
set self_rate=0.54
where type in (10,30) and self_role=10;
update income_rate_config
set self_rate=0.81
where type in (10,30) and self_role=20;
update income_rate_config
set self_rate=0.864
where type in (10,30) and self_role=30;
ALTER TABLE `huhu`.`partner_reward`
ADD COLUMN `tech_fee_rate` decimal(11, 6) NOT NULL DEFAULT 0 COMMENT '技术服务费扣除比例' AFTER `ratio_all`;
\ 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