Commit 7f6c80fc authored by m1991's avatar m1991

Merge remote-tracking branch 'origin/master'

parents 4181aec1 53caafc8
package cn.wisenergy.common.utils;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.Enumeration;
public class IpUtil {
/**
* 正确的IP拿法,即优先拿site-local地址
*
* @return
* @throws UnknownHostException
*/
public static InetAddress getLocalHostLANAddress() throws UnknownHostException {
try {
InetAddress candidateAddress = null;
// 遍历所有的网络接口
for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements(); ) {
NetworkInterface iface = ifaces.nextElement();
// 在所有的接口下再遍历IP
for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements(); ) {
InetAddress inetAddr = inetAddrs.nextElement();
if (!inetAddr.isLoopbackAddress()) {
// 排除loopback类型地址
if (inetAddr.isSiteLocalAddress()) {
// 如果是site-local地址,就是它了
return inetAddr;
} else if (candidateAddress == null) {
// site-local类型的地址未被发现,先记录候选地址
candidateAddress = inetAddr;
}
}
}
}
if (candidateAddress != null) {
return candidateAddress;
}
// 如果没有发现 non-loopback地址.只能用最次选的方案
InetAddress jdkSuppliedAddress = InetAddress.getLocalHost();
if (jdkSuppliedAddress == null) {
throw new UnknownHostException("The JDK InetAddress.getLocalHost() method unexpectedly returned null.");
}
return jdkSuppliedAddress;
} catch (Exception e) {
UnknownHostException unknownHostException = new UnknownHostException(
"Failed to determine LAN address: " + e);
unknownHostException.initCause(e);
throw unknownHostException;
}
}
}
......@@ -49,4 +49,11 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
* @return 订单列表
*/
List<OrderInfo> getListBySuccessTime(@Param("successTime") Date successTime);
/**
* 更据创建订单时间获取订单列表
* @param createTime 创建订单时间
* @return 订单列表
*/
List<OrderInfo> getByCreateTime(@Param("createTime") Date createTime);
}
......@@ -140,4 +140,17 @@
</where>
</select>
<select id="getByCreateTime" resultType="cn.wisenergy.model.app.OrderInfo">
SELECT
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="successTime != null ">
YEAR(create_time) = YEAR(#{successTime})
AND MONTH(create_time) = MONTH(#{successTime})
</if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -29,11 +29,9 @@ public interface AccountService {
/**
* 收益和业绩统计(月度肥料 -日)
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
R<Boolean> performanceCount();
/**
* 获取用户的商机信息
......
......@@ -21,11 +21,9 @@ public interface MonthTaskService {
/**
* 收益和业绩统计(月度肥料)-月任务
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
R<Boolean> performanceCount();
/**
* 进步奖收益统计(最大进步奖) -月任务
......
......@@ -113,7 +113,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
@Override
public R<Boolean> performanceCount(List<OrderInfo> list) {
public R<Boolean> performanceCount() {
//获取本月订单
List<OrderInfo> list = orderMapper.getByCreateTime(new Date());
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
......
......@@ -76,7 +76,10 @@ public class MonthTaskServiceImpl implements MonthTaskService {
}
@Override
public R<Boolean> performanceCount(List<OrderInfo> list) {
public R<Boolean> performanceCount() {
//获取上月订单
Date lastMonth = DateUtil.getLastMonth(new Date());
List<OrderInfo> list = orderMapper.getByCreateTime(lastMonth);
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
......@@ -99,7 +102,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
for (OrderInfo orderInfo : list) {
long createTime = orderInfo.getCreated().getTime();
long time = System.currentTimeMillis();
if (createTime <= time) {
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
......@@ -140,7 +143,6 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//4、更新账户月度绩效
accountManager.updateAccountPerformanceMonth(teamPerformances);
}
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser();
if (CollectionUtils.isEmpty(userList)) {
......
package cn.wisenergy.web.config;
import cn.wisenergy.common.utils.IpUtil;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.UnknownHostException;
@Configuration
public class XxlJobConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(XxlJobConfig.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.appname}")
private String appname;
@Value("${xxl.job.executor.address}")
private String address;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
LOGGER.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppname(appname);
xxlJobSpringExecutor.setAddress(address);
String ip = null;
try {
ip = IpUtil.getLocalHostLANAddress().getHostAddress();
} catch (UnknownHostException e) {
LOGGER.error("UnknownHostException ", e);
}
LOGGER.info("XxlJobSpringExecutor ip:" + ip);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
}
......@@ -60,7 +60,7 @@ xxl:
executor:
address:
appname: shop-mall
ip: 172.24.252.165
ip:
logpath: /var/logs/xxl-job/jobhandler
logretentiondays: 30
port: 9999
\ 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