From f8379c2b74fed7d6662ddab52d1a9503f2cdf540 Mon Sep 17 00:00:00 2001 From: dzq Date: Tue, 22 Apr 2025 10:46:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8QyLoginDTO=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0name=E5=AD=97=E6=AE=B5=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BC=80=E6=9F=9C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在QyLoginDTO中添加name字段以存储用户名称,并修改开柜逻辑以支持记录操作日志。具体更改包括: 1. 在QyLoginDTO中添加name字段 2. 将CabinetCellOperationEntity中的isInternal字段类型从Boolean改为Integer 3. 在PaymentController中获取用户名称并传递给QyLoginDTO 4. 在OrderController和OrderApplicationService中更新开柜逻辑,支持记录操作日志 --- .../api/controller/OrderController.java | 6 ++++-- .../api/controller/PaymentController.java | 4 +++- .../db/CabinetCellOperationEntity.java | 2 +- .../agileboot/domain/common/dto/QyLoginDTO.java | 1 + .../shop/order/OrderApplicationService.java | 17 ++++++++++++++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java index 5f29365..1caf913 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java @@ -2,6 +2,7 @@ package com.agileboot.api.controller; import com.agileboot.common.constant.PayApiConstants; import com.agileboot.common.core.base.BaseController; +import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand; import com.agileboot.domain.shop.order.dto.CreateOrderResult; import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO; import com.agileboot.domain.shop.order.model.OrderGoodsModelFactory; @@ -50,8 +51,9 @@ public class OrderController extends BaseController { * @return 空响应 */ @PostMapping("/openCabinet/{orderId}/{orderGoodsId}") - public ResponseDTO openCabinet(@PathVariable Long orderId, @PathVariable Long orderGoodsId) { - orderApplicationService.openOrderGoodsCabinet(orderId, orderGoodsId); + public ResponseDTO openCabinet(@PathVariable Long orderId, @PathVariable Long orderGoodsId, + @RequestBody AddCabinetCellOperationCommand operationCommand) { + orderApplicationService.openOrderGoodsCabinet(orderId, orderGoodsId, operationCommand); return ResponseDTO.ok(); } diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java index 54243ac..6f9bc4b 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java @@ -179,7 +179,9 @@ public class PaymentController { OpenidResponse openidResponse = QywxApiUtil.convertToOpenid(qyAccessToken.getAccessToken(), userid); - return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin)); + QyUserEntity qyUserEntity = qyUserApplicationService.getUserByUserId(userid, corpid); + + return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin, qyUserEntity.getName())); } catch (RestClientException e) { log.error("qyLogin失败", e); return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "微信服务调用失败")); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/operation/db/CabinetCellOperationEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/operation/db/CabinetCellOperationEntity.java index cee61fd..d9c746d 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/operation/db/CabinetCellOperationEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/operation/db/CabinetCellOperationEntity.java @@ -49,7 +49,7 @@ public class CabinetCellOperationEntity extends BaseEntity getOrderList(SearchShopOrderQuery query) { Page page = orderService.page(query.toPage(), query.toQueryWrapper()); return new PageDTO<>(page.getRecords(), page.getTotal()); } - public void openOrderGoodsCabinet(Long orderId, Long orderGoodsId) { + public void openOrderGoodsCabinet(Long orderId, Long orderGoodsId, AddCabinetCellOperationCommand operationCommand) { OrderModel orderModel = orderModelFactory.loadById(orderId); // 验证订单状态 if (orderModel.getStatus() != 2) { @@ -96,6 +100,12 @@ public class OrderApplicationService { throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "柜子不存在"); } + operationCommand.setCellId(goodsEntity.getCellId()); + operationCommand.setGoodsId(goodsEntity.getGoodsId()); + operationCommand.setGoodsName(goodsEntity.getGoodsName()); + operationCommand.setStatus(1); + CabinetCellOperationModel cellOperationModel = cabinetCellOperationModelFactory.create(); + // 构造MQTT开柜指令: // 指令格式:8A + 锁控编号(2位HEX) + 引脚号(2位HEX) + 操作码11 String mqttDate = "8A"; @@ -106,7 +116,12 @@ public class OrderApplicationService { mqttService.publish(mqttDate); } catch (Exception e) { log.error("mqtt publish error", e); + operationCommand.setStatus(2); throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "发送指令失败"); + } finally { + // 记录操作日志 + cellOperationModel.loadAddCommand(operationCommand); + cellOperationModel.insert(); } }