|
@@ -0,0 +1,125 @@
|
|
|
|
|
+package com.zhongshu.card.server.core.service.projectAbout;
|
|
|
|
|
+
|
|
|
|
|
+import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
|
|
+import com.github.microservice.net.ResultMessage;
|
|
|
|
|
+import com.zhongshu.card.client.model.projectAbout.PayChannelConfigModel;
|
|
|
|
|
+import com.zhongshu.card.client.model.projectAbout.PayChannelConfigParam;
|
|
|
|
|
+import com.zhongshu.card.client.model.projectAbout.PayChannelConfigSearch;
|
|
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.dao.projectAbout.PayChannelConfigDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
|
|
+import com.zhongshu.card.server.core.domain.projectAbout.PayChannelConfig;
|
|
|
|
|
+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.data.domain.Page;
|
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 项目的 支付配置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author TRX
|
|
|
|
|
+ * @date 2024/9/24
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Service
|
|
|
|
|
+public class ProjectChannelConfigService extends SuperService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ OrganizationDao organizationDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ PayChannelConfigDao payChannelConfigDao;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResultContent savePayChannelConfig(PayChannelConfigParam param) {
|
|
|
|
|
+ checkSaveParamProjectOid(param);
|
|
|
|
|
+
|
|
|
|
|
+ String projectOid = param.getProjectOid();
|
|
|
|
|
+ Organization projectInfo = organizationDao.findTopByOid(projectOid);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(projectInfo)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format("项目oid不存在:%s", projectOid));
|
|
|
|
|
+ }
|
|
|
|
|
+ PayChannelConfig entity = null;
|
|
|
|
|
+ PayChannelConfig nameTemp = payChannelConfigDao.findTopByProjectOidAndPaymentChannelType(projectOid, param.getPaymentChannelType());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(param.getId())) {
|
|
|
|
|
+ entity = payChannelConfigDao.findTopById(param.getId());
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(nameTemp) && !nameTemp.getId().equals(entity.getId())) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format("类型已存在:%s", param.getPaymentChannelType().getRemark()));
|
|
|
|
|
+ }
|
|
|
|
|
+ initUpdateEntity(entity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(nameTemp)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format("类型已存在:%s", param.getPaymentChannelType().getRemark()));
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setId(null);
|
|
|
|
|
+ entity = new PayChannelConfig();
|
|
|
|
|
+ entity.setIsDelete(Boolean.FALSE);
|
|
|
|
|
+ initEntityNoOid(entity);
|
|
|
|
|
+ }
|
|
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
|
|
+ entity.setProjectInfo(projectInfo);
|
|
|
|
|
+ entity.setProjectName(projectInfo.getName());
|
|
|
|
|
+ entity.setProjectCode(projectInfo.getCode());
|
|
|
|
|
+
|
|
|
|
|
+ entity.setOid(projectOid);
|
|
|
|
|
+ entity.setAboutOid(projectOid);
|
|
|
|
|
+ entity.setAboutAuthType(projectInfo.getAuthType());
|
|
|
|
|
+ payChannelConfigDao.save(entity);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @param pageable
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResultContent<Page<PayChannelConfigModel>> page(PayChannelConfigSearch param, Pageable pageable) {
|
|
|
|
|
+ initSearchParamCheckProjectOid(param);
|
|
|
|
|
+
|
|
|
|
|
+ Page<PayChannelConfig> page = payChannelConfigDao.page(pageable, param);
|
|
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent deleteData(String id) {
|
|
|
|
|
+ PayChannelConfig entity = payChannelConfigDao.findTopById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
|
|
+ }
|
|
|
|
|
+ payChannelConfigDao.delete(entity);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent getDetail(String id) {
|
|
|
|
|
+ PayChannelConfig entity = payChannelConfigDao.findTopById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultContent.buildSuccess(toModel(entity));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public PayChannelConfigModel toModel(PayChannelConfig entity) {
|
|
|
|
|
+ PayChannelConfigModel model = null;
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
|
|
+ model = new PayChannelConfigModel();
|
|
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
|
|
+ }
|
|
|
|
|
+ return model;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|