| | |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.system.api.constants.ConfigEnum; |
| | | import com.ruoyi.system.api.domain.CustomConfig; |
| | | import com.ruoyi.system.domain.dto.MgtAfterSaleSettingDTO; |
| | | import com.ruoyi.system.domain.dto.PointsConfigDTO; |
| | | import com.ruoyi.system.domain.vo.CustomConfigVO; |
| | | import com.ruoyi.system.mapper.CustomConfigMapper; |
| | |
| | | |
| | | private Optional<CustomConfig> getCustomConfigByKey(String key) { |
| | | return this.lambdaQuery() |
| | | .eq(CustomConfig::getConfigType, key) |
| | | .eq(CustomConfig::getConfigKey, key) |
| | | .eq(CustomConfig::getDelFlag, 0).oneOpt(); |
| | | } |
| | | |
| | |
| | | orderDescription.setConfigValue(description); |
| | | this.saveOrUpdate(orderDescription); |
| | | } |
| | | |
| | | /** |
| | | * 售后设置 |
| | | * |
| | | * @param dto 售后设置对象 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) |
| | | public void saveAfterSaleSetting(MgtAfterSaleSettingDTO dto) { |
| | | handleConfigSetting(dto.getReceiverName(), ConfigEnum.RETURN_ADDRESS_USER_NAME); |
| | | handleConfigSetting(dto.getReceiverPhone(), ConfigEnum.RETURN_ADDRESS_USER_PHONE); |
| | | handleConfigSetting(dto.getReceiverAddress(), ConfigEnum.RETURN_ADDRESS_USER_ADDRESS); |
| | | handleConfigSetting(dto.getReturnCycle().toString(), ConfigEnum.RETURN_CYCLE); |
| | | } |
| | | |
| | | private void handleConfigSetting(String value, ConfigEnum configEnum) { |
| | | Optional<CustomConfig> receiverNameConfigOptional = getCustomConfigByKey( |
| | | ConfigEnum.RETURN_ADDRESS_USER_NAME.getKey()); |
| | | CustomConfig receiverNameConfig = receiverNameConfigOptional.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()); |
| | | return config; |
| | | }); |
| | | receiverNameConfig.setConfigValue(value); |
| | | this.saveOrUpdate(receiverNameConfig); |
| | | } |
| | | |
| | | /** |
| | | * 获取售后设置 |
| | | * |
| | | * @return List<CustomConfigVO> |
| | | */ |
| | | @Override |
| | | public List<CustomConfigVO> getAfterSaleSetting() { |
| | | List<CustomConfig> list = this.lambdaQuery() |
| | | .in(CustomConfig::getConfigType, ConfigEnum.RETURN_ADDRESS_USER_NAME, |
| | | ConfigEnum.RETURN_ADDRESS_USER_PHONE, |
| | | ConfigEnum.RETURN_ADDRESS_USER_ADDRESS, ConfigEnum.RETURN_CYCLE) |
| | | .eq(CustomConfig::getDelFlag, 0).list(); |
| | | return BeanUtils.copyList(list, CustomConfigVO.class); |
| | | } |
| | | } |