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(); } }