From a4a9f43ac6cf7e0d533786a622dcd30b85478e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 22 Jul 2024 14:50:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/DataService.java | 138 +++++++++--------- 1 file changed, 71 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java index fd39d0d..e4a366b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java @@ -126,94 +126,98 @@ public class DataService { public Result handoverprint(Integer id,boolean isprintProduct){ - ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByPrimaryKey(id); -// ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndDay(tbShopInfo.getId(),tradeDay); - MsgException.checkNull(shopUserDuty, "交班信息不存在"); + if(ObjectUtil.isNotEmpty(id)){ + ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByPrimaryKey(id); + if(ObjectUtil.isNotEmpty(shopUserDuty)){ - TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopUserDuty.getShopId())); - MsgException.checkNull(tbShopInfo,"店铺信息不存在"); + TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopUserDuty.getShopId())); + MsgException.checkNull(tbShopInfo,"店铺信息不存在"); - TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId()); - if (ObjectUtil.isEmpty(shopInfo)) { - log.error("店铺信息不存在"); - return Result.fail(CodeEnum.SHOPINFONOEXIST); - } + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId()); + if (ObjectUtil.isEmpty(shopInfo)) { + log.error("店铺信息不存在"); + return Result.fail(CodeEnum.SHOPINFONOEXIST); + } - List bloBsList = tbPrintMachineMapper.selectByShopId(tbShopInfo.getId().toString()); + List bloBsList = tbPrintMachineMapper.selectByShopId(tbShopInfo.getId().toString()); - if (ObjectUtil.isEmpty(bloBsList) || bloBsList.size() <= 0) { - log.error("此店铺没有对应的打印机设备"); - return Result.fail(CodeEnum.printmachinenoexsit); - } + if (ObjectUtil.isEmpty(bloBsList) || bloBsList.size() <= 0) { + log.error("此店铺没有对应的打印机设备"); + return Result.fail(CodeEnum.printmachinenoexsit); + } - bloBsList.parallelStream().forEach(it-> { + bloBsList.parallelStream().forEach(it-> { - if (!"network".equals(it.getConnectionType())) { - log.error("非网络打印机"); - return; - } + if (!"network".equals(it.getConnectionType())) { + log.error("非网络打印机"); + return; + } - if (!"1".equals(it.getStatus().toString())) { - log.error("打印机状态异常"); - return; - } + if (!"1".equals(it.getStatus().toString())) { + log.error("打印机状态异常"); + return; + } - if (!it.getSubType().equals("cash")) { - log.error("非小票打印机"); - return; - } + if (!it.getSubType().equals("cash")) { + log.error("非小票打印机"); + return; + } - List list = null; - List memberData = null; - List productCategories = null; - List> mapList = shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId()); - if (ObjectUtil.isNotEmpty(mapList) && mapList.size() > 0) { - list = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class); - } + List list = null; + List memberData = null; + List productCategories = null; + List> mapList = shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId()); + if (ObjectUtil.isNotEmpty(mapList) && mapList.size() > 0) { + list = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class); + } - memberData = new ArrayList<>(); - ShopUserDutyPay shopUserDutyPay = shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(), "deposit"); - if (ObjectUtil.isNotEmpty(shopUserDutyPay)) { - memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(), "会员卡消费")); - } + memberData = new ArrayList<>(); + ShopUserDutyPay shopUserDutyPay = shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(), "deposit"); + if (ObjectUtil.isNotEmpty(shopUserDutyPay)) { + memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(), "会员卡消费")); + } - memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount()) ? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(), "会员卡充值")); + memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount()) ? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(), "会员卡充值")); - List> categries = shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId()); - if (ObjectUtil.isNotEmpty(categries) && categries.size() > 0) { - productCategories = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries), HandoverInfo.ProductCategory.class); - } + List> categries = shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId()); + if (ObjectUtil.isNotEmpty(categries) && categries.size() > 0) { + productCategories = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries), HandoverInfo.ProductCategory.class); + } - List productInfoPOS = null; - List productInfos = null; - if (isprintProduct) { + List productInfoPOS = null; + List productInfos = null; + if (isprintProduct) { // productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId()); - productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId()); + productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId()); + } + + HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(), + ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null, + DateUtils.getTime(new Date()), + "", + list, memberData, shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(), + "0", + shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(), + shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(), + shopUserDuty.getReturnAmount().toPlainString(), + shopUserDuty.getOrderNum().toString(), + productCategories, ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? "0" : shopUserDuty.getQuickAmount().toPlainString(), + null, productInfos + + ); + + String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; + PrinterUtils.printTickets(voiceJson, 1, 1, it.getAddress(), PrinterUtils.handoverprintData(handoverInfo)); + }); + } + } - HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(), - ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null, - DateUtils.getTime(new Date()), - "", - list, memberData, shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(), - "0", - shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(), - shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(), - shopUserDuty.getReturnAmount().toPlainString(), - shopUserDuty.getOrderNum().toString(), - productCategories, ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? "0" : shopUserDuty.getQuickAmount().toPlainString(), - null, productInfos - - ); - - String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; - PrinterUtils.printTickets(voiceJson, 1, 1, it.getAddress(), PrinterUtils.handoverprintData(handoverInfo)); - }); return Result.success(CodeEnum.SUCCESS); }