2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-03-21 34cc9fb821d30b64947c8a62d952f1621a515149
ximon-admin/src/main/java/com/sandu/ximon/admin/pay/alipay/UsrAlipayConfigService.java
@@ -12,8 +12,9 @@
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.AlipayConfigEntity;
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;
@@ -27,22 +28,22 @@
 */
@Service
@AllArgsConstructor
public class UsrAlipayConfigService extends BaseServiceImpl<UsrAlipayConfigMapper, AlipayConfigEntity> {
public class UsrAlipayConfigService extends BaseServiceImpl<UsrAlipayConfigMapper, AliConfigEntity> {
    private final UsrAlipayConfigMapper usrAlipayConfigMapper;
    private final ClientService clientService;
    private final PoleService poleService;
    public AlipayConfigEntity getConfigByPoleId(Long poleId) {
    public AliConfigEntity getConfigByPoleId(Long poleId) {
        Pole pole = poleService.getById(poleId);
        if (pole == null) {
            throw new BusinessException("灯杆id错误或灯杆不存在");
        }
        AlipayConfigEntity config;
        AliConfigEntity config;
        if (pole.getClientId() == null) {
            config = getById(0);
        }
        config = getOne(Wrappers.lambdaQuery(AlipayConfigEntity.class).eq(AlipayConfigEntity::getCreateUserId, SecurityUtils.getUserId()));
        config = getOne(Wrappers.lambdaQuery(AliConfigEntity.class).eq(AliConfigEntity::getCreateUserId, SecurityUtils.getUserId()));
        if(config==null){
            throw new BusinessException("用户未配置支付配置,请配置后重试");
        }
@@ -56,24 +57,30 @@
    public boolean addAliPayConfig(AlipayConfigParam configParam){
        AlipayConfigEntity config =new AlipayConfigEntity();
        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){
        AlipayConfigEntity byId = getById(id);
        AliConfigEntity byId = getById(id);
        if(byId==null){
            throw new BusinessException("配置id错误或配置不存在");
        }
        AlipayConfigEntity config =new AlipayConfigEntity();
        AliConfigEntity config =new AliConfigEntity();
        BeanUtil.copyProperties(configParam,config);
        config.setConfigId(id);
        return updateById(config);
    }
    public boolean deleteAliPayConfig(Integer id){
        AlipayConfigEntity byId = getById(id);
        AliConfigEntity byId = getById(id);
        if(byId==null){
            throw new BusinessException("配置id错误或配置不存在");
        }
@@ -82,21 +89,41 @@
    public List<AlipayConfigEntity> configList(BaseConditionVO baseConditionVO){
        LambdaQueryWrapper<AlipayConfigEntity> wrapper =new LambdaQueryWrapper<>();
    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(AlipayConfigEntity.class).eq(AlipayConfigEntity::getCreateUserId,SecurityUtils.getUserId());
                wrapper= Wrappers.lambdaQuery(AliConfigEntity.class).eq(AliConfigEntity::getCreateUserId,SecurityUtils.getUserId());
            }else if(!clientService.findClientId()){//一级客户
                PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
                wrapper= Wrappers.lambdaQuery(AlipayConfigEntity.class).eq(AlipayConfigEntity::getClientId,SecurityUtils.getUserId());
                wrapper= Wrappers.lambdaQuery(AliConfigEntity.class).eq(AliConfigEntity::getClientId,SecurityUtils.getUserId());
            }
        } else {//管理
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
            wrapper= Wrappers.lambdaQuery(AlipayConfigEntity.class);
            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);
    }