From 1dd5185c682c8ef6cf86b37e2720278cc9677258 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: Sat, 20 Jul 2024 09:22:42 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/controller/CloudPrinterController.java | 2 +- .../system/cashierservice/service/CloudPrinterService.java | 2 +- 2 files changed, 2 insertions(+), 2 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 6614cdc..0e14bca 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java @@ -28,7 +28,7 @@ public class CloudPrinterController { * @return */ @GetMapping("print") - public Result print( @RequestHeader("token") String token, + public Result print(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, @RequestParam("type") String type, 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 ba4a37a..c824db8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -645,7 +645,7 @@ public class CloudPrinterService { HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(), ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null, - ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"", + ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):DateUtils.getTime(new Date()), ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(), list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(), "0", From 9a5c02a949a5be743bf0144985a7a778bf0f6b1b Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 22 Jul 2024 11:39:57 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/controller/LoginContoller.java | 10 ++++++++++ .../interceptor/WebAppConfigurer.java | 1 + .../cashierservice/service/LoginService.java | 15 +++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 3c1c848..7a070db 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -8,9 +8,11 @@ import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.IpUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.Map; @CrossOrigin(origins = "*") @RestController @@ -50,4 +52,12 @@ public class LoginContoller { return loginService.getShopInfo(token); } + @RequestMapping(value = "getPhone") + public Result getPhone( @RequestBody Map map){ + if (CollectionUtils.isEmpty(map) || !map.containsKey("userId")) { + return Result.fail("id不允许为空"); + } + return loginService.getPhone(Integer.valueOf(map.get("userId").toString())); + } + } 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 907bebe..62e4c9a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java @@ -17,6 +17,7 @@ public class WebAppConfigurer implements WebMvcConfigurer { registry.addInterceptor(signInterceptor) .addPathPatterns("/**") .excludePathPatterns("/login/login") + .excludePathPatterns("/login/getPhone") .excludePathPatterns("/cloudPrinter/print") .excludePathPatterns("/cloudPrinter/handoverPrint") .excludePathPatterns("/data/handoverData") diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index 0d2066e..6f8b76b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -4,10 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; -import com.chaozhanggui.system.cashierservice.entity.TbPlussShopStaff; -import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; -import com.chaozhanggui.system.cashierservice.entity.TbToken; -import com.chaozhanggui.system.cashierservice.entity.TbmerchantAccount; +import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.model.LoginReq; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; @@ -35,6 +32,8 @@ public class LoginService { @Autowired TbShopInfoMapper tbShopInfoMapper; + @Autowired + TbUserInfoMapper userInfoMapper; @Autowired TbProductMapper tbProductMapper; @@ -187,4 +186,12 @@ public class LoginService { return Result.success(SUCCESS,shopInfo); } + + public Result getPhone(Integer userId) { + TbUserInfo userInfo = userInfoMapper.selectByPrimaryKey(userId); + if (userInfo != null) { + return Result.success(SUCCESS, userInfo.getTelephone()); + } + return Result.success(SUCCESS, ""); + } } From 60267f5576a0d7ad3a4764ef03581fccff120ba7 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:11:48 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CloudPrinterController.java | 5 +- .../controller/DataController.java | 12 ++ .../dao/ShopUserDutyMapper.java | 4 + .../dao/ShopUserDutyPayMapper.java | 3 + .../cashierservice/entity/po/ProductInfo.java | 14 +++ .../entity/po/ProductInfoPO.java | 16 +++ .../interceptor/WebAppConfigurer.java | 3 +- .../cashierservice/model/HandoverInfo.java | 13 +- .../service/CloudPrinterService.java | 15 ++- .../cashierservice/service/DataService.java | 101 +++++++++++++++- .../cashierservice/service/DutyService.java | 6 +- .../cashierservice/service/LoginService.java | 2 + .../cashierservice/util/PrinterUtils.java | 111 ++++++++++++++++-- 13 files changed, 284 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfoPO.java 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 0e14bca..bd13be6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CloudPrinterController.java @@ -51,9 +51,10 @@ public class CloudPrinterController { @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, @RequestParam("tradeDay") String tradeDay, - Integer id + @RequestParam("id") Integer id + ){ - return cloudPrinterService.handoverprintData(token,id,loginName); + return cloudPrinterService.handoverprintData(token,id,loginName,false); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/DataController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/DataController.java index f9cfc44..808d66c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/DataController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/DataController.java @@ -25,4 +25,16 @@ public class DataController { return dataService.handoverprintData(token,id); } + + + + @RequestMapping(value = "handoverprint") + public Result handoverprint(@RequestHeader("token") String token, + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + Integer id, + boolean isprintProduct){ + return dataService.handoverprint(id,isprintProduct); + + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java index 0afcd8b..4931b1a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java @@ -1,6 +1,7 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.ShopUserDuty; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; @@ -43,4 +44,7 @@ public interface ShopUserDutyMapper { void updateStatusById(@Param("id") Integer id, @Param("staffId") Integer staffId); // List selectByShopIdAndTradeAll(@Param("shopId") Integer shopId,@Param("day") String day,@Param("tokenId") Integer tokenId); + + + List selectByDutyId(Integer dutyId); } \ No newline at end of file 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 bb30eee..80e4ecc 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyPayMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyPayMapper.java @@ -1,6 +1,7 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.ShopUserDutyPay; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO; import com.chaozhanggui.system.cashierservice.model.HandoverInfo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -31,4 +32,6 @@ public interface ShopUserDutyPayMapper { List> selectCetoryBydutyId(Integer dutyId); + + List selectProductByDutyId(Integer dutyId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfo.java new file mode 100644 index 0000000..4bacf06 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfo.java @@ -0,0 +1,14 @@ +package com.chaozhanggui.system.cashierservice.entity.po; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class ProductInfo implements Serializable { + + private String productName; + private Integer num; + private BigDecimal amount; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfoPO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfoPO.java new file mode 100644 index 0000000..68df818 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/ProductInfoPO.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.entity.po; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class ProductInfoPO implements Serializable { + + private Integer productId; + private String productName; + private String skuName; + private Integer num; + private BigDecimal amount; +} 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 907bebe..b09ac72 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/WebAppConfigurer.java @@ -24,6 +24,7 @@ public class WebAppConfigurer implements WebMvcConfigurer { .excludePathPatterns("/order/getsendMessage") .excludePathPatterns("/qrcode/getscanCode") .excludePathPatterns("/order/sendMessage") - .excludePathPatterns("/order/getOrderById"); + .excludePathPatterns("/order/getOrderById") + .excludePathPatterns("/data/handoverprint"); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/model/HandoverInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/model/HandoverInfo.java index 1c0f29c..3e29b3a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/model/HandoverInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/model/HandoverInfo.java @@ -1,8 +1,11 @@ package com.chaozhanggui.system.cashierservice.model; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; @Data @@ -38,8 +41,12 @@ public class HandoverInfo implements Serializable { private String quickAmount; + private List productInfoPOS; + + private List productInfos; + public HandoverInfo(String merchantName, String startTime, String endTime, String staff, List payInfos, List memberData, String totalAmount, String imprest, String payable, String handIn, String returnAmount,String orderNum - ,List productCategories,String quickAmount + ,List productCategories,String quickAmount,List productInfoPOS,List productInfos ) { this.merchantName = merchantName; @@ -56,6 +63,8 @@ public class HandoverInfo implements Serializable { this.orderNum = orderNum; this.productCategories=productCategories; this.quickAmount=quickAmount; + this.productInfoPOS=productInfoPOS; + this.productInfos=productInfos; } @Data @@ -96,4 +105,6 @@ public class HandoverInfo implements Serializable { this.amount = amount; } } + + } 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 c824db8..123bfd0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -5,6 +5,8 @@ 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.entity.po.ProductInfo; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.model.CategoryInfo; import com.chaozhanggui.system.cashierservice.model.HandoverInfo; @@ -562,7 +564,7 @@ public class CloudPrinterService { } - public Result handoverprintData(String token,Integer id,String loginName){ + public Result handoverprintData(String token,Integer id,String loginName,boolean isprintProduct){ JSONObject info= TokenUtil.parseParamFromToken(token); @@ -642,6 +644,13 @@ public class CloudPrinterService { productCategories=JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries),HandoverInfo.ProductCategory.class); } + List productInfoPOS=null; + List productInfos=null; + if(isprintProduct){ +// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId()); + productInfos=shopUserDutyMapper.selectByDutyId(shopUserDuty.getId()); + } + HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(), ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null, @@ -653,7 +662,9 @@ public class CloudPrinterService { 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() + productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString(), + productInfoPOS, + productInfos ); String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; 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 5abdf94..55f4c0e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java @@ -4,6 +4,8 @@ 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.entity.po.ProductInfo; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.model.HandoverInfo; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; @@ -111,11 +113,108 @@ public class DataService { 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() + productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString(), + null,null ); return Result.success(CodeEnum.SUCCESS,handoverInfo); } + + + + public Result handoverprint(Integer id,boolean isprintProduct){ + ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByPrimaryKey(id); +// ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndDay(tbShopInfo.getId(),tradeDay); + MsgException.checkNull(shopUserDuty, "交班信息不存在"); + + 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); + } + + 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; + } + + + + 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.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 productInfoPOS = null; + List productInfos = null; + if (isprintProduct) { +// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId()); + productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId()); + } + + HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(), + ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null, + ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime()) ? DateUtils.getTime(shopUserDuty.getLoginOutTime()) : "", + "", + 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); + } } + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java index e440be9..b5da9ed 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java @@ -156,11 +156,11 @@ public class DutyService { // ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenId(tokenId); ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0"); // ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndTrade(shopId, day); -// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(tokenId, day, orderInfo.getShopId()); +// ShopUserDuty shopU serDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(tokenId, day, orderInfo.getShopId()); BigDecimal cashAmount = BigDecimal.ZERO; if (type.equals("create")) { - if (orderInfo.getPayType().equals("cash")) { + if ("cash".equals(orderInfo.getPayType())) { cashAmount = orderInfo.getPayAmount(); } if (Objects.isNull(shopUserDuty)) { @@ -362,7 +362,7 @@ public class DutyService { Integer shopId = tokenJson.getInteger("shopId"); Integer staffId = tokenJson.getInteger("staffId"); ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0"); - cloudPrinterService.handoverprintData(token, shopUserDuty.getId(), ""); + cloudPrinterService.handoverprintData(token, shopUserDuty.getId(), "",true); // shopUserDutyMapper.updateStatusByTokenId(day, shopId, staffId); shopUserDutyMapper.updateStatusById(shopUserDuty.getId(), staffId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index 0d2066e..86d8a37 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -173,6 +173,8 @@ public class LoginService { jsonObject.put("type", "close"); jsonObject.put("token", token); rabbitProducer.putOrderCollect(jsonObject.toJSONString()); + + return Result.success(SUCCESS); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java index 2eb4617..455a73a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java @@ -1,6 +1,8 @@ package com.chaozhanggui.system.cashierservice.util; import cn.hutool.core.util.ObjectUtil; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo; +import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO; import com.chaozhanggui.system.cashierservice.model.HandoverInfo; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; import org.springframework.http.HttpEntity; @@ -199,6 +201,80 @@ public class PrinterUtils { } } + if(ObjectUtil.isNotEmpty(handoverInfo.getProductInfos())&&handoverInfo.getProductInfos().size()>0) { + sb.append("商品数据
"); + + char paddingCharacter = ' '; + + sb.append(" "+String.format("%-10s","品名").replace(' ', paddingCharacter)+String.format("%-4s","数量").replace(' ', paddingCharacter)+String.format("%4s","小计").replace(' ', paddingCharacter)+"
"); + + for (ProductInfo productInfo : handoverInfo.getProductInfos()) { + if(productInfo.getProductName().length()>4&&productInfo.getProductName().length()<=8){ + + int count=getProducrName(productInfo.getProductName()); + if(count<=0){ + int length=15-(productInfo.getProductName().length()-4); + sb.append(" "+String.format("%-"+length+"s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%4s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + }else { + int length=15+count/2-(productInfo.getProductName().length()-4); + sb.append(" "+String.format("%-"+length+"s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%4s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + } + + }else if(productInfo.getProductName().length()>10){ + + sb.append(" "+productInfo.getProductName()+"
"); + sb.append(" "+String.format("%20s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%11s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + + }else { + sb.append(" "+String.format("%-10s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%6s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + } + sb.append("
"); + } + } + + + + if(ObjectUtil.isNotEmpty(handoverInfo.getProductInfoPOS())&&handoverInfo.getProductInfoPOS().size()>0){ + sb.append("商品数据
"); + char paddingCharacter = ' '; + + for (ProductInfoPO productInfoPO : handoverInfo.getProductInfoPOS()) { + + if(ObjectUtil.isNotEmpty(productInfoPO.getSkuName())){ + productInfoPO.setProductName(productInfoPO.getProductName().concat("(").concat(productInfoPO.getSkuName()).concat(")")); + } + if(productInfoPO.getProductName().length()>4&&productInfoPO.getProductName().length()<=10){ + + int count=getProducrName(productInfoPO.getProductName()); + if(count<=0){ + int length=15-(productInfoPO.getProductName().length()-4); + sb.append(""+String.format("%-"+length+"s",productInfoPO.getProductName()).replace(' ', paddingCharacter)+String.format("%-2s", productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%8s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"
"); + }else { + int length=15+count-(productInfoPO.getProductName().length()-4); + sb.append(""+String.format("%-"+length+"s",productInfoPO.getProductName()).replace(' ', paddingCharacter)+String.format("%-2s",productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%8s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"
"); + } + + }else if(productInfoPO.getProductName().length()>10){ + + sb.append(""+productInfoPO.getProductName()+"
"); + sb.append(""+String.format("%20s",productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%11s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"
"); + + }else { + sb.append(""+String.format("%-15s",productInfoPO.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%8s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"
"); + } + + sb.append("
"); + } + + + + + } + + + + + sb.append("快捷收款金额 :".concat(ObjectUtil.isNull(handoverInfo.getQuickAmount())?"0":handoverInfo.getQuickAmount())+"
"); sb.append("退款金额 :".concat(handoverInfo.getReturnAmount())+"
"); sb.append("总收入: "+handoverInfo.getTotalAmount()+"
"); @@ -279,22 +355,35 @@ public class PrinterUtils { public static int getProducrName(String str){ - int count = 0; - int digitCount=0; - for (int i=0;i='a' && str.charAt(i)<='z') || (str.charAt(i)>='A' && str.charAt(i)<='Z')){ + int count=0; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (c >= '0' && c <= '9') { + count++; + } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { count++; } - - if (Character.isDigit(str.charAt(i))) { - digitCount++; - } } - return count+digitCount; + return count; } public static void main(String[] args)throws Exception { + + int t=0; + + + String str="张三456987asdfg"; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (c >= '0' && c <= '9') { + t++; + } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { + t++; + } + } + System.out.println(t); + // // List payInfos=new ArrayList<>(); // @@ -331,8 +420,8 @@ public class PrinterUtils { - String voiceJson = "{\"bizType\":\"1\",\"content\":\"您有一笔新的订单,请及时处理\"}"; - printTickets(voiceJson,1,1,"ZF544PG03W00002", printInvoice("http://weixin.qq.com/q/020fVS8lcLeiG1ID3SxCcH","【30天内开票有效】","1000000")); +// String voiceJson = "{\"bizType\":\"1\",\"content\":\"您有一笔新的订单,请及时处理\"}"; +// printTickets(voiceJson,1,1,"ZF544PG03W00002", printInvoice("http://weixin.qq.com/q/020fVS8lcLeiG1ID3SxCcH","【30天内开票有效】","1000000")); } } From 1ea0eea537d6b42b76b0857e1d90d5a0dbdab5a0 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:12:12 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper/ShopUserDutyMapper.xml | 14 ++++++++++++++ .../resources/mapper/ShopUserDutyPayMapper.xml | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/resources/mapper/ShopUserDutyMapper.xml b/src/main/resources/mapper/ShopUserDutyMapper.xml index 00a2096..aefb088 100644 --- a/src/main/resources/mapper/ShopUserDutyMapper.xml +++ b/src/main/resources/mapper/ShopUserDutyMapper.xml @@ -250,4 +250,18 @@ select * from tb_shop_user_duty where status = #{status} and shop_id = #{shopId} order by id desc limit 1 + + \ No newline at end of file diff --git a/src/main/resources/mapper/ShopUserDutyPayMapper.xml b/src/main/resources/mapper/ShopUserDutyPayMapper.xml index 055131a..691420a 100644 --- a/src/main/resources/mapper/ShopUserDutyPayMapper.xml +++ b/src/main/resources/mapper/ShopUserDutyPayMapper.xml @@ -118,4 +118,17 @@ ORDER BY c.sort DESC + + \ No newline at end of file From 2a361fed46756abded2d7a7b7e6959e1924fc499 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:39:16 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/DataService.java | 3 ++- .../cashierservice/service/DutyService.java | 2 +- .../cashierservice/util/PrinterUtils.java | 19 ++++++++++++++++++- 3 files changed, 21 insertions(+), 3 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 55f4c0e..fd39d0d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -197,7 +198,7 @@ public class DataService { HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(), ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null, - ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime()) ? DateUtils.getTime(shopUserDuty.getLoginOutTime()) : "", + DateUtils.getTime(new Date()), "", list, memberData, shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(), "0", diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java index b5da9ed..7ebb0da 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java @@ -362,7 +362,7 @@ public class DutyService { Integer shopId = tokenJson.getInteger("shopId"); Integer staffId = tokenJson.getInteger("staffId"); ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0"); - cloudPrinterService.handoverprintData(token, shopUserDuty.getId(), "",true); +// cloudPrinterService.handoverprintData(token, shopUserDuty.getId(), "",true); // shopUserDutyMapper.updateStatusByTokenId(day, shopId, staffId); shopUserDutyMapper.updateStatusById(shopUserDuty.getId(), staffId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java index 455a73a..e2ca6a5 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/PrinterUtils.java @@ -204,6 +204,14 @@ public class PrinterUtils { if(ObjectUtil.isNotEmpty(handoverInfo.getProductInfos())&&handoverInfo.getProductInfos().size()>0) { sb.append("商品数据
"); + + + List productInfo1=handoverInfo.getProductInfos(); + + + Integer max= productInfo1.stream().max(Comparator.comparing(it->it.getProductName().length())).get().getProductName().length(); + + char paddingCharacter = ' '; sb.append(" "+String.format("%-10s","品名").replace(' ', paddingCharacter)+String.format("%-4s","数量").replace(' ', paddingCharacter)+String.format("%4s","小计").replace(' ', paddingCharacter)+"
"); @@ -226,7 +234,16 @@ public class PrinterUtils { sb.append(" "+String.format("%20s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%11s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); }else { - sb.append(" "+String.format("%-10s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%6s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + if(productInfo.getProductName().length() "+String.format("%-"+tt+"s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%6s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + }else { + sb.append(" "+String.format("%-10s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%6s",productInfo.getAmount()).replace(' ', paddingCharacter)+"
"); + } + + } sb.append("
"); } 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 6/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=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); } From 752fd56c44d5c1bf9cd4a07c637698c1539e564d 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 15:58:46 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A4=E7=8F=AD?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/DataService.java | 4 +++- .../cashierservice/service/MemberService.java | 13 +++++++------ 2 files changed, 10 insertions(+), 7 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 e4a366b..4af9af5 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DataService.java @@ -192,7 +192,9 @@ public class DataService { List productInfoPOS = null; List productInfos = null; if (isprintProduct) { -// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId()); +// +// +// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId()); productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId()); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java index c4d0efa..72a0411 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java @@ -624,14 +624,15 @@ public class MemberService { tbShopUserFlowMapper.insert(flow); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("token", token); - jsonObject.put("type", "memberIn"); - jsonObject.put("amount", memberIn.getAmount()); - - producer.putOrderCollect(jsonObject.toJSONString()); } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("token", token); + jsonObject.put("type", "memberIn"); + jsonObject.put("amount", memberIn.getAmount()); + + producer.putOrderCollect(jsonObject.toJSONString()); + return Result.success(CodeEnum.SUCCESS); }