| | |
| | | package com.ruoyi.errand.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.errand.domain.Agreement; |
| | | import com.ruoyi.errand.domain.VipSetting; |
| | | import com.ruoyi.errand.mapper.VipSettingMapper; |
| | | import com.ruoyi.errand.object.dto.app.AgreementDTO; |
| | | import com.ruoyi.errand.object.dto.sys.SetPriceDTO; |
| | | import com.ruoyi.errand.object.vo.app.VipInfoListVO; |
| | | import com.ruoyi.errand.service.AgreementService; |
| | | import com.ruoyi.errand.service.VipSettingService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class VipSettingServiceImpl extends ServiceImpl<VipSettingMapper, VipSetting> implements VipSettingService { |
| | | @Resource |
| | | private AgreementService agreementService; |
| | | |
| | | @Override |
| | | public List<VipInfoListVO> getVipInfoList() { |
| | |
| | | |
| | | @Override |
| | | public void setPrice(SetPriceDTO setPriceDTO) { |
| | | VipSetting byId = this.getById(setPriceDTO.getId()); |
| | | if (byId == null) { |
| | | byId=new VipSetting(); |
| | | byId.setId(setPriceDTO.getId()); |
| | | if (setPriceDTO.getId()==1) byId.setVip_name("月卡会员"); |
| | | if (setPriceDTO.getId()==2) byId.setVip_name("季卡会员"); |
| | | if (setPriceDTO.getId()==3) byId.setVip_name("半年卡会员"); |
| | | if (setPriceDTO.getId()==4) byId.setVip_name("年卡会员"); |
| | | byId.setVip_price(setPriceDTO.getVip_price()); |
| | | this.save(byId); |
| | | }else { |
| | | byId.setVip_price(setPriceDTO.getVip_price()); |
| | | this.updateById(byId); |
| | | List<VipSetting> vipSettings = this.baseMapper.selectList(new LambdaQueryWrapper<VipSetting>().in(VipSetting::getId, Arrays.asList(1, 2, 3, 4))); |
| | | vipSettings.forEach(vipSetting -> { |
| | | if (vipSetting.getId()==1) vipSetting.setVipPrice(setPriceDTO.getVipPriceOne()); |
| | | if (vipSetting.getId()==2) vipSetting.setVipPrice(setPriceDTO.getVipPriceTwo()); |
| | | if (vipSetting.getId()==3) vipSetting.setVipPrice(setPriceDTO.getVipPriceThree()); |
| | | if (vipSetting.getId()==4) vipSetting.setVipPrice(setPriceDTO.getVipPriceFour()); |
| | | }); |
| | | this.updateBatchById(vipSettings); |
| | | |
| | | |
| | | //设置会员协议 |
| | | Agreement one = agreementService.getOne(new LambdaQueryWrapper<Agreement>().eq(Agreement::getType,8)); |
| | | if (one!=null){ |
| | | agreementService.removeById(one); |
| | | } |
| | | |
| | | Agreement agreement = new Agreement(); |
| | | agreement.setType(8); |
| | | agreement.setContent(setPriceDTO.getContent()); |
| | | agreementService.save(agreement); |
| | | } |
| | | |
| | | @Override |
| | | public SetPriceDTO getPrice() { |
| | | SetPriceDTO setPriceDTO = new SetPriceDTO(); |
| | | List<VipSetting> vipSettings = this.baseMapper.selectList(new LambdaQueryWrapper<VipSetting>().in(VipSetting::getId, Arrays.asList(1, 2, 3, 4))); |
| | | vipSettings.forEach(vipSetting -> { |
| | | if (vipSetting.getId()==1) setPriceDTO.setVipPriceOne(vipSetting.getVipPrice()); |
| | | if (vipSetting.getId()==2) setPriceDTO.setVipPriceTwo(vipSetting.getVipPrice()); |
| | | if (vipSetting.getId()==3) setPriceDTO.setVipPriceThree(vipSetting.getVipPrice()); |
| | | if (vipSetting.getId()==4) setPriceDTO.setVipPriceFour(vipSetting.getVipPrice()); |
| | | }); |
| | | //会员协议 |
| | | Agreement one = agreementService.getOne(new LambdaQueryWrapper<Agreement>().eq(Agreement::getType,8)); |
| | | if (one!=null){ |
| | | setPriceDTO.setContent(one.getContent()); |
| | | } |
| | | |
| | | return setPriceDTO; |
| | | } |
| | | |
| | | } |