| | |
| | | import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; |
| | | import cn.stylefeng.roses.kernel.sms.modular.param.SysSmsVerifyParam; |
| | | import cn.stylefeng.roses.kernel.sms.modular.service.SysSmsInfoService; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | return new SuccessResponseData(openId); |
| | | } |
| | | |
| | | @ApiOperation(value = "绑定微信OpenId") |
| | | @PostResource(name = "绑定微信OpenId", path = "/bindOpenId") |
| | | @ApiOperation(value = "绑定/解绑微信OpenId") |
| | | @PostResource(name = "绑定/解绑微信OpenId", path = "/bindOpenId") |
| | | public ResponseData<Boolean> bindOpenId(@RequestBody CustomerBindOpenIdRequest req) { |
| | | // 获取当前登录用户信息 |
| | | LoginUser loginUser = LoginContext.me().getLoginUser(); |
| | |
| | | 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); |
| | | } |
| | | if (!req.getCode().equals("111111")) { |
| | | // 验证码通过 |
| | | sysSmsInfoService.validateSmsInfo(req); |
| | | } |
| | | |
| | | // 验证码通过 |
| | | sysSmsInfoService.validateSmsInfo(req); |
| | | |
| | | |
| | | |
| | | |
| | | if (StrUtil.isNotBlank(req.getWorkerNo())) { |
| | | // 绑定顾问岗位ID数据 |
| | | customerService.userBindClassConsultWorkerId(validCustomer.getCustomerId(), req.getWorkerNo()); |
| | | } |
| | | |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(customerLoginBizService.phoneLogin(req.getPhone(), CustomerUserTypeEnum.USER)); |
| | |
| | | String phoneMd5 = MD5.create().digestHex(md5Salt + req.getPhone()); |
| | | Assert.isTrue(phoneMd5.equals(req.getPhoneMd5()), "手机号验证失败"); |
| | | |
| | | |
| | | |
| | | |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(customerLoginBizService.phoneLogin(req.getPhone(), CustomerUserTypeEnum.USER)); |
| | | } |
| | | |
| | | @ApiOperation(value = "微信OpenId是否注册") |
| | | @GetResource(name = "微信OpenId是否注册", path = RuleConstants.NOT_LOGIN + "/getOpenIdExist", requiredPermission = false, requiredLogin = false) |
| | | public ResponseData<Boolean> wxOpenIdLogin(String wxOpenId) { |
| | | // 查询用户信息 |
| | | Wrapper wrapper = Wrappers.<Customer>lambdaQuery() |
| | | .eq(Customer::getUserType, CustomerUserTypeEnum.USER.getCode()) |
| | | .eq(Customer::getWxOpenId, wxOpenId); |
| | | long count = customerService.count(wrapper); |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(count > 0); |
| | | } |
| | | |
| | | @ApiOperation(value = "微信OpenId登录") |
| | | @PostResource(name = "微信OpenId登录", path = RuleConstants.NOT_LOGIN + "/wxOpenIdLogin", requiredPermission = false, requiredLogin = false) |
| | | public ResponseData<LoginResponse> wxOpenIdLogin(@RequestBody CustomerWxOpenIdLoginRequest req) { |
| | | if (StrUtil.isNotBlank(req.getWorkerNo())) { |
| | | // 获取绑定顾问岗位ID(这里做校验) |
| | | customerService.getBindWorkerPostIds(req.getWorkerNo(), PostIdEnum.PO_11, PostIdEnum.PO_21); |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(req.getPhone())) { |
| | | // 验证码通过 |
| | | sysSmsInfoService.validateSmsInfo(req); |
| | | } |
| | | |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(customerLoginBizService.wxOpenIdLogin(req.getWxOpenId(), req.getPhone(), CustomerUserTypeEnum.USER)); |
| | | return new SuccessResponseData<>(customerLoginBizService.wxOpenIdLogin(req.getWxOpenId(), req.getPhone(), req.getWorkerNo(), CustomerUserTypeEnum.USER)); |
| | | } |
| | | |
| | | @ApiOperation("获取帮助列表(分页)") |