SysSwitchConfigServiceImpl.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package com.ydtech.modules.admin.service.impl;
  2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.github.pagehelper.util.StringUtil;
  5. import com.ydtech.modules.admin.constants.ManagementSource;
  6. import com.ydtech.modules.admin.constants.SwitchConfig;
  7. import com.ydtech.modules.admin.dao.SysSwitchConfigMapper;
  8. import com.ydtech.modules.admin.model.SysDept;
  9. import com.ydtech.modules.admin.model.dto.FeeLookSwitchesDTO;
  10. import com.ydtech.modules.admin.model.po.SysSwitchConfig;
  11. import com.ydtech.modules.admin.model.vo.SysSwitchConfigQueryVo;
  12. import com.ydtech.modules.admin.model.vo.SysSwitchConfigVo;
  13. import com.ydtech.modules.admin.service.SysDeptService;
  14. import com.ydtech.modules.admin.service.SysSwitchConfigService;
  15. import com.ydtech.modules.base.controller.BaseController;
  16. import com.ydtech.modules.fee.constants.CostAllocation;
  17. import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
  18. import com.ydtech.modules.fee.service.InsFeeOrderConfigService;
  19. import com.ydtech.modules.order.entity.BasePageResult;
  20. import com.ydtech.modules.protocol.utils.AssertionUtils;
  21. import lombok.RequiredArgsConstructor;
  22. import org.apache.commons.lang3.ObjectUtils;
  23. import org.springframework.beans.BeanUtils;
  24. import org.springframework.stereotype.Service;
  25. import org.springframework.transaction.annotation.Transactional;
  26. import java.math.BigDecimal;
  27. import java.util.Date;
  28. /**
  29. * @author Administrator
  30. * @description 针对表【sys_switch_config(系统开关配置表)】的数据库操作Service实现
  31. * @createDate 2024-08-07 18:04:47
  32. */
  33. @Service
  34. @RequiredArgsConstructor
  35. public class SysSwitchConfigServiceImpl extends ServiceImpl<SysSwitchConfigMapper, SysSwitchConfig> implements SysSwitchConfigService {
  36. private final SysDeptService sysDeptService;
  37. private final InsFeeOrderConfigService insFeeOrderConfigService;
  38. @Override
  39. public BigDecimal getEnterProportion(String deptId, Integer entryStatus) {
  40. if (entryStatus != 2) {
  41. return BigDecimal.ZERO;
  42. }
  43. SysDept dept = sysDeptService.getById(deptId);
  44. SysSwitchConfig config;
  45. CostAllocation costAllocation;
  46. SwitchConfig switchConfig;
  47. // 渠道
  48. if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
  49. costAllocation = CostAllocation.CA_05;
  50. switchConfig = SwitchConfig.SC_02;
  51. // 代理人
  52. } else {
  53. costAllocation = CostAllocation.CA_04;
  54. switchConfig = SwitchConfig.SC_01;
  55. }
  56. config = lambdaQuery().eq(SysSwitchConfig::getKeyword, switchConfig.getCode()).one();
  57. if (config.getEnabled() == 1) {
  58. InsFeeOrderConfig insFeeOrderConfig = insFeeOrderConfigService.lambdaQuery()
  59. .eq(InsFeeOrderConfig::getKeyword, costAllocation.getCode())
  60. .one();
  61. return insFeeOrderConfig.getVal();
  62. }
  63. return BigDecimal.ZERO;
  64. }
  65. @Override
  66. public void add(SysSwitchConfigVo sysSwitchConfigVo) {
  67. SysSwitchConfig sysSwitchConfig = new SysSwitchConfig();
  68. BeanUtils.copyProperties(sysSwitchConfigVo, sysSwitchConfig);
  69. String userId = BaseController.getUserId();
  70. sysSwitchConfig.setCreateBy(userId);
  71. sysSwitchConfig.setCreateTime(new Date());
  72. boolean save = save(sysSwitchConfig);
  73. AssertionUtils.isSucceed(save, "增加失败");
  74. }
  75. @Override
  76. @Transactional
  77. public void revise(String id, SysSwitchConfigVo sysSwitchConfigVo) {
  78. SysSwitchConfig sysSwitchConfig = getByIdExist(id, "未查询到你所配置的开关");
  79. BeanUtils.copyProperties(sysSwitchConfigVo, sysSwitchConfig);
  80. String userId = BaseController.getUserId();
  81. sysSwitchConfig.setUpdateBy(userId);
  82. sysSwitchConfig.setUpdateTime(new Date());
  83. boolean b = updateById(sysSwitchConfig);
  84. AssertionUtils.isSucceed(b, "修改失败");
  85. }
  86. @Override
  87. public BasePageResult<SysSwitchConfig> queryPage(SysSwitchConfigQueryVo sysSwitchConfigQueryVo) {
  88. Page<SysSwitchConfig> page = new Page<>(sysSwitchConfigQueryVo.getPageNum(), sysSwitchConfigQueryVo.getPageSize());
  89. Page<SysSwitchConfig> sysSwitchConfigPage = lambdaQuery()
  90. .eq(!ObjectUtils.isEmpty(sysSwitchConfigQueryVo.getEnabled()), SysSwitchConfig::getEnabled, sysSwitchConfigQueryVo.getEnabled())
  91. .like(StringUtil.isNotEmpty(sysSwitchConfigQueryVo.getKeyword()), SysSwitchConfig::getKeyword, sysSwitchConfigQueryVo.getKeyword())
  92. .like(StringUtil.isNotEmpty(sysSwitchConfigQueryVo.getProject()), SysSwitchConfig::getProject, sysSwitchConfigQueryVo.getProject())
  93. .like(StringUtil.isNotEmpty(sysSwitchConfigQueryVo.getFunctionName()), SysSwitchConfig::getFunctionName, sysSwitchConfigQueryVo.getFunctionName())
  94. .page(page);
  95. return new BasePageResult<>(sysSwitchConfigQueryVo.getPageNum(), sysSwitchConfigQueryVo.getPageSize(),
  96. sysSwitchConfigPage.getTotal(), sysSwitchConfigPage.getPages(), sysSwitchConfigPage.getRecords());
  97. }
  98. @Override
  99. public FeeLookSwitchesDTO feeLookSwitches() {
  100. String deptId = BaseController.getDeptId();
  101. FeeLookSwitchesDTO feeLookSwitchesDTO = new FeeLookSwitchesDTO();
  102. SysDept dept = sysDeptService.getById(deptId);
  103. // 渠道
  104. if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
  105. feeLookSwitchesDTO.setFeeView(isEnabled(SwitchConfig.FEE_02.getCode()));
  106. feeLookSwitchesDTO.setFeeDisplay(isEnabled(SwitchConfig.FDA_02.getCode()));
  107. // 代理人
  108. } else if (ManagementSource.MS_02.getCode().equals(dept.getManagementSource())) {
  109. feeLookSwitchesDTO.setFeeView(isEnabled(SwitchConfig.FEE_01.getCode()));
  110. feeLookSwitchesDTO.setFeeDisplay(isEnabled(SwitchConfig.FDA_01.getCode()));
  111. }else {
  112. feeLookSwitchesDTO.setFeeView(false);
  113. feeLookSwitchesDTO.setFeeDisplay(true);
  114. }
  115. return feeLookSwitchesDTO;
  116. }
  117. @Override
  118. public boolean weComQRCodeDisplay() {
  119. String deptId = BaseController.getDeptId();
  120. SysDept dept = sysDeptService.getById(deptId);
  121. // 渠道
  122. if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
  123. return isEnabled(SwitchConfig.WCQCA_02.getCode());
  124. // 代理人
  125. } else if (ManagementSource.MS_02.getCode().equals(dept.getManagementSource())) {
  126. return isEnabled(SwitchConfig.WCQCA_01.getCode());
  127. }
  128. return isEnabled(SwitchConfig.WCQCA_03.getCode());
  129. }
  130. @Override
  131. public boolean feeDisplaySwitches() {
  132. String deptId = BaseController.getDeptId();
  133. SysDept dept = sysDeptService.getById(deptId);
  134. if (ManagementSource.MS_01.getCode().equals(dept.getManagementSource())) {
  135. return isEnabled(SwitchConfig.FEE_02.getCode());
  136. // 代理人
  137. } else if (ManagementSource.MS_02.getCode().equals(dept.getManagementSource())) {
  138. return isEnabled(SwitchConfig.FEE_01.getCode());
  139. }
  140. return false;
  141. }
  142. /**
  143. * @version
  144. * @author: hxl
  145. * @Date: 2024/9/26 15:05
  146. * @Description: 电销组员提现开关
  147. */
  148. public boolean dxtxDisplaySwitches() {
  149. return isEnabled(SwitchConfig.DX_01.getCode());
  150. }
  151. /**
  152. * @version
  153. * @author: hxl
  154. * @Date: 2024/10/25 11:40
  155. * @Description: 机构授权开关
  156. */
  157. public boolean xysqDisplaySwitches() {
  158. return isEnabled(SwitchConfig.XYSQ_01.getCode());
  159. }
  160. }