| | |
| | | import com.ruoyi.system.domain.vo.CustomConfigVO; |
| | | import com.ruoyi.system.mapper.CustomConfigMapper; |
| | | import com.ruoyi.system.service.ICustomConfigService; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | private Optional<CustomConfig> getCustomConfigByKey(String key) { |
| | | return this.lambdaQuery() |
| | | .eq(CustomConfig::getConfigType, key) |
| | | .eq(CustomConfig::getConfigKey, key) |
| | | .eq(CustomConfig::getDelFlag, 0).oneOpt(); |
| | | } |
| | | |
| | |
| | | * @return List<CustomConfigVO> |
| | | */ |
| | | @Override |
| | | public List<CustomConfigVO> getPointsConfig() { |
| | | public PointsConfigDTO getPointsConfig() { |
| | | PointsConfigDTO dto = new PointsConfigDTO(); |
| | | List<CustomConfig> list = this.lambdaQuery() |
| | | .in(CustomConfig::getConfigType, ConfigEnum.MEMBER_POINTS_MONEY.getKey(), |
| | | .in(CustomConfig::getConfigKey, ConfigEnum.MEMBER_POINTS_MONEY.getKey(), |
| | | ConfigEnum.MEMBER_POINTS_POINTS.getKey()) |
| | | .eq(CustomConfig::getDelFlag, 0).list(); |
| | | return BeanUtils.copyList(list, CustomConfigVO.class); |
| | | for (CustomConfig customConfig : list) { |
| | | if (ConfigEnum.MEMBER_POINTS_MONEY.getKey().equals(customConfig.getConfigKey())) { |
| | | dto.setConsumeAmount( |
| | | BigDecimal.valueOf(Double.parseDouble(customConfig.getConfigValue()))); |
| | | } |
| | | if (ConfigEnum.MEMBER_POINTS_POINTS.getKey().equals(customConfig.getConfigKey())) { |
| | | dto.setPoints(Integer.parseInt(customConfig.getConfigValue())); |
| | | } |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | | /** |
| | |
| | | this.saveOrUpdate(orderDescription); |
| | | } |
| | | |
| | | /** |
| | | * 售后设置 |
| | | * |
| | | * @param dto 售后设置对象 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) |
| | | public void saveAfterSaleSetting(MgtAfterSaleSettingDTO dto) { |
| | |
| | | } |
| | | |
| | | private void handleConfigSetting(String value, ConfigEnum configEnum) { |
| | | Optional<CustomConfig> receiverNameConfigOptional = getCustomConfigByKey( |
| | | ConfigEnum.RETURN_ADDRESS_USER_NAME.getKey()); |
| | | CustomConfig receiverNameConfig = receiverNameConfigOptional.orElseGet(() -> { |
| | | Optional<CustomConfig> configSettingOptional = getCustomConfigByKey(configEnum.getKey()); |
| | | CustomConfig configSetting = configSettingOptional.orElseGet(() -> { |
| | | CustomConfig config = new CustomConfig(); |
| | | config.setConfigKey(ConfigEnum.RETURN_ADDRESS_USER_NAME.getKey()); |
| | | config.setConfigType(ConfigEnum.RETURN_ADDRESS_USER_NAME.getKeyType()); |
| | | config.setConfigName(ConfigEnum.RETURN_ADDRESS_USER_NAME.getKeyName()); |
| | | config.setConfigKey(configEnum.getKey()); |
| | | config.setConfigType(configEnum.getKeyType()); |
| | | config.setConfigName(configEnum.getKeyName()); |
| | | return config; |
| | | }); |
| | | receiverNameConfig.setConfigValue(value); |
| | | this.saveOrUpdate(receiverNameConfig); |
| | | configSetting.setConfigValue(value); |
| | | this.saveOrUpdate(configSetting); |
| | | } |
| | | |
| | | /** |
| | | * 获取售后设置 |
| | | * |
| | | * @return List<CustomConfigVO> |
| | | */ |
| | | @Override |
| | | public MgtAfterSaleSettingDTO getAfterSaleSetting() { |
| | | MgtAfterSaleSettingDTO dto = new MgtAfterSaleSettingDTO(); |
| | | List<CustomConfig> list = this.lambdaQuery() |
| | | .in(CustomConfig::getConfigKey, ConfigEnum.RETURN_ADDRESS_USER_NAME, |
| | | ConfigEnum.RETURN_ADDRESS_USER_PHONE, |
| | | ConfigEnum.RETURN_ADDRESS_USER_ADDRESS, ConfigEnum.RETURN_CYCLE) |
| | | .eq(CustomConfig::getDelFlag, 0).list(); |
| | | for (CustomConfig customConfig : list) { |
| | | if (ConfigEnum.RETURN_ADDRESS_USER_NAME.getKey().equals(customConfig.getConfigKey())) { |
| | | dto.setReceiverName(customConfig.getConfigValue()); |
| | | } |
| | | if (ConfigEnum.RETURN_ADDRESS_USER_PHONE.getKey().equals(customConfig.getConfigKey())) { |
| | | dto.setReceiverPhone(customConfig.getConfigValue()); |
| | | } |
| | | if (ConfigEnum.RETURN_ADDRESS_USER_ADDRESS.getKey() |
| | | .equals(customConfig.getConfigKey())) { |
| | | dto.setReceiverAddress(customConfig.getConfigValue()); |
| | | } |
| | | if (ConfigEnum.RETURN_CYCLE.getKey().equals(customConfig.getConfigKey())) { |
| | | dto.setReturnCycle(Integer.parseInt(customConfig.getConfigValue())); |
| | | } |
| | | } |
| | | return dto; |
| | | } |
| | | } |