|
|
@@ -1,13 +1,8 @@
|
|
|
package com.zhongshu.card.server.core.service.pay;
|
|
|
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
-import com.github.microservice.core.util.net.apache.HttpClientUtil;
|
|
|
-import com.github.microservice.core.util.net.apache.HttpModel;
|
|
|
-import com.github.microservice.core.util.net.apache.ResponseModel;
|
|
|
import com.github.microservice.pay.client.model.PayProductParameter;
|
|
|
-import com.github.microservice.pay.client.model.ledger.GeneralLedgerModel;
|
|
|
import com.github.microservice.pay.client.model.ledger.GeneralLedgerQueryModel;
|
|
|
import com.github.microservice.pay.client.model.ledger.TransactionLogModel;
|
|
|
import com.github.microservice.pay.client.model.ledger.TransferTransactionsModel;
|
|
|
@@ -21,18 +16,14 @@ import com.github.microservice.pay.client.type.ledger.TransactionStatus;
|
|
|
import com.github.microservice.pay.client.type.ledger.TransactionType;
|
|
|
import com.github.microservice.types.payment.PaymentChannelType;
|
|
|
import com.github.microservice.types.payment.PaymentType;
|
|
|
-import com.wechat.pay.java.service.payments.model.Transaction;
|
|
|
import com.zhongshu.card.client.model.mqtt.SendMessageModel;
|
|
|
-import com.zhongshu.card.client.model.pay.PayAccountParam;
|
|
|
import com.zhongshu.card.client.model.pay.QueryRechargeParam;
|
|
|
import com.zhongshu.card.client.model.pay.RechargeOrderModel;
|
|
|
import com.zhongshu.card.client.model.pay.RechargeParam;
|
|
|
import com.zhongshu.card.client.model.wechat.MiniAppUserInfoVo;
|
|
|
-import com.zhongshu.card.client.type.payAccount.PayAccountLevel;
|
|
|
import com.zhongshu.card.client.type.payAccount.RechargeOrderStatus;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
import com.zhongshu.card.server.core.dao.pay.BalanceRechargeOrderDao;
|
|
|
-import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.domain.pay.BalanceRechargeOrder;
|
|
|
import com.zhongshu.card.server.core.domain.pay.PayAccount;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
@@ -51,11 +42,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@@ -203,7 +191,7 @@ public class BalancePayService extends SuperService {
|
|
|
rechargeOrderDao.save(rechargeOrder);
|
|
|
}
|
|
|
|
|
|
- public ResultContent<List<TransactionLogModel>> balancePay(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark) {
|
|
|
+ public com.github.microservice.net.ResultContent balancePay(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark) {
|
|
|
//获取用户余额支付子账户
|
|
|
PayAccount userBalancePayment = payAccountService.getUserChildren(projectOid, userId, PaymentChannelType.BalancePayment);
|
|
|
//获取机构待结算账户
|
|
|
@@ -232,7 +220,11 @@ public class BalancePayService extends SuperService {
|
|
|
destinationTransaction.setMeta(Map.of("paymentType",PaymentType.UserWallet, "description", "用户余额支付"));
|
|
|
transferModel.setDestinations(new TransferTransactionsModel.GeneralLedgerTransaction[]{destinationTransaction});
|
|
|
//发起转账
|
|
|
- return transactionLogService.transfer(transferModel);
|
|
|
+ ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferModel);
|
|
|
+ if (transfer.getState().equals(ResultState.Success)) {
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(transfer.getContent());
|
|
|
+ }
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail(transfer.getMsg());
|
|
|
}
|
|
|
|
|
|
public ResultContent queryRechargeOrder(QueryRechargeParam param) {
|
|
|
@@ -253,7 +245,7 @@ public class BalancePayService extends SuperService {
|
|
|
return ResultContent.buildContent(Map.of("list", balanceRechargeOrders.stream().map(this::toModel).toList(), "amountTotal", amountTotal));
|
|
|
}
|
|
|
|
|
|
- public ResultContent<Long> queryUserBalance(String projectOid, String userId) {
|
|
|
+ public com.github.microservice.net.ResultContent<Long> queryUserBalance(String projectOid, String userId) {
|
|
|
|
|
|
if (StringUtils.isEmpty(projectOid)){
|
|
|
projectOid = getCurrentProjectOid();
|
|
|
@@ -265,9 +257,9 @@ public class BalancePayService extends SuperService {
|
|
|
PayAccount userBalance = payAccountService.getUserChildren(projectOid, userId, PaymentChannelType.BalancePayment);
|
|
|
ResultContent<GeneralLedgerQueryModel> ret = generalLedgerService.get(userBalance.getLedgerId());
|
|
|
if (ret.getState().equals(ResultState.Success)) {
|
|
|
- return ResultContent.buildContent(ret.getContent().getBalance());
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(ret.getContent().getBalance());
|
|
|
}
|
|
|
- return ResultContent.build(ResultState.Fail);
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail(ret.getMsg());
|
|
|
}
|
|
|
|
|
|
public ResultContent queryInfo(String orderNo){
|
|
|
@@ -301,7 +293,7 @@ public class BalancePayService extends SuperService {
|
|
|
/**
|
|
|
* 商家退款
|
|
|
*/
|
|
|
- public ResultContent<List<TransactionLogModel>> refund(String projectOid, String oid, String userId, String orderNo, BigDecimal total, String remark){
|
|
|
+ public com.github.microservice.net.ResultContent<List<TransactionLogModel>> refund(String projectOid, String oid, String userId, String orderNo, BigDecimal total, String remark){
|
|
|
//获取用户余额支付子账户
|
|
|
PayAccount userAccount = payAccountService.getUserChildren(projectOid, userId, PaymentChannelType.BalancePayment);
|
|
|
//获取机构待结算子账户
|
|
|
@@ -328,7 +320,11 @@ public class BalancePayService extends SuperService {
|
|
|
destinationTransaction.setRemark(remark);
|
|
|
transferModel.setDestinations(new TransferTransactionsModel.GeneralLedgerTransaction[]{destinationTransaction});
|
|
|
//调用支付中心转账接口
|
|
|
- return transactionLogService.transfer(transferModel);
|
|
|
+ ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferModel);
|
|
|
+ if (transfer.getState().equals(ResultState.Success)) {
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(transfer.getContent());
|
|
|
+ }
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail(transfer.getMsg());
|
|
|
}
|
|
|
|
|
|
/**
|