|
|
@@ -4,9 +4,12 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
import com.github.microservice.types.payment.PaymentChannelType;
|
|
|
+import com.github.microservice.types.payment.PaymentType;
|
|
|
+import com.github.microservice.types.payment.PaymentTypeModel;
|
|
|
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.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.domain.org.Organization;
|
|
|
@@ -20,6 +23,10 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 项目的 支付配置
|
|
|
*
|
|
|
@@ -109,6 +116,8 @@ public class ProjectChannelConfigService extends SuperService {
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
+ // 判断是否可以删除
|
|
|
+
|
|
|
payChannelConfigDao.delete(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -139,11 +148,50 @@ public class ProjectChannelConfigService extends SuperService {
|
|
|
return entity;
|
|
|
}
|
|
|
|
|
|
+ public ResultContent changeState(String id, DataState state) {
|
|
|
+ PayChannelConfig entity = payChannelConfigDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ entity.setState(state);
|
|
|
+ payChannelConfigDao.save(entity);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 所有可用的支付产品
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent getPlatFormAllPay() {
|
|
|
+ List<PayChannelConfigModel> models = new ArrayList<>();
|
|
|
+ // 得到平台可用的支付渠道
|
|
|
+ List<PayChannelConfig> list = payChannelConfigDao.findByState(DataState.Enable);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ models = list.stream().map(it -> {
|
|
|
+ PayChannelConfigModel model = new PayChannelConfigModel();
|
|
|
+ return model;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(models);
|
|
|
+ }
|
|
|
+
|
|
|
public PayChannelConfigModel toModel(PayChannelConfig entity) {
|
|
|
PayChannelConfigModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
model = new PayChannelConfigModel();
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
+
|
|
|
+ // 可用的支付渠道
|
|
|
+ List<PaymentTypeModel> canUseAblePaymentTypes = new ArrayList<>();
|
|
|
+ for (PaymentType paymentType : PaymentType.values()) {
|
|
|
+ if (paymentType.getChannelType() != null && entity.getPaymentChannelType() == paymentType.getChannelType()) {
|
|
|
+ PaymentTypeModel typeModel = new PaymentTypeModel();
|
|
|
+ typeModel.setPaymentType(paymentType);
|
|
|
+ canUseAblePaymentTypes.add(typeModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.setCanUseAblePaymentTypes(canUseAblePaymentTypes);
|
|
|
}
|
|
|
return model;
|
|
|
}
|