|
|
@@ -1,5 +1,6 @@
|
|
|
package com.zhongshu.card.server.core.service.pay;
|
|
|
|
|
|
+import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
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;
|
|
|
@@ -14,9 +15,10 @@ 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.zhongshu.card.client.model.pay.ProcessWithdrawParam;
|
|
|
+import com.zhongshu.card.client.model.pay.WithdrawOrderModel;
|
|
|
+import com.zhongshu.card.client.model.pay.WithdrawPageParam;
|
|
|
import com.zhongshu.card.client.model.pay.WithdrawParam;
|
|
|
import com.zhongshu.card.client.model.paySetting.paySetting.OrgPayConfigModel;
|
|
|
-import com.zhongshu.card.client.service.org.UserAccountService;
|
|
|
import com.zhongshu.card.client.type.WithdrawStatus;
|
|
|
import com.zhongshu.card.client.type.paySetting.WithdrawMethodType;
|
|
|
import com.zhongshu.card.server.core.dao.pay.WithdrawOrderDao;
|
|
|
@@ -25,17 +27,19 @@ import com.zhongshu.card.server.core.domain.pay.PayAccount;
|
|
|
import com.zhongshu.card.server.core.domain.pay.WithdrawOrder;
|
|
|
import com.zhongshu.card.server.core.domain.paySetting.ProjectMainPaySetting;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.org.UserOrgPermissService;
|
|
|
import com.zhongshu.card.server.core.service.paySetting.ProjectMainPaySettingService;
|
|
|
import com.zhongshu.card.server.core.service.paySetting.ProjectPaySettingServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
|
+import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.awt.print.Pageable;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -63,6 +67,9 @@ public class WithdrawService extends SuperService {
|
|
|
@Autowired
|
|
|
WithdrawOrderDao withdrawOrderDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UserOrgPermissService userOrgPermissService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询可提现余额
|
|
|
*/
|
|
|
@@ -86,6 +93,13 @@ public class WithdrawService extends SuperService {
|
|
|
* 查询当前支付渠道可提现余额
|
|
|
*/
|
|
|
public com.github.microservice.net.ResultContent queryWithdrawAmount(String projectOid, String oid, PaymentType paymentType){
|
|
|
+ if (StringUtils.isBlank(projectOid)){
|
|
|
+ projectOid = getCurrentProjectOid();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(oid)){
|
|
|
+ oid = getCurrentOid();
|
|
|
+ }
|
|
|
Long amount = queryWithdrawAmountByPaymentType(projectOid, oid, paymentType);
|
|
|
if (null == amount){
|
|
|
return com.github.microservice.net.ResultContent.buildFail("查询余额失败");
|
|
|
@@ -182,6 +196,7 @@ public class WithdrawService extends SuperService {
|
|
|
withdrawOrder.setOrderNo(withdrawOrderNo);
|
|
|
withdrawOrder.setAmount(amount);
|
|
|
withdrawOrder.setWithdrawStatus(WithdrawStatus.Processing);
|
|
|
+ withdrawOrder.setSort(WithdrawStatus.Processing.getSort());
|
|
|
withdrawOrder.setWithdrawUser(userAccounts.get(0));
|
|
|
withdrawOrder.setFrozenTransactionLogs(transfer.getContent());
|
|
|
withdrawOrder.setProjectOid(projectOid);
|
|
|
@@ -199,6 +214,15 @@ public class WithdrawService extends SuperService {
|
|
|
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()){
|
|
|
return com.github.microservice.net.ResultContent.buildFail("用户信息不存在");
|
|
|
@@ -237,9 +261,11 @@ public class WithdrawService extends SuperService {
|
|
|
}
|
|
|
|
|
|
withdrawOrder.setWithdrawStatus(WithdrawStatus.Success);
|
|
|
+ withdrawOrder.setSort(WithdrawStatus.Success.getSort());
|
|
|
withdrawOrder.setReceiveAmount(withdrawOrder.getAmount().movePointLeft(2));
|
|
|
}else if (param.getStatus().equals(WithdrawStatus.Fail)){ //审批拒绝
|
|
|
withdrawOrder.setWithdrawStatus(WithdrawStatus.Fail);
|
|
|
+ withdrawOrder.setSort(WithdrawStatus.Fail.getSort());
|
|
|
//划账退回金额: 机构已冻结金额- 机构已结算 +
|
|
|
TransferTransactionsModel transferTransactionsModel = buildTransferModel(settleAccount, withdrawFrozenAccount, withdrawOrder.getOrderNo(),
|
|
|
withdrawOrder.getAmount(), TransactionType.WithdrawRefund,
|
|
|
@@ -284,8 +310,39 @@ public class WithdrawService extends SuperService {
|
|
|
/**
|
|
|
* 查询机构提现记录
|
|
|
*/
|
|
|
- public Object page(Pageable pageable){
|
|
|
- return null;
|
|
|
+ public com.github.microservice.net.ResultContent page(Pageable pageable, WithdrawPageParam param) {
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ String projectOid = param.getProjectOid();
|
|
|
+ if (StringUtils.isBlank(projectOid)){
|
|
|
+ projectOid = getCurrentProjectOid();
|
|
|
+ }
|
|
|
+ boolean isProjectManager = userOrgPermissService.userIsProjectManager(projectOid, userId);
|
|
|
+ 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()){
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.buildEmptyPage(pageable));
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, userManagerOids.get(0), param.getStartTime(), param.getEndTime(), param.getSearch());
|
|
|
+ return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
+ }
|
|
|
+
|
|
|
+ private WithdrawOrderModel toModel(WithdrawOrder withdrawOrder){
|
|
|
+ WithdrawOrderModel model = new WithdrawOrderModel();
|
|
|
+ if (withdrawOrder!=null){
|
|
|
+ BeanUtils.copyProperties(withdrawOrder, model, "withdrawUser", "processUser");
|
|
|
+ if (withdrawOrder.getWithdrawUser()!=null){
|
|
|
+ model.setWithdrawUser(withdrawOrder.getWithdrawUser().getName());
|
|
|
+ }
|
|
|
+ if (withdrawOrder.getProcessUser()!=null){
|
|
|
+ model.setProcessUser(withdrawOrder.getProcessUser().getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return model;
|
|
|
}
|
|
|
|
|
|
/**
|