master
wangning 7 years ago
parent 7372c93190
commit 06b857eb51

@ -10,4 +10,6 @@ public interface OfeiServer {
void checkOrder(String orderId);
void phoneTopUp(String price, boolean quickTopUp, String topUpDelayTime, String phoneNumber);
}

@ -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);
}
}

@ -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})

@ -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 '流量';
}
}
});

Loading…
Cancel
Save