|
|
package com.yohoufo.user.controller.wallet;
|
|
|
|
|
|
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.service.model.uic.request.UserSmsSendReqBO;
|
|
|
import com.yoho.service.model.wallet.request.WalletChangeBO;
|
|
|
import com.yoho.tools.common.beans.ApiResponse;
|
|
|
import com.yohoufo.common.annotation.IgnoreSession;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.interceptor.RemoteIPInterceptor;
|
|
|
import com.yohoufo.common.lock.RedisLock;
|
|
|
import com.yohoufo.common.lock.RedisLockFactory;
|
|
|
import com.yohoufo.user.requestVO.UserSmsSendReqVO;
|
|
|
import com.yohoufo.user.requestVO.WalletChangeVO;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -17,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
public class WalletChangeController {
|
...
|
...
|
@@ -26,6 +32,9 @@ public class WalletChangeController { |
|
|
@Autowired
|
|
|
private ServiceCaller serviceCaller;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisLockFactory redisLockFactory;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 钱包提现
|
...
|
...
|
@@ -34,13 +43,24 @@ public class WalletChangeController { |
|
|
*/
|
|
|
|
|
|
@RequestMapping(params = "method=ufo.wallet.assertWithdraw")
|
|
|
public ApiResponse assetWithdraw( WalletChangeVO walletChangeVO){
|
|
|
public ApiResponse assetWithdraw(WalletChangeVO walletChangeVO) {
|
|
|
logger.info("enter ufo.wallet.assertWithdraw with param {}", walletChangeVO);
|
|
|
WalletChangeBO reqBO = new WalletChangeBO();
|
|
|
BeanUtils.copyProperties(walletChangeVO, reqBO);
|
|
|
String ip = RemoteIPInterceptor.getRemoteIP();
|
|
|
reqBO.setIp(ip);
|
|
|
return serviceCaller.call("wallet.assetWithdraw", reqBO, ApiResponse.class);
|
|
|
RedisLock lock = redisLockFactory.newLock(RedisKeyBuilder.newInstance()
|
|
|
.appendFixed("ufo:wallet:assertWithdraw:lock:")
|
|
|
.appendVar(walletChangeVO.getUid() + "-" + walletChangeVO.getVerifyCode()), 5, TimeUnit.SECONDS);
|
|
|
if (lock.tryLock()) {
|
|
|
try {
|
|
|
WalletChangeBO reqBO = new WalletChangeBO();
|
|
|
BeanUtils.copyProperties(walletChangeVO, reqBO);
|
|
|
String ip = RemoteIPInterceptor.getRemoteIP();
|
|
|
reqBO.setIp(ip);
|
|
|
return serviceCaller.call("wallet.assetWithdraw", reqBO, ApiResponse.class);
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
}
|
|
|
} else {
|
|
|
throw new UfoServiceException(400, "钱包提现处理中,稍后再试");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|