diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java index a09180137..742cf07e4 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java @@ -10,12 +10,20 @@ import com.fuint.business.printer.service.PrinterService; import com.fuint.business.printer.template.*; import com.fuint.business.printer.unit.Methods; import com.fuint.business.printer.vo.OrderPayment; +import com.fuint.business.setting.entity.ReceiptPrinting; +import com.fuint.business.setting.service.ReceiptPrintingService; +import com.fuint.business.userManager.entity.LJUserGrade; +import com.fuint.business.userManager.entity.UserBalance; +import com.fuint.business.userManager.mapper.LJUserGradeMapper; +import com.fuint.business.userManager.mapper.UserBalanceMapper; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.Constants; import com.fuint.common.util.RedisUtil; import com.fuint.common.util.TokenUtil; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.MtUser; import com.google.gson.Gson; import com.google.gson.GsonBuilder; //import com.yly.print_sdk_librar.RequestMethod; @@ -53,7 +61,17 @@ public class printerController extends BaseController { @Resource PrinterService printerService; + @Resource + private ReceiptPrintingService receiptPrintingService; + @Resource + private MtUserMapper mtUserMapper; + + @Resource + private UserBalanceMapper userBalanceMapper; + + @Resource + private LJUserGradeMapper ljUserGradeMapper; @GetMapping("callback") public Map callback(Map map){ log.info("------print/callback-------"); @@ -256,13 +274,23 @@ public class printerController extends BaseController { // PrintOilOrderReport.setHandover(handover); // Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); // String url=m.print("4004872261", PrintOilOrderReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); - printerService.oilOrderReport(oilOrder,TokenUtil.getNowAccountInfo().getStoreId()); + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + ReceiptPrinting receiptPrinting = receiptPrintingService.queryReceiptPrintingOne(nowAccountInfo.getStoreId()); + MtUser mtUser=mtUserMapper.selectByPhone("13964068390"); + UserBalance userBalance=userBalanceMapper.getUserBalanceByUserId(mtUser.getId().toString()); + LJUserGrade ljUserGrade= ljUserGradeMapper.getUserGradeByUserId(userBalance.getGradeId().toString()); + printerService.oilOrderReport(oilOrder,TokenUtil.getNowAccountInfo().getStoreId(),receiptPrinting,mtUser,userBalance,ljUserGrade); } @PostMapping("rePrintOilOrderReport") public void reOilOrderReport(@RequestBody Map oilOrder) { - printerService.reOilOrderReport(oilOrder,TokenUtil.getNowAccountInfo().getStoreId()); + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + ReceiptPrinting receiptPrinting = receiptPrintingService.queryReceiptPrintingOne(nowAccountInfo.getStoreId()); + MtUser mtUser=mtUserMapper.selectByPhone("13964068390"); + UserBalance userBalance=userBalanceMapper.getUserBalanceByUserId(mtUser.getId().toString()); + LJUserGrade ljUserGrade= ljUserGradeMapper.getUserGradeByUserId(userBalance.getGradeId().toString()); + printerService.reOilOrderReport(oilOrder,TokenUtil.getNowAccountInfo().getStoreId(),receiptPrinting,mtUser,userBalance,ljUserGrade); } /** * 余额充值订单 @@ -278,7 +306,12 @@ public class printerController extends BaseController { // PrintCardValueReport.setHandover(cardValue); // Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); // String url=m.print("4004872261", PrintCardValueReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); - printerService.printCardValueReport(cardValue, TokenUtil.getNowAccountInfo().getStoreId()); + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + ReceiptPrinting receiptPrinting = receiptPrintingService.queryReceiptPrintingOne(nowAccountInfo.getStoreId()); + MtUser mtUser=mtUserMapper.selectByPhone("13964068390"); + UserBalance userBalance=userBalanceMapper.getUserBalanceByUserId(mtUser.getId().toString()); + LJUserGrade ljUserGrade= ljUserGradeMapper.getUserGradeByUserId(userBalance.getGradeId().toString()); + printerService.printCardValueReport(cardValue, TokenUtil.getNowAccountInfo().getStoreId(),receiptPrinting,mtUser,userBalance,ljUserGrade); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/PrintDeviceInfoMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/PrintDeviceInfoMapper.java index a7d341ab8..72ce8c2d7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/PrintDeviceInfoMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/PrintDeviceInfoMapper.java @@ -86,6 +86,6 @@ public interface PrintDeviceInfoMapper extends BaseMapper { int getIsAcquiesceByStoreId(Integer storeId); - + List getInfoListByStoreId(Integer storeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/xml/PrintDeviceInfoMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/xml/PrintDeviceInfoMapper.xml index f1cdef9ea..be2322612 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/xml/PrintDeviceInfoMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/mapper/xml/PrintDeviceInfoMapper.xml @@ -254,10 +254,14 @@ machine_code = values(machine_code)msign = values(msign)device_name = values(dev update print_device_info set acquiesce = false where store_id = #{storeId} - + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/PrinterService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/PrinterService.java index c6cbf89c3..297921c64 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/PrinterService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/PrinterService.java @@ -1,5 +1,9 @@ package com.fuint.business.printer.service; +import com.fuint.business.setting.entity.ReceiptPrinting; +import com.fuint.business.userManager.entity.LJUserGrade; +import com.fuint.business.userManager.entity.UserBalance; +import com.fuint.repository.model.MtUser; import org.springframework.web.bind.annotation.RequestParam; import java.math.BigDecimal; @@ -22,12 +26,12 @@ public interface PrinterService { String printIndex(BigDecimal payAmount,Integer storeId); void getHandover(Map handover,Integer storeId); - void oilOrderReport(Map handover,Integer storeId); - void reOilOrderReport(Map oilOrder, Integer storeId); + void oilOrderReport(Map handover, Integer storeId, ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade); + void reOilOrderReport(Map oilOrder, Integer storeId, ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade); void printTagReport(Map integral,Integer storeId); - void printCardValueReport(Map printCardValue,Integer storeId); + void printCardValueReport(Map printCardValue,Integer storeId, ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade); void printFuelDieselReport(Map printCardValue,Integer storeId); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java index 8c659c010..d1571a60c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java @@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alipay.api.internal.util.codec.Base64; +import com.fuint.business.order.mapper.AllOrderInfoMapper; +import com.fuint.business.order.vo.AllOrderInfoVo; import com.fuint.business.printer.entity.PrintDeviceInfo; import com.fuint.business.printer.mapper.PrintDeviceInfoMapper; import com.fuint.business.printer.service.PrintDeviceInfoService; @@ -11,7 +13,11 @@ import com.fuint.business.printer.service.PrinterService; import com.fuint.business.printer.template.*; import com.fuint.business.printer.unit.Methods; import com.fuint.business.printer.vo.OrderPayment; +import com.fuint.business.setting.entity.ReceiptPrinting; +import com.fuint.business.userManager.entity.LJUserGrade; +import com.fuint.business.userManager.entity.UserBalance; import com.fuint.common.util.RedisUtil; +import com.fuint.repository.model.MtUser; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.yly.print_sdk_library.RequestMethod; @@ -53,6 +59,8 @@ public class PrinterServiceImpl implements PrinterService { PrintDeviceInfoService printDeviceInfoService; @Resource PrintDeviceInfoMapper printDeviceInfoMapper; + @Resource + private AllOrderInfoMapper allOrderInfoMapper; @Override public Map PostPush(String ciphertext, String nonce, String tag, String additional_data, String iv, String signature) { @@ -227,9 +235,9 @@ public class PrinterServiceImpl implements PrinterService { } } - public void oilOrderReport(Map oilOrder,Integer storeId) { + public void oilOrderReport(Map oilOrder, Integer storeId,ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade) { PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); - + AllOrderInfoVo allOrderInfoVo=allOrderInfoMapper.getOneByOrderNo("234520241023114642fc06e4"); Methods m=Methods.getInstance(); Object accessToken = RedisUtil.get("scancodemodel+" + storeId); if (ObjectUtil.isNotEmpty(accessToken)) { @@ -244,7 +252,7 @@ public class PrinterServiceImpl implements PrinterService { m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); PrintOilOrderReport.setHandover(oilOrder); Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); - String url=m.print(infoByStoreId.getMachineCode(), PrintOilOrderReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + String url=m.print(infoByStoreId.getMachineCode(), PrintOilOrderReport.printOilOrder(receiptPrinting,mtUser,userBalance,ljUserGrade,allOrderInfoVo), "Z"+System.currentTimeMillis()+random6.toString()); if (ObjectUtil.isNotEmpty(url)) { // 使用 Fastjson 将 JSON 字符串解析为 JSONObject JSONObject jsonObject = JSON.parseObject(url); @@ -252,14 +260,14 @@ public class PrinterServiceImpl implements PrinterService { String error = jsonObject.getString("error"); if ("18".equals(error)) { getToken(storeId); - reOilOrderReport(oilOrder,storeId); + oilOrderReport(oilOrder,storeId,receiptPrinting,mtUser,userBalance,ljUserGrade); } } } - public void reOilOrderReport(Map oilOrder,Integer storeId) { + public void reOilOrderReport(Map oilOrder,Integer storeId,ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade) { PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); - + AllOrderInfoVo allOrderInfoVo=allOrderInfoMapper.getOneByOrderNo("234520241023114642fc06e4"); Methods m=Methods.getInstance(); Object accessToken = RedisUtil.get("scancodemodel+" + storeId); if (ObjectUtil.isNotEmpty(accessToken)) { @@ -275,7 +283,7 @@ public class PrinterServiceImpl implements PrinterService { m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); RePrintOilOrderReport.setHandover(oilOrder); Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); - String url=m.print(infoByStoreId.getMachineCode(), RePrintOilOrderReport.rePrintOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + String url=m.print(infoByStoreId.getMachineCode(), RePrintOilOrderReport.rePrintOilOrder(receiptPrinting,mtUser,userBalance,ljUserGrade,allOrderInfoVo), "Z"+System.currentTimeMillis()+random6.toString()); if (ObjectUtil.isNotEmpty(url)) { // 使用 Fastjson 将 JSON 字符串解析为 JSONObject JSONObject jsonObject = JSON.parseObject(url); @@ -283,16 +291,16 @@ public class PrinterServiceImpl implements PrinterService { String error = jsonObject.getString("error"); if ("18".equals(error)) { getToken(storeId); - reOilOrderReport(oilOrder,storeId); + reOilOrderReport(oilOrder,storeId,receiptPrinting,mtUser,userBalance,ljUserGrade); } } } - public void printCardValueReport(Map cardValue,Integer storeId) { + public void printCardValueReport(Map cardValue,Integer storeId,ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade) { PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); - + AllOrderInfoVo allOrderInfoVo=allOrderInfoMapper.getOneByOrderNo("234520241023114642fc06e4"); log.info("handover:{}",cardValue.toString()); Methods m=Methods.getInstance(); Object accessToken = RedisUtil.get("scancodemodel+" + storeId); @@ -309,7 +317,7 @@ public class PrinterServiceImpl implements PrinterService { m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); PrintCardValueReport.setHandover(cardValue); Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); - String url=m.print(infoByStoreId.getMachineCode(), PrintCardValueReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + String url=m.print(infoByStoreId.getMachineCode(), PrintCardValueReport.printOilOrder(receiptPrinting,mtUser,userBalance,ljUserGrade,allOrderInfoVo), "Z"+System.currentTimeMillis()+random6.toString()); if (ObjectUtil.isNotEmpty(url)) { // 使用 Fastjson 将 JSON 字符串解析为 JSONObject JSONObject jsonObject = JSON.parseObject(url); @@ -317,7 +325,7 @@ public class PrinterServiceImpl implements PrinterService { String error = jsonObject.getString("error"); if ("18".equals(error)) { getToken(storeId); - reOilOrderReport(cardValue,storeId); + printCardValueReport(cardValue,storeId,receiptPrinting,mtUser,userBalance,ljUserGrade); } } @@ -349,7 +357,7 @@ public class PrinterServiceImpl implements PrinterService { String error = jsonObject.getString("error"); if ("18".equals(error)) { getToken(storeId); - reOilOrderReport(fuelDiesel,storeId); + printFuelDieselReport(fuelDiesel,storeId); } } @@ -382,7 +390,7 @@ public class PrinterServiceImpl implements PrinterService { String error = jsonObject.getString("error"); if ("18".equals(error)) { getToken(storeId); - reOilOrderReport(integral,storeId); + printIntegralReport(integral,storeId); } } @@ -424,7 +432,7 @@ public class PrinterServiceImpl implements PrinterService { String error = jsonObject.getString("error"); if ("18".equals(error)) { getToken(storeId); - reOilOrderReport(integral,storeId); + printTagReport(integral,storeId); } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintCardValueReport.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintCardValueReport.java index c523f6b49..a9fdcce64 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintCardValueReport.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintCardValueReport.java @@ -1,19 +1,26 @@ package com.fuint.business.printer.template; import cn.hutool.core.util.ObjectUtil; +import com.fuint.business.order.vo.AllOrderInfoVo; +import com.fuint.business.setting.entity.ReceiptPrinting; +import com.fuint.business.userManager.entity.LJUserGrade; +import com.fuint.business.userManager.entity.UserBalance; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; +import com.fuint.repository.model.MtUser; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; public class PrintCardValueReport { public static Map handover = new HashMap<>(); - public static String printOilOrder() { - StringBuilder sb = new StringBuilder(); + public static String printOilOrder(ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade, + AllOrderInfoVo allOrderInfoVo) { + /* StringBuilder sb = new StringBuilder(); LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String formattedDateTime = now.format(formatter); @@ -55,7 +62,130 @@ public class PrintCardValueReport { sb.append("
谢谢惠顾,欢迎下次光临!
"); - return sb.toString(); + return sb.toString();*/ + StringBuilder sb=new StringBuilder(); + + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String formattedDateTime = now.format(formatter); + System.out.println("当前时间:" + formattedDateTime); +// AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + if(allOrderInfoVo.getPayChannel().equals("applet") && allOrderInfoVo.getContent().equals("油品订单")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","一键加油")); + }else { + if(allOrderInfoVo.getContent().equals("收银台订单")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","收银台消费")); + } + if(allOrderInfoVo.getContent().equals("储值卡充值")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","会员充值")); + } + } + + System.out.println( receiptPrinting.getPrintTemplateTop()); + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("xxxxx","32131566313655")); + if(mtUser.getUserNo()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("kkkkk",mtUser.getUserNo())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("卡号:kkkkk\r\n","")); + } + if(mtUser.getCarNo()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("ccccc",mtUser.getCarNo())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("车牌号:ccccc\r\n","")); + } + if(ljUserGrade.getName()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("ddddd",ljUserGrade.getName())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("等级:ddddd\r\n","")); + } + if(mtUser.getMobile()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("sssss",mtUser.getMobile())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("手机号:sssss\r\n","")); + } + if(userBalance.getCardBalance().toString()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("yyyyy",userBalance.getCardBalance().toString())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("余额:yyyyy\r\n","")); + } + if(userBalance.getPoints().toString()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("jjjjj",userBalance.getPoints().toString())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("积分:jjjjj\r\n","")); + } + + if (ObjectUtil.isNotEmpty(handover.get("oilOrder"))) { + + sb.append(""); + List> o = (List>)handover.get("oilOrder"); + for (Map stringStringMap : o) { + sb.append(""); + sb.append(""); + } + sb.append("
油品金额
"+stringStringMap.get("oilName")+"¥"+ stringStringMap.get("amount")+"
"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("goodsOrder"))) { + sb.append(""); + List> o = (List>)handover.get("goodsOrder"); + for (Map stringStringMap : o) { + sb.append(""); + sb.append(""); + + sb.append(""); + } + sb.append("
商品数量单价
"+stringStringMap.get("oilName")+""+stringStringMap.get("unit")+""+ stringStringMap.get("amount")+"
"); + sb.append("--------------------------------\r\n"); + + } + + sb.append("支付方式:"+handover.get("payType")+"\r\n"); + if ("credit".equals(handover.get("payType"))) { + sb.append("挂账单位:"+handover.get("unitName")+"\r\n"); + sb.append("挂账金额:¥"+handover.get("creditAmount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + +// if (ObjectUtil.isNotEmpty(handover.get("discount"))) { +// sb.append("订单总额:¥"+handover.get("discount")+"\r\n"); +// sb.append("------------------------------------\r\n"); +// +// } + if (ObjectUtil.isNotEmpty(handover.get("discount"))) { + sb.append("优惠合计:¥"+handover.get("discount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("amount"))) { + sb.append("总金额:¥"+handover.get("amount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("consumeAmount"))) { + sb.append("储值卡付款:¥"+handover.get("consumeAmount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("consumeRefuelMoney"))) { + sb.append("囤油卡付款:¥"+handover.get("consumeRefuelMoney")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("actualPay"))) { + sb.append("实付款:¥"+handover.get("actualPay")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("seekZero"))) { + sb.append("找零:¥"+handover.get("seekZero")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + receiptPrinting.setPrintTemplateDown(receiptPrinting.getPrintTemplateDown(). + replace("ttttt",formattedDateTime)); + return receiptPrinting.getPrintTemplateTop()+sb.toString()+receiptPrinting.getPrintTemplateDown(); } public static Map getHandover() { return handover; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintOilOrderReport.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintOilOrderReport.java index 8ce7d3e2c..7e0e505b0 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintOilOrderReport.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/PrintOilOrderReport.java @@ -1,8 +1,13 @@ package com.fuint.business.printer.template; import cn.hutool.core.util.ObjectUtil; +import com.fuint.business.order.vo.AllOrderInfoVo; +import com.fuint.business.setting.entity.ReceiptPrinting; +import com.fuint.business.userManager.entity.LJUserGrade; +import com.fuint.business.userManager.entity.UserBalance; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; +import com.fuint.repository.model.MtUser; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -10,25 +15,138 @@ import java.util.*; public class PrintOilOrderReport { public static Map handover = new HashMap<>(); - public static String printOilOrder(){ + public static String printOilOrder(ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade, + AllOrderInfoVo allOrderInfoVo){ +// StringBuilder sb=new StringBuilder(); +// +// +// LocalDateTime now = LocalDateTime.now(); +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// String formattedDateTime = now.format(formatter); +// System.out.println("当前时间:" + formattedDateTime); +// AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); +// sb.append("
订单统计\r\n
"); +// sb.append("打印时间:"+formattedDateTime +"\r\n"); +// sb.append("店铺名称:"+nowAccountInfo.getStoreName() +"\r\n"); +// sb.append("--------------------------------\r\n"); +// if (ObjectUtil.isNotEmpty(handover.get("oilOrder"))) { +// sb.append(""); +// List> o = (List>)handover.get("oilOrder"); +// for (Map stringStringMap : o) { +// sb.append(""); +// sb.append(""); +// } +// sb.append("
油品金额
"+stringStringMap.get("oilName")+"¥"+ stringStringMap.get("amount")+"
"); +// sb.append("--------------------------------\r\n"); +// } +// if (ObjectUtil.isNotEmpty(handover.get("goodsOrder"))) { +// sb.append(""); +// List> o = (List>)handover.get("goodsOrder"); +// for (Map stringStringMap : o) { +// sb.append(""); +// sb.append(""); +// +// sb.append(""); +// } +// sb.append("
商品数量单价
"+stringStringMap.get("oilName")+""+stringStringMap.get("unit")+""+ stringStringMap.get("amount")+"
"); +// sb.append("--------------------------------\r\n"); +// } +// sb.append("支付方式:"+handover.get("payType")+"\r\n"); +// if ("credit".equals(handover.get("payType"))) { +// sb.append("挂账单位:"+handover.get("unitName")+"\r\n"); +// sb.append("挂账金额:¥"+handover.get("creditAmount")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// } +//// if (ObjectUtil.isNotEmpty(handover.get("discount"))) { +//// sb.append("订单总额:¥"+handover.get("discount")+"\r\n"); +//// sb.append("------------------------------------\r\n"); +//// } +// if (ObjectUtil.isNotEmpty(handover.get("discount"))) { +// sb.append("优惠合计:¥"+handover.get("discount")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("amount"))) { +// sb.append("总金额:¥"+handover.get("amount")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("consumeAmount"))) { +// sb.append("储值卡付款:¥"+handover.get("consumeAmount")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("consumeRefuelMoney"))) { +// sb.append("囤油卡付款:¥"+handover.get("consumeRefuelMoney")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("actualPay"))) { +// sb.append("实付款:¥"+handover.get("actualPay")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("seekZero"))) { +// sb.append("找零:¥"+handover.get("seekZero")+"\r\n"); +// sb.append("--------------------------------\r\n"); +// +// } +// +// sb.append("
谢谢惠顾,欢迎下次光临!
"); +// +// return sb.toString(); StringBuilder sb=new StringBuilder(); - LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String formattedDateTime = now.format(formatter); System.out.println("当前时间:" + formattedDateTime); - AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); - - - sb.append("
订单统计\r\n
"); - - sb.append("打印时间:"+formattedDateTime +"\r\n"); - sb.append("店铺名称:"+nowAccountInfo.getStoreName() +"\r\n"); - - sb.append("--------------------------------\r\n"); +// AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + if(allOrderInfoVo.getPayChannel().equals("applet") && allOrderInfoVo.getContent().equals("油品订单")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","一键加油")); + }else { + if(allOrderInfoVo.getContent().equals("收银台订单")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","收银台消费")); + } + if(allOrderInfoVo.getContent().equals("储值卡充值")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","会员充值")); + } + } + System.out.println( receiptPrinting.getPrintTemplateTop()); + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("xxxxx","32131566313655")); + if(mtUser.getUserNo()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("kkkkk",mtUser.getUserNo())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("卡号:kkkkk\r\n","")); + } + if(mtUser.getCarNo()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("ccccc",mtUser.getCarNo())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("车牌号:ccccc\r\n","")); + } + if(ljUserGrade.getName()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("ddddd",ljUserGrade.getName())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("等级:ddddd\r\n","")); + } + if(mtUser.getMobile()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("sssss",mtUser.getMobile())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("手机号:sssss\r\n","")); + } + if(userBalance.getCardBalance().toString()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("yyyyy",userBalance.getCardBalance().toString())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("余额:yyyyy\r\n","")); + } + if(userBalance.getPoints().toString()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("jjjjj",userBalance.getPoints().toString())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("积分:jjjjj\r\n","")); + } if (ObjectUtil.isNotEmpty(handover.get("oilOrder"))) { + sb.append(""); List> o = (List>)handover.get("oilOrder"); for (Map stringStringMap : o) { @@ -87,7 +205,7 @@ public class PrintOilOrderReport { } if (ObjectUtil.isNotEmpty(handover.get("actualPay"))) { - sb.append("实付款:¥"+handover.get("actualPay")+"\r\n"); + sb.append("实付款:¥"+handover.get("actualPay")+"\r\n"); sb.append("--------------------------------\r\n"); } @@ -96,10 +214,9 @@ public class PrintOilOrderReport { sb.append("--------------------------------\r\n"); } - - sb.append("
谢谢惠顾,欢迎下次光临!
"); - - return sb.toString(); + receiptPrinting.setPrintTemplateDown(receiptPrinting.getPrintTemplateDown(). + replace("ttttt",formattedDateTime)); + return receiptPrinting.getPrintTemplateTop()+sb.toString()+receiptPrinting.getPrintTemplateDown(); } public static Map getHandover() { diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/RePrintOilOrderReport.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/RePrintOilOrderReport.java index 79a5d6747..cbe6c7703 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/RePrintOilOrderReport.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/template/RePrintOilOrderReport.java @@ -1,8 +1,13 @@ package com.fuint.business.printer.template; import cn.hutool.core.util.ObjectUtil; +import com.fuint.business.order.vo.AllOrderInfoVo; +import com.fuint.business.setting.entity.ReceiptPrinting; +import com.fuint.business.userManager.entity.LJUserGrade; +import com.fuint.business.userManager.entity.UserBalance; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; +import com.fuint.repository.model.MtUser; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -13,32 +18,153 @@ import java.util.Map; public class RePrintOilOrderReport { public static Map handover = new HashMap<>(); - public static String rePrintOilOrder(){ + public static String rePrintOilOrder(ReceiptPrinting receiptPrinting, MtUser mtUser, UserBalance userBalance, LJUserGrade ljUserGrade, + AllOrderInfoVo allOrderInfoVo){ +// StringBuilder sb=new StringBuilder(); +// +// LocalDateTime now = LocalDateTime.now(); +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// String formattedDateTime = now.format(formatter); +// System.out.println("当前时间:" + formattedDateTime); +// AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); +// +// +// sb.append("
订单统计\r\n
"); +// +// sb.append("打印时间:"+formattedDateTime +"\r\n"); +// sb.append("店铺名称:"+nowAccountInfo.getStoreName() +"\r\n"); +// sb.append("----------------------------\r\n"); +// +// if (ObjectUtil.isNotEmpty(handover.get("oilOrder"))) { +// sb.append("
油品金额
"); +// List> o = (List>)handover.get("oilOrder"); +// for (Map stringStringMap : o) { +// sb.append(""); +// sb.append(""); +// sb.append(""); +// } +// sb.append("
油品加油升数金额
"+stringStringMap.get("oilName")+""+stringStringMap.get("oilNum")+""+ stringStringMap.get("amount")+"
"); +// sb.append("----------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("goodsOrder"))) { +// sb.append(""); +// List> o = (List>)handover.get("goodsOrder"); +// for (Map stringStringMap : o) { +// sb.append(""); +// sb.append(""); +// sb.append(""); +// } +// sb.append("
商品数量单价
"+stringStringMap.get("oilName")+""+stringStringMap.get("unit")+""+ stringStringMap.get("amount")+"
"); +// sb.append("----------------------------\r\n"); +// +// } +// +// sb.append("支付方式:"+handover.get("payType")+"\r\n"); +// +// +// if (ObjectUtil.isNotEmpty(handover.get("amount"))) { +// sb.append("合计:¥"+handover.get("amount")+"\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("payAmount"))) { +// sb.append("实付款:¥"+handover.get("payAmount")+"\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("discount"))) { +// sb.append("优惠:¥"+handover.get("discount")+"\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("seekZero"))) { +// sb.append("找零:¥"+handover.get("seekZero")+"\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// +// if (ObjectUtil.isNotEmpty(handover.get("type")) && "2".equals(handover.get("type"))) { +// if (ObjectUtil.isNotEmpty(handover.get("balanceAmount"))) { +// sb.append("储值卡:¥"+handover.get("balanceAmount")+"\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("oilCardAmount"))) { +// sb.append("屯油卡:"+handover.get("oilCardAmount")+"L\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// if (ObjectUtil.isNotEmpty(handover.get("calculateRefundsV"))) { +// sb.append("退款:¥"+handover.get("calculateRefundsV")+"\r\n"); +// sb.append("----------------------------\r\n"); +// +// } +// } +// sb.append("
谢谢惠顾,欢迎下次光临!
"); +// +// return sb.toString(); StringBuilder sb=new StringBuilder(); LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String formattedDateTime = now.format(formatter); System.out.println("当前时间:" + formattedDateTime); - AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); +// AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + if(allOrderInfoVo.getPayChannel().equals("applet") && allOrderInfoVo.getContent().equals("油品订单")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","一键加油")); + }else { + if(allOrderInfoVo.getContent().equals("收银台订单")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","收银台消费")); + } + if(allOrderInfoVo.getContent().equals("储值卡充值")){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("zzzzz","会员充值")); + } + } - - sb.append("
订单统计\r\n
"); - - sb.append("打印时间:"+formattedDateTime +"\r\n"); - sb.append("店铺名称:"+nowAccountInfo.getStoreName() +"\r\n"); - sb.append("----------------------------\r\n"); + System.out.println( receiptPrinting.getPrintTemplateTop()); + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("xxxxx","32131566313655")); + if(mtUser.getUserNo()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("kkkkk",mtUser.getUserNo())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("卡号:kkkkk\r\n","")); + } + if(mtUser.getCarNo()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("ccccc",mtUser.getCarNo())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("车牌号:ccccc\r\n","")); + } + if(ljUserGrade.getName()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("ddddd",ljUserGrade.getName())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("等级:ddddd\r\n","")); + } + if(mtUser.getMobile()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("sssss",mtUser.getMobile())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("手机号:sssss\r\n","")); + } + if(userBalance.getCardBalance().toString()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("yyyyy",userBalance.getCardBalance().toString())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("余额:yyyyy\r\n","")); + } + if(userBalance.getPoints().toString()!=null){ + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("jjjjj",userBalance.getPoints().toString())); + }else { + receiptPrinting.setPrintTemplateTop(receiptPrinting.getPrintTemplateTop().replace("积分:jjjjj\r\n","")); + } if (ObjectUtil.isNotEmpty(handover.get("oilOrder"))) { - sb.append(""); + + sb.append("
油品加油升数金额
"); List> o = (List>)handover.get("oilOrder"); for (Map stringStringMap : o) { sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); } sb.append("
油品金额
"+stringStringMap.get("oilName")+""+stringStringMap.get("oilNum")+""+ stringStringMap.get("amount")+"
¥"+ stringStringMap.get("amount")+"
"); - sb.append("----------------------------\r\n"); + sb.append("--------------------------------\r\n"); } if (ObjectUtil.isNotEmpty(handover.get("goodsOrder"))) { @@ -47,57 +173,60 @@ public class RePrintOilOrderReport { for (Map stringStringMap : o) { sb.append(""+stringStringMap.get("oilName")+""); sb.append(""+stringStringMap.get("unit")+""); + sb.append(""+ stringStringMap.get("amount")+""); } sb.append(""); - sb.append("----------------------------\r\n"); + sb.append("--------------------------------\r\n"); } sb.append("支付方式:"+handover.get("payType")+"\r\n"); - - - if (ObjectUtil.isNotEmpty(handover.get("amount"))) { - sb.append("合计:¥"+handover.get("amount")+"\r\n"); - sb.append("----------------------------\r\n"); + if ("credit".equals(handover.get("payType"))) { + sb.append("挂账单位:"+handover.get("unitName")+"\r\n"); + sb.append("挂账金额:¥"+handover.get("creditAmount")+"\r\n"); + sb.append("--------------------------------\r\n"); } - if (ObjectUtil.isNotEmpty(handover.get("payAmount"))) { - sb.append("实付款:¥"+handover.get("payAmount")+"\r\n"); - sb.append("----------------------------\r\n"); - } +// if (ObjectUtil.isNotEmpty(handover.get("discount"))) { +// sb.append("订单总额:¥"+handover.get("discount")+"\r\n"); +// sb.append("------------------------------------\r\n"); +// +// } if (ObjectUtil.isNotEmpty(handover.get("discount"))) { - sb.append("优惠:¥"+handover.get("discount")+"\r\n"); - sb.append("----------------------------\r\n"); + sb.append("优惠合计:¥"+handover.get("discount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("amount"))) { + sb.append("总金额:¥"+handover.get("amount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("consumeAmount"))) { + sb.append("储值卡付款:¥"+handover.get("consumeAmount")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("consumeRefuelMoney"))) { + sb.append("囤油卡付款:¥"+handover.get("consumeRefuelMoney")+"\r\n"); + sb.append("--------------------------------\r\n"); + + } + if (ObjectUtil.isNotEmpty(handover.get("actualPay"))) { + sb.append("实付款:¥"+handover.get("actualPay")+"\r\n"); + sb.append("--------------------------------\r\n"); } if (ObjectUtil.isNotEmpty(handover.get("seekZero"))) { sb.append("找零:¥"+handover.get("seekZero")+"\r\n"); - sb.append("----------------------------\r\n"); + sb.append("--------------------------------\r\n"); } - - if (ObjectUtil.isNotEmpty(handover.get("type")) && "2".equals(handover.get("type"))) { - if (ObjectUtil.isNotEmpty(handover.get("balanceAmount"))) { - sb.append("储值卡:¥"+handover.get("balanceAmount")+"\r\n"); - sb.append("----------------------------\r\n"); - - } - if (ObjectUtil.isNotEmpty(handover.get("oilCardAmount"))) { - sb.append("屯油卡:"+handover.get("oilCardAmount")+"L\r\n"); - sb.append("----------------------------\r\n"); - - } - if (ObjectUtil.isNotEmpty(handover.get("calculateRefundsV"))) { - sb.append("退款:¥"+handover.get("calculateRefundsV")+"\r\n"); - sb.append("----------------------------\r\n"); - - } - } - sb.append("
谢谢惠顾,欢迎下次光临!
"); - - return sb.toString(); + receiptPrinting.setPrintTemplateDown(receiptPrinting.getPrintTemplateDown(). + replace("ttttt",formattedDateTime)); + return receiptPrinting.getPrintTemplateTop()+sb.toString()+receiptPrinting.getPrintTemplateDown(); } public static Map getHandover() { diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/ReceiptPrinting.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/ReceiptPrinting.java index 38b2c1539..5ccbc3cc0 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/ReceiptPrinting.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/ReceiptPrinting.java @@ -157,5 +157,18 @@ public class ReceiptPrinting extends BaseEntity implements Serializable { */ @TableField(exist = false) private String storeName; + + /** + * 打印模版顶部 + */ + private String printTemplateTop; + /** + * 打印模版底部 + */ + private String printTemplateDown; + /** + * 二维码的内容 + */ + private String codeContent; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/ReceiptPrintingMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/ReceiptPrintingMapper.java index e87bd301d..188f3e328 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/ReceiptPrintingMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/ReceiptPrintingMapper.java @@ -19,5 +19,9 @@ public interface ReceiptPrintingMapper extends BaseMapper { // 更具 stordid查询当前油站小票打印配置 List queryReceiptPrintingList(@Param("receiptPrinting") ReceiptPrinting receiptPrinting); + void addReceiptPrinting(@Param("receiptPrinting") ReceiptPrinting receiptPrinting); + + ReceiptPrinting queryReceiptPrintingOne(@Param("storeId") Integer storeId); + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/xml/ReceiptPrintingMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/xml/ReceiptPrintingMapper.xml index 9875f02cc..30757572e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/xml/ReceiptPrintingMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/mapper/xml/ReceiptPrintingMapper.xml @@ -11,5 +11,42 @@ store_id = #{receiptPrinting.storeId} and deleted = 0 order by id desc + + + INSERT into receipt_printing (logo_set, headfoot_set, shop_name, title, receipt_type, foot, top_set, + order_number, member_card, plate_number, membership_level, phone_number, + member_points, bottom_set, operate_time, + contact_way, console_operator, address, remarks, code_set, code_image, + loge_image,store_id,create_name,create_time,create_by,update_time,update_by,print_template_top,print_template_down) + VALUES (#{receiptPrinting.logoSet}, #{receiptPrinting.headfootSet}, #{receiptPrinting.shopName}, #{receiptPrinting.title}, + #{receiptPrinting.receiptType}, #{receiptPrinting.foot}, #{receiptPrinting.topSet}, + #{receiptPrinting.orderNumber}, #{receiptPrinting.memberCard}, #{receiptPrinting.plateNumber}, + #{receiptPrinting.membershipLevel}, #{receiptPrinting.phoneNumber}, #{receiptPrinting.memberPoints}, + #{receiptPrinting.bottomSet}, #{receiptPrinting.operateTime}, + #{receiptPrinting.contactWay}, #{receiptPrinting.consoleOperator}, #{receiptPrinting.address}, + #{receiptPrinting.remarks}, #{receiptPrinting.codeSet}, #{receiptPrinting.codeImage}, #{receiptPrinting.logeImage} + , #{receiptPrinting.storeId}, #{receiptPrinting.createName}, #{receiptPrinting.createTime}, #{receiptPrinting.createBy} + , #{receiptPrinting.updateTime}, #{receiptPrinting.updateBy}, #{receiptPrinting.printTemplateTop}, #{receiptPrinting.printTemplateDown}) + ON DUPLICATE KEY UPDATE + logo_set = #{receiptPrinting.logoSet}, headfoot_set = #{receiptPrinting.headfootSet}, shop_name = #{receiptPrinting.shopName}, + title = #{receiptPrinting.title}, receipt_type = #{receiptPrinting.receiptType}, foot = #{receiptPrinting.foot}, + top_set = #{receiptPrinting.topSet}, order_number = #{receiptPrinting.orderNumber}, member_card = #{receiptPrinting.memberCard}, + plate_number = #{receiptPrinting.plateNumber}, + member_points = #{receiptPrinting.membershipLevel}, bottom_set = #{receiptPrinting.bottomSet}, + operate_time = #{receiptPrinting.operateTime}, + contact_way = #{receiptPrinting.contactWay}, console_operator = #{receiptPrinting.consoleOperator}, + address = #{receiptPrinting.address}, remarks = #{receiptPrinting.remarks}, code_set = #{receiptPrinting.codeSet}, + code_image = #{receiptPrinting.codeImage},loge_image = #{receiptPrinting.logeImage},update_time = #{receiptPrinting.updateTime}, + update_by = #{receiptPrinting.updateBy},print_template_top= #{receiptPrinting.printTemplateTop},print_template_down= #{receiptPrinting.printTemplateDown} + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/ReceiptPrintingService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/ReceiptPrintingService.java index a9ac86f6c..698dce88c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/ReceiptPrintingService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/ReceiptPrintingService.java @@ -19,5 +19,5 @@ public interface ReceiptPrintingService extends IService { ReceiptPrinting queryReceiptPrintingList(ReceiptPrinting receiptPrinting); - + ReceiptPrinting queryReceiptPrintingOne(Integer storeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/ReceiptPrintingServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/ReceiptPrintingServiceImpl.java index 609fd7705..dc0af09b7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/ReceiptPrintingServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/ReceiptPrintingServiceImpl.java @@ -1,19 +1,31 @@ package com.fuint.business.setting.service.impl; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.printer.entity.PrintDeviceInfo; +import com.fuint.business.printer.mapper.PrintDeviceInfoMapper; +import com.fuint.business.printer.unit.Methods; import com.fuint.business.setting.entity.ReceiptPrinting; import com.fuint.business.setting.mapper.ReceiptPrintingMapper; import com.fuint.business.setting.service.ReceiptPrintingService; +import com.fuint.business.store.entity.MtStore; +import com.fuint.business.store.mapper.MtStoreMapper; import com.fuint.business.storeInformation.entity.LJStore; import com.fuint.business.storeInformation.service.ILJStoreService; import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.RedisUtil; import com.fuint.common.util.TokenUtil; +import com.yly.print_sdk_library.RequestMethod; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -24,28 +36,33 @@ import java.util.stream.Collectors; * @date : 2024-08-30 10:00 **/ @Service +@Slf4j public class ReceiptPrintingServiceImpl extends ServiceImpl implements ReceiptPrintingService { @Resource private ReceiptPrintingMapper receiptPrintingMapper; @Autowired private ILJStoreService storeService; - + @Autowired + private PrintDeviceInfoMapper printDeviceInfoMapper; + @Autowired + private MtStoreMapper mtStoreMapper; @Override @Transactional public int addReceiptPrinting(ReceiptPrinting receiptPrinting) { // id不为空 查询 删除 - if (receiptPrinting.getId() != null) { - ReceiptPrinting receiptPrinting1 = new ReceiptPrinting(); - receiptPrinting1.setId(receiptPrinting.getId()); - receiptPrinting1.setDeleted(1); - receiptPrintingMapper.updateById(receiptPrinting1); - } +// if (receiptPrinting.getId() != null) { +// ReceiptPrinting receiptPrinting1 = new ReceiptPrinting(); +// receiptPrinting1.setId(receiptPrinting.getId()); +// receiptPrinting1.setDeleted(1); +// receiptPrintingMapper.updateById(receiptPrinting1); +// } // 为空进行新增 AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); receiptPrinting.setStoreId(nowAccountInfo.getStoreId()); + MtStore mtStore = mtStoreMapper.selectById(nowAccountInfo.getStoreId()); if (receiptPrinting.getHeadfootSets() != null && receiptPrinting.getHeadfootSets().size() > 0 ) { receiptPrinting.setHeadfootSet(chke(receiptPrinting.getHeadfootSets())); @@ -59,10 +76,119 @@ public class ReceiptPrintingServiceImpl extends ServiceImpl infoByStoreId = printDeviceInfoMapper.getInfoListByStoreId(nowAccountInfo.getStoreId()); +// for(int i=0;ilogo_state:0"); + } + if(receiptPrinting.getHeadfootSet().contains("0")){ + sb.append("
"+nowAccountInfo.getStoreName() +"
"); + } + if(receiptPrinting.getHeadfootSet().contains("1")){ + sb.append("
"+receiptPrinting.getTitle() +"
"); + } + if(receiptPrinting.getHeadfootSet().contains("2")){ + sb.append("
"+"zzzzz
"); + } + sb.append("打印时间:"+formattedDateTime +"\r\n"); + if(receiptPrinting.getTopSet().contains("0")){ + sb.append("订单号:xxxxx\r\n"); + } + if(receiptPrinting.getTopSet().contains("1")){ + sb.append("卡号:kkkkk\r\n"); + } + if(receiptPrinting.getTopSet().contains("2")){ + sb.append("车牌号:ccccc\r\n"); + } + if(receiptPrinting.getTopSet().contains("3")){ + sb.append("等级:ddddd\r\n"); + } + if(receiptPrinting.getTopSet().contains("4")){ + sb.append("手机号:sssss\r\n"); + } + if(receiptPrinting.getTopSet().contains("5")){ + sb.append("余额:yyyyy\r\n"); + } + if(receiptPrinting.getTopSet().contains("6")){ + sb.append("积分:jjjjj\r\n"); + } + sb.append("----------------------------\r\n"); + receiptPrinting.setPrintTemplateTop(sb.toString()); + StringBuilder sb1=new StringBuilder(); + if(receiptPrinting.getBottomSet().contains("0")){ + sb1.append("操作时间:ttttt\r\n"); + } + if(receiptPrinting.getBottomSet().contains("1")){ + if(mtStore.getPhone().toString()!=null){ + sb1.append("联系方式:"+mtStore.getPhone()+"\r\n"); + } + } + if(receiptPrinting.getBottomSet().contains("2")){ + if(nowAccountInfo.getAccountName().toString()!=null){ + sb1.append("操作员:"+nowAccountInfo.getAccountName()+"\r\n"); + } + } + if(receiptPrinting.getBottomSet().contains("3")){ + if(mtStore.getAddress().toString()!=null){ + sb1.append("地址:"+mtStore.getAddress()+"\r\n"); + } + } + if(receiptPrinting.getBottomSet().contains("4")){ + if(receiptPrinting.getRemarks().toString()!=null){ + sb1.append("备注:"+receiptPrinting.getRemarks()+"\r\n"); + } + } + sb1.append("----------------------------\r\n"); + if(receiptPrinting.getHeadfootSet().contains("3")){ + sb1.append("
"+receiptPrinting.getFoot()+"
\r\n"); + } + if(receiptPrinting.getCodeSet().equals("1")){ +// sb1.append(""+receiptPrinting.getCodeContent()+"\r\n"); + sb1.append("www.baidu.com\r\n"); + } + sb1.append("----------------------------\r\n"); + sb1.append("
谢谢惠顾,欢迎下次光临!
\r\n"); + receiptPrinting.setPrintTemplateDown(sb1.toString()); + receiptPrintingMapper.addReceiptPrinting(receiptPrinting); + //int insert = receiptPrintingMapper.insert(receiptPrinting); + return 1; } @@ -109,4 +235,68 @@ public class ReceiptPrintingServiceImpl extends ServiceImpl infoByStoreId = printDeviceInfoMapper.getInfoListByStoreId(storeId); + for(int i=0;i { String selectByUserId(@Param("storeId") Integer storeId, @Param("userId") Integer userId); LJUserGrade selectAllByGradeId(String gradeId); + + LJUserGrade getUserGradeByUserId(String gradeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/UserBalanceMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/UserBalanceMapper.java index d2de06ab8..deedc1ee7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/UserBalanceMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/UserBalanceMapper.java @@ -24,4 +24,5 @@ public interface UserBalanceMapper extends BaseMapper { Map selectHoverBalance(); Map addNumberSum(); + UserBalance getUserBalanceByUserId(String userId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml index 82960b4e2..6c24b477a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml @@ -20,4 +20,7 @@ + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/UserBalanceMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/UserBalanceMapper.xml index 72b8ce543..97bc86dc3 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/UserBalanceMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/UserBalanceMapper.xml @@ -79,5 +79,11 @@ count(*) sumnum from mt_user_balance mub - - \ No newline at end of file + + diff --git a/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtUserMapper.java b/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtUserMapper.java index a374d01f7..a6af40b48 100644 --- a/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtUserMapper.java +++ b/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtUserMapper.java @@ -41,4 +41,6 @@ public interface MtUserMapper extends BaseMapper { Long getStoreUserCountByTime(@Param("storeId") Integer storeId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime); List getMemberConsumeTopList(@Param("merchantId") Integer merchantId, @Param("storeId") Integer storeId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); + + MtUser selectByPhone(@Param("phone") String phone); } diff --git a/fuintBackend/fuint-repository/src/main/resources/mapper/MtUserMapper.xml b/fuintBackend/fuint-repository/src/main/resources/mapper/MtUserMapper.xml index ff139e9ae..92b2e3faf 100644 --- a/fuintBackend/fuint-repository/src/main/resources/mapper/MtUserMapper.xml +++ b/fuintBackend/fuint-repository/src/main/resources/mapper/MtUserMapper.xml @@ -90,5 +90,7 @@ select * from mt_user t where t.Id = #{id} limit 1 - +