|
|
@@ -0,0 +1,153 @@
|
|
|
+package com.zhongshu.card.server.core.service.payment;
|
|
|
+
|
|
|
+import com.github.microservice.auth.security.type.AuthType;
|
|
|
+import com.zhongshu.card.client.model.feign.ProjectWxPayModel;
|
|
|
+import com.zhongshu.card.client.model.feign.ProjectWxPayParam;
|
|
|
+import com.zhongshu.card.client.model.payment.paySetting.*;
|
|
|
+import com.zhongshu.card.client.ret.ResultContent;
|
|
|
+import com.zhongshu.card.client.service.ProjectPaySettingService;
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
+import com.zhongshu.card.server.core.dao.payment.ProjectPaySettingDao;
|
|
|
+import com.zhongshu.card.server.core.dao.payment.WxPayConfigDao;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.payment.ProjectPaySetting;
|
|
|
+import com.zhongshu.card.server.core.domain.payment.WxPayConfig;
|
|
|
+import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 项目支付设置
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/7/26
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ProjectPaySettingServiceImpl extends SuperService implements ProjectPaySettingService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WxPayConfigDao wxPayConfigDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProjectPaySettingDao projectPaySettingDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrganizationDao organizationDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置项目的支付类型
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent setProjectPaySetting(ProjectPaySettingParam param) {
|
|
|
+ Organization projectOrg = organizationDao.findTopByOid(param.getProjectOid());
|
|
|
+ if (ObjectUtils.isEmpty(projectOrg)) {
|
|
|
+ return ResultContent.buildFail(String.format("oid不存在:%s", param.getProjectOid()));
|
|
|
+ }
|
|
|
+ if (projectOrg.getAuthType() != AuthType.Project) {
|
|
|
+ return ResultContent.buildFail(String.format("%s 结构不属于项目类型", projectOrg.getName()));
|
|
|
+ }
|
|
|
+ ProjectPaySetting setting = projectPaySettingDao.findTopByProjectOid(param.getProjectOid());
|
|
|
+ if (ObjectUtils.isEmpty(setting)) {
|
|
|
+ setting = new ProjectPaySetting();
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, setting);
|
|
|
+ projectPaySettingDao.save(setting);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到项目的支付方式配置
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent<ProjectPaySettingModel> getProjectPaySetting(ProjectPaySettingSearch param) {
|
|
|
+ ProjectPaySetting setting = projectPaySettingDao.findTopByProjectOid(param.getProjectOid());
|
|
|
+ ProjectPaySettingModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(setting)) {
|
|
|
+ model = toModel(setting);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存项目的微信支付设置
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent saveWxPayConfig(WxPayConfigParam param) {
|
|
|
+ Organization projectOrg = organizationDao.findTopByOid(param.getProjectOid());
|
|
|
+ if (ObjectUtils.isEmpty(projectOrg)) {
|
|
|
+ return ResultContent.buildFail(String.format("oid不存在:%s", param.getProjectOid()));
|
|
|
+ }
|
|
|
+ if (projectOrg.getAuthType() != AuthType.Project) {
|
|
|
+ return ResultContent.buildFail(String.format("%s 结构不属于项目类型", projectOrg.getName()));
|
|
|
+ }
|
|
|
+ WxPayConfig wxPayConfig = wxPayConfigDao.findTopByProjectOid(param.getProjectOid());
|
|
|
+ if (ObjectUtils.isEmpty(wxPayConfig)) {
|
|
|
+ wxPayConfig = new WxPayConfig();
|
|
|
+ initEntity(wxPayConfig);
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, wxPayConfig);
|
|
|
+ wxPayConfigDao.save(wxPayConfig);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到项目的微信支付配置
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent<WxPayConfigModel> getWxPayConfig(ProjectPaySettingSearch param) {
|
|
|
+ WxPayConfig entity = wxPayConfigDao.findTopByProjectOid(param.getProjectOid());
|
|
|
+ WxPayConfigModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = toModel(entity);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ProjectPaySettingModel toModel(ProjectPaySetting entity) {
|
|
|
+ ProjectPaySettingModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new ProjectPaySettingModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
+ public WxPayConfigModel toModel(WxPayConfig entity) {
|
|
|
+ WxPayConfigModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new WxPayConfigModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到appId关联的支付信息
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent<WxPayConfigModel> getProjectWxPayConfig(ProjectWxPayParam param) {
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|