feat:机器下单打印发票
This commit is contained in:
1 parent
13ef4c1f8e
commit
20fe371975
4 files changed
+151
No files matched your search
+5
@@ -5349,6 +5349,11 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (ObjectUtil.equals(hardOrderType, HardOrderTypeEnum.RESERVE)) {
|
||||
hardBroadcastService.addReserveOrderTask(orderdetail, userInfo);
|
||||
}
|
||||
// 食堂下单打印发票
|
||||
Boolean isPrint = hardInvoiceService.printByOrder(orderdetail);
|
||||
if (isPrint) {
|
||||
log.info("|{}|发送mq消息成功,食堂打印发票order|{}|", TAG, JSON.toJSONString(orderId));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package com.bsd.pjcloud.hard.service.impl.order;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardBroadcastService;
|
||||
import com.bsd.pjcloud.hard.service.HardInvoiceService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.mockito.Answers.CALLS_REAL_METHODS;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* 机器下单后置钩子的发票打印测试:超市与食堂下单均打印发票,食堂预约单额外发送订餐广播。
|
||||
*/
|
||||
class HardOrderServiceImplCreateOrderPrintTest {
|
||||
|
||||
/** 订单 Mapper,用于返回下单后重新读取的订单快照。 */
|
||||
private final HardOrderMapper hardOrderMapper = mock(HardOrderMapper.class);
|
||||
|
||||
/** 打印任务服务,用于验证下单后创建的发票打印任务。 */
|
||||
private final HardInvoiceService hardInvoiceService = mock(HardInvoiceService.class);
|
||||
|
||||
/** 取餐广播服务,用于验证食堂预约单仍发送订餐消息。 */
|
||||
private final HardBroadcastService hardBroadcastService = mock(HardBroadcastService.class);
|
||||
|
||||
/** 被测订单服务,仅执行真实方法,未涉及的庞大依赖保持空值。 */
|
||||
private final HardOrderServiceImpl service = mock(HardOrderServiceImpl.class, CALLS_REAL_METHODS);
|
||||
|
||||
/**
|
||||
* 为下单后置钩子注入实际访问的依赖。
|
||||
*/
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
when(hardInvoiceService.printByOrder(any())).thenReturn(true);
|
||||
ReflectionTestUtils.setField(service, "baseMapper", hardOrderMapper);
|
||||
ReflectionTestUtils.setField(service, "hardInvoiceService", hardInvoiceService);
|
||||
ReflectionTestUtils.setField(service, "hardBroadcastService", hardBroadcastService);
|
||||
}
|
||||
|
||||
/** 食堂即时消费单下单后创建发票打印任务,不发送订餐广播。 */
|
||||
@Test
|
||||
void canteenImmediateOrderPrintsInvoice() {
|
||||
HardOrderEntity order = order(HardTypeEnum.CANTEEN, HardOrderTypeEnum.BELOW);
|
||||
|
||||
service.createOrderAfterSendMqMsg(1L, null);
|
||||
|
||||
verify(hardInvoiceService).printByOrder(order);
|
||||
verify(hardBroadcastService, never()).addReserveOrderTask(any(), any());
|
||||
}
|
||||
|
||||
/** 食堂预约单下单后既发送订餐广播,也创建发票打印任务;兑换券仍在核销时打印。 */
|
||||
@Test
|
||||
void canteenReserveOrderPrintsInvoiceAndBroadcasts() {
|
||||
HardOrderEntity order = order(HardTypeEnum.CANTEEN, HardOrderTypeEnum.RESERVE);
|
||||
|
||||
service.createOrderAfterSendMqMsg(1L, null);
|
||||
|
||||
verify(hardBroadcastService).addReserveOrderTask(order, null);
|
||||
verify(hardInvoiceService).printByOrder(order);
|
||||
}
|
||||
|
||||
/** 超市订单下单后打印发票的既有行为保持不变。 */
|
||||
@Test
|
||||
void supermarketOrderPrintsInvoice() {
|
||||
HardOrderEntity order = order(HardTypeEnum.SUPERMARKET, HardOrderTypeEnum.BELOW);
|
||||
|
||||
service.createOrderAfterSendMqMsg(1L, null);
|
||||
|
||||
verify(hardInvoiceService).printByOrder(order);
|
||||
verify(hardBroadcastService, never()).addReserveOrderTask(any(), any());
|
||||
}
|
||||
|
||||
/** App 自助下单没有机器上下文,不进入打印分支。 */
|
||||
@Test
|
||||
void selfAppOrderSkipsPrinting() {
|
||||
order(HardTypeEnum.SELF_APP, HardOrderTypeEnum.RESERVE);
|
||||
|
||||
service.createOrderAfterSendMqMsg(1L, null);
|
||||
|
||||
verify(hardInvoiceService, never()).printByOrder(any());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造下单后置钩子使用的订单快照。
|
||||
*
|
||||
* @param sysType 下单设备类型
|
||||
* @param orderType 订单业务类型
|
||||
* @return 固定主键的订单
|
||||
*/
|
||||
private HardOrderEntity order(HardTypeEnum sysType, HardOrderTypeEnum orderType) {
|
||||
HardOrderEntity order = HardOrderEntity.builder()
|
||||
.id(1L)
|
||||
.sysType(sysType.getType())
|
||||
.orderType(orderType.getType())
|
||||
.build();
|
||||
when(hardOrderMapper.selectById(1L)).thenReturn(order);
|
||||
return order;
|
||||
}
|
||||
}
|
||||
+5
@@ -19,6 +19,11 @@ public class SysUserFaceVo extends SysUserFaceEntity implements BaseUserInterfac
|
||||
*/
|
||||
private String faceImgs;
|
||||
|
||||
/**
|
||||
* 当前人脸在该用户全部未删除人脸中的序号,按记录 id 升序从 1 开始,供前端下载命名。
|
||||
*/
|
||||
private Integer faceIndex;
|
||||
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
|
||||
+34
@@ -919,6 +919,8 @@ public class SysUserFaceServiceImpl extends ServiceImpl<SysUserFaceMapper, SysUs
|
||||
Page<SysUserFaceVo> list = baseMapper.scopePageList(page, dto, dataScope);
|
||||
// 批量补齐身份协议与学生、老师扩展资料,供管理端“身份信息”复合列展示。
|
||||
sysUserIdentityService.fillUserIdentities(list.getRecords());
|
||||
// 回填人脸序号,供前端按“姓名-班级-序号”命名下载当前行人脸图片。
|
||||
fillFaceIndex(list.getRecords());
|
||||
// 审批流程
|
||||
if (dto.getIsFindCheckUser()) {
|
||||
List<String> processInstanceIds = list.getRecords().stream().map(SysUserFaceVo::getProcessId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
@@ -939,6 +941,38 @@ public class SysUserFaceServiceImpl extends ServiceImpl<SysUserFaceMapper, SysUs
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量回填当前页人脸在该用户全部未删除人脸中的序号,按记录 id 升序从 1 开始。
|
||||
*
|
||||
* @param records 分页查询返回的人脸记录
|
||||
*/
|
||||
private void fillFaceIndex(List<SysUserFaceVo> records) {
|
||||
if (ObjectUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
List<Long> userIds = records.stream().map(SysUserFaceVo::getUserId).filter(Objects::nonNull).distinct().toList();
|
||||
if (ObjectUtil.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, List<Long>> faceIdsByUserId = list(new LambdaQueryWrapper<SysUserFaceEntity>()
|
||||
.select(SysUserFaceEntity::getId, SysUserFaceEntity::getUserId)
|
||||
.in(SysUserFaceEntity::getUserId, userIds)
|
||||
.orderByAsc(SysUserFaceEntity::getId))
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(SysUserFaceEntity::getUserId,
|
||||
Collectors.mapping(SysUserFaceEntity::getId, Collectors.toList())));
|
||||
for (SysUserFaceVo record : records) {
|
||||
List<Long> faceIds = faceIdsByUserId.get(record.getUserId());
|
||||
if (ObjectUtil.isEmpty(faceIds)) {
|
||||
continue;
|
||||
}
|
||||
int index = faceIds.indexOf(record.getId());
|
||||
if (index >= 0) {
|
||||
record.setFaceIndex(index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SysUserFaceVo> pageJoin(Page page, SysUserFaceDto dto) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getMerchantDeptIdOrGlobal())) {
|
||||
|
||||
Reference in new issue
Block a user