2021与蓝度共同重构项目,服务端
liuhaonan
2022-03-18 afeba1406c1b5848c532b7c6dcec7f320d2a14f1
ximon-admin/src/main/java/com/sandu/ximon/admin/pay/alipay/UsrAlipayConfigService.java
@@ -12,7 +12,7 @@
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.mapper.UsrAlipayConfigMapper;
import lombok.AllArgsConstructor;
@@ -27,22 +27,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 +56,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 +88,21 @@
    public List<AlipayConfigEntity> configList(BaseConditionVO baseConditionVO){
        LambdaQueryWrapper<AlipayConfigEntity> wrapper =new LambdaQueryWrapper<>();
    public List<AliConfigEntity> configList(BaseConditionVO baseConditionVO){
        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);
        }
        return list(wrapper);
    }