|
|
@ -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.apps.core.CustomerImpressionService;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper;
|
|
|
|
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.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.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
@ -39,6 +41,10 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private LookupService lookupService;
|
|
|
|
private LookupService lookupService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private CustomerRelationAlipayMapper customerRelationAlipayMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private CustomerMapper customerMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject listPageble(CustomerImpressionQuery customerImpressionQuery) {
|
|
|
|
public JSONObject listPageble(CustomerImpressionQuery customerImpressionQuery) {
|
|
|
@ -50,12 +56,12 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject findOne(int client_id, String customer_id) {
|
|
|
|
public JSONObject findOne(int client_id, String customer_id) {
|
|
|
|
JSONObject customer = clientCustomersMapper.getClientCustomerWithNull(client_id, customer_id);
|
|
|
|
JSONObject customer = clientCustomersMapper.getClientCustomerWithNull(client_id, customer_id);
|
|
|
|
if(customer==null){
|
|
|
|
if (customer == null) {
|
|
|
|
throw new BadRequestException("customer info not exist");
|
|
|
|
throw new BadRequestException("customer info not exist");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
params.put("customer_id", customer_id);
|
|
|
|
params.put("customer_id", customer_id);
|
|
|
|
params.put("include_success_status",4);
|
|
|
|
params.put("include_success_status", 4);
|
|
|
|
List<JSONObject> paymentInfos = new ArrayList<>();
|
|
|
|
List<JSONObject> paymentInfos = new ArrayList<>();
|
|
|
|
PageList<JSONObject> ordersLast = orderMapper.listOrderByCustomer(params, new PageBounds(1, 1, Order.formString("create_time.desc")));
|
|
|
|
PageList<JSONObject> ordersLast = orderMapper.listOrderByCustomer(params, new PageBounds(1, 1, Order.formString("create_time.desc")));
|
|
|
|
if (!CollectionUtils.isEmpty(ordersLast)) {
|
|
|
|
if (!CollectionUtils.isEmpty(ordersLast)) {
|
|
|
@ -63,7 +69,7 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
JSONObject paymentInfo = new JSONObject();
|
|
|
|
JSONObject paymentInfo = new JSONObject();
|
|
|
|
paymentInfo.put("pay_time", DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
paymentInfo.put("pay_time", DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
String city = lookupService.getLocation(order.getString("customer_ip")).city;
|
|
|
|
String city = lookupService.getLocation(order.getString("customer_ip")).city;
|
|
|
|
if(!StringUtils.isEmpty(city)){
|
|
|
|
if (!StringUtils.isEmpty(city)) {
|
|
|
|
paymentInfo.put("pay_location", city);
|
|
|
|
paymentInfo.put("pay_location", city);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -76,12 +82,12 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
JSONObject paymentInfo = new JSONObject();
|
|
|
|
JSONObject paymentInfo = new JSONObject();
|
|
|
|
paymentInfo.put("pay_time", DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
paymentInfo.put("pay_time", DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
String city = lookupService.getLocation(order.getString("customer_ip")).city;
|
|
|
|
String city = lookupService.getLocation(order.getString("customer_ip")).city;
|
|
|
|
if(!StringUtils.isEmpty(city)){
|
|
|
|
if (!StringUtils.isEmpty(city)) {
|
|
|
|
paymentInfo.put("pay_location", city);
|
|
|
|
paymentInfo.put("pay_location", city);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paymentInfos.add(paymentInfo);
|
|
|
|
paymentInfos.add(paymentInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
customer.put("payment_info",paymentInfos);
|
|
|
|
customer.put("payment_info", paymentInfos);
|
|
|
|
return customer;
|
|
|
|
return customer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -90,7 +96,7 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
public void generate(int client_id) {
|
|
|
|
public void generate(int client_id) {
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("include_success_status",3);
|
|
|
|
params.put("include_success_status", 3);
|
|
|
|
PageList<JSONObject> lastRecord = clientCustomersMapper.listCustomerInfo(params, new PageBounds(1, 1, Order.formString("update_time.desc")));
|
|
|
|
PageList<JSONObject> lastRecord = clientCustomersMapper.listCustomerInfo(params, new PageBounds(1, 1, Order.formString("update_time.desc")));
|
|
|
|
if (!CollectionUtils.isEmpty(lastRecord)) {
|
|
|
|
if (!CollectionUtils.isEmpty(lastRecord)) {
|
|
|
|
params.put("confirm_time", lastRecord.get(0).getDate("update_time"));
|
|
|
|
params.put("confirm_time", lastRecord.get(0).getDate("update_time"));
|
|
|
@ -98,75 +104,72 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
List<JSONObject> orders = orderMapper.listAnalysisClientCustomer(params);
|
|
|
|
List<JSONObject> orders = orderMapper.listAnalysisClientCustomer(params);
|
|
|
|
Date now = new Date();
|
|
|
|
Date now = new Date();
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
if(StringUtils.isEmpty(order.getString("channel"))){
|
|
|
|
if (StringUtils.isEmpty(order.getString("channel"))) {
|
|
|
|
continue;
|
|
|
|
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"));
|
|
|
|
JSONObject clientCustomerInfo = clientCustomersMapper.getClientCustomerWithNull(client_id, order.getString("customer_id"));
|
|
|
|
if (clientCustomerInfo == null) {
|
|
|
|
if (clientCustomerInfo == null) {
|
|
|
|
JSONObject client_customer = new JSONObject();
|
|
|
|
JSONObject client_customer = new JSONObject();
|
|
|
|
client_customer.put("client_id", order.getIntValue("client_id"));
|
|
|
|
client_customer.put("client_id", order.getIntValue("client_id"));
|
|
|
|
client_customer.put("customer_id", order.getString("customer_id"));
|
|
|
|
client_customer.put("customer_id", order.getString("customer_id"));
|
|
|
|
client_customer.put("channel", order.getString("channel"));
|
|
|
|
client_customer.put("channel", order.getString("channel"));
|
|
|
|
client_customer.put("tag","不活跃用户");
|
|
|
|
client_customer.put("tag", "不活跃用户");
|
|
|
|
if (order.getString("alipay_headimg") == null) {
|
|
|
|
if (userInfo != null) {
|
|
|
|
client_customer.put("headimg", order.getString("wechat_headimg"));
|
|
|
|
client_customer.put("headimg", userInfo.getString("headimg"));
|
|
|
|
client_customer.put("nick_name", order.getString("wechat_nickname"));
|
|
|
|
client_customer.put("nick_name", userInfo.getString("nickname"));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
client_customer.put("headimg", order.getString("alipay_headimg"));
|
|
|
|
|
|
|
|
client_customer.put("nick_name", order.getString("alipay_nickname"));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
client_customer.put("payment_times", order.getIntValue("payment_times"));
|
|
|
|
client_customer.put("payment_times", order.getIntValue("payment_times"));
|
|
|
|
client_customer.put("total_amount", order.getBigDecimal("total_amount"));
|
|
|
|
client_customer.put("total_amount", order.getBigDecimal("total_amount"));
|
|
|
|
client_customer.put("update_time", now);
|
|
|
|
client_customer.put("update_time", now);
|
|
|
|
client_customer.put("last_payment_time",order.getDate("confirm_time"));
|
|
|
|
client_customer.put("last_payment_time", order.getDate("confirm_time"));
|
|
|
|
clientCustomersMapper.insert(client_customer);
|
|
|
|
clientCustomersMapper.insert(client_customer);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
clientCustomerInfo.put("payment_times", clientCustomerInfo.getIntValue("payment_times") + order.getIntValue("payment_times"));
|
|
|
|
clientCustomerInfo.put("payment_times", clientCustomerInfo.getIntValue("payment_times") + order.getIntValue("payment_times"));
|
|
|
|
BigDecimal total_amount = clientCustomerInfo.getBigDecimal("total_amount");
|
|
|
|
BigDecimal total_amount = clientCustomerInfo.getBigDecimal("total_amount");
|
|
|
|
if(total_amount!=null){
|
|
|
|
if (total_amount != null) {
|
|
|
|
clientCustomerInfo.put("total_amount", clientCustomerInfo.getBigDecimal("total_amount").add(order.getBigDecimal("total_amount")));
|
|
|
|
clientCustomerInfo.put("total_amount", clientCustomerInfo.getBigDecimal("total_amount").add(order.getBigDecimal("total_amount")));
|
|
|
|
}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 {
|
|
|
|
} else {
|
|
|
|
clientCustomerInfo.put("headimg", order.getString("alipay_headimg"));
|
|
|
|
clientCustomerInfo.put("total_amount", order.getBigDecimal("total_amount"));
|
|
|
|
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("channel", order.getString("channel"));
|
|
|
|
clientCustomerInfo.put("tag","不活跃用户");
|
|
|
|
clientCustomerInfo.put("tag", "不活跃用户");
|
|
|
|
clientCustomerInfo.put("update_time",now);
|
|
|
|
clientCustomerInfo.put("update_time", now);
|
|
|
|
clientCustomerInfo.put("last_payment_time",order.getDate("confirm_time"));
|
|
|
|
clientCustomerInfo.put("last_payment_time", order.getDate("confirm_time"));
|
|
|
|
clientCustomersMapper.update(clientCustomerInfo);
|
|
|
|
clientCustomersMapper.update(clientCustomerInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
generateTag(client_id);
|
|
|
|
generateTag(client_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void generateTag(int client_id) {
|
|
|
|
private void generateTag(int client_id){
|
|
|
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
DateTime dt = new DateTime();
|
|
|
|
DateTime dt = new DateTime();
|
|
|
|
dt = dt.minusMonths(5);
|
|
|
|
dt = dt.minusMonths(5);
|
|
|
|
params.put("confirm_time",dt.toDate());
|
|
|
|
params.put("confirm_time", dt.toDate());
|
|
|
|
params.put("client_id",client_id);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
List<JSONObject> orders = orderMapper.listAnalysisClientCustomer(params);
|
|
|
|
List<JSONObject> orders = orderMapper.listAnalysisClientCustomer(params);
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
int payment_times = order.getInteger("payment_times");
|
|
|
|
int payment_times = order.getInteger("payment_times");
|
|
|
|
JSONObject updateRecord = new JSONObject();
|
|
|
|
JSONObject updateRecord = new JSONObject();
|
|
|
|
updateRecord.put("client_id",order.getIntValue("client_id"));
|
|
|
|
updateRecord.put("client_id", order.getIntValue("client_id"));
|
|
|
|
updateRecord.put("customer_id",order.getString("customer_id"));
|
|
|
|
updateRecord.put("customer_id", order.getString("customer_id"));
|
|
|
|
if(payment_times<2){
|
|
|
|
if (payment_times < 2) {
|
|
|
|
updateRecord.put("tag","不活跃用户");
|
|
|
|
updateRecord.put("tag", "不活跃用户");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(payment_times>=2 && payment_times<10){
|
|
|
|
if (payment_times >= 2 && payment_times < 10) {
|
|
|
|
updateRecord.put("tag","潜力用户");
|
|
|
|
updateRecord.put("tag", "潜力用户");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(payment_times>=10){
|
|
|
|
if (payment_times >= 10) {
|
|
|
|
updateRecord.put("tag","忠实用户");
|
|
|
|
updateRecord.put("tag", "忠实用户");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clientCustomersMapper.update(updateRecord);
|
|
|
|
clientCustomersMapper.update(updateRecord);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -175,11 +178,11 @@ public class CustomerImpressionServiceImpl implements CustomerImpressionService
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void modifyNameRemark(int client_id, String customer_id, String name_remark) {
|
|
|
|
public void modifyNameRemark(int client_id, String customer_id, String name_remark) {
|
|
|
|
JSONObject clientCustomerInfo = clientCustomersMapper.getClientCustomer(client_id,customer_id);
|
|
|
|
JSONObject clientCustomerInfo = clientCustomersMapper.getClientCustomer(client_id, customer_id);
|
|
|
|
if(clientCustomerInfo==null){
|
|
|
|
if (clientCustomerInfo == null) {
|
|
|
|
throw new NotFoundException("customer not found");
|
|
|
|
throw new NotFoundException("customer not found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clientCustomerInfo.put("name_remak",name_remark);
|
|
|
|
clientCustomerInfo.put("name_remak", name_remark);
|
|
|
|
clientCustomersMapper.update(clientCustomerInfo);
|
|
|
|
clientCustomersMapper.update(clientCustomerInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|