diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java index 44c521091..3077394ac 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java @@ -1,10 +1,12 @@ package au.com.royalpay.payment.manage.mappers.ofei; -import com.alibaba.fastjson.JSONObject; +import java.util.List; import org.apache.ibatis.annotations.Param; -import java.util.List; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; @@ -26,4 +28,5 @@ public interface TopUpOrderMapper { List findOrderIdByStatus(@Param("status") String status); + PageList listPageable(JSONObject jsonObject, PageBounds pageBounds); } diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/bean/PhoneTopUpQuery.java b/src/main/java/au/com/royalpay/payment/manage/ofei/bean/PhoneTopUpQuery.java new file mode 100644 index 000000000..3f10d8daa --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/bean/PhoneTopUpQuery.java @@ -0,0 +1,67 @@ +package au.com.royalpay.payment.manage.ofei.bean; + +import com.alibaba.fastjson.JSONObject; + +/** + * Created by wangning on 2018/1/3. + */ +public class PhoneTopUpQuery { + + private String status; + + private int amount; + + private String phone; + + private int page = 1; + + private int limit = 10; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public JSONObject toParam(){ + JSONObject param = new JSONObject(); + param.put("status",this.status); + param.put("amount",this.amount); + param.put("customer_number",this.phone); + return param; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/core/OfeiServer.java b/src/main/java/au/com/royalpay/payment/manage/ofei/core/OfeiServer.java index 842cc7400..a9b1428c6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/ofei/core/OfeiServer.java +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/core/OfeiServer.java @@ -10,4 +10,6 @@ public interface OfeiServer { void checkOrder(String orderId); + void phoneTopUp(String price, boolean quickTopUp, String topUpDelayTime, String phoneNumber); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/core/PhoneTopUpService.java b/src/main/java/au/com/royalpay/payment/manage/ofei/core/PhoneTopUpService.java new file mode 100644 index 000000000..c8240ed22 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/core/PhoneTopUpService.java @@ -0,0 +1,14 @@ +package au.com.royalpay.payment.manage.ofei.core; + +import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery; + +import com.alibaba.fastjson.JSONObject; + + +/** + * Created by wangning on 2018/1/3. + */ +public interface PhoneTopUpService { + + JSONObject listPageable(PhoneTopUpQuery phoneTopUpQuery); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiServceImpl.java b/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiServceImpl.java index f4ab6b2bb..6cf306b3d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiServceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiServceImpl.java @@ -1,8 +1,13 @@ package au.com.royalpay.payment.manage.ofei.core.impl; +import java.util.concurrent.TimeUnit; + import javax.annotation.Resource; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.StringUtils; import org.dom4j.Element; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSONObject; @@ -10,6 +15,7 @@ import com.alibaba.fastjson.JSONObject; import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper; import au.com.royalpay.payment.manage.ofei.core.OfeiClient; import au.com.royalpay.payment.manage.ofei.core.OfeiServer; +import au.com.royalpay.payment.tools.exceptions.ForbiddenException; /** * Created by wangning on 2017/12/8. @@ -20,6 +26,8 @@ public class OfeiServceImpl implements OfeiServer { private TopUpOrderMapper topUpOrderMapper; @Resource private OfeiClient ofeiClient; + @Resource + private StringRedisTemplate stringRedisTemplate; @Override public void checkOrderForNotify(JSONObject param) { @@ -74,4 +82,16 @@ public class OfeiServceImpl implements OfeiServer { topUpOrderMapper.update(order); } + @Override + public void phoneTopUp(String price, boolean quickTopUp, String topUpDelayTime, String phoneNumber) { + String reidsCheckCodeKey = "topup"+phoneNumber; + String value = stringRedisTemplate.boundValueOps(reidsCheckCodeKey).get(); + if (!StringUtils.isEmpty(value)) { + throw new ForbiddenException("A phone number can only be recharged in 10 minutes"); + } + ofeiClient.phoneTopUp(price,quickTopUp,topUpDelayTime,phoneNumber); + String bindId = RandomStringUtils.random(6, false, true); + stringRedisTemplate.boundValueOps(reidsCheckCodeKey).set(bindId, 10, TimeUnit.MINUTES); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/PhoneTopUpServieImpl.java b/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/PhoneTopUpServieImpl.java new file mode 100644 index 000000000..5cb6d6fdb --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/PhoneTopUpServieImpl.java @@ -0,0 +1,29 @@ +package au.com.royalpay.payment.manage.ofei.core.impl; + +import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper; +import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery; +import au.com.royalpay.payment.manage.ofei.core.PhoneTopUpService; +import au.com.royalpay.payment.tools.utils.PageListUtils; + +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 org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * Created by wangning on 2018/1/3. + */ +@Service +public class PhoneTopUpServieImpl implements PhoneTopUpService { + @Resource + private TopUpOrderMapper topUpOrderMapper; + @Override + public JSONObject listPageable(PhoneTopUpQuery phoneTopUpQuery) { + PageList topUpOrders = topUpOrderMapper.listPageable(phoneTopUpQuery.toParam(),new PageBounds(phoneTopUpQuery.getPage(), phoneTopUpQuery.getLimit(), Order.formString("create_time.desc"))); + return PageListUtils.buildPageListResult(topUpOrders); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/web/PhoneTopUpController.java b/src/main/java/au/com/royalpay/payment/manage/ofei/web/PhoneTopUpController.java index 896f2712c..3c68e9e41 100644 --- a/src/main/java/au/com/royalpay/payment/manage/ofei/web/PhoneTopUpController.java +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/web/PhoneTopUpController.java @@ -1,6 +1,10 @@ package au.com.royalpay.payment.manage.ofei.web; -import au.com.royalpay.payment.manage.ofei.core.OfeiClient; +import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery; +import au.com.royalpay.payment.manage.ofei.core.OfeiServer; +import au.com.royalpay.payment.manage.ofei.core.PhoneTopUpService; + +import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -16,10 +20,18 @@ import javax.annotation.Resource; @RequestMapping("/phone_top_up") public class PhoneTopUpController { @Resource - private OfeiClient ofeiClient; + private OfeiServer ofeiServer; + @Resource + private PhoneTopUpService phoneTopUpService; @RequestMapping(value = "/recharge",method = {RequestMethod.GET, RequestMethod.POST}) - public void listNotices(@RequestParam String phoneNumber, @RequestParam String amount) { - ofeiClient.phoneTopUp(amount,true,null,phoneNumber); + public void recharge(@RequestParam String phoneNumber, @RequestParam String amount) { + ofeiServer.phoneTopUp(amount,true,null,phoneNumber); } + + @RequestMapping(value = "/list",method = {RequestMethod.GET, RequestMethod.GET}) + public JSONObject list(PhoneTopUpQuery phoneTopUpQuery) { + return phoneTopUpService.listPageable(phoneTopUpQuery); + } + } \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml index b97315ef6..af1603283 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml @@ -1,5 +1,6 @@ - + + \ No newline at end of file diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index 7e015a543..4d201ef60 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -45,6 +45,8 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu }]); app.controller('CmsPhonetopupCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) { + $scope.queryParams = {}; + $scope.pagination = {}; $scope.topUp = function () { var params = angular.copy($scope.params); $http.get('/phone_top_up/recharge',{params: params}).then(function (resp) { @@ -53,6 +55,25 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu alert(resp.data.message); }) } + + $scope.listTopUpOrders = function (page) { + var params = angular.copy($scope.queryParams); + params.page = page || $scope.pagination.page || 1; + if(params.amount==''|| params.amount==null){ + delete params.amount; + } + if(params.phone==''|| params.phone==null){ + delete params.phone; + } + if(params.status==''|| params.status==null){ + delete params.status; + } + $http.get('/phone_top_up/list',{params: params}).then(function (resp) { + $scope.orders = resp.data.data; + $scope.pagination = resp.data.pagination; + }) + }; + $scope.listTopUpOrders(1); }]); app.controller('cmsArticleListCtrl', ['$scope', '$http', '$stateParams', function ($scope, $http, $stateParams) { @@ -103,5 +124,37 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu app.controller('cmsArticlePreviewCtrl', ['$scope', 'article', function ($scope, article) { $scope.article = article.data; - }]) + }]); + + app.filter('topUpType', function () { + return function (status) { + switch (status + '') { + case '1': + return '话费充值'; + case '2': + return '流量'; + } + } + }); + + app.filter('topUpStatus', function () { + return function (status) { + switch (status + '') { + case '0': + return 'Creating'; + case '1': + return 'Success'; + case '10': + return 'Wait for success'; + case '20': + return 'fail'; + case '30': + return 'refund'; + case '99': + return 'System Error'; + case '100': + return 'Ofei Error'; + } + } + }); }); \ No newline at end of file diff --git a/src/main/ui/static/cms/templates/phone_top_up.html b/src/main/ui/static/cms/templates/phone_top_up.html index 726fbca90..9940a0ae3 100644 --- a/src/main/ui/static/cms/templates/phone_top_up.html +++ b/src/main/ui/static/cms/templates/phone_top_up.html @@ -18,14 +18,17 @@
- +
- +
- +
@@ -33,4 +36,103 @@ + +
+
+
+
+
+
+ +
+

+ All | + Success | + Wating | + Refund | + fail | + Error +

+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
Order IDTypeAmountPhoneStatusCreate TimeDetail
+ {{order.id}} + + {{order.amount}} + {{order.customer_number}}{{order.create_time}} {{order.detail}}
+ +
+
+ +
+
Total Records:{{pagination.totalCount}};Total + Pages:{{pagination.totalPages}} +
+
+
+
+
+
+
+
+