|
|
@@ -4,7 +4,6 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.components.data.mongo.queue.service.ExecQueueService;
|
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
|
import com.github.microservice.pay.client.model.AccountModel;
|
|
|
-import com.github.microservice.pay.client.model.PayProductChannelConf;
|
|
|
import com.github.microservice.pay.client.model.PayProductParameter;
|
|
|
import com.github.microservice.pay.client.model.ledger.GeneralLedgerQueryModel;
|
|
|
import com.github.microservice.pay.client.model.ledger.TransactionLogModel;
|
|
|
@@ -52,7 +51,6 @@ import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -401,8 +399,12 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.setProcessTime(System.currentTimeMillis());
|
|
|
withdrawOrderDao.save(withdrawOrder);
|
|
|
execQueueService.add(Map.of("withdrawOrderId", withdrawOrder.getId()), 5, data->{
|
|
|
- withdrawQuery((String) data.get("withdrawOrderId"));
|
|
|
- return false;
|
|
|
+ com.github.microservice.net.ResultContent<WithdrawStatus> resultContent = withdrawQuery((String) data.get("withdrawUserId"));
|
|
|
+ if (resultContent.getState().equals(com.github.microservice.net.ResultState.Success)){
|
|
|
+ WithdrawStatus withdrawStatus = resultContent.getContent();
|
|
|
+ return !withdrawStatus.equals(WithdrawStatus.Accepted);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
});
|
|
|
return com.github.microservice.net.ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -460,16 +462,17 @@ public class WithdrawService extends SuperService {
|
|
|
private WithdrawOrderModel toModel(WithdrawOrder withdrawOrder){
|
|
|
WithdrawOrderModel model = new WithdrawOrderModel();
|
|
|
if (withdrawOrder!=null){
|
|
|
- BeanUtils.copyProperties(withdrawOrder, model, "withdrawUser", "processUser");
|
|
|
+ BeanUtils.copyProperties(withdrawOrder, model);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询提现状态
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public Object withdrawQuery(String id){
|
|
|
+ public com.github.microservice.net.ResultContent<WithdrawStatus> withdrawQuery(String id){
|
|
|
//获取提现订单数据
|
|
|
WithdrawOrder withdrawOrder = withdrawOrderDao.findTop1ById(id);
|
|
|
if (withdrawOrder == null){
|
|
|
@@ -477,13 +480,17 @@ public class WithdrawService extends SuperService {
|
|
|
}
|
|
|
|
|
|
if (!WithdrawStatus.Accepted.equals(withdrawOrder.getWithdrawStatus())){
|
|
|
-// return ResultContent.buildContent(withdrawOrder.getWithdrawStatus())
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(withdrawOrder.getWithdrawStatus());
|
|
|
}
|
|
|
|
|
|
+ PayAccount withdrawFrozenAccount = payAccountService.getOrgChildren(withdrawOrder.getProjectOid(), withdrawOrder.getOid(), PaymentChannelType.WithdrawFrozen);
|
|
|
+ PayAccount projectAccount = payAccountService.getProjectChildren(withdrawOrder.getProjectOid(), PaymentChannelType.SecretFreePayment);
|
|
|
+ PayAccount settleAccount = payAccountService.getOrgChildren(withdrawOrder.getProjectOid(), withdrawOrder.getOid(), PaymentChannelType.Settle);
|
|
|
+
|
|
|
+
|
|
|
switch (withdrawOrder.getPaymentType()){
|
|
|
case UnionFrictionlessPay -> {
|
|
|
|
|
|
-
|
|
|
String orgAccount = orgPayAccountService.queryOgPayAccount(withdrawOrder.getOid(), PaymentType.UnionFrictionlessPay);
|
|
|
String projectPayAccount = orgPayAccountService.queryOgPayAccount(withdrawOrder.getProjectOid(), PaymentType.UnionFrictionlessPay);
|
|
|
|
|
|
@@ -506,20 +513,58 @@ public class WithdrawService extends SuperService {
|
|
|
|
|
|
ResultContent<Object> resultContent = senselessPayService.withdrawQuery(parameter);
|
|
|
if (!resultContent.getState().equals(ResultState.Success)){
|
|
|
- return resultContent;
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("银联请求失败");
|
|
|
}
|
|
|
String json = JsonUtil.toJson(resultContent.getContent());
|
|
|
Map map = JsonUtil.toObject(json, Map.class);
|
|
|
- //TODO 有问题,提现时,如果是银联,则不从机构冻结账本- 项目账本+,这里成功再加,这里失败,机构冻结- 机构已结算账本+
|
|
|
|
|
|
- PayAccount orgChildren = payAccountService.getOrgChildren(withdrawOrder.getProjectOid(), withdrawOrder.getOid(), PaymentChannelType.WithdrawFrozen);
|
|
|
- PayAccount projectChildren = payAccountService.getProjectChildren(withdrawOrder.getProjectOid(), withdrawOrder.getPaymentType().getChannelType());
|
|
|
+ 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")){
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(WithdrawStatus.Accepted);
|
|
|
+ }
|
|
|
|
|
|
-// buildTransferModel(projectChildren, orgChildren, withdrawOrder.getOrderNo(), withdrawOrder.getAmount(), TransactionType.Withdrawal, )
|
|
|
- return ResultContent.buildContent(map.get("desc"));
|
|
|
+ if (status.equals("3")){
|
|
|
+ boolean update = withdrawOrderDao.updateWithdrawStatus(withdrawOrder.getId(), WithdrawStatus.Success, (String) map.get("desc"));
|
|
|
+ if (!update){
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("系统繁忙请重试");
|
|
|
+ }
|
|
|
+ //TODO 处理账单
|
|
|
+ //划账,机构已冻结金额- 项目无感支付+
|
|
|
+ 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)){
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail(transferResult.getMsg());
|
|
|
+ }
|
|
|
+ withdrawOrder.setWithdrawTransactionLogs(transferResult.getContent());
|
|
|
+ withdrawOrderDao.save(withdrawOrder);
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(WithdrawStatus.Success);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (status.equals("4")){
|
|
|
+ boolean update = withdrawOrderDao.updateWithdrawStatus(withdrawOrder.getId(), WithdrawStatus.Fail, (String) map.get("desc"));
|
|
|
+ if (!update){
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("系统繁忙请重试");
|
|
|
+ }
|
|
|
+ //TODO 处理账单
|
|
|
+ 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)){
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("余额退回失败");
|
|
|
+ }
|
|
|
+ withdrawOrder.setWithdrawTransactionLogs(transfer.getContent());
|
|
|
+ withdrawOrderDao.save(withdrawOrder);
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(WithdrawStatus.Fail);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return ResultContent.buildContent(withdrawOrder.getWithdrawStatus().getRemark());
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(withdrawOrder.getWithdrawStatus());
|
|
|
}
|
|
|
|
|
|
/**
|