guohongjin
2024-05-01 1901fceb6ddaa56a57f3131191454554c3e77e68
rest/src/main/java/cn/stylefeng/rest/modular/user/service/CustomerLoginBizService.java
@@ -49,12 +49,29 @@
        return loginResponse;
    }
    public LoginResponse wxOpenIdLogin(String wxOpenId, String phone, CustomerUserTypeEnum userType) {
    public LoginResponse wxOpenIdLogin(String wxOpenId, String phone, String workerNo, CustomerUserTypeEnum userType) {
        // 查询用户信息
        Wrapper wrapper = Wrappers.<Customer>lambdaQuery()
                .eq(Customer::getUserType, userType.getCode())
                .eq(Customer::getWxOpenId, wxOpenId);
        Customer customer = customerService.getOne(wrapper, false);
        if (customer == null && StrUtil.isNotBlank(phone)) {
            // 判断手机号是否注册
            Wrapper phonewrapper = Wrappers.<Customer>lambdaQuery()
                    .eq(Customer::getUserType, userType.getCode())
                    .eq(Customer::getAccount, phone)
                    .last("LIMIT 1");
            customer = customerService.getOne(phonewrapper, false);
            if (customer != null) {
                // 更新微信openId
                customerService.update(
                        Wrappers.<Customer>lambdaUpdate()
                                .set(Customer::getWxOpenId, wxOpenId)
                                .eq(Customer::getCustomerId, customer.getCustomerId())
                );
            }
        }
        // 账号不存在时,判断是否去注册
        assertAccountNoExistToReg(customer, userType, phone, wxOpenId);
@@ -63,6 +80,12 @@
            // 可能已经注册的用户,再获取一次用户
            customer = customerService.getOne(wrapper, false);
        }
        if (StrUtil.isNotBlank(workerNo)) {
            // 绑定顾问岗位ID数据
            customerService.userBindClassConsultWorkerId(customer.getCustomerId(), workerNo);
        }
        // 用户登录信息
        LoginResponse loginResponse = customerService.wrapperLoginResponse(customer, new LoginRequest());
        return loginResponse;