| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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.dto.FeeLookSwitchesDTO;
- 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 org.springframework.transaction.annotation.Transactional;
- 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
- @Transactional
- public void revise(String id, SysSwitchConfigVo sysSwitchConfigVo) {
- SysSwitchConfig sysSwitchConfig = getByIdExist(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());
- }
- @Override
- public FeeLookSwitchesDTO feeLookSwitches() {
- String deptId = BaseController.getDeptId();
- FeeLookSwitchesDTO feeLookSwitchesDTO = new FeeLookSwitchesDTO();
- SysDept dept = sysDeptService.getById(deptId);
- // 渠道
- if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
- feeLookSwitchesDTO.setFeeView(isEnabled(SwitchConfig.FEE_02.getCode()));
- feeLookSwitchesDTO.setFeeDisplay(isEnabled(SwitchConfig.FDA_02.getCode()));
- // 代理人
- } else if (ManagementSource.MS_02.getCode().equals(dept.getManagementSource())) {
- feeLookSwitchesDTO.setFeeView(isEnabled(SwitchConfig.FEE_01.getCode()));
- feeLookSwitchesDTO.setFeeDisplay(isEnabled(SwitchConfig.FDA_01.getCode()));
- }else {
- feeLookSwitchesDTO.setFeeView(false);
- feeLookSwitchesDTO.setFeeDisplay(true);
- }
- return feeLookSwitchesDTO;
- }
- @Override
- public boolean weComQRCodeDisplay() {
- String deptId = BaseController.getDeptId();
- SysDept dept = sysDeptService.getById(deptId);
- // 渠道
- if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
- return isEnabled(SwitchConfig.WCQCA_02.getCode());
- // 代理人
- } else if (ManagementSource.MS_02.getCode().equals(dept.getManagementSource())) {
- return isEnabled(SwitchConfig.WCQCA_01.getCode());
- }
- return isEnabled(SwitchConfig.WCQCA_03.getCode());
- }
- @Override
- public boolean feeDisplaySwitches() {
- String deptId = BaseController.getDeptId();
- SysDept dept = sysDeptService.getById(deptId);
- if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
- return isEnabled(SwitchConfig.FEE_02.getCode());
- // 代理人
- } else if (ManagementSource.MS_02.getCode().equals(dept.getManagementSource())) {
- return isEnabled(SwitchConfig.FEE_01.getCode());
- }
- return false;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/9/26 15:05
- * @Description: 电销组员提现开关
- */
- public boolean dxtxDisplaySwitches() {
- return isEnabled(SwitchConfig.DX_01.getCode());
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/10/25 11:40
- * @Description: 机构授权开关
- */
- public boolean xysqDisplaySwitches() {
- return isEnabled(SwitchConfig.XYSQ_01.getCode());
- }
- }
|