|
|
@@ -0,0 +1,98 @@
|
|
|
+package com.zhongshu.card.server.core.service.paySetting;
|
|
|
+
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
+import com.github.microservice.pay.client.model.AccountModel;
|
|
|
+import com.github.microservice.pay.client.model.PayProductChannelConf;
|
|
|
+import com.github.microservice.pay.client.product.senseless.laKaLacollection.conf.LaKaLaCollectionConf;
|
|
|
+import com.github.microservice.pay.client.ret.ResultState;
|
|
|
+import com.github.microservice.pay.client.service.PayProductAccountService;
|
|
|
+import com.github.microservice.pay.client.type.PayProductChannelType;
|
|
|
+import com.github.microservice.types.payment.PaymentType;
|
|
|
+import com.zhongshu.card.client.model.paySetting.payConfig.LaKaLaCollectionConfig;
|
|
|
+import com.zhongshu.card.server.core.dao.projectAbout.OrgPayAccountDao;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.paySetting.OrgPayAccount;
|
|
|
+import com.zhongshu.card.server.core.domain.paySetting.UnionFrictionlessSetting;
|
|
|
+import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 机构的支付类型账号管理
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/10/9
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class OrgPayAccountService extends SuperService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrgPayAccountDao orgPayAccountDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PayProductAccountService payProductAccountService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目无感支付初始账号
|
|
|
+ *
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent initUnionFrictionPayAccount(UnionFrictionlessSetting entity) {
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ Organization projectInfo = entity.getProjectInfo();
|
|
|
+ String projectOid = projectInfo.getOid();
|
|
|
+
|
|
|
+ PayProductChannelType productChannelType = null;
|
|
|
+ PaymentType paymentType = entity.getPaymentType();
|
|
|
+ PayProductChannelConf conf = null;
|
|
|
+ if (paymentType == PaymentType.LakalaFrictionlessPay) {
|
|
|
+ productChannelType = PayProductChannelType.LaKaLaCollection;
|
|
|
+ LaKaLaCollectionConf laKaLaCollectionConf = new LaKaLaCollectionConf();
|
|
|
+
|
|
|
+ LaKaLaCollectionConfig laKaLaCollectionConfig = entity.getLaKaLaCollectionConf();
|
|
|
+ BeanUtils.copyProperties(laKaLaCollectionConfig, laKaLaCollectionConf);
|
|
|
+ conf = laKaLaCollectionConf;
|
|
|
+ }
|
|
|
+
|
|
|
+ AccountModel model = new AccountModel();
|
|
|
+ model.setDisable(Boolean.FALSE);
|
|
|
+ model.setProductChannelType(productChannelType);
|
|
|
+ model.setName(projectOid);
|
|
|
+ model.setConf(conf);
|
|
|
+ model.setRemark(projectInfo.getName());
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent<Void> resultContent = payProductAccountService.upsert(model);
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
+ OrgPayAccount orgPayAccount = orgPayAccountDao.findTopByOidAndPaymentType(projectOid, paymentType);
|
|
|
+ if (orgPayAccount == null) {
|
|
|
+ orgPayAccount = new OrgPayAccount();
|
|
|
+ }
|
|
|
+ orgPayAccount.setPayAccountId(projectOid);
|
|
|
+ orgPayAccount.setPaymentType(paymentType);
|
|
|
+ orgPayAccount.setOrgName(projectInfo.getName());
|
|
|
+ orgPayAccount.setOid(projectOid);
|
|
|
+ orgPayAccount.setProductChannelType(productChannelType);
|
|
|
+ orgPayAccountDao.save(orgPayAccount);
|
|
|
+ } else {
|
|
|
+ log.error("初始支付账号出错:%s", resultContent.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询结构 支付账号
|
|
|
+ *
|
|
|
+ * @param oid 机构oid
|
|
|
+ * @param paymentType 支付方式
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public OrgPayAccount queryOgPayAccount(String oid, PaymentType paymentType) {
|
|
|
+ OrgPayAccount orgPayAccount = orgPayAccountDao.findTopByOidAndPaymentType(oid, paymentType);
|
|
|
+ return orgPayAccount;
|
|
|
+ }
|
|
|
+}
|