goupan
2024-04-24 dbebf83224d9aa1ad328d8d34e26d3a1f42597f8
rest/src/main/java/cn/stylefeng/rest/modular/user/controller/UserCenterController.java
@@ -135,6 +135,7 @@
            is.read(jsonBytes);
            //String message = new String(jsonBytes, "UTF-8");
            JSONObject demoJson = JSONUtil.parseObj(jsonBytes);
            log.info("微信授权access_token:{}", JSONUtil.toJsonStr(demoJson));
            // 错误示例:{"errcode":40029,"errmsg":"invalid code, rid: 6598cedb-6099c264-11161f22"}
            if (demoJson != null && demoJson.containsKey("errcode")) {
                log.error("获取微信openid失败!{}", demoJson);
@@ -182,13 +183,16 @@
        // 获取绑定顾问岗位ID
        String[] bindWorkerPostIds = customerService.getBindWorkerPostIds(workerNo, post11Enum, post21Enum);
        Customer workerByNo = customerService.getOne(
                Wrappers.<Customer>lambdaUpdate().eq(Customer::getWorkerNo, workerNo).last("LIMIT 1")
        );
        LambdaUpdateWrapper<Customer> wrapper = Wrappers.<Customer>lambdaUpdate().eq(Customer::getCustomerId, userId);
        for (String postId : bindWorkerPostIds) {
            if (postId.equals(post11Enum.getCode().toString())) {
                wrapper.set(Customer::getClassWorkerId, userId);
                wrapper.set(Customer::getClassWorkerId, workerByNo.getCustomerId());
            } else if (postId.equals(post21Enum.getCode().toString())) {
                wrapper.set(Customer::getConsultWorkerId, userId);
                wrapper.set(Customer::getConsultWorkerId, workerByNo.getCustomerId());
            }
        }
@@ -279,10 +283,38 @@
        if (StrUtil.isNotBlank(req.getWorkerNo())) {
            // 获取绑定顾问岗位ID(这里做校验)
            customerService.getBindWorkerPostIds(req.getWorkerNo(), PostIdEnum.PO_11, PostIdEnum.PO_21);
            //绑定工号
            // 幸福顾问
            PostIdEnum post11Enum = PostIdEnum.PO_11;
            // 咨询顾问
            PostIdEnum post21Enum = PostIdEnum.PO_21;
            // 获取绑定顾问岗位ID
            String[] bindWorkerPostIds = customerService.getBindWorkerPostIds(req.getWorkerNo(), post11Enum, post21Enum);
            Customer workerByNo = customerService.getOne(
                    Wrappers.<Customer>lambdaUpdate().eq(Customer::getWorkerNo, req.getWorkerNo()).last("LIMIT 1")
            );
            LambdaUpdateWrapper<Customer> wrapper = Wrappers.<Customer>lambdaUpdate().eq(Customer::getCustomerId, validCustomer.getCustomerId());
            for (String postId : bindWorkerPostIds) {
                if (postId.equals(post11Enum.getCode().toString())) {
                    wrapper.set(Customer::getClassWorkerId, workerByNo.getCustomerId());
                } else if (postId.equals(post21Enum.getCode().toString())) {
                    wrapper.set(Customer::getConsultWorkerId, workerByNo.getCustomerId());
                }
            }
            // 修改用户信息
            Boolean update = customerService.update(wrapper);
        }
        // 验证码通过
        sysSmsInfoService.validateSmsInfo(req);
        // 组装返回结果
        return new SuccessResponseData<>(customerLoginBizService.phoneLogin(req.getPhone(), CustomerUserTypeEnum.USER));
@@ -296,6 +328,9 @@
        String phoneMd5 = MD5.create().digestHex(md5Salt + req.getPhone());
        Assert.isTrue(phoneMd5.equals(req.getPhoneMd5()), "手机号验证失败");
        // 组装返回结果
        return new SuccessResponseData<>(customerLoginBizService.phoneLogin(req.getPhone(), CustomerUserTypeEnum.USER));
    }