diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java index dbd5c93c..85fb887d 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java @@ -45,6 +45,7 @@ public class ShopStorePrinterController { ShopStorePrinter shopStorePrinter = new ShopStorePrinter(); shopStorePrinter.setModel_id(model_id); + shopStorePrinter.setPrinter_name(printer_name); shopStorePrinter.setPrinter_sn(printer_sn); shopStorePrinter.setPrinter_key(printer_key); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStorePrinterMapper.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStorePrinterMapper.java index a02f6d24..b562a8f4 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStorePrinterMapper.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStorePrinterMapper.java @@ -27,4 +27,6 @@ public interface ShopStorePrinterMapper extends BaseMapper{ * @return */ IPage shopStorePrinterPageList(Page page, @Param("keyword") String keyword); + + IPage shopStorePrinterPageList2(Page page, @Param("keyword") String keyword); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStorePrinterService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStorePrinterService.java index 73fed204..d7fd37c9 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStorePrinterService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStorePrinterService.java @@ -3,6 +3,7 @@ package com.suisung.mall.shop.store.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.store.ShopStorePrinter; +import com.suisung.mall.common.pojo.vo.ShopStorePrinterVO; import com.suisung.mall.core.web.service.IBaseService; import java.util.Map; @@ -19,6 +20,8 @@ public interface ShopStorePrinterService extends IBaseService */ IPage shopStorePrinterPageList(String keyword, Integer pageNum, Integer pageSize); + IPage shopStorePrinterPageList2(String keyword, Integer pageNum, Integer pageSize); + /** * 门店新增一个打票机 * diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStorePrinterServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStorePrinterServiceImpl.java index d88e346b..6711be8b 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStorePrinterServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStorePrinterServiceImpl.java @@ -45,6 +45,13 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl shopStorePrinterPageList2(String keyword, Integer pageNum, Integer pageSize) { + Page page = new Page(); + page.setCurrent(pageNum); + page.setSize(pageSize); + return shopStorePrinterMapper.shopStorePrinterPageList2(page, keyword); + } + @Override public CommonResult addNewShopStorePrinter(ShopStorePrinter record) { diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/utis/FeieUtil.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/utis/FeieUtil.java index ffc62208..82df6db9 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/utis/FeieUtil.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/utis/FeieUtil.java @@ -218,42 +218,39 @@ public class FeieUtil { String resultStr = ""; resultStr += "商品名称 数量 金额
"; resultStr += "--------------------------------
"; - for (int i = 0; i < productList.size(); i++) { - String product_sn = productList.get(i).getProduct_sn(); - String title = productList.get(i).getTitle(); - String num = productList.get(i).getNum().toString(); - if (productList.get(i).getNum() > 1) { - num = "x" + num; - } - String amount = productList.get(i).getAmount(); + for (ProductSimpleInfo product : productList) { + String productSn = product.getProduct_sn(); + String title = product.getTitle(); + String num = product.getNum() > 1 ? "x" + product.getNum() : product.getNum().toString(); num = addSpace(num, numLen); - amount = addSpace(amount, amountLen); - String otherStr = "" + num + "" + "" + amount + ""; + String amount = addSpace(product.getAmount(), amountLen); + String otherStr = "" + num + "" + amount + ""; - int tl = asciiByteLen(title); - int spaceNum = (tl / titleLen + 1) * titleLen - tl; - if (tl < titleLen) { + int titleLength = asciiByteLen(title); + int spaceNum = (titleLength / titleLen + 1) * titleLen - titleLength; + + if (titleLength < titleLen) { for (int k = 0; k < spaceNum; k++) { title += " "; } title += otherStr; - } else if (tl == titleLen) { + } else if (titleLength == titleLen) { title += otherStr; } else { - List list = null; + List titleStrList; if (isEn(title)) { - // 英文 - list = getStrList(title, titleLen); + titleStrList = getStrList(title, titleLen); } else { - // 中文 - list = getStrList(title, titleLen / 2); + titleStrList = getStrList(title, titleLen / 2); } - String s0 = titleAddSpace(list.get(0), titleLen); - title = s0 + otherStr + "
";// 添加 单价 数量 总额 + + String s0 = titleAddSpace(titleStrList.get(0), titleLen); + title = s0 + otherStr + "
"; + String s = ""; - for (int k = 1; k < list.size(); k++) { - s += list.get(k); + for (int k = 1; k < titleStrList.size(); k++) { + s += titleStrList.get(k); } try { @@ -261,10 +258,12 @@ public class FeieUtil { } catch (Exception e) { e.printStackTrace(); } - title += "" + s + " "; + + title += "" + s + ""; } - resultStr += "" + title + " " + "
"; - resultStr += "" + product_sn + "
"; + + resultStr += "" + title + "" + "
"; + resultStr += "" + productSn + "
"; } return resultStr; @@ -297,27 +296,21 @@ public class FeieUtil { if (len >= size) { return str; } + int cz = size - len; - if (cz % 2 == 0) { - // 偶数 - for (int i = 1; i <= cz; i++) { - if (i % 2 == 0) { - str = " " + str; - } else { - str = str + " "; - } - } - } else { - // 奇数 - for (int i = 1; i <= cz; i++) { - if (i % 2 == 0) { - str = str + " "; - } else { - str = " " + str; - } - } + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < cz / 2; i++) { + sb.append(" "); } - return str; + + sb.append(str); + + for (int i = 0; i < cz / 2; i++) { + sb.append(" "); + } + + return sb.toString(); } /** @@ -338,7 +331,6 @@ public class FeieUtil { } - /** * 判断字符串是否为英文 * @@ -392,17 +384,17 @@ public class FeieUtil { * 截取字符串 * * @param str - * @param f - * @param t + * @param start + * @param end * @return */ - public String subString(String str, int f, int t) { - if (f > str.length()) + public String subString(String str, int start, int end) { + if (start > str.length()) return ""; - if (t > str.length()) { - return str.substring(f); + if (end > str.length()) { + return str.substring(start); } else { - return str.substring(f, t); + return str.substring(start, end); } } diff --git a/mall-shop/src/main/resources/mapper/store/ShopStorePrinterMapper.xml b/mall-shop/src/main/resources/mapper/store/ShopStorePrinterMapper.xml index 26db5231..a5cba0a6 100644 --- a/mall-shop/src/main/resources/mapper/store/ShopStorePrinterMapper.xml +++ b/mall-shop/src/main/resources/mapper/store/ShopStorePrinterMapper.xml @@ -3,25 +3,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/mall-shop/target/classes/static/ip/ip2region.xdb b/mall-shop/target/classes/static/ip/ip2region.xdb index bf62f4aa..7052c057 100644 Binary files a/mall-shop/target/classes/static/ip/ip2region.xdb and b/mall-shop/target/classes/static/ip/ip2region.xdb differ diff --git a/pom.xml b/pom.xml index 5fb7a1a9..d1a6796e 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,12 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-devtools + runtime + true + cn.hutool hutool-all