|
|
@@ -10,6 +10,7 @@ import com.zhongshu.card.client.model.paySetting.paySetting.*;
|
|
|
import com.zhongshu.card.client.model.projectAbout.PayChannelConfigModel;
|
|
|
import com.zhongshu.card.client.type.DataState;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
+import com.zhongshu.card.server.core.dao.projectAbout.PayChannelConfigDao;
|
|
|
import com.zhongshu.card.server.core.dao.projectAbout.ProjectPaySettingDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
import com.zhongshu.card.server.core.domain.paySetting.PayChannelConfig;
|
|
|
@@ -19,6 +20,7 @@ import com.zhongshu.card.server.core.util.AesUtils;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -51,8 +53,50 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
@Autowired
|
|
|
ProjectChannelConfigService projectChannelConfigService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ PayChannelConfigDao payChannelConfigDao;
|
|
|
+
|
|
|
//-----------------------------微信支付的配置 start------------------
|
|
|
|
|
|
+ /**
|
|
|
+ * 关联支付渠道
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent savePayChannel(ProjectPaySettingParam param) {
|
|
|
+ String projectOid = param.getProjectOid();
|
|
|
+ if (StringUtils.isEmpty(projectOid)) {
|
|
|
+ return ResultContent.buildFail("projectOid不能为空");
|
|
|
+ }
|
|
|
+ Organization project = organizationDao.findTopByOid(projectOid);
|
|
|
+ if (ObjectUtils.isEmpty(project)) {
|
|
|
+ return ResultContent.buildFail("项目不存在");
|
|
|
+ }
|
|
|
+ PayChannelConfig payChannelConfig = payChannelConfigDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(payChannelConfig)) {
|
|
|
+ return ResultContent.buildFail("支付产品不存在");
|
|
|
+ }
|
|
|
+ PaymentType paymentType = payChannelConfig.getPaymentType();
|
|
|
+
|
|
|
+ ProjectPaySetting projectPaySetting = projectPaySettingDao.findTopByProjectOidAndChannelType(
|
|
|
+ projectOid, paymentType);
|
|
|
+ if (ObjectUtils.isNotEmpty(projectPaySetting)) {
|
|
|
+ return ResultContent.buildFail(String.format("%s已存在", paymentType.name()));
|
|
|
+ }
|
|
|
+ projectPaySetting = new ProjectPaySetting();
|
|
|
+ initEntityNoCheckOid(projectPaySetting);
|
|
|
+ projectPaySetting.setProjectOid(projectOid);
|
|
|
+ projectPaySetting.setProjectInfo(project);
|
|
|
+ projectPaySetting.setProjectCode(project.getCode());
|
|
|
+ projectPaySetting.setProjectName(project.getName());
|
|
|
+ projectPaySetting.setChannelType(paymentType);
|
|
|
+ projectPaySetting.setPaymentChannelType(payChannelConfig.getPaymentChannelType());
|
|
|
+
|
|
|
+ projectPaySetting.setState(DataState.Disable);
|
|
|
+ projectPaySettingDao.save(projectPaySetting);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存项目的微信支付设置
|
|
|
*
|
|
|
@@ -166,6 +210,9 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
if (ObjectUtils.isEmpty(paySetting)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
+ if (state == DataState.Enable && paySetting.getPayConfig() == null) {
|
|
|
+ return ResultContent.buildFail("参数未配置,不能启用");
|
|
|
+ }
|
|
|
paySetting.setState(state);
|
|
|
projectPaySettingDao.save(paySetting);
|
|
|
return ResultContent.buildSuccess();
|
|
|
@@ -212,6 +259,7 @@ public class ProjectPaySettingServiceImpl extends SuperService {
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
model = new ProjectPaySettingModel();
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
+ // 关联的支付产品信息
|
|
|
model.setPayChannelConfigModel(projectChannelConfigService.getProjectPayChannelModel(entity.getChannelType()));
|
|
|
}
|
|
|
return model;
|