| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.pay.alipay; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.AlipayConfigParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.service.ClientService; |
| | | import com.sandu.ximon.admin.service.PoleService; |
| | | import com.sandu.ximon.admin.utils.SpringContextUtil; |
| | | import com.sandu.ximon.dao.domain.AliConfigEntity; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.WxConfigEntity; |
| | | import com.sandu.ximon.dao.mapper.UsrAlipayConfigMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author liuhaonan |
| | | * @Date 2022/3/15 |
| | | * @Version 1.0 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UsrAlipayConfigService extends BaseServiceImpl<UsrAlipayConfigMapper, AliConfigEntity> { |
| | | |
| | | private final UsrAlipayConfigMapper usrAlipayConfigMapper; |
| | | private final ClientService clientService; |
| | | private final PoleService poleService; |
| | | |
| | | public AliConfigEntity getConfigByPoleId(Long poleId) { |
| | | Pole pole = poleService.getById(poleId); |
| | | if (pole == null) { |
| | | throw new BusinessException("ç¯æidé误æç¯æä¸åå¨"); |
| | | } |
| | | AliConfigEntity config; |
| | | if (pole.getClientId() == null) { |
| | | config = getById(0); |
| | | } |
| | | config = getOne(Wrappers.lambdaQuery(AliConfigEntity.class).eq(AliConfigEntity::getCreateUserId, SecurityUtils.getUserId())); |
| | | if(config==null){ |
| | | throw new BusinessException("ç¨æ·æªé
ç½®æ¯ä»é
ç½®,请é
ç½®åéè¯"); |
| | | } |
| | | return config; |
| | | } |
| | | |
| | | |
| | | public static UsrAlipayConfigService getBean(){ |
| | | return (UsrAlipayConfigService) SpringContextUtil.getBean("UsrAlipayConfigService"); |
| | | } |
| | | |
| | | |
| | | public boolean addAliPayConfig(AlipayConfigParam configParam){ |
| | | AliConfigEntity config =new AliConfigEntity(); |
| | | BeanUtil.copyProperties(configParam,config); |
| | | if(SecurityUtils.getClientId()!=null){ |
| | | config.setCreateUserId(SecurityUtils.getUserId()); |
| | | if(clientService.findClientId()){ |
| | | config.setClientId(clientService.getClientId()); |
| | | } |
| | | } |
| | | return save(config); |
| | | } |
| | | |
| | | public boolean updateAliPayConfig(Integer id,AlipayConfigParam configParam){ |
| | | AliConfigEntity byId = getById(id); |
| | | if(byId==null){ |
| | | throw new BusinessException("é
ç½®idé误æé
ç½®ä¸åå¨"); |
| | | } |
| | | AliConfigEntity config =new AliConfigEntity(); |
| | | BeanUtil.copyProperties(configParam,config); |
| | | config.setConfigId(id); |
| | | return updateById(config); |
| | | } |
| | | |
| | | public boolean deleteAliPayConfig(Integer id){ |
| | | AliConfigEntity byId = getById(id); |
| | | if(byId==null){ |
| | | throw new BusinessException("é
ç½®idé误æé
ç½®ä¸åå¨"); |
| | | } |
| | | return removeById(id); |
| | | } |
| | | |
| | | |
| | | |
| | | public List<AliConfigEntity> configList(BaseConditionVO baseConditionVO,String keyword){ |
| | | LambdaQueryWrapper<AliConfigEntity> wrapper =new LambdaQueryWrapper<>(); |
| | | System.out.println("----------------------------"+clientService.findClientId()); |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | if(SecurityUtils.getClientId()!=null){//å®¢æ· |
| | | if(clientService.findClientId()){//äºçº§å®¢æ· |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | wrapper= Wrappers.lambdaQuery(AliConfigEntity.class).eq(AliConfigEntity::getCreateUserId,SecurityUtils.getUserId()); |
| | | }else if(!clientService.findClientId()){//ä¸çº§å®¢æ· |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | wrapper= Wrappers.lambdaQuery(AliConfigEntity.class).eq(AliConfigEntity::getClientId,SecurityUtils.getUserId()); |
| | | } |
| | | } else {//管ç |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | wrapper= Wrappers.lambdaQuery(AliConfigEntity.class); |
| | | } |
| | | |
| | | if(!keyword.isEmpty()){ |
| | | wrapper= wrapper.like(AliConfigEntity::getConfigId,keyword).or( |
| | | getAppId->{ |
| | | getAppId.like(AliConfigEntity::getAppId,keyword); |
| | | } |
| | | ).or( |
| | | getPid->{ |
| | | getPid.like(AliConfigEntity::getPid,keyword); |
| | | } |
| | | ).or( |
| | | getPublicKey->{ |
| | | getPublicKey.like(AliConfigEntity::getPublicKey,keyword); |
| | | } |
| | | ).or( |
| | | getPrivateKey->{ |
| | | getPrivateKey.like(AliConfigEntity::getPrivateKey,keyword); |
| | | } |
| | | ); |
| | | } |
| | | return list(wrapper); |
| | | } |
| | | |
| | | |
| | | |
| | | } |