京西打印
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package jxprint
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -243,17 +244,23 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
|
||||
if len(order.Skus) == 0 {
|
||||
return
|
||||
}
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
//content = c.getOrderContentBig(order, store.Tel1, storeDetail)
|
||||
} else {
|
||||
if storeDetail.PrinterTemplate != "" {
|
||||
content = c.getOrderContentByTemplate(order, store.Tel1, storeDetail)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1, storeDetail)
|
||||
}
|
||||
printData := ManagerOrderAndStore(order, store.Tel1, storeDetail)
|
||||
printData[BigFont] = false
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
|
||||
printData[BigFont] = true
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, utils.Int2Str(order.OrderSeq), order.VendorOrderID, content)
|
||||
// 打印次数
|
||||
printData[PrintNumber] = 1
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2 {
|
||||
printData[PrintNumber] = 2
|
||||
}
|
||||
|
||||
orderPrint, err := json.Marshal(printData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.PrintMsg(ctx, store.PrinterSN, utils.Int2Str(order.OrderSeq), order.VendorOrderID, string(orderPrint))
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
|
||||
96
business/partner/printer/jxprint/jxprint_const.go
Normal file
96
business/partner/printer/jxprint/jxprint_const.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package jxprint
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
EBailOrderNo = "eBaiOrderNo" // 饿百取货码
|
||||
BusinessType = "businessType" // 是否为预定单
|
||||
PayOrderTime = "payOrderTime" // 下单时间
|
||||
TrySendTime = "trySendTime" // 预计送达时间
|
||||
OrderNo = "orderNo" // 订单编号
|
||||
VendorName = "vendorName" // 订单来源平台名称
|
||||
VendorOrderNo = "vendorOrderNo" // 订单序号
|
||||
QRCOrder = "qRCOrder" // 订单二维码单号,还是订单Id
|
||||
ConsigneeName = "consigneeName" // 客户名称
|
||||
ConsigneeMobile = "consigneeMobile" // 客户电话
|
||||
ConsigneeAddress = "consigneeAddress" // 客户地址
|
||||
BuyerComment = "buyerComment" // 客户备注
|
||||
SkuList = "skuList" // 商品列表
|
||||
SkuName = "skuName" // 商品名称
|
||||
SkuCount = "skuCount" // 商品件数
|
||||
SkuOnePrice = "skuOnePrice" // 商品单价
|
||||
SkuAllPrice = "skuAllPrice" // 商品总价 = 商品件数 x 商品件数
|
||||
AllSkuTypeCount = "allSkuTypeCount" // 商品种类
|
||||
AllSkuCount = "allSkuCount" // 商品总数量
|
||||
UserPayMoney = "userPayMoney" // 用户支付
|
||||
StoreName = "storeName" // 门店名称
|
||||
StoreTel = "storeTel" // 门店电话
|
||||
OfficialName = "officialName" // 官方名称
|
||||
BigFont = "bigFont" // 是否为大字体
|
||||
PrintNumber = "printNumber" // 打印次数
|
||||
)
|
||||
|
||||
type SkuListPrintOrder struct {
|
||||
SkuName string `json:"skuName"`
|
||||
SkuCount string `json:"skuCount"`
|
||||
SalePrice string `json:"salePrice"` // 单价
|
||||
TotalCountPrice string `json:"totalCountPrice"` // 总价
|
||||
Upc string `json:"upc"` // 条形码
|
||||
}
|
||||
|
||||
// ManagerOrderAndStore 京西云参数组装
|
||||
func ManagerOrderAndStore(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) map[string]interface{} {
|
||||
printOrder := make(map[string]interface{}, 0)
|
||||
skuList := make([]*SkuListPrintOrder, 0, 0)
|
||||
// 获取品牌名称
|
||||
if storeDetail != nil && storeDetail.BrandIsPrint == model.NO {
|
||||
if order.VendorOrgCode == "34665" {
|
||||
printOrder[EBailOrderNo] = globals.StoreNameEbai2
|
||||
} else {
|
||||
printOrder[EBailOrderNo] = storeDetail.BrandName
|
||||
}
|
||||
}
|
||||
// 是否为预定单
|
||||
if order.BusinessType == model.BusinessTypeDingshida {
|
||||
printOrder[BusinessType] = model.BusinessTypeDingshida
|
||||
} else {
|
||||
printOrder[BusinessType] = model.BusinessTypeImmediate
|
||||
}
|
||||
|
||||
printOrder[PayOrderTime] = utils.Time2Str(order.OrderCreatedAt)
|
||||
printOrder[TrySendTime] = utils.Time2Str(order.ExpectedDeliveredTime)
|
||||
printOrder[OrderNo] = order.VendorOrderID
|
||||
printOrder[VendorName] = jxutils.GetVendorName(order.VendorID)
|
||||
printOrder[VendorOrderNo] = order.OrderSeq
|
||||
printOrder[QRCOrder] = order.VendorOrderID
|
||||
printOrder[ConsigneeName] = order.ConsigneeName
|
||||
printOrder[ConsigneeMobile] = order.ConsigneeMobile
|
||||
printOrder[ConsigneeAddress] = order.ConsigneeAddress
|
||||
printOrder[BuyerComment] = order.BuyerComment
|
||||
// 商品列表
|
||||
for _, sku := range order.Skus {
|
||||
skuList = append(skuList, &SkuListPrintOrder{
|
||||
SkuName: sku.SkuName,
|
||||
SkuCount: "X" + utils.Int2Str(sku.Count),
|
||||
SalePrice: utils.Int64ToStr(sku.SalePrice),
|
||||
TotalCountPrice: jxutils.IntPrice2StandardCurrencyString(sku.SalePrice * int64(sku.Count)),
|
||||
Upc: sku.Upc,
|
||||
})
|
||||
}
|
||||
skuListByte, _ := json.Marshal(skuList)
|
||||
printOrder[SkuList] = string(skuListByte)
|
||||
printOrder[AllSkuTypeCount] = order.SkuCount
|
||||
printOrder[AllSkuCount] = order.GoodsCount
|
||||
printOrder[UserPayMoney] = order.ActualPayPrice
|
||||
printOrder[StoreName] = order.StoreName
|
||||
printOrder[StoreTel] = storeTel
|
||||
printOrder[OfficialName] = globals.StoreName
|
||||
return printOrder
|
||||
}
|
||||
Reference in New Issue
Block a user