|
|
@@ -0,0 +1,114 @@
|
|
|
+package com.ydtech.modules.admin.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
|
+import com.ydtech.modules.admin.constants.ManagementSource;
|
|
|
+import com.ydtech.modules.admin.constants.SwitchConfig;
|
|
|
+import com.ydtech.modules.admin.dao.SysSwitchConfigMapper;
|
|
|
+import com.ydtech.modules.admin.model.SysDept;
|
|
|
+import com.ydtech.modules.admin.model.po.SysSwitchConfig;
|
|
|
+import com.ydtech.modules.admin.model.vo.SysSwitchConfigQueryVo;
|
|
|
+import com.ydtech.modules.admin.model.vo.SysSwitchConfigVo;
|
|
|
+import com.ydtech.modules.admin.service.SysDeptService;
|
|
|
+import com.ydtech.modules.admin.service.SysSwitchConfigService;
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
+import com.ydtech.modules.fee.constants.CostAllocation;
|
|
|
+import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
|
|
|
+import com.ydtech.modules.fee.service.InsFeeOrderConfigService;
|
|
|
+import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
+import com.ydtech.modules.protocol.utils.AssertionUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Administrator
|
|
|
+ * @description 针对表【sys_switch_config(系统开关配置表)】的数据库操作Service实现
|
|
|
+ * @createDate 2024-08-07 18:04:47
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class SysSwitchConfigServiceImpl extends ServiceImpl<SysSwitchConfigMapper, SysSwitchConfig> implements SysSwitchConfigService {
|
|
|
+
|
|
|
+ private final SysDeptService sysDeptService;
|
|
|
+
|
|
|
+ private final InsFeeOrderConfigService insFeeOrderConfigService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BigDecimal getEnterProportion(String deptId, Integer entryStatus) {
|
|
|
+ if (entryStatus != 2) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysDept dept = sysDeptService.getById(deptId);
|
|
|
+ SysSwitchConfig config;
|
|
|
+ CostAllocation costAllocation;
|
|
|
+ SwitchConfig switchConfig;
|
|
|
+ // 渠道
|
|
|
+ if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
|
|
|
+ costAllocation = CostAllocation.CA_05;
|
|
|
+ switchConfig = SwitchConfig.SC_02;
|
|
|
+ // 代理人
|
|
|
+ } else {
|
|
|
+ costAllocation = CostAllocation.CA_04;
|
|
|
+ switchConfig = SwitchConfig.SC_01;
|
|
|
+ }
|
|
|
+
|
|
|
+ config = lambdaQuery().eq(SysSwitchConfig::getKeyword, switchConfig.getCode()).one();
|
|
|
+ if (config.getEnabled() == 1) {
|
|
|
+ InsFeeOrderConfig insFeeOrderConfig = insFeeOrderConfigService.lambdaQuery()
|
|
|
+ .eq(InsFeeOrderConfig::getKeyword, costAllocation.getCode())
|
|
|
+ .one();
|
|
|
+ return insFeeOrderConfig.getVal();
|
|
|
+ }
|
|
|
+
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(SysSwitchConfigVo sysSwitchConfigVo) {
|
|
|
+ SysSwitchConfig sysSwitchConfig = new SysSwitchConfig();
|
|
|
+ BeanUtils.copyProperties(sysSwitchConfigVo, sysSwitchConfig);
|
|
|
+ String userId = BaseController.getUserId();
|
|
|
+ sysSwitchConfig.setCreateBy(userId);
|
|
|
+ sysSwitchConfig.setCreateTime(new Date());
|
|
|
+ boolean save = save(sysSwitchConfig);
|
|
|
+ AssertionUtils.isSucceed(save, "增加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void revise(String id, SysSwitchConfigVo sysSwitchConfigVo) {
|
|
|
+ SysSwitchConfig sysSwitchConfig = getByIdExists(id);
|
|
|
+ BeanUtils.copyProperties(sysSwitchConfigVo, sysSwitchConfig);
|
|
|
+ String userId = BaseController.getUserId();
|
|
|
+ sysSwitchConfig.setUpdateBy(userId);
|
|
|
+ sysSwitchConfig.setUpdateTime(new Date());
|
|
|
+ boolean b = updateById(sysSwitchConfig);
|
|
|
+ AssertionUtils.isSucceed(b, "修改失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BasePageResult<SysSwitchConfig> queryPage(SysSwitchConfigQueryVo sysSwitchConfigQueryVo) {
|
|
|
+ Page<SysSwitchConfig> page = new Page<>(sysSwitchConfigQueryVo.getPageNum(), sysSwitchConfigQueryVo.getPageSize());
|
|
|
+
|
|
|
+ Page<SysSwitchConfig> sysSwitchConfigPage = lambdaQuery()
|
|
|
+ .eq(!ObjectUtils.isEmpty(sysSwitchConfigQueryVo.getEnabled()), SysSwitchConfig::getEnabled, sysSwitchConfigQueryVo.getEnabled())
|
|
|
+ .like(StringUtil.isNotEmpty(sysSwitchConfigQueryVo.getKeyword()), SysSwitchConfig::getKeyword, sysSwitchConfigQueryVo.getKeyword())
|
|
|
+ .like(StringUtil.isNotEmpty(sysSwitchConfigQueryVo.getProject()), SysSwitchConfig::getProject, sysSwitchConfigQueryVo.getProject())
|
|
|
+ .like(StringUtil.isNotEmpty(sysSwitchConfigQueryVo.getFunctionName()), SysSwitchConfig::getFunctionName, sysSwitchConfigQueryVo.getFunctionName())
|
|
|
+ .page(page);
|
|
|
+
|
|
|
+ return new BasePageResult<>(sysSwitchConfigQueryVo.getPageNum(), sysSwitchConfigQueryVo.getPageSize(), sysSwitchConfigPage.getTotal(), sysSwitchConfigPage.getPages(), sysSwitchConfigPage.getRecords());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|