2021与蓝度共同重构项目,服务端
liuhaonan
2022-06-27 a648f3e08210a1ed04bf819cccedc56e5afc24c3
ximon-admin/src/main/java/com/sandu/ximon/admin/pay/wxpay/UsrWxPayConfigService.java
@@ -41,10 +41,10 @@
        }
        WxConfigEntity config;
        //未设置支付参数,则使用默认支付参数
        if (pole.getClientId() == null) {
            config = getById(0);
        }
        config = getOne(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, pole.getClientId()).eq(WxConfigEntity::getState, 1));
        if (pole.getClientId() == null) {
            config = getById(15);  // todo 暂时写死,后续需要改成配置文件
        }
        if (config == null) {
            throw new BusinessException("用户未配置支付配置,请配置后重试");
        }
@@ -69,6 +69,9 @@
            } else {
                config.setClientId(SecurityUtils.getUserId());
            }
        } else {
            config.setClientId(SecurityUtils.getUserId());
            config.setCreateUserId(SecurityUtils.getUserId());
        }
        return save(config);
    }
@@ -99,15 +102,19 @@
        LambdaQueryWrapper<WxConfigEntity> wrapper = new LambdaQueryWrapper<>();
        System.out.println("----------------------------" + clientService.findClientId());
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        if (SecurityUtils.getClientId() != null) {//客户
            if (clientService.findClientId()) {//二级客户
        if (SecurityUtils.getClientId() != null) {
            //客户
            if (clientService.findClientId()) {
                //二级客户
                PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
                wrapper = Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId());
            } else if (!clientService.findClientId()) {//一级客户
            } else if (!clientService.findClientId()) {
                //一级客户
                PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
                wrapper = Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, SecurityUtils.getUserId());
            }
        } else {//管理
        } else {
            //管理
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
            wrapper = Wrappers.lambdaQuery(WxConfigEntity.class);
        }
@@ -155,28 +162,38 @@
        /**
         * 获取当前用户所有的wx支付配置
         */
        List<WxConfigEntity> configList;
        if (SecurityUtils.getClientId() != null) {
            //客户
            List<WxConfigEntity> configList = list(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, SecurityUtils.getUserId())
            configList = list(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, SecurityUtils.getUserId())
                    .or(
                            user -> {
                                user.eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId());
                            }
                    ));
            if (configList.size() == 1 && state == 0) {
                throw new BusinessException("当前用户只有一个支付配置,不能停用");
            }
            //设置当前用户所有的支付配置为停用
            configList.forEach(
                    wxConfigEntity -> {
                        wxConfigEntity.setState(0);
                    }
            );
            boolean b = updateBatchById(configList);
            if (!b) {
                throw new BusinessException("更新失败");
            }
        } else {
            //管理
            configList = list(Wrappers.lambdaQuery(WxConfigEntity.class).eq(WxConfigEntity::getClientId, byId.getCreateUserId())
                    .or(
                            user -> {
                                user.eq(WxConfigEntity::getCreateUserId, SecurityUtils.getUserId());
                            }
                    ));
        }
        if (configList.size() == 1 && state == 0) {
            throw new BusinessException("当前用户只有一个支付配置,不能停用");
        }
        //设置当前用户所有的支付配置为停用
        configList.forEach(
                wxConfigEntity -> {
                    wxConfigEntity.setState(0);
                }
        );
        boolean b = updateBatchById(configList);
        if (!b) {
            throw new BusinessException("更新失败");
        }
        WxConfigEntity config = new WxConfigEntity();
        config.setConfigId(id);
        config.setState(state);