|
|
@@ -49,6 +49,7 @@ import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
@@ -289,7 +290,6 @@ public class CashController {
|
|
|
@ApiOperation("管理平台确认提现")
|
|
|
@ResponseBody
|
|
|
public Result alipayPay(@PathVariable Long cashId) {
|
|
|
-
|
|
|
CashOut one = cashOutService.selectById(cashId);
|
|
|
if (one == null) {
|
|
|
return Result.error("提现记录不存在!");
|
|
|
@@ -403,8 +403,6 @@ public class CashController {
|
|
|
return Result.error("转账失败!");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
private Result aliPay(CashOut one) {
|
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.CASH_OUT_LOCK, one.getUserId()));
|
|
|
try {
|
|
|
@@ -551,146 +549,6 @@ public class CashController {
|
|
|
return Result.error("系统繁忙,请稍后再试!");
|
|
|
}
|
|
|
|
|
|
- /*@RequestMapping(value = "/alipay/{cashId}", method = RequestMethod.POST)
|
|
|
- @ApiOperation("管理平台确认提现")
|
|
|
- @ResponseBody
|
|
|
- public Result alipayPay(@PathVariable Long cashId) {
|
|
|
- reentrantReadWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- //提现订单
|
|
|
- CashOut one = cashOutService.selectById(cashId);
|
|
|
- log.error("进来了!!!");
|
|
|
- //订单记录不为空
|
|
|
- if (one == null) {
|
|
|
- return Result.error("提现记录不存在!");
|
|
|
- }
|
|
|
- //订单状态不是待转帐
|
|
|
- if (one.getState()!=0) {
|
|
|
- return Result.error(9999, one.getZhifubaoName() + "转账失败!原因是用户已转账");
|
|
|
- }
|
|
|
- //订单编号为空
|
|
|
- if(StringUtils.isEmpty(one.getOrderNumber())){
|
|
|
- one.setOrderNumber(String.valueOf(System.currentTimeMillis()));
|
|
|
- }
|
|
|
- //配置文件对象
|
|
|
- CommonInfo commonInfo = commonInfoService.findOne(98);
|
|
|
-
|
|
|
- CommonInfo name = commonInfoService.findOne(12);
|
|
|
- if (commonInfo.getValue() != null && commonInfo.getValue().equals("1")) {
|
|
|
-
|
|
|
- try {
|
|
|
- CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
|
|
|
- certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); //gateway:支付宝网关(固定)https://openapi.alipay.com/gateway.do
|
|
|
- certAlipayRequest.setAppId(commonInfoService.findOne(63).getValue()); //APPID 即创建应用后生成,详情见创建应用并获取 APPID
|
|
|
- certAlipayRequest.setPrivateKey(commonInfoService.findOne(65).getValue()); //开发者应用私钥,由开发者自己生成
|
|
|
- certAlipayRequest.setFormat("json"); //参数返回格式,只支持 json 格式
|
|
|
- certAlipayRequest.setCharset(AliPayConstants.CHARSET); //请求和签名使用的字符编码格式,支持 GBK和 UTF-8
|
|
|
- certAlipayRequest.setSignType(AliPayConstants.SIGNTYPE); //商户生成签名字符串所使用的签名算法类型,目前支持 RSA2 和 RSA,推荐商家使用 RSA2。
|
|
|
- CommonInfo url = commonInfoService.findOne(200);
|
|
|
- certAlipayRequest.setCertPath(url.getValue()+"/appCertPublicKey.crt"); //应用公钥证书路径(app_cert_path 文件绝对路径)
|
|
|
- certAlipayRequest.setAlipayPublicCertPath(url.getValue()+"/alipayCertPublicKey_RSA2.crt"); //支付宝公钥证书文件路径(alipay_cert_path 文件绝对路径)
|
|
|
- certAlipayRequest.setRootCertPath(url.getValue()+"/alipayRootCert.crt"); //支付宝CA根证书文件路径(alipay_root_cert_path 文件绝对路径)
|
|
|
- AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest);
|
|
|
- AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
|
|
|
- request.setBizContent("{" +
|
|
|
- "\"out_biz_no\":\""+one.getOrderNumber()+"\"," + //订单编号
|
|
|
- "\"trans_amount\":"+new BigDecimal(one.getMoney())+"," + //转账金额
|
|
|
- "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," +
|
|
|
- "\"biz_scene\":\"DIRECT_TRANSFER\"," +
|
|
|
- "\"order_title\":\""+name.getValue() + "佣金结算"+"\"," +
|
|
|
- "\"payee_info\":{" +
|
|
|
- "\"identity\":\""+one.getZhifubao()+"\"," + //支付宝账号
|
|
|
- "\"identity_type\":\"ALIPAY_LOGON_ID\"," +
|
|
|
- "\"name\":\""+one.getZhifubaoName()+"\"," + //支付宝名称
|
|
|
- "}," +
|
|
|
- "\"remark\":\""+name.getValue() + "佣金结算"+"\"" +
|
|
|
- "}");
|
|
|
- AlipayFundTransUniTransferResponse response = null;
|
|
|
- response = alipayClient.certificateExecute(request);
|
|
|
- log.error("支付宝转账返回值:"+response.getBody());
|
|
|
- //如果转账成功
|
|
|
- if (AliPayConstants.SUCCESS_CODE.equalsIgnoreCase(response.getCode())) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- //修改状态为转账成功
|
|
|
- one.setState(1);
|
|
|
- //设置转账时间
|
|
|
- one.setOutAt(sdf.format(new Date()));
|
|
|
- //更新转账订单
|
|
|
- cashOutService.update(one);
|
|
|
- //查询用户
|
|
|
- UserEntity userInfo=userService.queryByUserId(one.getUserId());
|
|
|
- cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(), commonInfoService.findOne(19).getValue());
|
|
|
-
|
|
|
- return Result.success(one.getZhifubaoName() + "转账成功");
|
|
|
- } else {
|
|
|
- return Result.error(9999, one.getZhifubaoName() + "转账失败!" + response.getSubMsg());
|
|
|
- }
|
|
|
- } catch (AlipayApiException e) {
|
|
|
- log.error("零钱提现异常原因:" + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- return Result.error(9999, one.getZhifubaoName() + "转账失败!" + e.getMessage());
|
|
|
- }
|
|
|
- }else if (commonInfo.getValue() != null && commonInfo.getValue().equals("2")) {
|
|
|
- AlipayClient alipayClient = new DefaultAlipayClient(AliPayConstants.REQUEST_URL,
|
|
|
- commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), AliPayConstants.FORMAT,
|
|
|
- AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), AliPayConstants.SIGNTYPE);
|
|
|
- val aliPayWithdrawModel = AliPayWithdrawModel.builder()
|
|
|
- .out_biz_no(one.getOrderNumber())
|
|
|
- .amount(new BigDecimal(one.getMoney()))
|
|
|
- .payee_account(one.getZhifubao())
|
|
|
- .payee_real_name(one.getZhifubaoName())
|
|
|
- .payee_type(AliPayConstants.PAY_TYPE)
|
|
|
- .remark(name.getValue())
|
|
|
- .build();
|
|
|
- String json = JSON.toJSONString(aliPayWithdrawModel);
|
|
|
- //实例化连接对象
|
|
|
- AlipayFundTransToaccountTransferRequest withdrawRequest = new AlipayFundTransToaccountTransferRequest();
|
|
|
- withdrawRequest.setBizContent(json);
|
|
|
- try {
|
|
|
- AlipayFundTransToaccountTransferResponse response = alipayClient.execute(withdrawRequest);
|
|
|
- if (AliPayConstants.SUCCESS_CODE.equalsIgnoreCase(response.getCode())) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- //修改状态为转账成功
|
|
|
- one.setState(1);
|
|
|
- //设置转账时间
|
|
|
- one.setOutAt(sdf.format(new Date()));
|
|
|
- //更新转账订单
|
|
|
- cashOutService.update(one);
|
|
|
- //查询用户
|
|
|
- UserEntity userInfo=userService.queryByUserId(one.getUserId());
|
|
|
- cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(), commonInfoService.findOne(19).getValue());
|
|
|
- return Result.success(one.getZhifubaoName() + "转账成功");
|
|
|
- } else {
|
|
|
- return Result.error(9999, one.getZhifubaoName() + "转账失败!" + response.getSubMsg());
|
|
|
- }
|
|
|
- } catch (AlipayApiException e) {
|
|
|
- log.error("零钱提现异常原因:" + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- return Result.error(9999, one.getZhifubaoName() + "转账失败!" + e.getMessage());
|
|
|
-
|
|
|
- }
|
|
|
- }else{
|
|
|
- //人工转账后改变状态的
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Date now = new Date();
|
|
|
- one.setState(1);
|
|
|
- one.setOutAt(sdf.format(now));
|
|
|
- cashOutService.update(one);
|
|
|
- UserEntity userInfo=userService.queryByUserId(one.getUserId());
|
|
|
- cashOutService.cashOutSuccess(userInfo, one.getOutAt(), one.getMoney(), one.getZhifubao(),commonInfoService.findOne(19).getValue());
|
|
|
- return Result.success(one.getZhifubaoName() + "转账成功");
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- log.error("转账异常"+e.getMessage());
|
|
|
- }finally {
|
|
|
- reentrantReadWriteLock.writeLock().unlock();
|
|
|
- }
|
|
|
- return Result.error("系统繁忙,请稍后再试!");
|
|
|
- }
|
|
|
-*/
|
|
|
-
|
|
|
-
|
|
|
@RequestMapping(value = "/refund", method = RequestMethod.POST)
|
|
|
@ApiOperation("管理平台退款")
|
|
|
@ResponseBody
|
|
|
@@ -737,8 +595,11 @@ public class CashController {
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ @PostMapping(value = "confirm-cash/{cashId}")
|
|
|
+ @ApiOperation("确认提现")
|
|
|
+ @ResponseBody
|
|
|
+ public Result confirmCash(@PathVariable Long cashId) {
|
|
|
+ cashOutService.confirmCash(cashId);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
}
|