修改打印机打印数据

This commit is contained in:
邹宗楠
2022-12-05 17:02:47 +08:00
parent c8c33d38c1
commit a1847b2aae
3 changed files with 172 additions and 58 deletions

View File

@@ -127,47 +127,51 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
err := mtpsapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID, order.Status) // 骑手位置更新
if order.OrderVendorID == model.VendorIDDD {
result := &mtpsapi.RiderInfo{
OrderId: order.VendorOrderID,
ThirdCarrierOrderId: order.VendorOrderID,
CourierName: order.CourierName,
CourierPhone: order.CourierMobile,
LogisticsProviderCode: "10032",
LogisticsStatus: order.Status,
OpCode: "",
}
switch msg.Status {
case mtpsapi.OrderStatusWaitingForSchedule: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case mtpsapi.OrderStatusAccepted: // 已接单
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case mtpsapi.OrderStatusDeliverred: // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case mtpsapi.OrderStatusCanceled: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case mtpsapi.OrderStatusPickedUp: // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
globals.SugarLogger.Debugf("===========================mtps:%s", utils.Format4Output(result, false))
delivery.PullTiktokRiderInfo(result)
if result.LogisticsStatus == model.WaybillStatusCourierArrived {
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
delivery.PullTiktokRiderInfo(result)
}
pushMTPSToTiktok(msg.Status, order)
}
return err
}
func pushMTPSToTiktok(msgStatus int, order *model.Waybill) {
result := &mtpsapi.RiderInfo{
OrderId: order.VendorOrderID,
ThirdCarrierOrderId: order.VendorOrderID,
CourierName: order.CourierName,
CourierPhone: order.CourierMobile,
LogisticsProviderCode: "10032",
LogisticsStatus: order.Status,
OpCode: "",
}
switch msgStatus {
case mtpsapi.OrderStatusWaitingForSchedule: // 待接单,召唤骑手
result.LogisticsStatus = model.WaybillStatusNew
result.LogisticsContext = model.RiderWaitRider
case mtpsapi.OrderStatusAccepted: // 已接单
result.LogisticsStatus = model.WaybillStatusCourierAssigned // 分配骑手
result.LogisticsContext = model.RiderWaitGetGoods
case mtpsapi.OrderStatusDeliverred: // 完成
result.LogisticsStatus = model.WaybillStatusDelivered
result.LogisticsContext = model.RiderGetOrderDelivered
case mtpsapi.OrderStatusCanceled: // 取消
result.LogisticsStatus = model.WaybillStatusCanceled
result.LogisticsContext = model.RiderGetOrderCanceled
case mtpsapi.OrderStatusPickedUp: // 骑手到店
result.LogisticsStatus = model.WaybillStatusCourierArrived
result.LogisticsContext = model.RiderToStore
default:
result.LogisticsStatus = 0
result.LogisticsContext = model.RiderGetOrderDeliverOther
}
globals.SugarLogger.Debugf("===========================mtps:%s", utils.Format4Output(result, false))
delivery.PullTiktokRiderInfo(result)
if result.LogisticsStatus == model.WaybillStatusCourierArrived {
result.LogisticsStatus = model.WaybillStatusDelivering
result.LogisticsContext = model.RiderGetOrderDelivering
delivery.PullTiktokRiderInfo(result)
}
}
func (c *DeliveryHandler) pushToGy(msg *mtpsapi.CallbackOrderMsg) {
cl := http.Client{}
params := make(map[string]interface{})

View File

@@ -53,8 +53,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
}
orderFmt += `
<C>手机买菜上京西</C><BR>
<C>极速到家送惊喜</C><BR>
<B>%s#%d</B><BR><BR>
--------------------------------<BR>
下单时间: %s<BR>
预计送达: %s<BR>
@@ -68,7 +67,6 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
orderFmt += `
<BR>
<B>%s#%d</B><BR><BR>
<QR>%s</QR><BR>
` + getCode +
`客户: %s<BR>
@@ -85,11 +83,11 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
--------------------------------<BR>`
// <BOLD>实际支付:</BOLD>%s<BR>
orderParams = append(orderParams,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
@@ -149,15 +147,13 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
}
orderFmt += `
<C>手机买菜上京西</C><BR>
<C>极速到家送惊喜</C><BR>
<B>%s#%d</B><BR><BR>
--------------------------------<BR>
<B>下单时间: %s<BR><BR><BR></B>
<B>预计送达: %s<BR><BR><BR></B>
<B>订单编号: %s<BR></B>
<BR>
<B>%s#%d</B><BR><BR>
<QR>%s</QR><BR>
` + getCode +
`<B>客户: %s<BR></B>
@@ -174,11 +170,11 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
--------------------------------<BR>`
// <B><BOLD>实际支付:</BOLD></B><B>%s<BR></B>
orderParams = append(orderParams,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
@@ -214,6 +210,109 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), 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 += `
<CB>%s</CB><BR><BR>
`
if order.VendorOrgCode == "34665" {
orderParams = append(orderParams, globals.StoreNameEbai2)
} else {
orderParams = append(orderParams, storeDetail.BrandName)
}
}
}
// 加载用户取消订单售后单
title := ``
if printType == model.YES { // 取消订单
title = `<CB>取消订单详情</CB><BR>`
} else { // 售后订单
title = `<CB>退款订单详情</CB><BR>`
}
orderFmt +=
`--------------------------------\n
下单时间: %s\n
订单编号: %s\n
`
orderFmt += `
\n
<B>%s <B>#%d</B></B><BR><BR>
` + title + `
--------------------------------\n`
orderParams = append(orderParams,
utils.Time2Str(order.OrderCreatedAt),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
)
orderFmt += `
--------------------------------\n
`
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice))
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
}
// 打印取消或者退款订单,大字体
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 += `
<CB>%s</CB><BR><BR>
`
if order.VendorOrgCode == "34665" {
orderParams = append(orderParams, globals.StoreNameEbai2)
} else {
orderParams = append(orderParams, storeDetail.BrandName)
}
}
}
title := ``
if printType == model.YES { // 退单
title = `<CB>取消订单详情</CB><BR>`
} else {
title = `<CB>退款订单详情</CB><BR>`
}
orderFmt += `--------------------------------<BR>
<B>下单时间: %s<BR></B>
<B>订单编号: %s<BR></B>
\n
<B>%s <B>#%d</B></B><BR><BR>
\n
` + title + `
--------------------------------\n`
orderParams = append(orderParams,
utils.Time2Str(order.OrderCreatedAt),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
//order.VendorOrderID,
)
orderFmt += `
--------------------------------<BR>
`
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice))
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
}
func (c *PrinterHandler) GetVendorID() int {
return model.VendorIDFeiE
}
@@ -264,7 +363,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) RegisterPrinter(ctx *jxcontext.Context, printerSN, printerKey, printerName string, storeID int64) (notUsed1, notUsed2 string, err error) {

View File

@@ -49,8 +49,8 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
}
}
orderFmt += `<center>手机买菜上京西</center>\n
<center>极速到家送惊喜</center>\n
orderFmt += `
<FS2>%s#%d</FS2>\n\n
--------------------------------\n
下单时间: %s\n
预计送达: %s\n
@@ -64,7 +64,6 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
orderFmt += `
\n
<FS>%s#%d</FS>\n\n
<QR>%s</QR>
` + getCode + `\n
客户: %s\n
@@ -79,11 +78,11 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
品名 数量 小计\n
--------------------------------\n`
orderParams = append(orderParams,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
@@ -139,14 +138,13 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
}
}
orderFmt += `<center>手机买菜上京西</center>\n
<center>极速到家送惊喜</center>\n
orderFmt += `
<FS2>%s#%d</FS2>\n\n
--------------------------------\n
<FS>下单时间: %s\n\n</FS>
<FS>预计送达: %s\n\n</FS>
<FS>订单编号: %s\n</FS>
\n
<FS>%s#%d</FS>\n\n
<QR>%s</QR>
` + getCode + `\n
<FS>客户: %s\n</FS>
@@ -161,11 +159,11 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
品名 数量 小计\n
--------------------------------\n`
orderParams = append(orderParams,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
@@ -243,7 +241,6 @@ func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder,
orderParams = append(orderParams,
utils.Time2Str(order.OrderCreatedAt),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
)