diff --git a/business/partner/printer/jxprint/jxprint.go b/business/partner/printer/jxprint/jxprint.go
index 54108c79a..60e8b1eb0 100644
--- a/business/partner/printer/jxprint/jxprint.go
+++ b/business/partner/printer/jxprint/jxprint.go
@@ -4,12 +4,15 @@ import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
"git.rosy.net.cn/baseapi/utils"
+ "git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
+ "strings"
+ "time"
)
var (
@@ -29,6 +32,19 @@ func (c *PrinterHandler) GetVendorID() int {
}
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
+ globals.SugarLogger.Debugf("PrintMsg id1:%s", id1)
+ if id1 != "" {
+ if globals.EnableStoreWrite {
+ _, err = api.JxPrintAPI.DoPrint(id1, msgContent, utils.Str2Int(id2))
+ }
+ if err == nil {
+ printerStatus, err = c.GetPrinterStatus(ctx, id1, "")
+ }
+ } else {
+ printerStatus = &partner.PrinterStatus{
+ PrintResult: partner.PrintResultNoPrinter,
+ }
+ }
return nil, err
}
@@ -71,8 +87,104 @@ func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *p
return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDJxprint])
}
+func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
+ expectedDeliveryTime := order.ExpectedDeliveredTime
+ if utils.IsTimeZero(expectedDeliveryTime) {
+ expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
+ }
+ orderParams := []interface{}{}
+ getCode := ""
+ if order.VendorID == model.VendorIDEBAI {
+ getCode = fmt.Sprintf("饿百取货码:%s
\n", jxutils.GetEbaiOrderGetCode(order))
+ }
+ 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)
+ }
+ }
+ }
+ orderFmt += `
+手机买菜上京西
+极速到家送惊喜
+--------------------------------
+下单时间: %s
+预计送达: %s
+订单编号: %s
+
+
+%s#%d
+%s
+` + getCode +
+ `客户: %s
+电话: %s
+地址: %s
+
+客户备注:
+%s
+
+
+
+商品明细:
+品名 数量 单价 小计
+--------------------------------
`
+ // 实际支付:%s
+ orderParams = append(orderParams,
+ 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 += `%s
`
+ orderFmt += `%8s%10s%10s
`
+ orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
+ }
+ orderFmt += `
+共%d种%d件商品
+
+--------------------------------
+商品质量问题请联系:
+%s:%s
+
+更多信息请关注官方微信: %s
+
+
+--------------------------------
+--------------------------------
+
+`
+ // http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk
+ orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
+ return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
+}
+
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
- return nil, err
+ globals.SugarLogger.Debugf("jxprint PrintOrderByOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
+ if len(order.Skus) == 0 {
+ return
+ }
+ content := ""
+ if store.PrinterFontSize == partner.PrinterFontSizeBig {
+ //content = c.getOrderContentBig(order, store.Tel1, storeDetail)
+ } else {
+ content = c.getOrderContent(order, store.Tel1, storeDetail)
+ }
+ return c.PrintMsg(ctx, store.PrinterSN, utils.Int2Str(order.OrderSeq), order.VendorOrderID, content)
}
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {