|
|
@@ -6,6 +6,7 @@ import com.github.microservice.pay.client.ret.ResultState;
|
|
|
import com.github.microservice.types.OrderState;
|
|
|
import com.github.microservice.types.payment.PaymentType;
|
|
|
import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationMiniModel;
|
|
|
import com.zhongshu.card.client.model.payment.ExpenseRefundParam;
|
|
|
import com.zhongshu.card.client.type.LogsLevel;
|
|
|
import com.zhongshu.card.client.type.MessageType;
|
|
|
@@ -13,8 +14,11 @@ import com.zhongshu.card.client.type.RefundState;
|
|
|
import com.zhongshu.card.client.utils.PayExceptionToShowUtil;
|
|
|
import com.zhongshu.card.server.core.dao.payment.ExpenseFlowDao;
|
|
|
import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
|
|
|
+import com.zhongshu.card.server.core.domain.schedule.ScheduleTaskConfig;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.orgManager.ProjectBindOrgServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.pay.BalancePayService;
|
|
|
+import com.zhongshu.card.server.core.service.pay.SettleService;
|
|
|
import com.zhongshu.card.server.core.service.user.OperationLogsService;
|
|
|
import com.zhongshu.card.server.core.util.NextNoUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -24,7 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -44,6 +50,12 @@ public class PayCallService extends SuperService {
|
|
|
@Autowired
|
|
|
ExpenseFlowDao expenseFlowDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProjectBindOrgServiceImpl projectBindOrgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SettleService settleService;
|
|
|
+
|
|
|
/**
|
|
|
* 统一调用支付服务
|
|
|
*
|
|
|
@@ -76,9 +88,7 @@ public class PayCallService extends SuperService {
|
|
|
logsAddParam.setDataId(entity.getPaymentNo());
|
|
|
entity.setPayStartTime(System.currentTimeMillis());
|
|
|
|
|
|
- com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent = balancePayService.balancePay(
|
|
|
- entity.getProjectOid(), entity.getShopOid(), entity.getUserId(),
|
|
|
- entity.getPayAmount(), entity.getPaymentNo(), entity.getRemark());
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent = balancePayService.balancePay(entity.getProjectOid(), entity.getShopOid(), entity.getUserId(), entity.getPayAmount(), entity.getPaymentNo(), entity.getRemark());
|
|
|
if (resultContent.getState() == ResultState.Success) {
|
|
|
// 关联参数
|
|
|
String msg = "支付成功";
|
|
|
@@ -196,9 +206,7 @@ public class PayCallService extends SuperService {
|
|
|
public ResultContent<List<TransactionLogModel>> walletRefund(ExpenseFlow entity, ExpenseRefundParam param) {
|
|
|
String refundNo = NextNoUtil.getNextPaymentNo(null);
|
|
|
entity.setRefundNo(refundNo);
|
|
|
- com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent = balancePayService.refund(
|
|
|
- entity.getProjectOid(), entity.getShopOid(), entity.getUserId(),
|
|
|
- refundNo, entity.getPayAmount(), param.getRemark());
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent = balancePayService.refund(entity.getProjectOid(), entity.getShopOid(), entity.getUserId(), refundNo, entity.getPayAmount(), param.getRemark());
|
|
|
if (resultContent.getState() == ResultState.Success) {
|
|
|
return ResultContent.buildSuccess(resultContent.getContent());
|
|
|
} else {
|
|
|
@@ -206,4 +214,45 @@ public class PayCallService extends SuperService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 结算
|
|
|
+ *
|
|
|
+ * @param taskConfig
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent settlement(ScheduleTaskConfig taskConfig) {
|
|
|
+ HashMap<String, Object> data = taskConfig.getData();
|
|
|
+ String projectOid = data.get("projectOid").toString();
|
|
|
+ PaymentType paymentType = PaymentType.valueOf(data.get("paymentType").toString());
|
|
|
+ if (StringUtils.isNotEmpty(projectOid) && paymentType != null) {
|
|
|
+ String remark = "定时结算";
|
|
|
+ Long endTime = System.currentTimeMillis();
|
|
|
+ // 项目包含的机构列表
|
|
|
+ ResultContent<List<OrganizationMiniModel>> content = projectBindOrgService.getProjectOrgList(projectOid);
|
|
|
+ if (content.isSuccess()) {
|
|
|
+ List<OrganizationMiniModel> list = content.getContent();
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ for (OrganizationMiniModel organizationMiniModel : list) {
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent resultContent = settleService.settle(projectOid, organizationMiniModel.getOid(), endTime, remark, paymentType);
|
|
|
+ //TODO 标记订单已结算
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
+ Object object = resultContent.getContent();
|
|
|
+ if (object != null) {
|
|
|
+ Set<String> orderNoSet = (Set<String>) object;
|
|
|
+ markOrderSettlement(orderNoSet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void markOrderSettlement(Set<String> orderNoSet) {
|
|
|
+ if (orderNoSet != null && !orderNoSet.isEmpty()) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|