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