remove unnecessary code

master
wangning 7 years ago
parent 950fdc67e4
commit d5acfc2bbd

@ -14,7 +14,6 @@ public interface CustomerImpressionService {
JSONObject findOne(int client_id,String customer_id);
void generateTag(int client_id);
void generate(int client_id);
void generateInfo();

@ -1,11 +1,21 @@
package au.com.royalpay.payment.manage.apps.core.impls;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import au.com.royalpay.payment.manage.apps.bean.CustomerImpressionQuery;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import javax.annotation.Resource;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.maxmind.geoip.LookupService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -18,23 +28,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.maxmind.geoip.LookupService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import au.com.royalpay.payment.manage.apps.bean.CustomerImpressionQuery;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.lock.LockerRedisImpl;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import javax.annotation.Resource;
/**
* Created by wangning on 2017/12/28.
@ -104,68 +102,6 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
return customer;
}
@Override
public void generate(int client_id) {
Date now = new Date();
DateTime dt = new DateTime(2018, 1, 20, 0, 0);
if (now.compareTo(dt.toDate()) > 0) {
return;
}
JSONObject params = new JSONObject();
params.put("client_id", client_id);
params.put("include_success_status", 3);
PageList<JSONObject> lastRecord = clientCustomersMapper.listCustomerInfo(params, new PageBounds(1, 1, Order.formString("update_time.desc")));
if (!CollectionUtils.isEmpty(lastRecord)) {
params.put("confirm_time", lastRecord.get(0).getDate("update_time"));
}
List<JSONObject> orders = orderMapper.listAnalysisClientCustomer(params);
for (JSONObject order : orders) {
if (StringUtils.isEmpty(order.getString("channel"))) {
continue;
}
String customer_id = order.getString("customer_id");
JSONObject userInfo = customerMapper.findCustomerByOpenId(customer_id);
if (userInfo == null) {
userInfo = customerRelationAlipayMapper.findCustomerByUserId(customer_id);
}
JSONObject clientCustomerInfo = clientCustomersMapper.getClientCustomerWithNull(client_id, customer_id);
if (clientCustomerInfo == null) {
locker.lock(CUSTOMER_IMPRESSION_PREFIX + customer_id, 30_000, 30_000);
try {
JSONObject client_customer = new JSONObject();
client_customer.put("client_id", order.getIntValue("client_id"));
client_customer.put("customer_id", order.getString("customer_id"));
client_customer.put("channel", order.getString("channel"));
client_customer.put("tag", "不活跃用户");
if (userInfo != null) {
client_customer.put("headimg", userInfo.getString("headimg"));
client_customer.put("nick_name", userInfo.getString("nickname"));
}
client_customer.put("payment_times", order.getIntValue("payment_times"));
client_customer.put("total_amount", order.getBigDecimal("total_amount"));
client_customer.put("update_time", now);
client_customer.put("last_payment_time", order.getDate("confirm_time"));
clientCustomersMapper.insert(client_customer);
} finally {
locker.unlock(customer_id);
}
} else {
clientCustomerInfo.put("payment_times", clientCustomerInfo.getIntValue("payment_times") + order.getIntValue("payment_times"));
clientCustomerInfo.put("payment_times", order.getIntValue("payment_times"));
clientCustomerInfo.put("client_id", order.getIntValue("client_id"));
clientCustomerInfo.put("customer_id", order.getString("customer_id"));
clientCustomerInfo.put("total_amount", order.getBigDecimal("total_amount"));
if (userInfo != null) {
clientCustomerInfo.put("headimg", userInfo.getString("headimg"));
clientCustomerInfo.put("nick_name", userInfo.getString("nickname"));
}
clientCustomerInfo.put("last_payment_time", order.getDate("confirm_time"));
clientCustomersMapper.updateAfterPaymentFinish(clientCustomerInfo);
}
}
}
@Override
@Transactional
public void generateTag(int client_id) {
@ -197,10 +133,6 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
@Override
public void generateInfo() {
Date now = new Date();
DateTime dt = new DateTime(2018, 1, 19, 3, 0);
if (dt.toDate().compareTo(now) > 0) {
return;
}
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
String redisValue = ops.leftPop();

@ -1,21 +1,21 @@
package au.com.royalpay.payment.manage.task;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import javax.annotation.Resource;
import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import javax.annotation.Resource;
/**
* Created by yishuqian on 12/03/2017.
@ -51,27 +51,6 @@ public class CustomerImpressionTask {
}
}
@Scheduled(cron = "0 0 3 * * ?")
public void generate() {
List<JSONObject> clients = clientMapper.listValidClient();
List<List<JSONObject>> splitList = new ArrayList<>();
for (int i = 0; i < clients.size(); i+=200) {
if(i+200>clients.size()){
splitList.add(clients.subList(i,clients.size()));
}else {
splitList.add(clients.subList(i,i+200));
}
}
for (List<JSONObject> splitClients : splitList) {
Runnable task = () -> splitClients.forEach((p)->{
System.out.println("当前执行到"+p.getIntValue("client_id"));
customerImpressionService.generate(p.getIntValue("client_id"));
});
generatePool.execute(task);
}
}
@Scheduled(cron = "0/1 * * * * ?")
public void generateInfo() {
customerImpressionService.generateInfo();

Loading…
Cancel
Save