im
This commit is contained in:
@@ -33,25 +33,26 @@ func (c *PrinterHandler) GetVendorID() int {
|
||||
}
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, sn, copies, voiceType, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
if sn != "" {
|
||||
if globals.EnableStoreWrite {
|
||||
globals.SugarLogger.Debugf("printMsg voiceType====%s", voiceType)
|
||||
printOrderID, err1 := api.XpyunAPI.Print(&xpyunapi.PrintRequest{
|
||||
Sn: sn,
|
||||
Content: msgContent,
|
||||
Copies: 1,
|
||||
Voice: utils.Str2Int(voiceType),
|
||||
Mode: xpyunapi.ModeCheckYes,
|
||||
ExpiresIn: xpyunapi.ExpiresInDefault,
|
||||
})
|
||||
if err1 == nil && printOrderID != "" {
|
||||
printerStatus, err = c.GetPrinterStatus(ctx, sn, "")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrintResult: partner.PrintResultNoPrinter,
|
||||
//if globals.EnableStoreWrite {
|
||||
globals.SugarLogger.Debugf("printMsg voiceType====%s", voiceType)
|
||||
printOrderID, err1 := api.XpyunAPI.Print(&xpyunapi.PrintRequest{
|
||||
Sn: sn,
|
||||
Content: msgContent,
|
||||
Copies: 1,
|
||||
Voice: utils.Str2Int(voiceType),
|
||||
Mode: xpyunapi.ModeCheckYes,
|
||||
ExpiresIn: xpyunapi.ExpiresInDefault,
|
||||
})
|
||||
if err1 == nil && printOrderID != "" {
|
||||
printerStatus, err = c.GetPrinterStatus(ctx, sn, "")
|
||||
}
|
||||
//}
|
||||
}
|
||||
//else {
|
||||
// printerStatus = &partner.PrinterStatus{
|
||||
// PrintResult: partner.PrintResultNoPrinter,
|
||||
// }
|
||||
//}
|
||||
return printerStatus, err
|
||||
}
|
||||
|
||||
@@ -107,9 +108,11 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
|
||||
}
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
|
||||
content = c.getOrderContentBig(order, store.Tel1, storeDetail)
|
||||
//content = c.getOrderContentBig(order, store.Tel1, storeDetail)
|
||||
content = c.getOrderContentBigV2(order, store.Tel1, storeDetail)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1, storeDetail)
|
||||
//content = c.getOrderContent(order, store.Tel1, storeDetail)
|
||||
content = c.getOrderContentV2(order, store.Tel1, storeDetail)
|
||||
}
|
||||
count := 0
|
||||
for {
|
||||
@@ -169,6 +172,134 @@ func (c *PrinterHandler) SetSound(ctx *jxcontext.Context, sn, id2, sound string)
|
||||
return err
|
||||
}
|
||||
|
||||
//不包含价格版本
|
||||
func (c *PrinterHandler) getOrderContentV2(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
|
||||
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
if utils.IsTimeZero(expectedDeliveryTime) {
|
||||
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||
}
|
||||
getCode := ""
|
||||
if order.VendorID == model.VendorIDEBAI {
|
||||
getCode = fmt.Sprintf("<CB>饿百取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
if order.BuyerComment == "" {
|
||||
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
|
||||
}
|
||||
orderParams := []interface{}{}
|
||||
orderFmt := ``
|
||||
if storeDetail != nil {
|
||||
if storeDetail.BrandIsPrint == model.NO {
|
||||
orderFmt += `<C><B>%s</B><C>`
|
||||
if order.VendorOrgCode == "34665" {
|
||||
orderParams = append(orderParams, globals.StoreNameEbai2)
|
||||
} else {
|
||||
orderParams = append(orderParams, storeDetail.BrandName)
|
||||
}
|
||||
}
|
||||
}
|
||||
orderFmt += `
|
||||
` + xpyunapi.StrRepeat("-", 32) + `
|
||||
<L>下单时间: %s
|
||||
<L>预计送达: %s
|
||||
<L>客户姓名: %s
|
||||
<L>客户电话: %s<BR>
|
||||
<HB>订单编号: %s</HB><BR>
|
||||
<CB>%s#%d
|
||||
<C><QRCODE s=6 e=L l=center>%s</QRCODE></C></CB>
|
||||
` + getCode +
|
||||
xpyunapi.StrRepeat("-", 32) + `
|
||||
<HB>客户地址: %s</HB>
|
||||
` + xpyunapi.StrRepeat("-", 32) + `客户备注: %s
|
||||
` + xpyunapi.StrRepeat("-", 32) + `
|
||||
商品列表
|
||||
商品名` + xpyunapi.StrRepeat(" ", 20) + `数量<BR>` + xpyunapi.StrRepeat("-", 32)
|
||||
orderParams = append(orderParams,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeAddress,
|
||||
order.BuyerComment,
|
||||
)
|
||||
|
||||
for k, sku := range order.Skus {
|
||||
orderFmt += xpyunapi.FormatPrintOrderItemV2(sku.SkuName, sku.Count, k+1)
|
||||
}
|
||||
orderFmt += `<BR><HB><L>共%d种%d件商品</L></HB>`
|
||||
orderFmt += `<BR>`
|
||||
orderFmt += "<HB>" + xpyunapi.StrRepeat("-", 14) + "#%d完" + xpyunapi.StrRepeat("-", 13) + `</HB><BR><BR>`
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.OrderSeq)
|
||||
return fmt.Sprintf(orderFmt, orderParams...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContentBigV2(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
|
||||
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
if utils.IsTimeZero(expectedDeliveryTime) {
|
||||
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||
}
|
||||
getCode := ""
|
||||
if order.VendorID == model.VendorIDEBAI {
|
||||
getCode = fmt.Sprintf("<CB>饿百取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
if order.BuyerComment == "" {
|
||||
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
|
||||
}
|
||||
orderParams := []interface{}{}
|
||||
orderFmt := ``
|
||||
if storeDetail != nil {
|
||||
if storeDetail.BrandIsPrint == model.NO {
|
||||
orderFmt += `<C><B>%s</B><C>`
|
||||
if order.VendorOrgCode == "34665" {
|
||||
orderParams = append(orderParams, globals.StoreNameEbai2)
|
||||
} else {
|
||||
orderParams = append(orderParams, storeDetail.BrandName)
|
||||
}
|
||||
}
|
||||
}
|
||||
orderFmt += `
|
||||
` + xpyunapi.StrRepeat("-", 32) + `
|
||||
<HB><L>下单时间: %s
|
||||
<L>预计送达: %s
|
||||
<L>客户姓名: %s
|
||||
<L>客户电话: %s</HB><BR>
|
||||
<HB>订单编号: %s</HB><BR>
|
||||
<CB>%s#%d
|
||||
<C><QRCODE s=6 e=L l=center>%s</QRCODE></C></CB>
|
||||
` + getCode +
|
||||
xpyunapi.StrRepeat("-", 32) + `
|
||||
<HB>客户地址: %s</HB>
|
||||
` + xpyunapi.StrRepeat("-", 32) + `客户备注: %s
|
||||
` + xpyunapi.StrRepeat("-", 32) + `
|
||||
商品列表
|
||||
商品名` + xpyunapi.StrRepeat(" ", 20) + `数量<BR>` + xpyunapi.StrRepeat("-", 32)
|
||||
orderParams = append(orderParams,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeAddress,
|
||||
order.BuyerComment,
|
||||
)
|
||||
|
||||
for k, sku := range order.Skus {
|
||||
orderFmt += xpyunapi.FormatPrintOrderItemV2(sku.SkuName, sku.Count, k+1)
|
||||
}
|
||||
orderFmt += `<BR><HB><L>共%d种%d件商品</L></HB>`
|
||||
orderFmt += `<BR>`
|
||||
orderFmt += "<HB>" + xpyunapi.StrRepeat("-", 14) + "#%d完" + xpyunapi.StrRepeat("-", 13) + `</HB><BR><BR>`
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.OrderSeq)
|
||||
return fmt.Sprintf(orderFmt, orderParams...)
|
||||
}
|
||||
|
||||
//包含价格版本
|
||||
// 新订单正常尺寸打印模板
|
||||
func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
|
||||
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
|
||||
Reference in New Issue
Block a user