|
|
@ -38,14 +38,16 @@ import javax.annotation.Resource;
|
|
|
|
import javax.validation.Validator;
|
|
|
|
import javax.validation.Validator;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.RECHARGE;
|
|
|
|
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.*;
|
|
|
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
|
|
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -134,19 +136,35 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
|
|
|
paramMap.put("alipay_cert_path_string", keyContent1);
|
|
|
|
paramMap.put("alipay_cert_path_string", keyContent1);
|
|
|
|
paramMap.put("alipay_root_cert_path_string", keyContent2);
|
|
|
|
paramMap.put("alipay_root_cert_path_string", keyContent2);
|
|
|
|
paramMap.put("remark", "余额提现到支付宝");
|
|
|
|
paramMap.put("remark", "余额提现到支付宝");
|
|
|
|
paramMap.put("out_biz_no", "111222333");
|
|
|
|
paramMap.put("out_biz_no", new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())+"-"+withdraw.getId());
|
|
|
|
paramMap.put("account", "13233904609");//账号
|
|
|
|
paramMap.put("account", withdraw.getAccountNo());//账号
|
|
|
|
paramMap.put("name", "马腾达");
|
|
|
|
paramMap.put("name", withdraw.getName());
|
|
|
|
paramMap.put("amount", "0.1");
|
|
|
|
paramMap.put("amount", BigDecimal.valueOf(withdraw.getPrice()).subtract(BigDecimal.valueOf(withdraw.getFeePrice())).divide(BigDecimal.valueOf(100)));
|
|
|
|
String result= HttpUtil.post(gateway, paramMap);
|
|
|
|
String result= HttpUtil.post(gateway, JSON.toJSONString(paramMap));
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
|
|
|
|
|
if(jsonObject.containsKey("msg")){
|
|
|
|
|
|
|
|
if(ObjectUtil.equal("success",jsonObject.getString("msg"))){
|
|
|
|
|
|
|
|
withdraw.setStatus(11);
|
|
|
|
|
|
|
|
withdraw.setAuditTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
withdraw.setStatus(21);
|
|
|
|
|
|
|
|
withdraw.setAuditTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
//提现失败返还余额
|
|
|
|
|
|
|
|
PayWalletDTO orCreateWallet = payWalletApi.getOrCreateWallet(withdraw.getUserId(), 1);
|
|
|
|
|
|
|
|
payWalletApi.addWalletBalance(orCreateWallet.getId(),withdraw.getId()+"",WITHDRAW_LOSE,withdraw.getPrice());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
brokerageWithdrawMapper.updateById(withdraw);
|
|
|
|
System.out.println(result);
|
|
|
|
System.out.println(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO 疯狂:调用转账接口
|
|
|
|
// TODO 疯狂:调用转账接口
|
|
|
|
} else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) {
|
|
|
|
} else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) {
|
|
|
|
templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT;
|
|
|
|
//提现失败返还余额
|
|
|
|
// 3.2 驳回时需要退还用户佣金
|
|
|
|
PayWalletDTO orCreateWallet = payWalletApi.getOrCreateWallet(withdraw.getUserId(), 1);
|
|
|
|
brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT,
|
|
|
|
payWalletApi.addWalletBalance(orCreateWallet.getId(),withdraw.getId()+"",WITHDRAW_REJECT,withdraw.getPrice());
|
|
|
|
String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle());
|
|
|
|
withdraw.setStatus(20);
|
|
|
|
|
|
|
|
withdraw.setAuditTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
brokerageWithdrawMapper.updateById(withdraw);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new IllegalArgumentException("不支持的提现状态:" + status);
|
|
|
|
throw new IllegalArgumentException("不支持的提现状态:" + status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|