| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.constant.WxConstant; |
| | | import com.ruoyi.common.core.controller.FileController; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.query.TSysAppUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.utils.util.ObsUploadUtil; |
| | | import com.ruoyi.system.utils.wx.model.WeixinProperties; |
| | | import com.ruoyi.system.utils.wx.tools.WxAppletTools; |
| | | import com.ruoyi.system.utils.xiMaUtil.XimaAIUtil; |
| | | import com.ruoyi.system.vo.TSysAppUserVO; |
| | | import com.ruoyi.system.vo.TSysOrderVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.*; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TSysAppUser sysAppUser = sysAppUserService.getById(userId); |
| | | |
| | | if(StringUtils.isBlank(sysAppUser.getNickName()) || StringUtils.isBlank(sysAppUser.getPhone()) || Objects.isNull(sysAppUser.getSex()) ||Objects.isNull(sysAppUser.getUserHeight()) || Objects.isNull(sysAppUser.getUserWeight())){ |
| | | if(StringUtils.isBlank(sysAppUser.getNickName()) |
| | | || StringUtils.isBlank(sysAppUser.getPhone()) |
| | | || Objects.isNull(sysAppUser.getSex()) |
| | | || Objects.isNull(sysAppUser.getBirthTime()) |
| | | || Objects.isNull(sysAppUser.getUserHeight()) |
| | | || Objects.isNull(sysAppUser.getUserWeight())){ |
| | | return R.fail("请先完善用户信息"); |
| | | } |
| | | |
| | |
| | | sysAppUser.setIdentifierNumber(identifierNumber); |
| | | sysAppUserService.updateById(sysAppUser); |
| | | } |
| | | JSONObject authorizationH5 = ximaAIUtil.getAuthorizationH5(sysAppUser.getIdentifierNumber(), sysAppUser.getNickName(), sysAppUser.getPhone(), sysAppUser.getSex() == 1 ? "0" : "1", sysAppUser.getUserHeight(), sysAppUser.getUserWeight(), deviceType); |
| | | JSONObject authorizationH5 = ximaAIUtil.getAuthorizationH5(sysAppUser.getIdentifierNumber(), sysAppUser.getNickName(), sysAppUser.getPhone(), sysAppUser.getSex() == 1 ? "0" : "1",sysAppUser.getBirthTime().toString(), sysAppUser.getUserHeight(), sysAppUser.getUserWeight(), deviceType); |
| | | return R.ok(authorizationH5); |
| | | } |
| | | |
| | |
| | | if(Objects.isNull(crmClinic)){ |
| | | return R.fail("未找到该诊所信息"); |
| | | } |
| | | if(StringUtils.isBlank(crmClinic.getQrCode())){ |
| | | WxAppletTools wxAppletTools = new WxAppletTools(restTemplate, wxConfig, redisCache); |
| | | // 获取access_token |
| | | String accessToken = wxAppletTools.getAccessToken(); |
| | | // 替换CREATE_CODE_URL |
| | | String url = WxConstant.CREATE_CODE_URL.replace("ACCESS_TOKEN", accessToken); |
| | | // 发送请求 |
| | | try { |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("path", ""); |
| | | map.put("scene", "clinicId=" + crmClinic.getId()); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | HttpEntity requestEntity = new HttpEntity(map, headers); |
| | | ResponseEntity<byte[]> rep = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class); |
| | | byte[] bytes = rep.getBody(); |
| | | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); |
| | | MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), byteArrayInputStream); |
| | | String stringApiResult = ObsUploadUtil.obsUpload(file); |
| | | crmClinic.setQrCode(stringApiResult); |
| | | } catch (Exception e) { |
| | | log.error("生成小程序码失败:{}", e.getMessage()); |
| | | } |
| | | crmClinicService.updateById(crmClinic); |
| | | } |
| | | return R.ok(crmClinic.getQrCode()); |
| | | } |
| | | |