Merge branch 'mark' of git.coding.net:XJH-Rosy/jx-callback into mark
This commit is contained in:
@@ -807,7 +807,11 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID
|
||||
index := jxutils.Combine2Int(v.StoreID, v.VendorID)*1000 + int64(status)
|
||||
saleInfo := saleInfoMap[index]
|
||||
if saleInfo == nil {
|
||||
saleInfo = &dao.StoresOrderSaleInfo{}
|
||||
saleInfo = &dao.StoresOrderSaleInfo{
|
||||
StoreID: v.StoreID,
|
||||
VendorID: v.VendorID,
|
||||
Status: status,
|
||||
}
|
||||
saleInfoMap[index] = saleInfo
|
||||
}
|
||||
saleInfo.ShopPrice += v.ShopPrice
|
||||
@@ -860,11 +864,15 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID
|
||||
v.EarningPrice = orderMap[universalOrderID].ActualPayPrice
|
||||
}
|
||||
}
|
||||
|
||||
index := jxutils.Combine2Int(v.StoreID, v.VendorID)*1000 + -1
|
||||
status := -1
|
||||
index := jxutils.Combine2Int(v.StoreID, v.VendorID)*1000 + int64(status)
|
||||
saleInfo := saleInfoMap[index]
|
||||
if saleInfo == nil {
|
||||
saleInfo = &dao.StoresOrderSaleInfo{}
|
||||
saleInfo = &dao.StoresOrderSaleInfo{
|
||||
StoreID: v.StoreID,
|
||||
VendorID: v.VendorID,
|
||||
Status: status,
|
||||
}
|
||||
saleInfoMap[index] = saleInfo
|
||||
}
|
||||
saleInfo.ActualPayPrice += v.ActualPayPrice
|
||||
|
||||
@@ -19,6 +19,11 @@ const (
|
||||
PrintResultNoPrinter = 1 // 没有配置网络打印机
|
||||
)
|
||||
|
||||
const (
|
||||
PrinterFontSizeNormal = int8(0)//正常大小
|
||||
PrinterFontSizeBig = int8(1)//两倍大小
|
||||
)
|
||||
|
||||
var (
|
||||
PrinterStatusName = map[int]string{
|
||||
PrinterStatusUnknown: "未知",
|
||||
|
||||
@@ -101,6 +101,80 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string) (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("<B>饿百取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
orderFmt := `
|
||||
<CB>%s</CB><BR><BR>
|
||||
<C>手机买菜上京西</C><BR>
|
||||
<C>极速到家送惊喜</C><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>
|
||||
<B>电话: %s<BR></B>
|
||||
<B>地址: %s<BR></B>
|
||||
<BR>
|
||||
<B>客户备注: <BR></B>
|
||||
<B>%s</B><BR>
|
||||
<BR>
|
||||
|
||||
<B><BOLD>实际支付:</BOLD></B><B>%s<BR></B>
|
||||
<BR>
|
||||
<B>商品明细: <BR></B>
|
||||
<B>品名数量单价小计<BR></B>
|
||||
--------------------------------<BR>`
|
||||
orderParams := []interface{}{
|
||||
globals.StoreName,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.ConsigneeAddress,
|
||||
order.BuyerComment,
|
||||
jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
|
||||
}
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `<B>%s<BR></B>`
|
||||
orderFmt += `<B>%s %s %s<BR><BR></B>`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `<BR>
|
||||
<B><BOLD>共%d种%d件商品</BOLD></B>
|
||||
<BR>
|
||||
--------------------------------<BR>
|
||||
<C><L><BOLD>商品质量问题请联系:</BOLD></L><BR></C>
|
||||
<C><L><BOLD>%s:%s</BOLD></L><BR></C><BR>
|
||||
<BR>
|
||||
<B>更多信息请关注官方微信: %s<BR></B>
|
||||
<BR>
|
||||
<BR><BR>
|
||||
--------------------------------<BR>
|
||||
--------------------------------<BR>
|
||||
<BR><BR>
|
||||
`
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetVendorID() int {
|
||||
return model.VendorIDFeiE
|
||||
}
|
||||
@@ -136,7 +210,12 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerSN, pri
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("feie PrintOrderByOrder orderID:%s", order.VendorOrderID)
|
||||
content := c.getOrderContent(order, store.Tel1)
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
content = c.getOrderContentBig(order, store.Tel1)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1)
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,16 +18,17 @@ func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
|
||||
func TestGetCityShops(t *testing.T) {
|
||||
orderID := "919864156000342"
|
||||
func TestPrintMsg(t *testing.T) {
|
||||
orderID := "910838879000442"
|
||||
vendorID := 0
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
context := CurPrinterHandler.getOrderContent(order, "mobile")
|
||||
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "id1", "id2", "title", context)
|
||||
context := CurPrinterHandler.getOrderContent(order, "13412345678")
|
||||
//context := CurPrinterHandler.getOrderContentBig(order, "13412345678")
|
||||
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "218510310", "ztdpveyg", "test", context)
|
||||
t.Log(utils.Format4Output(status, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -35,7 +36,7 @@ func TestGetCityShops(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRegisterPrinter(t *testing.T) {
|
||||
newID1, newID2, err := CurPrinterHandler.RegisterPrinter(jxcontext.AdminCtx, "id1", "id2", "title")
|
||||
newID1, newID2, err := CurPrinterHandler.RegisterPrinter(jxcontext.AdminCtx, "218510310", "ztdpveyg", "title")
|
||||
t.Log(newID1 + "," + newID2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -59,9 +59,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
*
|
||||
客户备注: *
|
||||
<big>%s*
|
||||
*
|
||||
<S011>实际支付: %s*
|
||||
*
|
||||
商品明细: *
|
||||
品名 数量 单价 小计
|
||||
--------------------------------*
|
||||
@@ -105,6 +103,80 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
return content
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string) (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("<big>饿百取货码:%s**\n", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
buyerComment := order.BuyerComment
|
||||
if buyerComment == "" {
|
||||
buyerComment = " "
|
||||
}
|
||||
orderFmt := `
|
||||
<big> %s**
|
||||
手机买菜上京西*
|
||||
极速到家送惊喜*
|
||||
------------------------------*
|
||||
<big>下单时间: %s**
|
||||
<big>预计送达: %s**
|
||||
<big>订单编号: %s*
|
||||
*
|
||||
<big>%s\#%d*
|
||||
<qrcA4>%s*
|
||||
` + getCode +
|
||||
`<big>客户: %s*
|
||||
<big>电话: %s*
|
||||
<big>地址: %s*
|
||||
*
|
||||
<big>客户备注: *
|
||||
<big>%s*
|
||||
<big>实际支付: %s*
|
||||
<big>商品明细: *
|
||||
<big>品名数量单价小计*
|
||||
--------------------------------*
|
||||
`
|
||||
orderParams := []interface{}{
|
||||
globals.StoreName,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.ConsigneeAddress,
|
||||
buyerComment,
|
||||
jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
|
||||
}
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `<big>%s*`
|
||||
orderFmt += `<big>%s %s %s*`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `
|
||||
<big>共%d种%d件商品*
|
||||
--------------------------------*
|
||||
<S020>商品质量问题请联系:*
|
||||
<S020>%s:%s*
|
||||
*
|
||||
<big>更多信息请关注官方微信: %s*
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
*<BEEP13500,3,2,1>*
|
||||
`
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
|
||||
content = fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), escapeString4Printer(orderParams)...)
|
||||
// globals.SugarLogger.Debugf("xiaowm orderParams:%s\n", utils.Format4Output(orderParams, false))
|
||||
// globals.SugarLogger.Debugf("xiaowm getOrderContent:%s\n", content)
|
||||
return content
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContent2(order *model.GoodsOrder, storeTel string) (content string) {
|
||||
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
if utils.IsTimeZero(expectedDeliveryTime) {
|
||||
@@ -223,7 +295,11 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
|
||||
if isV500(store.PrinterSN) {
|
||||
content = c.getOrderContent2(order, store.Tel1)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1)
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
content = c.getOrderContentBig(order, store.Tel1)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1)
|
||||
}
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
}
|
||||
|
||||
44
business/partner/printer/xiaowm/xiaowm_test.go
Normal file
44
business/partner/printer/xiaowm/xiaowm_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package xiaowm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
|
||||
func TestPrintMsg(t *testing.T) {
|
||||
orderID := "910838879000442"
|
||||
vendorID := 0
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// context := CurPrinterHandler.getOrderContent(order, "13412345678")
|
||||
context := CurPrinterHandler.getOrderContentBig(order, "13412345678")
|
||||
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "7JizmSyiXNzkggaqU", "177f213277dd842ba2b53f6c926a48ea", "test", context)
|
||||
t.Log(utils.Format4Output(status, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterPrinter(t *testing.T) {
|
||||
newID1, newID2, err := CurPrinterHandler.RegisterPrinter(jxcontext.AdminCtx, "7JizmSyiXNzkggaqU", "", "title")
|
||||
t.Log(newID1 + "," + newID2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,74 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string) (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("<FS2>饿百取货码:%s</FS2>\\n\n", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
orderFmt := `
|
||||
<FS2><center>%s</center></FS2>\n\n
|
||||
<center>手机买菜上京西</center>
|
||||
<center>极速到家送惊喜</center>\n
|
||||
--------------------------------
|
||||
<FS2>下单时间: %s\n\n</FS2>
|
||||
<FS2>预计送达: %s\n\n</FS2>
|
||||
<FS2>订单编号: %s\n</FS2>
|
||||
\n
|
||||
<FS2>%s#%d</FS2>\n\n
|
||||
<QR>%s</QR>
|
||||
` + getCode + `\n
|
||||
<FS2>客户: %s\n</FS2>
|
||||
<FS2>电话: %s\n</FS2>
|
||||
<FS2>地址: %s\n</FS2>
|
||||
\n
|
||||
<FS2>客户备注: \n</FS2>
|
||||
<FS2>%s</FS2>\n
|
||||
\n
|
||||
<FS2><FB>实际支付:</FB>%s\n</FS2>
|
||||
\n
|
||||
<FS2>商品明细: \n</FS2>
|
||||
<FS2>品名数量单价小计\n</FS2>
|
||||
--------------------------------\n`
|
||||
orderParams := []interface{}{
|
||||
globals.StoreName,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.ConsigneeAddress,
|
||||
order.BuyerComment,
|
||||
jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
|
||||
}
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `<FS2>%s\n</FS2>`
|
||||
orderFmt += `<FS2>%s %s %s\n\n</FS2>`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `\n
|
||||
<FS2><FB>共%d种%d件商品</FB></FS2>
|
||||
\n
|
||||
--------------------------------\n
|
||||
<center><FH2>商品质量问题请联系:</FH2></center>
|
||||
<center><FH2>%s:%s</FH2></center>\n
|
||||
<FS2>更多信息请关注官方微信: %s\n</FS2>
|
||||
--------------------------------\n
|
||||
--------------------------------\n
|
||||
`
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
|
||||
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetVendorID() int {
|
||||
return model.VendorIDYiLianYun
|
||||
}
|
||||
@@ -135,7 +203,12 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, machineCode, p
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("yilianyun PrintOrderByOrder orderID:%s", order.VendorOrderID)
|
||||
content := c.getOrderContent(order, store.Tel1)
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
content = c.getOrderContentBig(order, store.Tel1)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1)
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
}
|
||||
|
||||
|
||||
46
business/partner/printer/yilianyun/yilianyun_test.go
Normal file
46
business/partner/printer/yilianyun/yilianyun_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package yilianyun
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
api.YilianyunAPI.SetToken("8d54951744984b7a8908251c3063b445")
|
||||
}
|
||||
|
||||
func TestPrintMsg(t *testing.T) {
|
||||
orderID := "910838879000442"
|
||||
vendorID := 0
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// context := CurPrinterHandler.getOrderContent(order, "13412345678")
|
||||
context := CurPrinterHandler.getOrderContentBig(order, "13412345678")
|
||||
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "4004600675", "fem2ukwvduik", "test", context)
|
||||
t.Log(utils.Format4Output(status, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterPrinter(t *testing.T) {
|
||||
newID1, newID2, err := CurPrinterHandler.RegisterPrinter(jxcontext.AdminCtx, "4004600675", "fem2ukwvduik", "title")
|
||||
t.Log(newID1 + "," + newID2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,74 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string) (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("<S2>饿百取货码:%s</S2><RN>\n", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
orderFmt := `
|
||||
<S2><C>%s</C></S2><RN><RN>
|
||||
<C>手机买菜上京西</C>
|
||||
<C>极速到家送惊喜</C><RN>
|
||||
********************************
|
||||
<S2>下单时间: %s<RN><RN></S2>
|
||||
<S2>预计送达: %s<RN><RN></S2>
|
||||
<S2>订单编号: %s<RN></S2>
|
||||
<RN>
|
||||
<S2>%s#%d</S2><RN><RN>
|
||||
<QR>%s</QR>
|
||||
` + getCode + `<RN>
|
||||
<S2>客户: %s<RN></S2>
|
||||
<S2>电话: %s<RN></S2>
|
||||
<S2>地址: %s<RN></S2>
|
||||
<RN>
|
||||
<S2>客户备注: <RN></S2>
|
||||
<S2>%s</S2><RN>
|
||||
<RN>
|
||||
<S2><B1>实际支付:</B1>%s<RN></S2>
|
||||
<RN>
|
||||
<S2>商品明细: <RN></S2>
|
||||
<S2>品名数量单价小计<RN></S2>
|
||||
********************************<RN>`
|
||||
orderParams := []interface{}{
|
||||
globals.StoreName,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.ConsigneeAddress,
|
||||
order.BuyerComment,
|
||||
jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
|
||||
}
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `<S2>%s<RN></S2>`
|
||||
orderFmt += `<S2>%s %s %s<RN><RN></S2>`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `<RN>
|
||||
<S2><B1>共%d种%d件商品</B1></S2>
|
||||
<RN>
|
||||
********************************<RN>
|
||||
<C><H2>商品质量问题请联系:</H2></C>
|
||||
<C><H2>%s:%s</H2></C><RN>
|
||||
<S2>更多信息请关注官方微信: %s<RN></S2>
|
||||
********************************<RN>
|
||||
********************************<RN>
|
||||
`
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetVendorID() int {
|
||||
return model.VendorIDZhongWu
|
||||
}
|
||||
@@ -128,7 +196,12 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, deviceID, devi
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("zhongwu PrintOrderByOrder orderID:%s", order.VendorOrderID)
|
||||
content := c.getOrderContent(order, store.Tel1)
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
content = c.getOrderContentBig(order, store.Tel1)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1)
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
}
|
||||
|
||||
|
||||
44
business/partner/printer/zhongwu/zhongwu_test.go
Normal file
44
business/partner/printer/zhongwu/zhongwu_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package zhongwu
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
|
||||
func TestPrintMsg(t *testing.T) {
|
||||
orderID := "910838879000442"
|
||||
vendorID := 0
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// context := CurPrinterHandler.getOrderContent(order, "13412345678")
|
||||
context := CurPrinterHandler.getOrderContentBig(order, "13412345678")
|
||||
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "12364142", "v7rvjv9b", "test", context)
|
||||
t.Log(utils.Format4Output(status, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterPrinter(t *testing.T) {
|
||||
newID1, newID2, err := CurPrinterHandler.RegisterPrinter(jxcontext.AdminCtx, "12364142", "v7rvjv9b", "title")
|
||||
t.Log(newID1 + "," + newID2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user