|
|
@@ -3,11 +3,13 @@ package com.zhongshu.card.server.core.service.pay;
|
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
|
import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
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.TransactionLogModel;
|
|
|
import com.github.microservice.pay.client.model.ledger.TransferTransactionsModel;
|
|
|
import com.github.microservice.pay.client.model.weChatMiniApp.WeChatMiniAppPayRet;
|
|
|
import com.github.microservice.pay.client.ret.ResultContent;
|
|
|
import com.github.microservice.pay.client.ret.ResultState;
|
|
|
+import com.github.microservice.pay.client.service.ledger.GeneralLedgerService;
|
|
|
import com.github.microservice.pay.client.service.ledger.TransactionLogService;
|
|
|
import com.github.microservice.pay.client.service.product.MiniAppPayService;
|
|
|
import com.github.microservice.pay.client.type.ledger.TransactionStatus;
|
|
|
@@ -16,10 +18,12 @@ 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.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.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.pay.BalanceRechargeOrder;
|
|
|
import com.zhongshu.card.server.core.domain.pay.PayAccount;
|
|
|
@@ -35,6 +39,7 @@ import java.math.BigDecimal;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class BalancePayService {
|
|
|
@@ -57,6 +62,9 @@ public class BalancePayService {
|
|
|
@Autowired
|
|
|
TransactionLogService transactionLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ GeneralLedgerService generalLedgerService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 下单并生成调用支付参数
|
|
|
@@ -171,6 +179,22 @@ public class BalancePayService {
|
|
|
return transactionLogService.transfer(transferModel);
|
|
|
}
|
|
|
|
|
|
+ public ResultContent queryRechargeOrder(QueryRechargeParam param){
|
|
|
+ Long monthStartTime = DateUtils.getMonthStartTime(param.getYear(), param.getMonth());
|
|
|
+ Long monthEndTime = DateUtils.getMonthEndTime(param.getYear(), param.getMonth());
|
|
|
+ List<BalanceRechargeOrder> balanceRechargeOrders = rechargeOrderDao.listByMonth(param.getProjectOid(), param.getUserId(), monthStartTime, monthEndTime);
|
|
|
+ return ResultContent.buildContent(balanceRechargeOrders.stream().map(this::toModel).toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent queryUserBalance(String projectOid, String userId){
|
|
|
+ PayAccount userBalance = payAccountService.getUserChildren(projectOid, userId, PaymentChannelType.BalancePayment);
|
|
|
+ ResultContent<GeneralLedgerModel> ret = generalLedgerService.get(userBalance.getLedgerId());
|
|
|
+ if (ret.equals(ResultState.Success)){
|
|
|
+ return ResultContent.buildContent(ret.getContent().getBalance());
|
|
|
+ }
|
|
|
+ return ResultContent.build(ResultState.Fail);
|
|
|
+ }
|
|
|
+
|
|
|
private RechargeOrderModel toModel(BalanceRechargeOrder balanceRechargeOrder){
|
|
|
RechargeOrderModel rechargeOrderModel = new RechargeOrderModel();
|
|
|
if (balanceRechargeOrder != null){
|