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/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/web/PhoneTopUpController.java b/src/main/java/au/com/royalpay/payment/manage/ofei/web/PhoneTopUpController.java index 5c005f661..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,7 +1,7 @@ package au.com.royalpay.payment.manage.ofei.web; import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery; -import au.com.royalpay.payment.manage.ofei.core.OfeiClient; +import au.com.royalpay.payment.manage.ofei.core.OfeiServer; import au.com.royalpay.payment.manage.ofei.core.PhoneTopUpService; import com.alibaba.fastjson.JSONObject; @@ -20,13 +20,13 @@ 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 recharge(@RequestParam String phoneNumber, @RequestParam String amount) { - ofeiClient.phoneTopUp(amount,true,null,phoneNumber); + ofeiServer.phoneTopUp(amount,true,null,phoneNumber); } @RequestMapping(value = "/list",method = {RequestMethod.GET, RequestMethod.GET}) diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index 14408ea6f..4d201ef60 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -130,9 +130,9 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu return function (status) { switch (status + '') { case '1': - return 'telephone fare'; + return '话费充值'; case '2': - return 'data usage'; + return '流量'; } } });