- 中午云与易联云打印机添加注册验证
This commit is contained in:
@@ -140,6 +140,9 @@ func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerNumber,
|
||||
err = fmt.Errorf("外卖管家打印机设备编号:%s长度不合法", printerNumber)
|
||||
} else {
|
||||
printerToken, err = api.XiaoWMAPI.AuthPrinter(printerNumber, "", "")
|
||||
if _, err = c.GetPrinterStatus(ctx, printerName, printerToken); err != nil {
|
||||
c.UnregisterPrinter(ctx, printerNumber, printerToken)
|
||||
}
|
||||
}
|
||||
return "", printerToken, err
|
||||
}
|
||||
|
||||
@@ -34,31 +34,29 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||
}
|
||||
orderFmt := `
|
||||
<CB>京西菜市</CB><BR>
|
||||
<C>手机买菜上京西</C><BR>
|
||||
<C>极速到家送惊喜</C><BR>
|
||||
--------------------------------<BR>
|
||||
下单时间: %s<BR>
|
||||
预计送达: %s<BR>
|
||||
订单编号: %s<BR>
|
||||
<BR>
|
||||
|
||||
<B>%s#%d</B><BR><BR>
|
||||
<S2><C>京西菜市</center></FS2><RN><RN>
|
||||
<C>手机买菜上京西</center>
|
||||
<C>极速到家送惊喜</center><RN>
|
||||
********************************
|
||||
下单时间: %s<RN>
|
||||
预计送达: %s<RN>
|
||||
订单编号: %s<RN>
|
||||
<RN>
|
||||
<S2>%s#%d</FS2><RN><RN>
|
||||
<QR>%s</QR>
|
||||
<BR>
|
||||
客户: %s<BR>
|
||||
电话: %s<BR>
|
||||
地址: %s<BR>
|
||||
<BR>
|
||||
客户备注: <BR>
|
||||
<B>%s</B><BR>
|
||||
<BR>
|
||||
|
||||
<BOLD>实际支付:</BOLD>%s<BR>
|
||||
<BR>
|
||||
商品明细: <BR>
|
||||
品名 数量 单价 小计<BR>
|
||||
--------------------------------<BR>`
|
||||
<RN>
|
||||
客户: %s<RN>
|
||||
电话: %s<RN>
|
||||
地址: %s<RN>
|
||||
<RN>
|
||||
客户备注: <RN>
|
||||
<S2>%s</FS2><RN>
|
||||
<RN>
|
||||
<B1>实际支付:</FB>%s<RN>
|
||||
<RN>
|
||||
商品明细: <RN>
|
||||
品名 数量 单价 小计<RN>
|
||||
********************************<RN>`
|
||||
orderParams := []interface{}{
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
@@ -74,28 +72,23 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
}
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `%s<BR>`
|
||||
orderFmt += `%10s%10s%10s<BR>`
|
||||
orderFmt += `%s<RN>`
|
||||
orderFmt += `%8s%10s%10s<RN>`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `<BR>
|
||||
<BOLD>共%d种%d件商品</BOLD>
|
||||
<BR>
|
||||
--------------------------------<BR>
|
||||
<C><L><BOLD>商品质量问题请联系:</BOLD></L><BR></C>
|
||||
<C><L><BOLD>%s:%s</BOLD></L><BR></C><BR>
|
||||
<BR>
|
||||
官方服务热线: 18011516898<BR>
|
||||
更多信息请关注官方微信: 京西菜市<BR>
|
||||
<BR>
|
||||
<BR><BR>
|
||||
--------------------------------<BR>
|
||||
--------------------------------<BR>
|
||||
<BR><BR>
|
||||
orderFmt += `<RN>
|
||||
<B1>共%d种%d件商品</FB>
|
||||
<RN>
|
||||
********************************<RN>
|
||||
<C><H2>商品质量问题请联系:</FH2></center>
|
||||
<C><H2>%s:%s</FH2></center><RN>
|
||||
更多信息请关注官方微信: 京西菜市<RN>
|
||||
********************************<RN>
|
||||
********************************<RN>
|
||||
`
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel)
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "<RN>", "", -1), orderParams...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetVendorID() int {
|
||||
@@ -136,7 +129,7 @@ func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, deviceID, devic
|
||||
if deviceID == "" || deviceSecret == "" {
|
||||
err = fmt.Errorf("打印机ID与打印机密钥都不能为空")
|
||||
}
|
||||
// 中午云不需要注册
|
||||
_, err = c.GetPrinterStatus(ctx, deviceID, deviceSecret)
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user