From aff8f909fbdd357e2a00be4cf6acf063cdf8aed7 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 3 Apr 2024 10:28:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?PC=E7=AB=AF=E6=B7=BB=E5=8A=A0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=89=93=E5=8D=B0=E6=9C=BA=20=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E4=B8=BAlocal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/TbPrintPCMachineService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPrintPCMachineService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPrintPCMachineService.java index f451227..6c2ebb9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPrintPCMachineService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbPrintPCMachineService.java @@ -11,6 +11,7 @@ import com.chaozhanggui.system.cashierservice.util.JSONUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -59,6 +60,7 @@ public class TbPrintPCMachineService { */ public Result queryByPage(TbPrintPCMachine tbPrintMachine) { PageHelper.startPage(tbPrintMachine.getPage(), tbPrintMachine.getPageSize()); + tbPrintMachine.setContentType("local"); List tbPrintMachines = this.tbPrintMachineMapper.queryAll(tbPrintMachine); PageInfo pageInfo=new PageInfo(tbPrintMachines); return Result.success(CodeEnum.SUCCESS,pageInfo); @@ -73,7 +75,11 @@ public class TbPrintPCMachineService { public Result insert(PrintMachineDto resources) { TbPrintPCMachine tbPrintMachine = new TbPrintPCMachine(); tbPrintMachine.setCreatedAt(Instant.now().toEpochMilli()); + tbPrintMachine.setContentType("local"); if (resources.getConfig() != null){ + if(CollectionUtils.isEmpty(resources.getConfig().getCategoryList())){ + resources.getConfig().setCategoryList(null); + } tbPrintMachine.setConfig(JSONUtil.toJSONString(resources.getConfig(),true)); } BeanUtils.copyProperties(resources,tbPrintMachine); From 97da8f839241d24cb6db8a73718d7f785d69e153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E9=B9=8F=E8=BE=89?= <18322780655@163.com> Date: Wed, 3 Apr 2024 10:56:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=B0=8F=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CloudPrinterController.java | 23 +++-- .../dao/ShopUserDutyPayMapper.java | 7 ++ .../interceptor/WebAppConfigurer.java | 2 +- .../service/CloudPrinterService.java | 97 ++++++++++++++++++- src/main/resources/application.yml | 2 +- .../mapper/ShopUserDutyPayMapper.xml | 17 ++++ 6 files changed, 135 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java index 136d01a..43b622b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java @@ -38,11 +38,20 @@ public class CloudPrinterController { return cloudPrinterService.printReceipt(type,orderId,ispre); } -// public Result handoverPrint( @RequestHeader("token") String token, -// @RequestHeader("loginName") String loginName, -// @RequestHeader("clientType") String clientType, -// @RequestParam("tradeDay") String tradeDay -// ){ -// -// } + /** + * 打印结算小票 + * @param token + * @param loginName + * @param clientType + * @param tradeDay + * @return + */ + @GetMapping("handoverPrint") + public Result handoverPrint( @RequestHeader("token") String token, + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestParam("tradeDay") String tradeDay + ){ + return cloudPrinterService.handoverprintData(token,tradeDay,loginName); + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyPayMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyPayMapper.java index 38f8ffc..9d56098 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyPayMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyPayMapper.java @@ -1,10 +1,14 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.ShopUserDutyPay; +import com.chaozhanggui.system.cashierservice.model.HandoverInfo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Map; + @Component @Mapper public interface ShopUserDutyPayMapper { @@ -21,4 +25,7 @@ public interface ShopUserDutyPayMapper { int updateByPrimaryKey(ShopUserDutyPay record); ShopUserDutyPay selectByDuctIdAndType(@Param("dutyId") Integer dutyId,@Param("payType") String payType); + + + List> selectByDutyId(Integer dutyId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java index 341edc6..21c01b2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java @@ -18,6 +18,6 @@ public class WebAppConfigurer implements WebMvcConfigurer { registry.addInterceptor(signInterceptor) .addPathPatterns("/**") .excludePathPatterns("/login/login") - .excludePathPatterns("/cloudPrinter/print"); + ; } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java index 8c265b2..a02f3b1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -5,14 +5,13 @@ import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.model.CategoryInfo; +import com.chaozhanggui.system.cashierservice.model.HandoverInfo; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; -import com.chaozhanggui.system.cashierservice.util.DateUtils; -import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil; -import com.chaozhanggui.system.cashierservice.util.JSONUtil; -import com.chaozhanggui.system.cashierservice.util.PrinterUtils; +import com.chaozhanggui.system.cashierservice.util.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,6 +19,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; @Service @Slf4j @@ -44,6 +44,21 @@ public class CloudPrinterService { @Autowired private TbOrderDetailMapper tbOrderDetailMapper; + @Autowired + private TbmerchantAccountMapper tbmerchantAccountMapper; + + + @Autowired + private ShopUserDutyMapper shopUserDutyMapper; + + + @Autowired + private TbPlussShopStaffMapper tbPlussShopStaffMapper; + + + @Autowired + ShopUserDutyPayMapper shopUserDutyPayMapper; + @@ -342,6 +357,80 @@ public class CloudPrinterService { } + public Result handoverprintData(String token,String tradeDay,String loginName){ + + + JSONObject info= TokenUtil.parseParamFromToken(token); + MsgException.checkNull(info,"获取信息失败"); + + TbmerchantAccount tbmerchantAccount= tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(info.get("accountId").toString())); + MsgException.checkNull(tbmerchantAccount,"商户信息不存在"); + + TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbmerchantAccount.getShopId())); + MsgException.checkNull(tbShopInfo,"店铺信息不存在"); + + + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId()); + if (ObjectUtil.isEmpty(shopInfo)) { + log.error("店铺信息不存在"); + return Result.fail(CodeEnum.SHOPINFONOEXIST); + } + + + List bloBsList = tbPrintMachineMapper.selectByShopId(tbShopInfo.getId().toString()); + + if (ObjectUtil.isEmpty(bloBsList) || bloBsList.size() <= 0) { + log.error("此店铺没有对应的打印机设备"); + return Result.fail(CodeEnum.printmachinenoexsit); + } + + bloBsList.parallelStream().forEach(it->{ + + if (!"network".equals(it.getConnectionType())) { + log.error("非网络打印机"); + return; + } + + if (!"1".equals(it.getStatus().toString())) { + log.error("打印机状态异常"); + return; + } + + if(!it.getSubType().equals("cash")){ + log.error("非小票打印机"); + return; + } + + ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndTrade(tbShopInfo.getId(),tradeDay); + MsgException.checkNull(shopUserDuty,"交班信息不存在"); + + + TbPlussShopStaff shopStaff= tbPlussShopStaffMapper.selectByPrimaryKey(Integer.valueOf(info.get("staffId").toString())); + MsgException.checkNull(shopStaff,"员工信息不存在"); + + + List list=null; + List memberData=null; + List> mapList= shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId()); + if(ObjectUtil.isNotEmpty(mapList)&&mapList.size()>0){ + list= JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class); + } + + ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit"); + if(ObjectUtil.isNotEmpty(shopUserDutyPay)){ + memberData=new ArrayList<>(); + memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"储值卡支付")); + } + + HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(),ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null,ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"",ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(),list,memberData,shopUserDuty.getAmount().toPlainString(),"0",shopUserDuty.getAmount().toPlainString(),shopUserDuty.getAmount().toPlainString(),shopUserDuty.getOrderNum().toString()); + + + PrinterUtils.printTickets(1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo)); + + }); + return Result.success(CodeEnum.SUCCESS); + + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9e2d8b9..bc36433 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,9 +2,9 @@ spring: profiles: active: hph server: - servlet: context-path: /cashier-client/ + port: 10587 # 日志配置 logging: level: diff --git a/src/main/resources/mapper/ShopUserDutyPayMapper.xml b/src/main/resources/mapper/ShopUserDutyPayMapper.xml index 1878e3b..aeafefc 100644 --- a/src/main/resources/mapper/ShopUserDutyPayMapper.xml +++ b/src/main/resources/mapper/ShopUserDutyPayMapper.xml @@ -83,4 +83,21 @@ amount = #{amount,jdbcType=DECIMAL} where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file