|
@@ -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);
|