From 8c8c06c1a286ae152d1ae4559192655a057cb381 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 14:12:32 +0800 Subject: [PATCH 1/7] 1 --- business/partner/printer/xpyun/xpyun.go | 86 +++++++++++++------------ 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index caab30d53..b2bf825ea 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -161,11 +161,14 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin if order.VendorID == model.VendorIDEBAI { getCode = fmt.Sprintf("饿百取货码:%s", jxutils.GetEbaiOrderGetCode(order)) } + if order.BuyerComment == "" { + order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!" + } orderParams := []interface{}{} orderFmt := `` if storeDetail != nil { if storeDetail.BrandIsPrint == model.NO { - orderFmt += `
%s
\n` + orderFmt += `%s` if order.VendorOrgCode == "34665" { orderParams = append(orderParams, globals.StoreNameEbai2) } else { @@ -175,21 +178,20 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin } orderFmt += ` ` + xpyunapi.StrRepeat("-", 32) + ` -
下单时间: %s -
预计送达: %s -
客户姓名: %s -
客户电话: %s -
订单编号: %s -
%s: #%d -%s" -` + getCode + ` -` + xpyunapi.StrRepeat("-", 32) + ` +下单时间: %s +预计送达: %s +客户姓名: %s +客户电话: %s
+订单编号: %s
+%s#%d +%s +` + getCode + + xpyunapi.StrRepeat("-", 32) + ` 客户地址: %s +` + xpyunapi.StrRepeat("-", 32) + `客户备注: %s ` + xpyunapi.StrRepeat("-", 32) + ` -
客户备注: %s -` + xpyunapi.StrRepeat("-", 32) + ` -
商品列表
-商品名` + xpyunapi.StrRepeat(" ", 2) + `数量` + xpyunapi.StrRepeat(" ", 3) + `单价` + xpyunapi.StrRepeat(" ", 5) + `小计
+商品列表 +商品名` + xpyunapi.StrRepeat(" ", 2) + `数量` + xpyunapi.StrRepeat(" ", 3) + `单价` + xpyunapi.StrRepeat(" ", 5) + `小计 ` + xpyunapi.StrRepeat("-", 32) + ` ` orderParams = append(orderParams, @@ -209,14 +211,16 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin orderFmt += xpyunapi.FormatPrintOrderItem(sku.SkuName, sku.Count, utils.Int64ToFloat64(sku.SalePrice)) } orderFmt += ` -共%d种%d件商品
-实际支付: %s元
+共%d种%d件商品 +实际支付: %s ` - orderFmt += `

` - orderFmt += xpyunapi.StrRepeat("-", 14) + "#23完" + xpyunapi.StrRepeat("-", 14) - orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice)) + orderFmt += `
` + orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完" + xpyunapi.StrRepeat("-", 14) + orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq) return fmt.Sprintf(orderFmt, orderParams...) } + +//todo 待修改 func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) { expectedDeliveryTime := order.ExpectedDeliveredTime if utils.IsTimeZero(expectedDeliveryTime) { @@ -226,11 +230,14 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st if order.VendorID == model.VendorIDEBAI { getCode = fmt.Sprintf("饿百取货码:%s", jxutils.GetEbaiOrderGetCode(order)) } + if order.BuyerComment == "" { + order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!" + } orderParams := []interface{}{} orderFmt := `` if storeDetail != nil { if storeDetail.BrandIsPrint == model.NO { - orderFmt += `
%s
\n` + orderFmt += `%s` if order.VendorOrgCode == "34665" { orderParams = append(orderParams, globals.StoreNameEbai2) } else { @@ -240,21 +247,21 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st } orderFmt += ` ` + xpyunapi.StrRepeat("-", 32) + ` -
下单时间: %s
-
预计送达: %s
-
客户姓名: %s
-
客户电话: %s
-
订单编号: %s
-
%s: #%d
-%s" -` + getCode + ` +下单时间: %s +预计送达: %s +客户姓名: %s +客户电话: %s
+订单编号: %s
+%s#%d +%s +` + getCode + + xpyunapi.StrRepeat("-", 32) + ` +客户地址: %s +` + xpyunapi.StrRepeat("-", 32) + `客户备注: %s ` + xpyunapi.StrRepeat("-", 32) + ` -客户地址: %s
-` + xpyunapi.StrRepeat("-", 32) + ` -
客户备注: %s
-` + xpyunapi.StrRepeat("-", 32) + ` -
商品列表 ` + xpyunapi.StrRepeat("-", 6) + `
-商品名` + xpyunapi.StrRepeat("-", 2) + `数量` + xpyunapi.StrRepeat("-", 3) + `单价` + xpyunapi.StrRepeat("-", 5) + `小计
" +商品列表 +商品名` + xpyunapi.StrRepeat(" ", 2) + `数量` + xpyunapi.StrRepeat(" ", 3) + `单价` + xpyunapi.StrRepeat(" ", 5) + `小计
+` + xpyunapi.StrRepeat("-", 32) + "" + ` ` orderParams = append(orderParams, utils.Time2Str(order.OrderCreatedAt), @@ -272,12 +279,11 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st for _, sku := range order.Skus { orderFmt += xpyunapi.FormatPrintOrderItem(sku.SkuName, sku.Count, utils.Int64ToFloat64(sku.SalePrice)) } - orderFmt += ` -共%d种%d件商品
-实际支付: %s元
-` + xpyunapi.StrRepeat("-", 2) + ` + orderFmt += `共%d种%d件商品 +实际支付: %s ` - orderFmt += `

` - orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice)) + orderFmt += `
` + orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完
" + xpyunapi.StrRepeat("-", 14) + orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq) return fmt.Sprintf(orderFmt, orderParams...) } From 2606015f5701448567ade9ebe4be977d12ebbc08 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 14:50:50 +0800 Subject: [PATCH 2/7] 1 --- business/partner/printer/xpyun/xpyun.go | 114 +++++++++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index b2bf825ea..5e2018cc9 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -130,7 +130,21 @@ func (c *PrinterHandler) PrintStore(ctx *jxcontext.Context, store *model.Store, } func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) { - return nil, err + if len(order.Skus) == 0 { + return + } + content := "" + if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 { + content = c.getCancelOrRefundOrderContent(order, printType, storeDetail) + } else { + content = c.getCancelOrRefundOrderContentBig(order, printType, storeDetail) + } + + if content == "" { + return nil, nil + } + + return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content) } func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, sn, id2 string) (err error) { @@ -151,7 +165,7 @@ func (c *PrinterHandler) SetSound(ctx *jxcontext.Context, sn, id2, sound string) return err } -// 正常打印模板 +// 新订单正常尺寸打印模板 func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) { expectedDeliveryTime := order.ExpectedDeliveredTime if utils.IsTimeZero(expectedDeliveryTime) { @@ -220,7 +234,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin return fmt.Sprintf(orderFmt, orderParams...) } -//todo 待修改 +//新订单大尺寸打印模板 func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) { expectedDeliveryTime := order.ExpectedDeliveredTime if utils.IsTimeZero(expectedDeliveryTime) { @@ -287,3 +301,97 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq) return fmt.Sprintf(orderFmt, orderParams...) } + +//退货/取消订单 正常尺寸模板 +func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) { + expectedDeliveryTime := order.ExpectedDeliveredTime + if utils.IsTimeZero(expectedDeliveryTime) { + expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour) + } + var orderParams []interface{} + orderFmt := `` + if storeDetail != nil { + if storeDetail.BrandIsPrint == model.NO { + orderFmt += `%s` + if order.VendorOrgCode == "34665" { + orderParams = append(orderParams, globals.StoreNameEbai2) + } else { + orderParams = append(orderParams, storeDetail.BrandName) + } + } + } + + // 加载用户取消订单售后单 + + title := `` + if printType == model.YES { // 取消订单 + title = `取消订单详情` + } else { // 售后订单 + title = `退款订单详情` + } + + orderFmt += + xpyunapi.StrRepeat("-", 32) + ` +下单时间: %s +订单编号: %s
+` + orderFmt += ` +%s#%d +` + title + xpyunapi.StrRepeat("-", 32) + orderParams = append(orderParams, + utils.Time2Str(order.OrderCreatedAt), + order.VendorOrderID, + jxutils.GetVendorName(order.VendorID), + order.OrderSeq, + ) + orderFmt += xpyunapi.StrRepeat("-", 32) + orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice)) + return fmt.Sprintf(orderFmt, orderParams...) +} + +//退货/取消订单 大尺寸模板 +func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) { + expectedDeliveryTime := order.ExpectedDeliveredTime + if utils.IsTimeZero(expectedDeliveryTime) { + expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour) + } + var orderParams []interface{} + orderFmt := `` + if storeDetail != nil { + if storeDetail.BrandIsPrint == model.NO { + orderFmt += `%s` + if order.VendorOrgCode == "34665" { + orderParams = append(orderParams, globals.StoreNameEbai2) + } else { + orderParams = append(orderParams, storeDetail.BrandName) + } + } + } + + // 加载用户取消订单售后单 + + title := `` + if printType == model.YES { // 取消订单 + title = `取消订单详情` + } else { // 售后订单 + title = `退款订单详情` + } + + orderFmt += + xpyunapi.StrRepeat("-", 32) + ` +下单时间: %s +订单编号: %s
+` + orderFmt += ` +%s#%d +` + title + xpyunapi.StrRepeat("-", 32) + orderParams = append(orderParams, + utils.Time2Str(order.OrderCreatedAt), + order.VendorOrderID, + jxutils.GetVendorName(order.VendorID), + order.OrderSeq, + ) + orderFmt += xpyunapi.StrRepeat("-", 32) + orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice)) + return fmt.Sprintf(orderFmt, orderParams...) +} From a5dd2174cbe88c0c2cdead6c9967609a5beef9f5 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 15:28:52 +0800 Subject: [PATCH 3/7] 1 --- business/partner/printer/xpyun/xpyun.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index 5e2018cc9..8e96484f2 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -229,7 +229,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin 实际支付: %s ` orderFmt += `
` - orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完" + xpyunapi.StrRepeat("-", 14) + orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完" + xpyunapi.StrRepeat("-", 14) + `
` orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq) return fmt.Sprintf(orderFmt, orderParams...) } @@ -297,7 +297,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st 实际支付: %s ` orderFmt += `
` - orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完
" + xpyunapi.StrRepeat("-", 14) + orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完
" + xpyunapi.StrRepeat("-", 14) + `
` orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq) return fmt.Sprintf(orderFmt, orderParams...) } @@ -320,14 +320,11 @@ func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, } } } - - // 加载用户取消订单售后单 - title := `` if printType == model.YES { // 取消订单 - title = `取消订单详情` + title = `取消订单详情` } else { // 售后订单 - title = `退款订单详情` + title = `退款订单详情` } orderFmt += From 97186b846fbcfbbf76614a6d370ed1864408e6c3 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 15:30:13 +0800 Subject: [PATCH 4/7] 1 --- business/partner/printer/xpyun/xpyun.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index 8e96484f2..10c726697 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -312,7 +312,7 @@ func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, orderFmt := `` if storeDetail != nil { if storeDetail.BrandIsPrint == model.NO { - orderFmt += `%s` + orderFmt += `%s` if order.VendorOrgCode == "34665" { orderParams = append(orderParams, globals.StoreNameEbai2) } else { From 660ba5e09baf5bff96d1203a6f70121ab9e296a0 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 15:42:58 +0800 Subject: [PATCH 5/7] 1 --- business/partner/printer/xpyun/xpyun.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index 10c726697..4f9c13136 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -330,11 +330,9 @@ func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, orderFmt += xpyunapi.StrRepeat("-", 32) + ` 下单时间: %s -订单编号: %s
-` - orderFmt += ` +订单编号: %s %s#%d -` + title + xpyunapi.StrRepeat("-", 32) +` + title orderParams = append(orderParams, utils.Time2Str(order.OrderCreatedAt), order.VendorOrderID, @@ -378,10 +376,8 @@ func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrde xpyunapi.StrRepeat("-", 32) + ` 下单时间: %s 订单编号: %s
-` - orderFmt += ` %s#%d -` + title + xpyunapi.StrRepeat("-", 32) +` + title orderParams = append(orderParams, utils.Time2Str(order.OrderCreatedAt), order.VendorOrderID, From ba5bc7d34ddd2215216c6376dc9c9778a2742875 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 15:51:36 +0800 Subject: [PATCH 6/7] 1 --- business/partner/printer/xpyun/xpyun.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index 4f9c13136..e79434097 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -31,7 +31,7 @@ func init() { func (c *PrinterHandler) GetVendorID() int { return model.VendorIDXpYun } -func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, sn, copies, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) { +func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, sn, copies, voiceType, msgContent string) (printerStatus *partner.PrinterStatus, err error) { if sn != "" { if globals.EnableStoreWrite { if utils.Str2Int(copies) < 0 || utils.Str2Int(copies) > 3 { @@ -41,7 +41,7 @@ func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, sn, copies, msgTitle, Sn: sn, Content: msgContent, Copies: utils.Str2Int(copies), - Voice: xpyunapi.VoicePlayOrder, + Voice: utils.Str2Int(voiceType), Mode: xpyunapi.ModeCheckYes, ExpiresIn: xpyunapi.ExpiresInDefault, }) @@ -115,7 +115,7 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, } count := 0 for { - printerStatus, err := c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content) + printerStatus, err := c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, utils.Int2Str(xpyunapi.VoicePlayOrder), content) if (store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2) && count < 1 { count += 1 continue @@ -134,6 +134,12 @@ func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printT return } content := "" + voiceType := "" + if printType == model.YES { // 取消订单 + voiceType = utils.Int2Str(xpyunapi.VoiceCancelOrder) + } else { // 售后订单 + voiceType = utils.Int2Str(xpyunapi.VoiceUserChargeback) + } if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 { content = c.getCancelOrRefundOrderContent(order, printType, storeDetail) } else { @@ -144,7 +150,7 @@ func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printT return nil, nil } - return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content) + return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, voiceType, content) } func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, sn, id2 string) (err error) { From 73444292d9159efd36efa4d4a7d186900299a424 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 20 Mar 2023 15:59:18 +0800 Subject: [PATCH 7/7] 1 --- business/partner/printer/xpyun/xpyun.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/partner/printer/xpyun/xpyun.go b/business/partner/printer/xpyun/xpyun.go index e79434097..c881e7514 100644 --- a/business/partner/printer/xpyun/xpyun.go +++ b/business/partner/printer/xpyun/xpyun.go @@ -37,6 +37,7 @@ func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, sn, copies, voiceType, if utils.Str2Int(copies) < 0 || utils.Str2Int(copies) > 3 { copies = "1" } + globals.SugarLogger.Debugf("printMsg voiceType====%s", voiceType) printOrderID, err1 := api.XpyunAPI.Print(&xpyunapi.PrintRequest{ Sn: sn, Content: msgContent, @@ -145,7 +146,7 @@ func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printT } else { content = c.getCancelOrRefundOrderContentBig(order, printType, storeDetail) } - + globals.SugarLogger.Debugf("PrintCancelOrRefundOrder content=====%s", content) if content == "" { return nil, nil }