ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -835,6 +835,8 @@ TErpGoods goods = erpGoodsService.getById(dto.getId()); goods.setClinicPurchasePrice(BigDecimal.valueOf(dto.getClinicPurchasePrice()).setScale(2, RoundingMode.HALF_UP)); goods.setPlatformCommissionPrice(BigDecimal.valueOf(dto.getPlatformCommissionPrice()).setScale(2, RoundingMode.HALF_UP)); goods.setRetailPrice(dto.getRetailPrice()); goods.setSalesAmount(dto.getRetailPrice()); erpGoodsService.updateById(goods); } return R.ok(); ruoyi-admin/src/main/resources/application-test.yml
@@ -235,6 +235,6 @@ # 证书序列号 mchSerialNo: 39C7F6152E38A62B5786634D5C1F984FB5A38AD5 # 支付成功回调地址 notifyPayUrl: http://221.182.45.100/wx/pay/notify notifyPayUrl: http://221.182.45.100:8089/wx/pay/notify # 支付退款回调地址 notifyRefundUrl: http://221.182.45.100/wx/refund/notify notifyRefundUrl: http://221.182.45.100:8089/wx/refund/notify ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/H5AICallbackController.java
@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -134,7 +135,7 @@ @PostMapping("/xiMaReportPush") public JSONObject xiMaReportPush(JSONObject json) throws Exception { public JSONObject xiMaReportPush(@RequestBody JSONObject json){ TSysAiConfig sysAiConfig = sysAiConfigService.getById(1); // 应用AES秘钥 String clientKey = sysAiConfig.getClientKey(); @@ -217,7 +218,7 @@ } @PostMapping("/xiMaDoubleScreenReportPush") public JSONObject xiMaDoubleScreenReportPush(JSONObject jsonObject) throws Exception { public JSONObject xiMaDoubleScreenReportPush(@RequestBody JSONObject jsonObject){ log.info("双屏仪报告推送:{}",jsonObject); // 主体信息 String reportTime = jsonObject.getString("report_time"); // 报告时间 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysAppUserController.java
@@ -4,35 +4,37 @@ 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.common.core.redis.RedisCache; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.model.TCrmClinic; import com.ruoyi.system.model.TSysAppUser; import com.ruoyi.system.model.TSysChronicDisease; import com.ruoyi.system.model.TSysInspection; import com.ruoyi.system.model.*; 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> @@ -60,8 +62,9 @@ private final WeixinProperties wxConfig; private final TCrmClinicService crmClinicService; private final ISysUserService sysUserService; private final TSysOtherConfigService sysOtherConfigService; @Autowired public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, TokenService tokenService, RedisCache redisCache, XimaAIUtil ximaAIUtil, RestTemplate restTemplate, FileController fileController, WeixinProperties wxConfig, TCrmClinicService crmClinicService, ISysUserService sysUserService) { public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, TokenService tokenService, RedisCache redisCache, XimaAIUtil ximaAIUtil, RestTemplate restTemplate, FileController fileController, WeixinProperties wxConfig, TCrmClinicService crmClinicService, ISysUserService sysUserService, TSysOtherConfigService sysOtherConfigService) { this.sysAppUserService = sysAppUserService; this.sysInspectionService = sysInspectionService; this.sysOrderService = sysOrderService; @@ -74,6 +77,7 @@ this.wxConfig = wxConfig; this.crmClinicService = crmClinicService; this.sysUserService = sysUserService; this.sysOtherConfigService = sysOtherConfigService; } /** @@ -123,6 +127,9 @@ }else { sysAppUserVO.setIsClinicUser(0); } // 查询免费次数 TSysOtherConfig sysOtherConfig = sysOtherConfigService.getById(1); sysAppUserVO.setAiFreeCount(sysOtherConfig.getAiFreeCount()); return R.ok(sysAppUserVO); } @@ -167,7 +174,12 @@ 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("请先完善用户信息"); } @@ -176,7 +188,7 @@ 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); } @@ -196,6 +208,31 @@ 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", "pages/invite/invite"); 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.obsUploadQrCode(file,"qrcode_"+crmClinic.getId()+".jpg"); crmClinic.setQrCode(stringApiResult); } catch (Exception e) { log.error("生成小程序码失败:{}", e.getMessage()); } crmClinicService.updateById(crmClinic); } return R.ok(crmClinic.getQrCode()); } ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysInspectionController.java
@@ -10,9 +10,11 @@ import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.model.TSysAppUser; import com.ruoyi.system.model.TSysInspection; import com.ruoyi.system.model.TSysOtherConfig; import com.ruoyi.system.query.TSysInspectionQuery; import com.ruoyi.system.service.TSysAppUserService; import com.ruoyi.system.service.TSysInspectionService; import com.ruoyi.system.service.TSysOtherConfigService; import com.ruoyi.system.utils.util.AIUtil; import com.ruoyi.system.vo.TSysInspectionVO; import io.swagger.annotations.Api; @@ -40,13 +42,15 @@ private final TSysInspectionService sysInspectionService; private final TokenService tokenService; private final TSysAppUserService sysAppUserService; private final TSysOtherConfigService sysOtherConfigService; private final AIUtil aiUtil; private final RedisCache redisCache; @Autowired public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService, TSysAppUserService sysAppUserService, AIUtil aiUtil, RedisCache redisCache) { public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService, TSysAppUserService sysAppUserService, TSysOtherConfigService sysOtherConfigService, AIUtil aiUtil, RedisCache redisCache) { this.sysInspectionService = sysInspectionService; this.tokenService = tokenService; this.sysAppUserService = sysAppUserService; this.sysOtherConfigService = sysOtherConfigService; this.aiUtil = aiUtil; this.redisCache = redisCache; } @@ -67,7 +71,24 @@ @ApiOperation(value = "查看用户检测信息管理详情") @GetMapping(value = "/getDetailById") public R<TSysInspection> getDetailById(@RequestParam String id) { return R.ok(sysInspectionService.getById(id)); // 查询用户信息 String userId = tokenService.getLoginUserApplet().getUserId(); TSysAppUser sysAppUser = sysAppUserService.getById(userId); // 匹配免费次数 TSysOtherConfig sysOtherConfig = sysOtherConfigService.getById(1); TSysInspection sysInspection = sysInspectionService.getById(id); if(sysInspection.getIsPay() == 0 && sysInspection.getInspectionType() == 2){ // 匹配免费次数 if(Objects.equals(sysAppUser.getUseAiFreeCount(), sysOtherConfig.getAiFreeCount())){ return R.fail("您已使用完免费次数"); } // 检测免费次数 sysAppUser.setUseAiFreeCount(sysAppUser.getUseAiFreeCount() + 1); sysAppUserService.updateById(sysAppUser); sysInspection.setIsPay(1); sysInspectionService.updateById(sysInspection); } return R.ok(sysInspection); } /** ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxPayController.java
@@ -66,7 +66,7 @@ */ @ApiOperation("订单支付") @PostMapping("orderPay") public R<Map<String, Object>> orderPay(@RequestParam(value = "inspectionId") String inspectionId,@RequestParam(value = "orderType") Integer orderType) { public R<Map<String, Object>> orderPay(@RequestParam(value = "inspectionId",required = false) String inspectionId,@RequestParam(value = "orderType") Integer orderType) { TSysOtherConfig sysOtherConfig = sysOtherConfigService.getById(1); String userId = tokenService.getLoginUserApplet().getUserId(); @@ -138,8 +138,9 @@ TSysAppUser appUser = sysAppUserService.getById(appUserId); if (sysPayRecord.getOrderType()==2){ LocalDateTime localDateTime = LocalDateTime.now().plusMonths(1L); localDateTime = localDateTime.withHour(23).withMinute(59).withSecond(59); localDateTime = localDateTime.withHour(23).withMinute(59).withSecond(57); appUser.setVipEndTime(localDateTime); sysAppUserService.updateById(appUser); List<TSysInspection> list = sysInspectionService.lambdaQuery().eq(TSysInspection::getAppUserId, appUserId) .list(); if (!list.isEmpty()){ @@ -148,13 +149,13 @@ } sysInspectionService.updateBatchById(list); } }else { // 处理检测报告为可见 TSysInspection sysInspection = sysInspectionService.getById(sysPayRecord.getInspectionId()); sysInspection.setIsPay(1); sysInspectionService.updateById(sysInspection); } sysPayRecordService.updateById(sysPayRecord); // 处理检测报告为可见 TSysInspection sysInspection = sysInspectionService.getById(sysPayRecord.getInspectionId()); sysInspection.setIsPay(1); sysInspectionService.updateById(sysInspection); PrintWriter out = response.getWriter(); out.print("SUCCESS"); ruoyi-applet/src/main/resources/application-prod.yml
@@ -225,7 +225,7 @@ secretId: 79c234527fd3b6553679d52be5e29b19 v3: # 加签串 apiKey: V7mKp9qL2Rs4jU6tX8wZ0bC3eF5hN1yD4gA apiKey: V7mKp9qL2Rs4jU6tX8wZ0bC3eF5hN1yD # 加签证书地址 privateKeyPath: /usr/local/project/cert/weixin/apiclient_key.pem # 微信支付公钥id ruoyi-applet/src/main/resources/application-test.yml
@@ -213,7 +213,7 @@ secretId: 79c234527fd3b6553679d52be5e29b19 v3: # 加签串 apiKey: V7mKp9qL2Rs4jU6tX8wZ0bC3eF5hN1yD4gA apiKey: V7mKp9qL2Rs4jU6tX8wZ0bC3eF5hN1yD # 加签证书地址 privateKeyPath: D:/app/cert/weixin/apiclient_key.pem # 微信支付公钥id @@ -223,6 +223,6 @@ # 证书序列号 mchSerialNo: 39C7F6152E38A62B5786634D5C1F984FB5A38AD5 # 支付成功回调地址 notifyPayUrl: http://221.182.45.100/wx/pay/notify notifyPayUrl: http://221.182.45.100:8088/wx/pay/notify # 支付退款回调地址 notifyRefundUrl: http://221.182.45.100/wx/refund/notify notifyRefundUrl: http://221.182.45.100:8088/wx/refund/notify ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -126,7 +126,7 @@ "/t-sys-educational-info/list","/t-sys-educational-info/getDetailById","/t-sys-educational-info/pageList", "/t-sys-live/list","/t-sys-live/getDetailById","/t-sys-live/pageList","/t-sys-qualifications/list", "/open/**","/cos/get/**","/openIdByJsCode","/t-sys-order/**","/openIdByCode","/tRegion/sendTest" ,"/t-sys-qualifications/pageList","/t-sys-qualifications/getDetailById" ,"/t-sys-qualifications/pageList","/t-sys-qualifications/getDetailById","/wx/pay/notify" ).permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsInfoSaveDto.java
@@ -93,4 +93,10 @@ @ApiModelProperty(value = "贮藏") private String storage; @ApiModelProperty(value = "封面") private String cover; @ApiModelProperty(value = "详情图") private String detailPictures; } ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsSetCommissionDto.java
@@ -1,5 +1,6 @@ package com.ruoyi.system.dto; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -21,4 +22,7 @@ @ApiModelProperty(value = "平台分佣金额") @NotNull(message = "平台分佣金额不能为空") private Double platformCommissionPrice; @ApiModelProperty(value = "建议零售价") @NotNull(message = "建议零售价不能为空") private BigDecimal retailPrice; } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysBannerServiceImpl.java
@@ -56,30 +56,32 @@ return pageInfo; } for (TSysBannerVO sysBannerVO : list) { switch (sysBannerVO.getJumpType()){ case 2: TSysEducationalInfo educationalInfo = sysEducationalInfoMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(educationalInfo)){ sysBannerVO.setContentName(educationalInfo.getInfoTitle()); } break; case 3: TSysLive sysLive = sysLiveMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(sysLive)){ sysBannerVO.setContentName(sysLive.getLiveTitle()); } break; case 4: TSysProductIntroduction sysProductIntroduction = sysProductIntroductionMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(sysProductIntroduction)){ sysBannerVO.setContentName(sysProductIntroduction.getProductName()); } break; case 5: TSysActivity sysActivity = sysActivityMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(sysActivity)){ sysBannerVO.setContentName(sysActivity.getActivityName()); } if(Objects.nonNull(sysBannerVO.getJumpType())){ switch (sysBannerVO.getJumpType()){ case 2: TSysEducationalInfo educationalInfo = sysEducationalInfoMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(educationalInfo)){ sysBannerVO.setContentName(educationalInfo.getInfoTitle()); } break; case 3: TSysLive sysLive = sysLiveMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(sysLive)){ sysBannerVO.setContentName(sysLive.getLiveTitle()); } break; case 4: TSysProductIntroduction sysProductIntroduction = sysProductIntroductionMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(sysProductIntroduction)){ sysBannerVO.setContentName(sysProductIntroduction.getProductName()); } break; case 5: TSysActivity sysActivity = sysActivityMapper.selectById(sysBannerVO.getContentId()); if(Objects.nonNull(sysActivity)){ sysBannerVO.setContentName(sysActivity.getActivityName()); } } } } pageInfo.setRecords(list); ruoyi-system/src/main/java/com/ruoyi/system/utils/util/ObsUploadUtil.java
@@ -36,6 +36,21 @@ } return fileName; } public static String obsUploadQrCode(MultipartFile file,String originalFilename) throws IOException{ String fileName = ""; if(file!=null){ InputStream content = file.getInputStream();//获得指定文件的输入流 ObjectMetadata meta = new ObjectMetadata();// 创建上传Object的Metadata meta.setContentLength(file.getSize()); // 必须设置ContentLength fileName = UUID.randomUUID().toString().replaceAll("-","") + originalFilename.subSequence(originalFilename.lastIndexOf("."), originalFilename.length()); obsClient.putObject(bucketName,"file/"+fileName,content,meta);// 上传Object. if(fileName != null && !"".equals(fileName)){ System.out.println(fileName); fileName = oss_domain+"file/"+fileName; } } return fileName; } /** * 删除某个Object ruoyi-system/src/main/java/com/ruoyi/system/utils/xiMaUtil/AesUtil.java
@@ -1,16 +1,12 @@ package com.ruoyi.system.utils.xiMaUtil; import java.security.Security; import org.bouncycastle.jce.provider.BouncyCastleProvider; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import org.bouncycastle.jce.provider.BouncyCastleProvider; import java.security.Security; /** * @@ -41,8 +37,8 @@ byte[] iv = Base64.getDecoder().decode(keyStr); byte[] key = Base64.getDecoder().decode(keyStr); */ String key = "ciicciicciicciic"; String iv = "ciic2022ciic2022"; String key = "7bc47ce80ff74c1cbebad1ced111243d"; String iv = "69b84732eace4e6a"; String content = "1234567890"; String encrypted = encrypt(key, iv, content); System.out.println("加密后: " + encrypted); ruoyi-system/src/main/java/com/ruoyi/system/utils/xiMaUtil/XimaAIUtil.java
@@ -34,7 +34,7 @@ * @param device_type 设备类型:android ios * @return */ public JSONObject getAuthorizationH5(String out_user_id,String nickname,String phone,String sex,Integer height,Integer weight,String device_type) { public JSONObject getAuthorizationH5(String out_user_id,String nickname,String phone,String sex,String birthday,Integer height,Integer weight,String device_type) { TSysAiConfig sysAiConfig = sysAiConfigService.getById(1); JSONObject jsonObject = new JSONObject(); jsonObject.put("client_id", sysAiConfig.getClientId()); @@ -42,6 +42,7 @@ jsonObject.put("out_user_id", out_user_id); jsonObject.put("nickname", nickname); jsonObject.put("phone", phone); jsonObject.put("birthday", birthday); jsonObject.put("sex", sex); jsonObject.put("height", height); jsonObject.put("weight", weight); ruoyi-system/src/main/java/com/ruoyi/system/vo/TSysAppUserVO.java
@@ -37,4 +37,7 @@ @ApiModelProperty(value = "是否为诊所用户 1=是 0=否") private Integer isClinicUser; @ApiModelProperty(value = "系统免费次数") private Integer aiFreeCount; } ruoyi-system/src/main/java/com/ruoyi/system/wxPay/utils/WxV3Pay.java
@@ -134,7 +134,7 @@ JsapiPrepay.DirectAPIv3JsapiPrepayResponse response = client.run(request); return wxTuneUp(this.privateKeySigner, this.config.getAppId(), response.prepayId); } catch (WXPayUtility.ApiException e) { throw new RuntimeException("获取支付数据错误!"); throw new RuntimeException("获取支付数据错误!"+e.getErrorMessage()); } } // /** ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -464,7 +464,7 @@ t1.instructions_use like concat('%',#{query.queryCondition},'%') or t1.ingredient like concat('%',#{query.queryCondition},'%') or t1.trait like concat('%',#{query.queryCondition},'%') or t1.indication like concat('%',#{query.queryCondition},'%') or t1.indication like concat('%',#{query.queryCondition},'%') ) </if> <if test="query.goodsIds != null and query.goodsIds.size()>0">