Commit dfba251b by guanchen

Merge commit 'a8770582' into finance

# Conflicts: # pom.xml # src/main/resources/logback.xml
parents 505d9403 a8770582
......@@ -192,8 +192,7 @@
<redis.host>10.9.48.21</redis.host>
<redis.password>Ws_LrqD_20180319_REdis_MQLRd</redis.password>
<spring.profiles.active>prod</spring.profiles.active>
<!--<logfile_path>/data/logs/huhu/lanren</logfile_path>-->
<logfile_path>/Users/chen/Develop/workspace/partner/data/release/dev/logs</logfile_path>
<logfile_path>/data/logs2/huhu/lanren</logfile_path>
<providers-path>/data/java/service</providers-path>
</properties>
......
......@@ -33,6 +33,7 @@ public class Constants {
public static final int AGENT_REWARD_TYPE_SHARE_ORDER = 760;
public static final String AGENT_REWARD_TYPE_SHARE_ORDER_REMARK = "推荐奖励-分享赚";
public static final int JD_OFFSET = 1000; //用于查找京东的平推奖励比例
public static final int MT_OFFSET = 2000; //用于查找美团的平推奖励比例
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 final int AGENT_LEVEL_1 = 1;
......@@ -43,6 +44,7 @@ public class Constants {
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 ORDER_TYPE_JD = "jd";
public static final String ORDER_TYPE_MT = "mt";
/**
* 回扣类型
*/
......@@ -149,6 +151,7 @@ public class Constants {
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.put(AGENT_REWARD_TYPE_SELF_ORDER + MT_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"));
......@@ -160,13 +163,23 @@ public class Constants {
// 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(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(1, new BigDecimal("0.02"));
/**
* 自购省
*/
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(1, new BigDecimal("0.009"));
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 + JD_OFFSET).put(1, new BigDecimal("0.0087"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER + MT_OFFSET).put(0, new BigDecimal("0.01"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SELF_ORDER + MT_OFFSET).put(1, new BigDecimal("0.01"));
/**
* 分享赚
*/
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.009"));
AGENT_RATE_MAP.get(AGENT_REWARD_TYPE_SHARE_ORDER + JD_OFFSET).put(0, new BigDecimal("0.0087"));
......
package com.lanren.huhu.partner.controller;
import com.alibaba.fastjson.JSON;
import com.lanren.huhu.partner.manager.UserManager;
import com.lanren.huhu.partner.model.User;
import com.lanren.huhu.partner.result.Result;
......@@ -38,7 +39,9 @@ public class UserController {
if (logger.isInfoEnabled()) {
logger.info("getRelationNocache userId:{},header:{},time:{}", user.getUserId(), headers.keySet().toArray(), LocalDateTime.now());
}
return userManager.getRelationNoCache(user.getUserId());
Result<User> result = userManager.getRelationNoCache(user.getUserId());
logger.info("uid:{} call /relation/nocache api, return: {}", user.getUserId(), JSON.toJSONString(result));
return result;
}
@RequestMapping(value = "/relation/delete", method = RequestMethod.POST)
......@@ -54,7 +57,7 @@ public class UserController {
if (logger.isInfoEnabled()) {
logger.info("purgeRelation userId:{},header:{},time:{}", user.getUserId(), headers.keySet().toArray(), LocalDateTime.now());
}
userManager.purgeRelation(user.getUserId());
// userManager.purgeRelation(user.getUserId());
logger.info("============>" + Thread.currentThread().getName());
Result<String> result = new Result<String>();
result.setData("异步,正在执行刷新......");
......
......@@ -14,7 +14,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
......@@ -45,7 +44,7 @@ public class AgentDailyExpandTask {
@Autowired
AgentExpandDailyService agentExpandDailyService;
@Scheduled(fixedDelay = DELAY)
// @Scheduled(fixedDelay = DELAY)
public void runScheduledTask() {
try {
Date dat = new Date(System.currentTimeMillis() - DELAY);
......
......@@ -22,7 +22,6 @@ 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;
......@@ -64,7 +63,7 @@ public class AgentRewardQueueTask {
@Autowired
TransactionDefinition transactionDefinition;
@Scheduled(fixedDelay = 5000L)
// @Scheduled(fixedDelay = 5000L)
public void runScheduledTask() {
logger.info("run AgentRewardQueueTask");
runConsume();
......@@ -111,6 +110,9 @@ public class AgentRewardQueueTask {
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 if (rewardType == AGENT_REWARD_TYPE_SELF_ORDER
&& message.getOrderType().equals(ORDER_TYPE_MT) ) {
rateMap = AGENT_RATE_MAP.get(rewardType + MT_OFFSET);
} else {
rateMap = AGENT_RATE_MAP.get(rewardType);
}
......
......@@ -9,7 +9,6 @@ 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 +40,7 @@ public class RevokeAgentRewardTask {
@Autowired
TransactionDefinition transactionDefinition;
@Scheduled(fixedDelay = 5000L)
// @Scheduled(fixedDelay = 5000L)
public void runScheduledTask() {
logger.info("run RevokeAgentRewardTask");
runConsume();
......@@ -49,11 +48,10 @@ public class RevokeAgentRewardTask {
private void runConsume() {
List<AgentRevokeRecords> revokeRecordList = null;
while (true) {
try {
revokeRecordList = agentRevokeRecordsService.getAllPending();
if (null == revokeRecordList || revokeRecordList.size() == 0) {
break;
return;
}
process(revokeRecordList);
} catch (Exception e) {
......@@ -61,7 +59,6 @@ public class RevokeAgentRewardTask {
logger.error(e.getMessage(), e);
}
}
}
@Async
public void process(List<AgentRevokeRecords> revokeRecordList) {
......
......@@ -147,6 +147,7 @@ public class UserServiceImpl implements UserService {
}
partnerList.add(parentPartner);
loopUserId = parentPartner.getUserId();
}
loopTimes++;
if (loopTimes > 500) {
partnerList.clear();
......@@ -154,7 +155,6 @@ public class UserServiceImpl implements UserService {
break;
}
}
}
if (logger.isInfoEnabled()) {
logger.info("setPartnerList for user: {} end", userId);
}
......@@ -249,7 +249,7 @@ public class UserServiceImpl implements UserService {
@Override
public List<ParentAgent> getAgentListByUserId(Integer userId, String parentColumnName) {
if (logger.isInfoEnabled()) {
logger.info("getAgentListByUserId for user: {} ......", userId);
logger.info("getAgentListByUserId {} for user: {} ......", parentColumnName, userId);
}
ArrayList<ParentAgent> agentList = new ArrayList<ParentAgent>();
HashSet<Integer> existingUserIdSet = new HashSet<Integer>();
......@@ -298,12 +298,6 @@ public class UserServiceImpl implements UserService {
* 这个人不是代理商 继续往上找
*/
loopUserId = parentPartner.getUserId();
loopTimes++;
if (loopTimes > 500) {
agentList.clear();
logger.error("用户ID:{} 合伙人关系异常, 已超500层", userId);
break;
}
if (existingUserIdSet.contains(loopUserId)) {
logger.info("发现互为上级的用户邀请关系 用户ID({})", loopUserId);
logger.info("退出循环, 不再继续查找");
......@@ -319,6 +313,12 @@ public class UserServiceImpl implements UserService {
}
break;
}
loopTimes++;
if (loopTimes > 500) {
agentList.clear();
logger.error("用户ID:{} 合伙人关系异常, 已超500层", userId);
break;
}
}
} else {
firstAgent = selfAgent;
......@@ -344,6 +344,7 @@ public class UserServiceImpl implements UserService {
logger.info("loop find parent agent start ......");
}
int loogAgentId = firstAgent.getAgentId();
loopTimes = 0;
while (true) {
ParentAgent loopUserAgent = getParentAgent(loogAgentId, parentColumnName);
if (null == loopUserAgent) {
......@@ -365,14 +366,14 @@ public class UserServiceImpl implements UserService {
break;
}
loogAgentId = loopUserAgent.getAgentId();
}
loopTimes++;
if (loopTimes > 500) {
agentList.clear();
logger.error("用户ID:{} 代理商关系异常, 已超500层", userId);
logger.error("用户ID:{} 合伙人关系异常, 已超500层", userId);
break;
}
}
}
/**
* 找完 "第一个是代理商的合伙人" 的 全部上级代理后 退出while循环
*/
......@@ -395,7 +396,7 @@ public class UserServiceImpl implements UserService {
}
if (logger.isInfoEnabled()) {
logger.info("setAgentList for user: {} end", userId);
logger.info("setAgentList {} for user: {} end", parentColumnName, userId);
}
return agentList;
}
......
......@@ -103,7 +103,7 @@ mybatis-plus:
logging:
level:
#打印SQL信息
com.lanren.huhu.partner.dao: debug
com.lanren.huhu.partner.dao: info
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="pattern" value="[%level] %d{yy-MM-dd HH:mm:ss.SSS} [%thread] %logger{50}:%line - %msg%n"/>
<property name="log_file" value="@logfile_path@/@profiles.active@/@artifactId@-@profiles.active@"/>
<property name="MaxHistory" value="90"/><!--日志保留天数-->
<property name="MaxFileSize" value="256MB"/><!--单个文件大小-->
<property name="totalSizeCap" value="256MB"/><!--单个文件大小-->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${pattern}</pattern>
<pattern>%date [%thread] [%level] %logger - %msg %n</pattern>
</encoder>
</appender>
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${log_file}-info.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${log_file}-info.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<MaxHistory>${MaxHistory}</MaxHistory>
<MaxFileSize>${MaxFileSize}</MaxFileSize>
<totalSizeCap>${totalSizeCap}</totalSizeCap>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log_file}-info.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>90</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${pattern}</pattern>
<encoder>
<pattern>%date [%thread] [%level] %logger - %msg %n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
......@@ -29,15 +22,12 @@
</appender>
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${log_file}-error.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${log_file}-error.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<MaxHistory>${MaxHistory}</MaxHistory>
<MaxFileSize>${MaxFileSize}</MaxFileSize>
<totalSizeCap>${totalSizeCap}</totalSizeCap>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log_file}-error.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>90</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${pattern}</pattern>
<encoder>
<pattern>%date [%thread] [%level] %logger - %msg %n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
......
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