diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java index d232ac72e..104d20a87 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java @@ -55,23 +55,30 @@ public class CustomerImpressionImpl implements CustomerImpression { } JSONObject params = new JSONObject(); params.put("customer_id", customer_id); - JSONObject paymentInfos = new JSONObject(); + List paymentInfos = new ArrayList<>(); PageList ordersLast = orderMapper.listOrderByCustomer(params, new PageBounds(1, 1, Order.formString("create_time.desc"))); if (!CollectionUtils.isEmpty(ordersLast)) { JSONObject order = ordersLast.get(0); JSONObject paymentInfo = new JSONObject(); - paymentInfo.put("last_pay_time", DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss")); - paymentInfo.put("last_pay_location", lookupService.getLocation(order.getString("customer_ip")).city); - paymentInfos.put("last_payment_info",paymentInfo); + 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; + if(!StringUtils.isEmpty(city)){ + paymentInfo.put("pay_location", city); + } + + paymentInfos.add(paymentInfo); } PageList ordersFirst = orderMapper.listOrderByCustomer(params, new PageBounds(1, 1, Order.formString("create_time.asc"))); if (!CollectionUtils.isEmpty(ordersFirst)) { JSONObject order = ordersFirst.get(0); JSONObject paymentInfo = new JSONObject(); - paymentInfo.put("first_pay_time", DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss")); - paymentInfo.put("first_pay_location", lookupService.getLocation(order.getString("customer_ip")).city); - paymentInfos.put("first_payment_info",paymentInfo); + 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; + if(!StringUtils.isEmpty(city)){ + paymentInfo.put("pay_location", city); + } + paymentInfos.add(paymentInfo); } customer.put("payment_info",paymentInfos); return customer;