|
|
@@ -95,17 +95,17 @@ public class WithdrawService extends SuperService {
|
|
|
/**
|
|
|
* 查询可提现余额
|
|
|
*/
|
|
|
- public Object queryWithdrawAmount(String projectOid, String oid){
|
|
|
- if (StringUtils.isBlank(projectOid)){
|
|
|
+ public Object queryWithdrawAmount(String projectOid, String oid) {
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
projectOid = getCurrentProjectOid();
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(oid)){
|
|
|
+ if (StringUtils.isBlank(oid)) {
|
|
|
oid = getCurrentOid();
|
|
|
}
|
|
|
PayAccount settleAccount = payAccountService.getOrgChildren(projectOid, oid, PaymentChannelType.Settle);
|
|
|
ResultContent<GeneralLedgerQueryModel> ledgerQueryModelResultContent = generalLedgerService.get(settleAccount.getLedgerId());
|
|
|
- if (!ledgerQueryModelResultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!ledgerQueryModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("提现账本数据不存在");
|
|
|
}
|
|
|
return ResultContent.buildContent(ledgerQueryModelResultContent.getContent().getBalance());
|
|
|
@@ -114,12 +114,12 @@ public class WithdrawService extends SuperService {
|
|
|
/**
|
|
|
* 查询当前支付渠道可提现余额
|
|
|
*/
|
|
|
- public com.github.microservice.net.ResultContent queryWithdrawAmount(String projectOid, String oid, PaymentType paymentType){
|
|
|
- if (StringUtils.isBlank(projectOid)){
|
|
|
+ public com.github.microservice.net.ResultContent<Long> queryWithdrawAmount(String projectOid, String oid, PaymentType paymentType) {
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
projectOid = getCurrentProjectOid();
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(oid)){
|
|
|
+ if (StringUtils.isBlank(oid)) {
|
|
|
oid = getCurrentOid();
|
|
|
}
|
|
|
return queryWithdrawAmountByPaymentType(projectOid, oid, paymentType);
|
|
|
@@ -132,19 +132,19 @@ public class WithdrawService extends SuperService {
|
|
|
@SneakyThrows
|
|
|
private com.github.microservice.net.ResultContent<Long> queryWithdrawAmountByPaymentType(String projectOid, String oid, PaymentType paymentType) {
|
|
|
|
|
|
- if (paymentType.equals(PaymentType.UnionFrictionlessPay)){
|
|
|
+ if (paymentType.equals(PaymentType.UnionFrictionlessPay)) {
|
|
|
String orgAccount = orgPayAccountService.queryOgPayAccount(oid, paymentType);
|
|
|
String projectAccount = orgPayAccountService.queryOgPayAccount(projectOid, paymentType);
|
|
|
|
|
|
ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(orgAccount);
|
|
|
|
|
|
- if (!accountModelResultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(accountModelResultContent.getMsg());
|
|
|
}
|
|
|
|
|
|
- ChinaumsSenselessConf conf = (ChinaumsSenselessConf)accountModelResultContent.getContent().getConf();
|
|
|
+ ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
String withdrawMchId = conf.getWithdrawMchId();
|
|
|
- if (StringUtils.isEmpty(withdrawMchId)){
|
|
|
+ if (StringUtils.isEmpty(withdrawMchId)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("未配置提现商户号");
|
|
|
}
|
|
|
|
|
|
@@ -152,12 +152,12 @@ public class WithdrawService extends SuperService {
|
|
|
parameter.setAccountName(projectAccount);
|
|
|
parameter.setMeta(Map.of("mchntNo", withdrawMchId));
|
|
|
ResultContent<Object> resultContent = senselessPayService.withdrawAmountQuery(parameter);
|
|
|
- if (!resultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!resultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(resultContent.getMsg());
|
|
|
}
|
|
|
String data = JsonUtil.toJson(resultContent.getContent());
|
|
|
Map map = JsonUtil.toObject(data, Map.class);
|
|
|
- if (!map.get("respCode").equals("000000")){
|
|
|
+ if (!map.get("respCode").equals("000000")) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail((String) map.get("respDesc"));
|
|
|
}
|
|
|
return com.github.microservice.net.ResultContent.buildContent(Long.parseLong((String) map.get("tzWithdrawAmt")));
|
|
|
@@ -168,7 +168,7 @@ public class WithdrawService extends SuperService {
|
|
|
queryTransactionLogModel.setFilter(Map.of("meta.paymentType", paymentType));
|
|
|
queryTransactionLogModel.setGeneralLedgerId(new String[]{settleAccount.getLedgerId()});
|
|
|
ResultContent<TransactionLogAggregateRetModel> aggregateRetModelResultContent = transactionLogService.aggregateAmount(queryTransactionLogModel);
|
|
|
- if (!aggregateRetModelResultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!aggregateRetModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(aggregateRetModelResultContent.getMsg());
|
|
|
}
|
|
|
long amount = aggregateRetModelResultContent.getContent().getStatistics().getCreditCount() + aggregateRetModelResultContent.getContent().getStatistics().getDebitCount();
|
|
|
@@ -178,44 +178,44 @@ public class WithdrawService extends SuperService {
|
|
|
/**
|
|
|
* 发起提现
|
|
|
*/
|
|
|
- public Object withdrawApply(WithdrawParam param){
|
|
|
+ public Object withdrawApply(WithdrawParam param) {
|
|
|
String projectOid = param.getProjectOid();
|
|
|
String oid = param.getOid();
|
|
|
String userId = param.getUserId();
|
|
|
PaymentType paymentType = param.getPaymentType();
|
|
|
BigDecimal amount = param.getAmount();
|
|
|
|
|
|
- if (StringUtils.isBlank(projectOid)){
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
projectOid = getCurrentProjectOid();
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(oid)){
|
|
|
+ if (StringUtils.isBlank(oid)) {
|
|
|
oid = getCurrentOid();
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(userId)){
|
|
|
+ if (StringUtils.isBlank(userId)) {
|
|
|
userId = getCurrentUserId();
|
|
|
}
|
|
|
|
|
|
List<UserAccount> userAccounts = userAccountService.getUserAccounts(List.of(userId));
|
|
|
- if (userAccounts==null || userAccounts.isEmpty()){
|
|
|
+ if (userAccounts == null || userAccounts.isEmpty()) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("用户信息不存在");
|
|
|
}
|
|
|
|
|
|
//校验提现金额是否大约可以提现金额
|
|
|
com.github.microservice.net.ResultContent<Long> resultContent = queryWithdrawAmountByPaymentType(projectOid, oid, paymentType);
|
|
|
|
|
|
- if (!resultContent.getState().equals(com.github.microservice.net.ResultState.Success)){
|
|
|
+ if (!resultContent.getState().equals(com.github.microservice.net.ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(resultContent.getMsg());
|
|
|
}
|
|
|
Long waitAmount = resultContent.getContent();
|
|
|
- if (amount.compareTo(new BigDecimal(waitAmount))>0){
|
|
|
+ if (amount.compareTo(new BigDecimal(waitAmount)) > 0) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("大于可提现金额");
|
|
|
}
|
|
|
//获取支付配置 为线上或者线下
|
|
|
ProjectMainPaySetting projectMainPaySetting = projectMainPaySettingService.getProjectMainPaySetting(projectOid, paymentType);
|
|
|
OrgPayConfigModel orgPayConfig = projectPaySettingService.getOrgPayConfig(projectOid, oid, paymentType);
|
|
|
- if (null == orgPayConfig || null == projectMainPaySetting){
|
|
|
+ if (null == orgPayConfig || null == projectMainPaySetting) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("支付产品未配置完成");
|
|
|
}
|
|
|
//支付中心划账:机构-已结算子账户- 机构-已冻结金额+
|
|
|
@@ -243,7 +243,7 @@ public class WithdrawService extends SuperService {
|
|
|
destinationTransaction.setMeta(Map.of("paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "提现冻结"));
|
|
|
transferModel.setDestinations(new TransferTransactionsModel.GeneralLedgerTransaction[]{destinationTransaction});
|
|
|
ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferModel);
|
|
|
- if (!transfer.getState().equals(ResultState.Success)){
|
|
|
+ if (!transfer.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(transfer.getMsg());
|
|
|
}
|
|
|
//创建流程
|
|
|
@@ -269,24 +269,33 @@ public class WithdrawService extends SuperService {
|
|
|
* 审核
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public com.github.microservice.net.ResultContent withdraw(ProcessWithdrawParam param){
|
|
|
+ public com.github.microservice.net.ResultContent withdraw(ProcessWithdrawParam param) {
|
|
|
String userId = param.getUserId();
|
|
|
- if (StringUtils.isBlank(userId)){
|
|
|
+ if (StringUtils.isBlank(userId)) {
|
|
|
userId = getCurrentUserId();
|
|
|
}
|
|
|
+ String projectOid = getCurrentProjectOid();
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("当前项目oid为空");
|
|
|
+ }
|
|
|
+ boolean isProjectManager = userOrgPermissService.userIsProjectManager(projectOid, userId);
|
|
|
+ if (!isProjectManager) {
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("无操作权限");
|
|
|
+ }
|
|
|
+
|
|
|
List<UserAccount> userAccounts = userAccountService.getUserAccounts(List.of(userId));
|
|
|
- if (userAccounts==null || userAccounts.isEmpty()){
|
|
|
+ if (userAccounts == null || userAccounts.isEmpty()) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("用户信息不存在");
|
|
|
}
|
|
|
//TODO 判断权限?
|
|
|
|
|
|
//获取提现订单数据
|
|
|
WithdrawOrder withdrawOrder = withdrawOrderDao.findTop1ById(param.getId());
|
|
|
- if (withdrawOrder == null){
|
|
|
+ if (withdrawOrder == null) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("数据不存在");
|
|
|
}
|
|
|
//判断状态是否为待审核
|
|
|
- if (!withdrawOrder.getAuditStatus().equals(AuditStatus.Wait)){
|
|
|
+ if (!withdrawOrder.getAuditStatus().equals(AuditStatus.Wait)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("只能操作处理中的订单");
|
|
|
}
|
|
|
|
|
|
@@ -298,24 +307,24 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.setAttachFile(param.getAttachFile());
|
|
|
|
|
|
//TODO 审批通过, 判断当前可提现余额是否大于提现订单金额
|
|
|
- if (param.getStatus().equals(AuditStatus.Success)){//审批通过
|
|
|
+ if (param.getStatus().equals(AuditStatus.Success)) {//审批通过
|
|
|
withdrawOrder.setAuditStatus(AuditStatus.Success);
|
|
|
withdrawOrder.setSort(AuditStatus.Success.getSort());
|
|
|
//判断是否线上提现,调用支付渠道对应的提现接口
|
|
|
if (withdrawOrder.getWithdrawMethodType().equals(WithdrawMethodType.OnLine)) {
|
|
|
return onlineWithdraw(withdrawOrder, userAccounts.get(0), settleAccount, withdrawFrozenAccount);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//划账,机构已冻结金额- 项目无感支付+
|
|
|
TransferTransactionsModel transferTransactionsModel = buildTransferModel(projectAccount, withdrawFrozenAccount, withdrawOrder.getOrderNo(),
|
|
|
withdrawOrder.getAmount(), TransactionType.Withdrawal,
|
|
|
Map.of("paymentType", withdrawOrder.getPaymentType(), "paymentChannelType", withdrawOrder.getPaymentType().getChannelType(), "description", "提现"));
|
|
|
ResultContent<List<TransactionLogModel>> transferResult = transactionLogService.transfer(transferTransactionsModel);
|
|
|
- if (!transferResult.getState().equals(ResultState.Success)){
|
|
|
+ if (!transferResult.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(transferResult.getMsg());
|
|
|
}
|
|
|
withdrawOrder.setWithdrawTransactionLogs(transferResult.getContent());
|
|
|
}
|
|
|
- }else if (param.getStatus().equals(AuditStatus.Fail)){ //审批拒绝
|
|
|
+ } else if (param.getStatus().equals(AuditStatus.Fail)) { //审批拒绝
|
|
|
withdrawOrder.setAuditStatus(AuditStatus.Fail);
|
|
|
withdrawOrder.setSort(AuditStatus.Fail.getSort());
|
|
|
//划账退回金额: 机构已冻结金额- 机构已结算 +
|
|
|
@@ -323,7 +332,7 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.getAmount(), TransactionType.WithdrawRefund,
|
|
|
Map.of("paymentType", withdrawOrder.getPaymentType(), "paymentChannelType", withdrawOrder.getPaymentType().getChannelType(), "description", "提现退回"));
|
|
|
ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferTransactionsModel);
|
|
|
- if (!transfer.getState().equals(ResultState.Success)){
|
|
|
+ if (!transfer.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("余额退回失败");
|
|
|
}
|
|
|
withdrawOrder.setWithdrawTransactionLogs(transfer.getContent());
|
|
|
@@ -339,39 +348,39 @@ public class WithdrawService extends SuperService {
|
|
|
|
|
|
@SneakyThrows
|
|
|
private com.github.microservice.net.ResultContent onlineWithdraw(WithdrawOrder withdrawOrder, UserAccount userAccount, PayAccount settleAccount, PayAccount withdrawFrozenAccount) {
|
|
|
- switch (withdrawOrder.getPaymentType()){
|
|
|
- case UnionFrictionlessPay-> {
|
|
|
+ switch (withdrawOrder.getPaymentType()) {
|
|
|
+ case UnionFrictionlessPay -> {
|
|
|
String orgAccount = orgPayAccountService.queryOgPayAccount(withdrawOrder.getOid(), PaymentType.UnionFrictionlessPay);
|
|
|
String projectPayAccount = orgPayAccountService.queryOgPayAccount(withdrawOrder.getProjectOid(), PaymentType.UnionFrictionlessPay);
|
|
|
|
|
|
ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(orgAccount);
|
|
|
|
|
|
- if (!accountModelResultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(accountModelResultContent.getMsg());
|
|
|
}
|
|
|
|
|
|
- ChinaumsSenselessConf conf = (ChinaumsSenselessConf)accountModelResultContent.getContent().getConf();
|
|
|
+ ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
String withdrawMchId = conf.getWithdrawMchId();
|
|
|
- if (StringUtils.isEmpty(withdrawMchId)){
|
|
|
+ if (StringUtils.isEmpty(withdrawMchId)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("未配置提现商户号");
|
|
|
}
|
|
|
|
|
|
PayProductParameter<Object> parameter = new PayProductParameter<>();
|
|
|
parameter.setAccountName(projectPayAccount);
|
|
|
- parameter.setMeta(Map.of("mchntNo", withdrawMchId,"orderNo", withdrawOrder.getOrderNo(), "amount", withdrawOrder.getAmount().toString()));
|
|
|
+ parameter.setMeta(Map.of("mchntNo", withdrawMchId, "orderNo", withdrawOrder.getOrderNo(), "amount", withdrawOrder.getAmount().toString()));
|
|
|
ResultContent<Object> withdrawRet = senselessPayService.withdraw(parameter);
|
|
|
withdrawOrder.setExpand(withdrawRet.getContent());
|
|
|
|
|
|
Map bodyMap = JsonUtil.toObject(JsonUtil.toJson(withdrawRet.getContent()), Map.class);
|
|
|
|
|
|
- if (!bodyMap.get("respCode").equals("000000")){//银联提现失败
|
|
|
+ if (!bodyMap.get("respCode").equals("000000")) {//银联提现失败
|
|
|
withdrawOrder.setWithdrawStatusDesc("银行处理失败");
|
|
|
//划账退回金额: 机构已冻结金额- 机构已结算 +
|
|
|
TransferTransactionsModel transferTransactionsModel = buildTransferModel(settleAccount, withdrawFrozenAccount, withdrawOrder.getOrderNo(),
|
|
|
withdrawOrder.getAmount(), TransactionType.WithdrawRefund,
|
|
|
Map.of("paymentType", withdrawOrder.getPaymentType(), "paymentChannelType", withdrawOrder.getPaymentType().getChannelType(), "description", "提现退回"));
|
|
|
ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferTransactionsModel);
|
|
|
- if (!transfer.getState().equals(ResultState.Success)){
|
|
|
+ if (!transfer.getState().equals(ResultState.Success)) {
|
|
|
withdrawOrder.setWithdrawStatusDesc("银行处理失败,余额退回失败");
|
|
|
withdrawOrderDao.save(withdrawOrder);
|
|
|
return com.github.microservice.net.ResultContent.buildFail("银行处理失败,余额退回失败");
|
|
|
@@ -380,7 +389,7 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.setWithdrawStatus(WithdrawStatus.Fail);
|
|
|
withdrawOrderDao.save(withdrawOrder);
|
|
|
return com.github.microservice.net.ResultContent.buildFail((String) bodyMap.get("respDesc"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
withdrawOrder.setWithdrawStatus(WithdrawStatus.Accepted);
|
|
|
withdrawOrder.setWithdrawStatusDesc("银行已受理");
|
|
|
}
|
|
|
@@ -389,7 +398,7 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.setProcessTime(System.currentTimeMillis());
|
|
|
withdrawOrderDao.save(withdrawOrder);
|
|
|
WithdrawStatus w = ExecuteQueueUtil.execute(1440, index -> {
|
|
|
- return Map.of(1, 1000L, 2, 3000L, 3, 5000L, 4, 5000L, 5, 5000L).getOrDefault(index, 60*1000L);
|
|
|
+ return Map.of(1, 1000L, 2, 3000L, 3, 5000L, 4, 5000L, 5, 5000L).getOrDefault(index, 60 * 1000L);
|
|
|
}, data -> {
|
|
|
var result = new ExecuteQueueUtil.Result<WithdrawStatus>();
|
|
|
com.github.microservice.net.ResultContent<WithdrawStatus> resultContent = withdrawQuery(withdrawOrder.getId());
|
|
|
@@ -404,7 +413,7 @@ public class WithdrawService extends SuperService {
|
|
|
}
|
|
|
result.setData(withdrawStatus);
|
|
|
long time = System.currentTimeMillis() - data.getStartTime();
|
|
|
- if (time>3000L){
|
|
|
+ if (time > 3000L) {
|
|
|
result.setAsync(true);
|
|
|
return result;
|
|
|
}
|
|
|
@@ -416,7 +425,7 @@ public class WithdrawService extends SuperService {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("该支付产品不支持线上提现方式");
|
|
|
}
|
|
|
|
|
|
- private TransferTransactionsModel buildTransferModel(PayAccount credit, PayAccount debit, String orderNo, BigDecimal amount, TransactionType type, Map<String, Object> meta){
|
|
|
+ private TransferTransactionsModel buildTransferModel(PayAccount credit, PayAccount debit, String orderNo, BigDecimal amount, TransactionType type, Map<String, Object> meta) {
|
|
|
TransferTransactionsModel transferModel = new TransferTransactionsModel();
|
|
|
//构建出账账户
|
|
|
TransferTransactionsModel.GeneralLedgerTransaction sourceTransaction = new TransferTransactionsModel.GeneralLedgerTransaction();
|
|
|
@@ -445,17 +454,17 @@ public class WithdrawService extends SuperService {
|
|
|
public com.github.microservice.net.ResultContent page(Pageable pageable, WithdrawPageParam param) {
|
|
|
String userId = getCurrentUserId();
|
|
|
String projectOid = param.getProjectOid();
|
|
|
- if (StringUtils.isBlank(projectOid)){
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
projectOid = getCurrentProjectOid();
|
|
|
}
|
|
|
boolean isProjectManager = userOrgPermissService.userIsProjectManager(projectOid, userId);
|
|
|
- if (isProjectManager){
|
|
|
+ if (isProjectManager) {
|
|
|
Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, null, param.getStartTime(), param.getEndTime(), param.getSearch());
|
|
|
return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
List<String> userManagerOids = userOrgPermissService.getUserManagerOids(projectOid, userId);
|
|
|
|
|
|
- if (userManagerOids==null || userManagerOids.isEmpty()){
|
|
|
+ if (userManagerOids == null || userManagerOids.isEmpty()) {
|
|
|
return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.buildEmptyPage(pageable));
|
|
|
}
|
|
|
|
|
|
@@ -463,9 +472,9 @@ public class WithdrawService extends SuperService {
|
|
|
return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
|
|
|
- private WithdrawOrderModel toModel(WithdrawOrder withdrawOrder){
|
|
|
+ private WithdrawOrderModel toModel(WithdrawOrder withdrawOrder) {
|
|
|
WithdrawOrderModel model = new WithdrawOrderModel();
|
|
|
- if (withdrawOrder!=null){
|
|
|
+ if (withdrawOrder != null) {
|
|
|
BeanUtils.copyProperties(withdrawOrder, model);
|
|
|
}
|
|
|
return model;
|
|
|
@@ -476,14 +485,14 @@ public class WithdrawService extends SuperService {
|
|
|
* 查询提现状态
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public com.github.microservice.net.ResultContent<WithdrawStatus> withdrawQuery(String id){
|
|
|
+ public com.github.microservice.net.ResultContent<WithdrawStatus> withdrawQuery(String id) {
|
|
|
//获取提现订单数据
|
|
|
WithdrawOrder withdrawOrder = withdrawOrderDao.findTop1ById(id);
|
|
|
- if (withdrawOrder == null){
|
|
|
+ if (withdrawOrder == null) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("数据不存在");
|
|
|
}
|
|
|
|
|
|
- if (!WithdrawStatus.Accepted.equals(withdrawOrder.getWithdrawStatus())){
|
|
|
+ if (!WithdrawStatus.Accepted.equals(withdrawOrder.getWithdrawStatus())) {
|
|
|
return com.github.microservice.net.ResultContent.buildContent(withdrawOrder.getWithdrawStatus());
|
|
|
}
|
|
|
|
|
|
@@ -492,7 +501,7 @@ public class WithdrawService extends SuperService {
|
|
|
PayAccount settleAccount = payAccountService.getOrgChildren(withdrawOrder.getProjectOid(), withdrawOrder.getOid(), PaymentChannelType.Settle);
|
|
|
|
|
|
|
|
|
- switch (withdrawOrder.getPaymentType()){
|
|
|
+ switch (withdrawOrder.getPaymentType()) {
|
|
|
case UnionFrictionlessPay -> {
|
|
|
|
|
|
String orgAccount = orgPayAccountService.queryOgPayAccount(withdrawOrder.getOid(), PaymentType.UnionFrictionlessPay);
|
|
|
@@ -500,39 +509,39 @@ public class WithdrawService extends SuperService {
|
|
|
|
|
|
ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(orgAccount);
|
|
|
|
|
|
- if (!accountModelResultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!accountModelResultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(accountModelResultContent.getMsg());
|
|
|
}
|
|
|
|
|
|
- ChinaumsSenselessConf conf = (ChinaumsSenselessConf)accountModelResultContent.getContent().getConf();
|
|
|
+ ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
|
|
|
String withdrawMchId = conf.getWithdrawMchId();
|
|
|
- if (StringUtils.isEmpty(withdrawMchId)){
|
|
|
+ if (StringUtils.isEmpty(withdrawMchId)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("未配置提现商户号");
|
|
|
}
|
|
|
|
|
|
PayProductParameter<Object> parameter = new PayProductParameter<>();
|
|
|
parameter.setAccountName(projectPayAccount);
|
|
|
|
|
|
- parameter.setMeta(Map.of("mchntNo", withdrawMchId,"orderNo", withdrawOrder.getOrderNo(), "transDate", DateUtils.paresTime(withdrawOrder.getCreateTime(), DateUtils.patternyyyyMMDD)));
|
|
|
+ parameter.setMeta(Map.of("mchntNo", withdrawMchId, "orderNo", withdrawOrder.getOrderNo(), "transDate", DateUtils.paresTime(withdrawOrder.getCreateTime(), DateUtils.patternyyyyMMDD)));
|
|
|
|
|
|
ResultContent<Object> resultContent = senselessPayService.withdrawQuery(parameter);
|
|
|
- if (!resultContent.getState().equals(ResultState.Success)){
|
|
|
+ if (!resultContent.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("银联请求失败");
|
|
|
}
|
|
|
String json = JsonUtil.toJson(resultContent.getContent());
|
|
|
Map map = JsonUtil.toObject(json, Map.class);
|
|
|
|
|
|
- if (!map.get("respCode").equals("000000")){//查询成功
|
|
|
+ if (!map.get("respCode").equals("000000")) {//查询成功
|
|
|
return com.github.microservice.net.ResultContent.buildFail("银联请求错误");
|
|
|
}
|
|
|
String status = (String) map.get("status");
|
|
|
- if (status.equals("-1") || status.equals("0") || status.equals("1") || status.equals("2") || status.equals("6")){
|
|
|
+ if (status.equals("-1") || status.equals("0") || status.equals("1") || status.equals("2") || status.equals("6")) {
|
|
|
return com.github.microservice.net.ResultContent.buildContent(WithdrawStatus.Accepted);
|
|
|
}
|
|
|
|
|
|
- if (status.equals("3")){
|
|
|
+ if (status.equals("3")) {
|
|
|
boolean update = withdrawOrderDao.updateWithdrawStatus(withdrawOrder.getId(), WithdrawStatus.Success, (String) map.get("desc"));
|
|
|
- if (!update){
|
|
|
+ if (!update) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("系统繁忙请重试");
|
|
|
}
|
|
|
//TODO 处理账单
|
|
|
@@ -541,7 +550,7 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.getAmount(), TransactionType.Withdrawal,
|
|
|
Map.of("paymentType", withdrawOrder.getPaymentType(), "paymentChannelType", withdrawOrder.getPaymentType().getChannelType(), "description", "提现"));
|
|
|
ResultContent<List<TransactionLogModel>> transferResult = transactionLogService.transfer(transferTransactionsModel);
|
|
|
- if (!transferResult.getState().equals(ResultState.Success)){
|
|
|
+ if (!transferResult.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail(transferResult.getMsg());
|
|
|
}
|
|
|
withdrawOrder.setWithdrawTransactionLogs(transferResult.getContent());
|
|
|
@@ -549,9 +558,9 @@ public class WithdrawService extends SuperService {
|
|
|
return com.github.microservice.net.ResultContent.buildContent(WithdrawStatus.Success);
|
|
|
}
|
|
|
|
|
|
- if (status.equals("4")){
|
|
|
+ if (status.equals("4")) {
|
|
|
boolean update = withdrawOrderDao.updateWithdrawStatus(withdrawOrder.getId(), WithdrawStatus.Fail, (String) map.get("desc"));
|
|
|
- if (!update){
|
|
|
+ if (!update) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("系统繁忙请重试");
|
|
|
}
|
|
|
//TODO 处理账单
|
|
|
@@ -559,7 +568,7 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.getAmount(), TransactionType.WithdrawRefund,
|
|
|
Map.of("paymentType", withdrawOrder.getPaymentType(), "paymentChannelType", withdrawOrder.getPaymentType().getChannelType(), "description", "提现退回"));
|
|
|
ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferTransactionsModel);
|
|
|
- if (!transfer.getState().equals(ResultState.Success)){
|
|
|
+ if (!transfer.getState().equals(ResultState.Success)) {
|
|
|
return com.github.microservice.net.ResultContent.buildFail("余额退回失败");
|
|
|
}
|
|
|
withdrawOrder.setWithdrawTransactionLogs(transfer.getContent());
|
|
|
@@ -574,7 +583,7 @@ public class WithdrawService extends SuperService {
|
|
|
/**
|
|
|
* 查询详情
|
|
|
*/
|
|
|
- public Object queryDetailById(String id){
|
|
|
+ public Object queryDetailById(String id) {
|
|
|
WithdrawOrder withdrawOrder = withdrawOrderDao.findTop1ById(id);
|
|
|
WithdrawOrderModel model = toModel(withdrawOrder);
|
|
|
|
|
|
@@ -615,14 +624,14 @@ public class WithdrawService extends SuperService {
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
- public Object queryDetailByOrderNo(String orderNo){
|
|
|
+ public Object queryDetailByOrderNo(String orderNo) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理银联无感支付,提现结果通知回调
|
|
|
*/
|
|
|
- public Object handleWithdrawMessage(){
|
|
|
+ public Object handleWithdrawMessage() {
|
|
|
return null;
|
|
|
}
|
|
|
}
|