From 8509cf16f54ec1cd501a7e1187cfa75d45abaa9a Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Tue, 12 Aug 2025 18:15:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/device/DeviceController.java | 14 +++- .../product/service/device/DeviceService.java | 7 +- .../service/device/DeviceServiceImpl.java | 65 +++++++++++++++++-- .../src/main/resources/application-local.yaml | 4 +- .../src/main/resources/application.yaml | 8 ++- 5 files changed, 84 insertions(+), 14 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/device/DeviceController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/device/DeviceController.java index f86b7b9..08dec9b 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/device/DeviceController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/device/DeviceController.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.product.controller.admin.device; import org.springframework.web.bind.annotation.*; + import javax.annotation.Resource; + import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.v3.oas.annotations.tags.Tag; @@ -18,11 +20,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; + import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; import cn.iocoder.yudao.module.product.controller.admin.device.vo.*; @@ -53,6 +57,12 @@ public class DeviceController { return success(true); } + @GetMapping("/refresh-wechat-code") + @Operation(summary = "刷新小程序二维码") + public CommonResult refreshWechantCode(@RequestParam Long id) { + return success(deviceService.refreshWechantCode(id)); + } + @DeleteMapping("/delete") @Operation(summary = "删除贩卖机信息") @Parameter(name = "id", description = "编号", required = true) @@ -84,12 +94,12 @@ public class DeviceController { @PreAuthorize("@ss.hasPermission('product:device:export')") @ApiAccessLog(operateType = EXPORT) public void exportDeviceExcel(@Valid DevicePageReqVO pageReqVO, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = deviceService.getDevicePage(pageReqVO).getList(); // 导出 Excel ExcelUtils.write(response, "贩卖机信息.xls", "数据", DeviceRespVO.class, - BeanUtils.toBean(list, DeviceRespVO.class)); + BeanUtils.toBean(list, DeviceRespVO.class)); } } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java index 1ff3e79..1b397bd 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.device; import java.util.*; import javax.validation.*; + import cn.iocoder.yudao.module.product.controller.admin.device.vo.*; import cn.iocoder.yudao.module.product.dal.dataobject.device.DeviceDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -29,6 +30,11 @@ public interface DeviceService { */ void updateDevice(@Valid DeviceSaveReqVO updateReqVO); + /** + * 刷新小程序二维码 + */ + String refreshWechantCode(Long id); + /** * 删除贩卖机信息 * @@ -51,5 +57,4 @@ public interface DeviceService { * @return 贩卖机信息分页 */ PageResult getDevicePage(DevicePageReqVO pageReqVO); - } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java index bf90cec..2e52d39 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java @@ -1,17 +1,26 @@ package cn.iocoder.yudao.module.product.service.device; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.product.service.device.bo.DispenseRequestBo; import cn.iocoder.yudao.module.product.service.device.bo.DispenseResponseBo; +import cn.iocoder.yudao.module.system.api.social.SocialClientApi; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.*; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; + import javax.annotation.Resource; + import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.*; + import cn.iocoder.yudao.module.product.controller.admin.device.vo.*; import cn.iocoder.yudao.module.product.dal.dataobject.device.DeviceDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -37,6 +46,11 @@ public class DeviceServiceImpl implements DeviceService { @Resource private DeviceMapper deviceMapper; + @Resource + private SocialClientApi socialClientApi; + @Resource + private FileApi fileApi; + // TOKEN @Value("${xr.cabinet.token}") private String token; @@ -45,6 +59,9 @@ public class DeviceServiceImpl implements DeviceService { @Value("${xr.cabinet.api_url}") private String api_url; + @Value("${xr.cabinet.wechat-product-path}") + private String wechatProductPath; + @Override public Long createDevice(DeviceSaveReqVO createReqVO) { // 插入 @@ -52,7 +69,7 @@ public class DeviceServiceImpl implements DeviceService { deviceMapper.insert(device); DispenseRequestBo request = new DispenseRequestBo(); request.setDeviceId(createReqVO.getDeviceId()); - request.setMessage(createReqVO.getProductUrl()+","+createReqVO.getFileUrl()); + request.setMessage(createReqVO.getProductUrl() + "," + createReqVO.getFileUrl()); // 设置请求头 HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); @@ -80,12 +97,12 @@ public class DeviceServiceImpl implements DeviceService { System.out.println("上传成功!详情: " + body.getData()); } else { System.out.println("操作失败!原因: " + body.getMsg()); - log.error("设备--{}:[图片上传失败]:原因: {}",createReqVO.getDeviceId(), body.getMsg()); + log.error("设备--{}:[图片上传失败]:原因: {}", createReqVO.getDeviceId(), body.getMsg()); } } } catch (Exception e) { System.err.println("图片上传请求异常: " + e.getMessage()); - log.error("设备--{}:[图片上传异常]:原因: {}",createReqVO.getDeviceId(), e.getMessage()); + log.error("设备--{}:[图片上传异常]:原因: {}", createReqVO.getDeviceId(), e.getMessage()); } // 返回 return device.getId(); @@ -99,7 +116,7 @@ public class DeviceServiceImpl implements DeviceService { DeviceDO updateObj = BeanUtils.toBean(updateReqVO, DeviceDO.class); DispenseRequestBo request = new DispenseRequestBo(); request.setDeviceId(updateReqVO.getDeviceId()); - request.setMessage(updateReqVO.getProductUrl()+","+updateReqVO.getFileUrl()); + request.setMessage(updateReqVO.getProductUrl() + "," + updateReqVO.getFileUrl()); // 设置请求头 HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); @@ -127,16 +144,52 @@ public class DeviceServiceImpl implements DeviceService { System.out.println("上传成功!详情: " + body.getData()); } else { System.out.println("操作失败!原因: " + body.getMsg()); - log.error("设备--{}:[图片上传失败]:原因: {}",updateReqVO.getDeviceId(), body.getMsg()); + log.error("设备--{}:[图片上传失败]:原因: {}", updateReqVO.getDeviceId(), body.getMsg()); } } } catch (Exception e) { System.err.println("图片上传请求异常: " + e.getMessage()); - log.error("设备--{}:[图片上传异常]:原因: {}",updateReqVO.getDeviceId(), e.getMessage()); + log.error("设备--{}:[图片上传异常]:原因: {}", updateReqVO.getDeviceId(), e.getMessage()); } deviceMapper.updateById(updateObj); } + @Override + public String refreshWechantCode(Long id) { + // 校验存在 + validateDeviceExists(id); + + String wechatPagePath = wechatProductPath; + String wechatPathParams = String.format("deviceId=%s", id); + String wechatFullPath = String.format("%s?%s", wechatPagePath, wechatPathParams); + + SocialWxQrcodeReqDTO codeObj = new SocialWxQrcodeReqDTO(); + codeObj.setPath(wechatPagePath); + codeObj.setAutoColor(false); + codeObj.setHyaline(false); + codeObj.setScene(wechatPathParams); + try { + // 生成微信小程序二维码 + byte[] imageByte = socialClientApi.getWxaQrcode(codeObj); + // 保存二维码 + String file = fileApi.createFile(imageByte); + if (ObjectUtil.isEmpty(file)) { + log.error("设备--{}:[微信二维码保存失败]", id); + return null; + } + // 更新一下 + DeviceDO updateObj = DeviceDO.builder().id(id).productUrl(wechatFullPath).fileUrl(file).build(); + deviceMapper.updateById(updateObj); + // 刷新一下硬件设备 + updateDevice(BeanUtil.toBean(deviceMapper.selectById(id), DeviceSaveReqVO.class)); + return file; + } catch (Exception e) { + e.printStackTrace(); + log.error("设备--{}:[微信二维码生成失败]:原因: {}", id, e.getMessage()); + } + return ""; + } + @Override public void deleteDevice(Long id) { // 校验存在 diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index ce33a4c..627b168 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -80,7 +80,7 @@ spring: host: 127.0.0.1 # 地址 port: 6379 # 端口 database: 10 # 数据库索引 - password: 123456 # 密码,建议生产环境开启 + # password: 123456 # 密码,建议生产环境开启 --- #################### 定时任务相关配置 #################### @@ -236,7 +236,7 @@ yudao: enable: false demo: false # 关闭演示模式 wxa-code: - env-version: develop # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop" + env-version: trial # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop" wxa-subscribe-message: miniprogram-state: developer # 跳转小程序类型:开发版为 “developer”;体验版为 “trial”为;正式版为 “formal” tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index a107521..1c1efd1 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -3,8 +3,8 @@ spring: name: yudao-server profiles: - active: prod -# active: local + # active: prod + active: local main: allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 @@ -367,4 +367,6 @@ pf4j: xr: cabinet: token: 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcHAxIiwiaWF0IjoxNzQ5MTMzNzE5LCJleHAiOjIwNjAxNzM3MTl9.u2VUKxPxE2H8xldabMVRYSJKf6LN-XZfbcfyj1T7czI' - api_url: 'http://116.148.200.224:9527/ots/multiDispense' \ No newline at end of file + api_url: 'http://116.148.200.224:9527/ots/multiDispense' + # 小程序的自提柜商品 + wechat-product-path: 'pages/selfpickupcabinet/index' \ No newline at end of file From f371735230ecf567655e217d0282376ffa51a77e Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Tue, 12 Aug 2025 18:21:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/product/service/device/DeviceService.java | 6 ------ .../module/product/service/device/DeviceServiceImpl.java | 5 ----- 2 files changed, 11 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java index 8d4d137..77c1bc1 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceService.java @@ -3,10 +3,7 @@ package cn.iocoder.yudao.module.product.service.device; import java.util.*; import javax.validation.*; -<<<<<<< HEAD -======= import cn.iocoder.yudao.module.product.api.device.dto.DeviceRespDto; ->>>>>>> 6cfa240cdbf3588398a1cbdc4c81c7b8eabb9e20 import cn.iocoder.yudao.module.product.controller.admin.device.vo.*; import cn.iocoder.yudao.module.product.dal.dataobject.device.DeviceDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -61,13 +58,10 @@ public interface DeviceService { * @return 贩卖机信息分页 */ PageResult getDevicePage(DevicePageReqVO pageReqVO); -<<<<<<< HEAD -======= DeviceRespDto getDeviceByDeviceId(String deviceId); List getDeviceByDeviceIds(List deviceIds); int updateDeviceLastChannel(String deviceId, String cabinetChannel); ->>>>>>> 6cfa240cdbf3588398a1cbdc4c81c7b8eabb9e20 } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java index 7584f38..675c247 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/device/DeviceServiceImpl.java @@ -1,13 +1,9 @@ package cn.iocoder.yudao.module.product.service.device; -<<<<<<< HEAD import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.module.infra.api.file.FileApi; -======= import cn.iocoder.yudao.module.product.api.device.dto.DeviceRespDto; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; ->>>>>>> 6cfa240cdbf3588398a1cbdc4c81c7b8eabb9e20 import cn.iocoder.yudao.module.product.service.device.bo.DispenseRequestBo; import cn.iocoder.yudao.module.product.service.device.bo.DispenseResponseBo; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; @@ -15,7 +11,6 @@ import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.*; -import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import javax.annotation.Resource; From 00849fbf7622b561e095a748b7298d9babe8f023 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Tue, 12 Aug 2025 18:24:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-server/src/main/resources/application-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-server/src/main/resources/application-prod.yaml b/yudao-server/src/main/resources/application-prod.yaml index 5e6fd5b..f961325 100644 --- a/yudao-server/src/main/resources/application-prod.yaml +++ b/yudao-server/src/main/resources/application-prod.yaml @@ -221,7 +221,7 @@ yudao: enable: false demo: false # 关闭演示模式 wxa-code: - env-version: develop # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop" + env-version: release # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop" wxa-subscribe-message: miniprogram-state: developer # 跳转小程序类型:开发版为 “developer”;体验版为 “trial”为;正式版为 “formal” tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc