From 5f9b173fe6e59df3c4882e67796397c4c10428cd Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Wed, 25 Apr 2018 18:48:05 +0800 Subject: [PATCH] add ip location --- .../payment/manage/dev/web/IPController.java | 24 +++++++++++++++++++ .../static/commons/services/orderService.js | 7 +++++- .../commons/templates/order_detail.html | 10 +++++++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/dev/web/IPController.java diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/IPController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/IPController.java new file mode 100644 index 000000000..fb3c75895 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/IPController.java @@ -0,0 +1,24 @@ +package au.com.royalpay.payment.manage.dev.web; + +import com.alibaba.fastjson.JSONObject; +import com.maxmind.geoip.LookupService; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping(value = "/dev/ip") + +public class IPController { + @Resource + private LookupService lookupService; + + @RequestMapping(value = "/{ipAddr}", method = RequestMethod.GET) + public String getIpInfo(@PathVariable String ipAddr) { + String city = lookupService.getLocation(ipAddr).city; + return city; + } +} diff --git a/src/main/ui/static/commons/services/orderService.js b/src/main/ui/static/commons/services/orderService.js index b6fb25d7e..1c628772a 100644 --- a/src/main/ui/static/commons/services/orderService.js +++ b/src/main/ui/static/commons/services/orderService.js @@ -36,8 +36,13 @@ define(['../app'], function (app) { } } }]); - app.controller('orderDetailDialogCtrl', ['$scope', 'order', function ($scope, order) { + app.controller('orderDetailDialogCtrl', ['$scope', 'order','$http', function ($scope, order,$http) { $scope.order = order.data; + $scope.getPayLocation=function (ip) { + $http.get('/dev/ip/'+ip).then(function (res) { + $scope.pay_location = res.data; + }) + } }]); app.controller('orderDetailEditCtrl', ['$scope', '$http', 'commonDialog', 'order', function ($scope, $http, commonDialog,order) { $scope.order = order.data; diff --git a/src/main/ui/static/commons/templates/order_detail.html b/src/main/ui/static/commons/templates/order_detail.html index ae0bd21de..f077f56d2 100644 --- a/src/main/ui/static/commons/templates/order_detail.html +++ b/src/main/ui/static/commons/templates/order_detail.html @@ -75,7 +75,9 @@
-

+

+ {{order.customer_ip}}  查询地区 : {{pay_location}} +

@@ -128,6 +130,12 @@

+
+ +
+

+
+