Merge remote-tracking branch 'origin/master'

master
yixian 8 years ago
commit 9feb531c12

@ -24,6 +24,8 @@ 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.utils.PageListUtils;
@ -39,6 +41,10 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
private OrderMapper orderMapper;
@Resource
private LookupService lookupService;
@Resource
private CustomerRelationAlipayMapper customerRelationAlipayMapper;
@Resource
private CustomerMapper customerMapper;
@Override
public JSONObject listPageble(CustomerImpressionQuery customerImpressionQuery) {
@ -101,6 +107,11 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
if (StringUtils.isEmpty(order.getString("channel"))) {
continue;
}
JSONObject userInfo = customerMapper.findCustomerByOpenId(order.getString("customer_id"));
if (userInfo == null) {
userInfo = customerRelationAlipayMapper.findCustomerByUserId(order.getString("customer_id"));
}
JSONObject clientCustomerInfo = clientCustomersMapper.getClientCustomerWithNull(client_id, order.getString("customer_id"));
if (clientCustomerInfo == null) {
JSONObject client_customer = new JSONObject();
@ -108,12 +119,9 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
client_customer.put("customer_id", order.getString("customer_id"));
client_customer.put("channel", order.getString("channel"));
client_customer.put("tag", "不活跃用户");
if (order.getString("alipay_headimg") == null) {
client_customer.put("headimg", order.getString("wechat_headimg"));
client_customer.put("nick_name", order.getString("wechat_nickname"));
} else {
client_customer.put("headimg", order.getString("alipay_headimg"));
client_customer.put("nick_name", order.getString("alipay_nickname"));
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"));
@ -128,13 +136,9 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
} else {
clientCustomerInfo.put("total_amount", order.getBigDecimal("total_amount"));
}
if (order.getString("alipay_headimg") == null) {
clientCustomerInfo.put("headimg", order.getString("wechat_headimg"));
clientCustomerInfo.put("nick_name", order.getString("wechat_nickname"));
} else {
clientCustomerInfo.put("headimg", order.getString("alipay_headimg"));
clientCustomerInfo.put("nick_name", order.getString("alipay_nickname"));
if (userInfo != null) {
clientCustomerInfo.put("headimg", userInfo.getString("headimg"));
clientCustomerInfo.put("nick_name", userInfo.getString("nickname"));
}
clientCustomerInfo.put("channel", order.getString("channel"));
clientCustomerInfo.put("tag", "不活跃用户");
@ -146,7 +150,6 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
generateTag(client_id);
}
private void generateTag(int client_id) {
JSONObject params = new JSONObject();
DateTime dt = new DateTime();

@ -1,6 +1,10 @@
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 javax.annotation.Resource;
@ -24,11 +28,26 @@ public class CustomerImpressionTask {
@Resource
private CustomerImpressionService customerImpressionService;
private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
@Scheduled(cron = "0 0 3 * * ?")
public void generate() {
List<JSONObject> clients = clientMapper.listValidClient();
clients.forEach(p -> {
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);
}
}
}

@ -265,7 +265,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text})
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}
or o.client_order_id = #{search_text})
</if>
<if test="text_type=='client_moniker'">
and p.client_moniker=#{search_text}
@ -345,7 +346,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} )
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}
or o.client_order_id = #{search_text})
</if>
<if test="text_type=='client_moniker'">
and p.client_moniker=#{search_text}
@ -362,6 +364,15 @@
<if test="text_type=='sys_trans_id'">
and t.system_transaction_id =#{search_text}
</if>
<if test="text_type=='remark'">
and o.order_detail like #{name_pattern}
</if>
<if test="text_type=='order_id'">
and t.order_id = #{search_text}
</if>
<if test="text_type=='client_order_id'">
and o.client_order_id = #{search_text}
</if>
</if>
<if test="org_ids!=null">and p.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
@ -555,15 +566,9 @@
o.client_id client_id,
o.customer_id customer_id,
o.channel channel,
cra.headimg alipay_headimg,
cra.nickname alipay_nickname,
cr.nickname wechat_nickname,
cr.headimg wechat_headimg,
max( o.confirm_time) confirm_time
from pmt_orders o
left join sys_customer_relation cr on cr.wepay_openid = o.customer_id
left join sys_customer_relation_alipay cra on cra.alipay_uid = o.customer_id
where o.customer_id is not null and o.channel is not null
and client_id = #{client_id}
<if test="confirm_time">

@ -1,9 +1,12 @@
package au.com.royalpay.payment.manage.apps.core.impls;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson.JSONObject;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -11,9 +14,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import javax.annotation.Resource;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
/**
* Created by wangning on 05/01/2018.
@ -26,6 +30,9 @@ public class CustomerImpressionImplTest {
private CustomerImpressionService customerImpression;
@Resource
private ClientMapper clientMapper;
private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
@Test
public void generate() throws Exception {
customerImpression.generate(9);
@ -34,9 +41,28 @@ public class CustomerImpressionImplTest {
@Test
public void generateAll(){
List<JSONObject> clients = clientMapper.listValidClient();
clients.forEach(p -> {
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"));
customerImpression.generate(p.getIntValue("client_id"));
});
generatePool.execute(task);
}
generatePool.shutdown();
try {
generatePool.awaitTermination(5, TimeUnit.HOURS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save