交班相关代码

This commit is contained in:
Tankaikai
2025-03-01 15:38:08 +08:00
parent dfb5fa9b70
commit 84556a1016
9 changed files with 87 additions and 3 deletions

View File

@@ -87,9 +87,7 @@ public class HandoverRecordController {
//@SaAdminCheckPermission("handoverRecord:handover") //@SaAdminCheckPermission("handoverRecord:handover")
public CzgResult<Void> handover(@RequestParam Integer isPrint) { public CzgResult<Void> handover(@RequestParam Integer isPrint) {
Long id = handoverRecordService.handover(); Long id = handoverRecordService.handover();
if (isPrint == 1) { handoverRecordService.printHandoverReceipt(id, isPrint);
// TODO 后续需要发生mq消息给打印机
}
return CzgResult.success(); return CzgResult.success();
} }

View File

@@ -14,5 +14,6 @@ public interface RabbitConstants {
public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue"; public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue";
public static final String ORDER_PRINT_QUEUE = "order.print.queue"; public static final String ORDER_PRINT_QUEUE = "order.print.queue";
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue"; public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.print.queue";
} }
} }

View File

@@ -45,6 +45,15 @@ public class RabbitPublisher {
sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId); sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId);
} }
/**
* 交班小票打印消息
*
* @param handoverRecordId 交班记录id
*/
public void sendHandoverPrintMsg(String handoverRecordId) {
sendMsg(RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, handoverRecordId);
}
private void sendMsg(String queue, String msg) { private void sendMsg(String queue, String msg) {

View File

@@ -0,0 +1,15 @@
package com.czg.account.service;
import com.czg.account.dto.HandoverRecordDTO;
/**
* 交班记录RPC服务接口
*
* @author tankaikai
* @since 2025-03-01 15:34
*/
public interface HandoverRecordRpcService {
HandoverRecordDTO getHandoverRecordById(Long handoverRecordId);
}

View File

@@ -53,4 +53,12 @@ public interface HandoverRecordService extends IService<HandoverRecord> {
*/ */
Long handover(); Long handover();
/**
* 交班打印小票
*
* @param handoverRecordId 交班记录id
* @param isPrint 是否打印 1-是 0-否
*/
void printHandoverReceipt(Long handoverRecordId, Integer isPrint);
} }

View File

@@ -147,4 +147,11 @@ public interface OrderInfoRpcService {
* @param orderId 订单id * @param orderId 订单id
*/ */
void orderCancelCallback(Long orderId); void orderCancelCallback(Long orderId);
/**
* 订单交班回调 发送答应交班小票消息至MQ
*
* @param handoverRecordId 交班记录id
*/
void sendHandoverReceiptPrintMsgToMq(Long handoverRecordId);
} }

View File

@@ -0,0 +1,28 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.service.HandoverRecordRpcService;
import com.czg.service.account.mapper.HandoverRecordMapper;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;
/**
* 交班记录RPC服务实现
*
* @author tankaikai
* @since 2025-03-01 15:35
*/
@DubboService
public class HandoverRecordRpcServiceImpl implements HandoverRecordRpcService {
@Resource
private HandoverRecordMapper handoverRecordMapper;
@Override
public HandoverRecordDTO getHandoverRecordById(Long handoverRecordId) {
HandoverRecord record = handoverRecordMapper.selectOneById(handoverRecordId);
return BeanUtil.copyProperties(record, HandoverRecordDTO.class);
}
}

View File

@@ -12,6 +12,7 @@ import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverCategoryListVo; import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo; import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo; import com.czg.account.vo.HandoverTotalVo;
import com.czg.enums.YesNoEnum;
import com.czg.order.service.OrderInfoRpcService; import com.czg.order.service.OrderInfoRpcService;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.account.mapper.HandoverRecordMapper; import com.czg.service.account.mapper.HandoverRecordMapper;
@@ -138,6 +139,13 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
return entity.getId(); return entity.getId();
} }
@Override
public void printHandoverReceipt(Long handoverRecordId, Integer isPrint) {
if (isPrint == YesNoEnum.YES.value()) {
orderInfoRpcService.sendHandoverReceiptPrintMsgToMq(handoverRecordId);
}
}
private BigDecimal sumCashAmount(Long shopId, String loginTime, String handoverTime) { private BigDecimal sumCashAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoRpcService.getHandoverCashAmount(shopId, loginTime, handoverTime); return orderInfoRpcService.getHandoverCashAmount(shopId, loginTime, handoverTime);
} }

View File

@@ -1,9 +1,11 @@
package com.czg.service.order.service.impl; package com.czg.service.order.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import com.czg.account.vo.HandoverCategoryListVo; import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo; import com.czg.account.vo.HandoverProductListVo;
import com.czg.config.RabbitPublisher;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.order.entity.OrderDetail; import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
@@ -46,6 +48,9 @@ public class OrderInfoRpcServiceImpl implements OrderInfoRpcService {
@DubboReference @DubboReference
private ProductRpcService productRpcService; private ProductRpcService productRpcService;
@Resource
private RabbitPublisher rabbitPublisher;
@Override @Override
public BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime) { public BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverWechatAmount(shopId, loginTime, handoverTime); return orderInfoMapper.getHandoverWechatAmount(shopId, loginTime, handoverTime);
@@ -167,4 +172,9 @@ public class OrderInfoRpcServiceImpl implements OrderInfoRpcService {
// 调用商品服务恢复库存 // 调用商品服务恢复库存
productRpcService.orderCancelRecoverStock(orderId, dataList); productRpcService.orderCancelRecoverStock(orderId, dataList);
} }
@Override
public void sendHandoverReceiptPrintMsgToMq(Long handoverRecordId) {
rabbitPublisher.sendHandoverPrintMsg(Convert.toStr(handoverRecordId));
}
} }