浏览代码

fixed 云打印设置优化

fushengqian 5 月之前
父节点
当前提交
c213813619

+ 2 - 1
fuint-application/src/main/java/com/fuint/common/service/PrinterService.java

@@ -38,9 +38,10 @@ public interface PrinterService extends IService<MtPrinter> {
      * 打印订单
      *
      * @param orderInfo 订单信息
+     * @param autoPrint 自动打印
      * @return
      * */
-    Boolean printOrder(UserOrderDto orderInfo) throws Exception;
+    Boolean printOrder(UserOrderDto orderInfo, boolean autoPrint) throws Exception;
 
     /**
      * 根据ID获取打印机信息

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java

@@ -1489,7 +1489,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
 
         try {
             // 打印订单
-            printerService.printOrder(orderInfo);
+            printerService.printOrder(orderInfo, true);
 
             // 给商家发送通知短信
             MtStore mtStore = storeService.queryStoreById(mtOrder.getStoreId());

+ 16 - 4
fuint-application/src/main/java/com/fuint/common/service/impl/PrinterServiceImpl.java

@@ -28,6 +28,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.github.pagehelper.Page;
 import org.springframework.beans.BeanUtils;
+import org.springframework.core.env.Environment;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -53,6 +54,11 @@ public class PrinterServiceImpl extends ServiceImpl<MtPrinterMapper, MtPrinter>
      * */
     private SettingService settingService;
 
+    /**
+     * 环境变量
+     * */
+    private Environment env;
+
     /**
      * 分页查询数据列表
      *
@@ -147,10 +153,11 @@ public class PrinterServiceImpl extends ServiceImpl<MtPrinterMapper, MtPrinter>
      * 打印订单
      *
      * @param orderInfo 订单信息
+     * @param autoPrint 自动打印
      * @return
      * */
     @Override
-    public Boolean printOrder(UserOrderDto orderInfo) throws Exception {
+    public Boolean printOrder(UserOrderDto orderInfo, boolean autoPrint) throws Exception {
         PrintRequest printRequest = new PrintRequest();
         createRequestHeader(orderInfo.getMerchantId(), printRequest);
         if (orderInfo.getStoreInfo() == null) {
@@ -161,7 +168,9 @@ public class PrinterServiceImpl extends ServiceImpl<MtPrinterMapper, MtPrinter>
         Map<String, Object> params = new HashMap<>();
         params.put("storeId", orderInfo.getStoreInfo().getId());
         params.put("status", StatusEnum.ENABLED.getKey());
-        params.put("autoPrint", YesOrNoEnum.YES.getKey());
+        if (autoPrint) {
+            params.put("autoPrint", YesOrNoEnum.YES.getKey());
+        }
         List<MtPrinter> printers = queryPrinterListByParams(params);
         if (printers == null || printers.size() < 1) {
             return false;
@@ -221,8 +230,11 @@ public class PrinterServiceImpl extends ServiceImpl<MtPrinterMapper, MtPrinter>
                     .append("下单时间:").append(orderInfo.getCreateTime()).append("<BR>")
                     .append("订单备注:").append(StringUtil.isEmpty(orderInfo.getRemark()) ? "无" : orderInfo.getRemark()).append("<BR>");
 
-            // 二维码
-            printContent.append("<C>").append("<QR>https://www.fuint.cn</QR>").append("</C>");
+            // 网站二维码
+            String webSite = env.getProperty("website.url");
+            if (StringUtil.isNotEmpty(webSite)) {
+                printContent.append("<C>").append("<QR>" + webSite + "</QR>").append("</C>");
+            }
 
             printRequest.setContent(printContent.toString());
             printRequest.setCopies(1);

+ 1 - 1
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendPrinterController.java

@@ -341,7 +341,7 @@ public class BackendPrinterController extends BaseController {
         }
 
         // 打印订单
-        Boolean result = printerService.printOrder(orderInfo);
+        Boolean result = printerService.printOrder(orderInfo, false);
 
         return getSuccessResult(result);
     }