This commit is contained in:
suyl
2021-10-19 18:46:17 +08:00
parent 2bc28240d4
commit 2fbcae6263

View File

@@ -176,15 +176,11 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
func (c *PrinterHandler) getOrderContentByTemplate(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
orderParams := []interface{}{}
orderFmt := ""
if storeDetail != nil {
//开头加上语音
if storeDetail.PrinterSound != "" {
orderFmt += `
<sound>%s</sound><br>
`
orderParams = append(orderParams, storeDetail.PrinterSound)
orderFmt += "<sound>" + storeDetail.PrinterSound + "</sound><br>"
}
}
//把带有${}的变量换成实际值
@@ -233,11 +229,12 @@ func (c *PrinterHandler) getOrderContentByTemplate(order *model.GoodsOrder, stor
skuParams = append(skuParams, jxutils.IntPrice2StandardCurrencyString(order.Skus[i].SalePrice))
skuParams = append(skuParams, jxutils.IntPrice2StandardCurrencyString(order.Skus[i].SalePrice*int64(order.Skus[i].Count)))
}
template = strings.ReplaceAll(template, v[0], fmt.Sprintf(skus, skuParams))
skus = fmt.Sprintf(skus, skuParams...)
template = strings.ReplaceAll(template, v[0], skus)
}
}
orderFmt += template
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
return strings.Replace(orderFmt, "\n", "", -1)
}
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {