|
|
@@ -1,9 +1,13 @@
|
|
|
package com.zhongshu.card.server.core.service.paySetting;
|
|
|
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
-import com.zhongshu.card.client.model.paySetting.paySetting.ProjectMainPaySettingParam;
|
|
|
+import com.zhongshu.card.client.model.paySetting.paySetting.*;
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
+import com.zhongshu.card.server.core.dao.projectAbout.PayShareListDao;
|
|
|
import com.zhongshu.card.server.core.dao.projectAbout.ProjectMainPaySettingDao;
|
|
|
-import com.zhongshu.card.server.core.dao.projectAbout.ProjectPaySettingInfoDao;
|
|
|
+import com.zhongshu.card.server.core.dao.projectAbout.ProjectOrgPaySettingInfoDao;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.paySetting.PayShareList;
|
|
|
import com.zhongshu.card.server.core.domain.paySetting.ProjectMainPaySetting;
|
|
|
import com.zhongshu.card.server.core.domain.paySetting.ProjectOrgPaySettingInfo;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
@@ -14,6 +18,10 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 项目的配置
|
|
|
*
|
|
|
@@ -28,7 +36,13 @@ public class ProjectMainPaySettingService extends SuperService {
|
|
|
private ProjectMainPaySettingDao projectMainPaySettingDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private ProjectPaySettingInfoDao projectPaySettingInfoDao;
|
|
|
+ private ProjectOrgPaySettingInfoDao projectPaySettingInfoDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PayShareListDao payShareListDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
|
|
|
/**
|
|
|
* 保存项目配置
|
|
|
@@ -50,6 +64,7 @@ public class ProjectMainPaySettingService extends SuperService {
|
|
|
mainPaySetting = new ProjectMainPaySetting();
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, mainPaySetting);
|
|
|
+
|
|
|
mainPaySetting.setPaySettingInfo(orgPaySettingInfo);
|
|
|
mainPaySetting.setBelongOig(orgPaySettingInfo.getBelongOig());
|
|
|
mainPaySetting.setBelongOrgName(orgPaySettingInfo.getBelongOrgName());
|
|
|
@@ -60,4 +75,102 @@ public class ProjectMainPaySettingService extends SuperService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 得到项目配置
|
|
|
+ *
|
|
|
+ * @param projectOid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<ProjectMainPaySettingModel> getMainPaySetting(String projectOid) {
|
|
|
+ ProjectMainPaySetting mainPaySetting = projectMainPaySettingDao.findTopByProjectOid(projectOid);
|
|
|
+ return ResultContent.buildSuccess(toMainModel(mainPaySetting));
|
|
|
+ }
|
|
|
+
|
|
|
+ //---------------------------项目上的灵活 分账配置 start -----------------------
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存项目的灵活分账规则
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent savePayShareList(PayShareListParam param) {
|
|
|
+ if (StringUtils.isEmpty(param.getProjectOid())) {
|
|
|
+ return ResultContent.buildFail("projectOid不能为空");
|
|
|
+ }
|
|
|
+ Organization projectInfo = organizationDao.findTopByOid(param.getProjectOid());
|
|
|
+ PayShareList entity = null;
|
|
|
+ PayShareList nameTemp = payShareListDao.findTopByProjectOidAndName(param.getProjectOid(), param.getName());
|
|
|
+ if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
+ entity = payShareListDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ return ResultContent.buildFail("id不存在");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotEmpty(nameTemp) && !nameTemp.getId().equals(entity.getId())) {
|
|
|
+ return ResultContent.buildFail(String.format("名称已存在:%s", param.getName()));
|
|
|
+ }
|
|
|
+ initUpdateEntity(entity);
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotEmpty(nameTemp)) {
|
|
|
+ return ResultContent.buildFail(String.format("名称已存在:%s", param.getName()));
|
|
|
+ }
|
|
|
+ entity = new PayShareList();
|
|
|
+ initEntityNoCheckOid(entity);
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ entity.setProjectInfo(projectInfo);
|
|
|
+ entity.setProjectCode(projectInfo.getCode());
|
|
|
+ entity.setProjectName(projectInfo.getName());
|
|
|
+
|
|
|
+ payShareListDao.save(entity);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<List<PayShareListModel>> getPayShareList(String projectOid) {
|
|
|
+ List<PayShareList> list = payShareListDao.findByProjectOidOrderBySortAsc(projectOid);
|
|
|
+ List<PayShareListModel> models = new ArrayList<>();
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ models = list.stream().map(this::toModel).collect(Collectors.toUnmodifiableList());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(models);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除分账灵活规则
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent deletePayShareList(String id) {
|
|
|
+ PayShareList entity = payShareListDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ return ResultContent.buildFail("数据不存在");
|
|
|
+ }
|
|
|
+ payShareListDao.delete(entity);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ public PayShareListModel toModel(PayShareList entity) {
|
|
|
+ PayShareListModel model = null;
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ model = new PayShareListModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ProjectMainPaySettingModel toMainModel(ProjectMainPaySetting entity) {
|
|
|
+ ProjectMainPaySettingModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new ProjectMainPaySettingModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+
|
|
|
+ ProjectOrgPaySettingInfo paySettingInfo = entity.getPaySettingInfo();
|
|
|
+ if (ObjectUtils.isNotEmpty(paySettingInfo)) {
|
|
|
+ model.setPaySettingInfoId(paySettingInfo.getId());
|
|
|
+ model.setPaySettingInfoName(paySettingInfo.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
}
|