1
This commit is contained in:
@@ -5,7 +5,6 @@ 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"
|
||||
@@ -13,8 +12,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -88,151 +85,153 @@ func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *p
|
||||
}
|
||||
|
||||
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("<b>饿百取货码:%s</b><br><br>\n", jxutils.GetEbaiOrderGetCode(order))
|
||||
}
|
||||
orderFmt := ``
|
||||
if storeDetail != nil {
|
||||
if storeDetail.BrandIsPrint == model.NO {
|
||||
orderFmt += `
|
||||
<sound>您有新订单啦!</sound><br>
|
||||
<center><b>%s</b></center><br><br>
|
||||
`
|
||||
if order.VendorOrgCode == "34665" {
|
||||
orderParams = append(orderParams, globals.StoreNameEbai2)
|
||||
} else {
|
||||
orderParams = append(orderParams, storeDetail.BrandName)
|
||||
}
|
||||
}
|
||||
}
|
||||
orderFmt += `
|
||||
<center>手机买菜上京西</center><br>
|
||||
<center>极速到家送惊喜</center><br>
|
||||
--------------------------------<br>
|
||||
下单时间: %s<br>
|
||||
预计送达: %s<br>
|
||||
订单编号: %s<br>
|
||||
<br>
|
||||
|
||||
<b>%s#%d</b><br>
|
||||
<qrc>%s</qrc><br>
|
||||
` + getCode +
|
||||
`客户: %s<br>
|
||||
电话: %s<br>
|
||||
地址: %s<br>
|
||||
<br>
|
||||
客户备注: <br>
|
||||
<b>%s</b><br>
|
||||
<br>
|
||||
|
||||
<br>
|
||||
商品明细: <br>
|
||||
品名 数量 单价 小计<br>
|
||||
--------------------------------<br>`
|
||||
// <BOLD>实际支付:</BOLD>%s<BR>
|
||||
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<br>`
|
||||
orderFmt += `%8s%10s%10s<br>`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `<br>
|
||||
共%d种%d件商品
|
||||
<br>
|
||||
--------------------------------<br>
|
||||
<center><hb>商品质量问题请联系:</hb></center><br>
|
||||
<center><hb>%s:%s</hb></center><br>
|
||||
<br>
|
||||
更多信息请关注官方微信: %s<br>
|
||||
<br>
|
||||
<br>
|
||||
--------------------------------<br>
|
||||
--------------------------------<br>
|
||||
<br>
|
||||
`
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, "京西菜市")
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
// 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("<b>饿百取货码:%s</b><br><br>\n", jxutils.GetEbaiOrderGetCode(order))
|
||||
// }
|
||||
// orderFmt := ``
|
||||
// if storeDetail != nil {
|
||||
// if storeDetail.BrandIsPrint == model.NO {
|
||||
// orderFmt += `
|
||||
// <sound>您有新订单啦!</sound><br>
|
||||
// <center><b>%s</b></center><br><br>
|
||||
// `
|
||||
// if order.VendorOrgCode == "34665" {
|
||||
// orderParams = append(orderParams, globals.StoreNameEbai2)
|
||||
// } else {
|
||||
// orderParams = append(orderParams, storeDetail.BrandName)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// orderFmt += `
|
||||
//<center>手机买菜上京西</center><br>
|
||||
//<center>极速到家送惊喜</center><br>
|
||||
//--------------------------------<br>
|
||||
//下单时间: %s<br>
|
||||
//预计送达: %s<br>
|
||||
//订单编号: %s<br>
|
||||
//<br>
|
||||
//
|
||||
//<b>%s#%d</b><br>
|
||||
//<qrc>%s</qrc><br>
|
||||
//` + getCode +
|
||||
// `客户: %s<br>
|
||||
//电话: %s<br>
|
||||
//地址: %s<br>
|
||||
//<br>
|
||||
//客户备注: <br>
|
||||
//<b>%s</b><br>
|
||||
//<br>
|
||||
//
|
||||
//<br>
|
||||
//商品明细: <br>
|
||||
//品名 数量 单价 小计<br>
|
||||
//--------------------------------<br>`
|
||||
// // <BOLD>实际支付:</BOLD>%s<BR>
|
||||
// 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<br>`
|
||||
// orderFmt += `%8s%10s%10s<br>`
|
||||
// orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
// }
|
||||
// orderFmt += `<br>
|
||||
//共%d种%d件商品
|
||||
//<br>
|
||||
//--------------------------------<br>
|
||||
//<center><hb>商品质量问题请联系:</hb></center><br>
|
||||
//<center><hb>%s:%s</hb></center><br>
|
||||
//<br>
|
||||
//更多信息请关注官方微信: %s<br>
|
||||
//<br>
|
||||
//<br>
|
||||
//--------------------------------<br>
|
||||
//--------------------------------<br>
|
||||
//<br>
|
||||
//`
|
||||
// orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, "京西菜市")
|
||||
// return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContentByTemplate(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
|
||||
orderFmt := ""
|
||||
if storeDetail != nil {
|
||||
//开头加上语音
|
||||
if storeDetail.PrinterSound != "" {
|
||||
orderFmt += "<sound>" + storeDetail.PrinterSound + "</sound><br>"
|
||||
}
|
||||
}
|
||||
//把带有${}的变量换成实际值
|
||||
template := storeDetail.PrinterTemplate
|
||||
regexpValues := regexpPrint.FindAllStringSubmatch(template, -1)
|
||||
for _, v := range regexpValues {
|
||||
switch v[0] {
|
||||
case "${下单时间}":
|
||||
template = strings.ReplaceAll(template, v[0], utils.Time2Str(order.OrderCreatedAt))
|
||||
case "${预计送达}":
|
||||
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
if utils.IsTimeZero(expectedDeliveryTime) {
|
||||
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||
}
|
||||
template = strings.ReplaceAll(template, v[0], utils.Time2Str(expectedDeliveryTime))
|
||||
case "${订单号}":
|
||||
template = strings.ReplaceAll(template, v[0], order.VendorOrderID)
|
||||
case "${平台名}":
|
||||
template = strings.ReplaceAll(template, v[0], jxutils.GetVendorName(order.VendorID))
|
||||
case "${订单序号}":
|
||||
template = strings.ReplaceAll(template, v[0], utils.Int2Str(order.OrderSeq))
|
||||
case "${客户名}":
|
||||
template = strings.ReplaceAll(template, v[0], order.ConsigneeName)
|
||||
case "${客户电话}":
|
||||
template = strings.ReplaceAll(template, v[0], order.ConsigneeMobile)
|
||||
case "${客户地址}":
|
||||
template = strings.ReplaceAll(template, v[0], order.ConsigneeAddress)
|
||||
case "${备注}":
|
||||
template = strings.ReplaceAll(template, v[0], order.BuyerComment)
|
||||
case "${商品种数}":
|
||||
template = strings.ReplaceAll(template, v[0], utils.Int2Str(order.SkuCount))
|
||||
case "${商品件数}":
|
||||
template = strings.ReplaceAll(template, v[0], utils.Int2Str(order.GoodsCount))
|
||||
case "${门店名}":
|
||||
template = strings.ReplaceAll(template, v[0], order.StoreName)
|
||||
case "${门店电话}":
|
||||
template = strings.ReplaceAll(template, v[0], storeTel)
|
||||
case "${商品明细}":
|
||||
skus := ""
|
||||
skuParams := []interface{}{}
|
||||
for i := 0; i < len(order.Skus); i++ {
|
||||
skus += "%s<br>"
|
||||
skus += "%8s%10s%10s<br><br>"
|
||||
skuParams = append(skuParams, order.Skus[i].SkuName)
|
||||
skuParams = append(skuParams, "x"+utils.Int2Str(order.Skus[i].Count))
|
||||
skuParams = append(skuParams, jxutils.IntPrice2StandardCurrencyString(order.Skus[i].SalePrice))
|
||||
skuParams = append(skuParams, jxutils.IntPrice2StandardCurrencyString(order.Skus[i].SalePrice*int64(order.Skus[i].Count)))
|
||||
}
|
||||
skus = fmt.Sprintf(skus, skuParams...)
|
||||
template = strings.ReplaceAll(template, v[0], skus)
|
||||
}
|
||||
}
|
||||
orderFmt += template
|
||||
return strings.Replace(orderFmt, "\n", "", -1)
|
||||
//orderFmt := ""
|
||||
//if storeDetail != nil {
|
||||
// //开头加上语音
|
||||
// if storeDetail.PrinterSound != "" {
|
||||
// orderFmt += "<sound>" + storeDetail.PrinterSound + "</sound><br>"
|
||||
// }
|
||||
//}
|
||||
////把带有${}的变量换成实际值
|
||||
//template := storeDetail.PrinterTemplate
|
||||
//regexpValues := regexpPrint.FindAllStringSubmatch(template, -1)
|
||||
//for _, v := range regexpValues {
|
||||
// switch v[0] {
|
||||
// case "${下单时间}":
|
||||
// template = strings.ReplaceAll(template, v[0], utils.Time2Str(order.OrderCreatedAt))
|
||||
// case "${预计送达}":
|
||||
// expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
// if utils.IsTimeZero(expectedDeliveryTime) {
|
||||
// expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||
// }
|
||||
// template = strings.ReplaceAll(template, v[0], utils.Time2Str(expectedDeliveryTime))
|
||||
// case "${订单号}":
|
||||
// template = strings.ReplaceAll(template, v[0], order.VendorOrderID)
|
||||
// case "${平台名}":
|
||||
// template = strings.ReplaceAll(template, v[0], jxutils.GetVendorName(order.VendorID))
|
||||
// case "${订单序号}":
|
||||
// template = strings.ReplaceAll(template, v[0], utils.Int2Str(order.OrderSeq))
|
||||
// case "${客户名}":
|
||||
// template = strings.ReplaceAll(template, v[0], order.ConsigneeName)
|
||||
// case "${客户电话}":
|
||||
// template = strings.ReplaceAll(template, v[0], order.ConsigneeMobile)
|
||||
// case "${客户地址}":
|
||||
// template = strings.ReplaceAll(template, v[0], order.ConsigneeAddress)
|
||||
// case "${备注}":
|
||||
// template = strings.ReplaceAll(template, v[0], order.BuyerComment)
|
||||
// case "${商品种数}":
|
||||
// template = strings.ReplaceAll(template, v[0], utils.Int2Str(order.SkuCount))
|
||||
// case "${商品件数}":
|
||||
// template = strings.ReplaceAll(template, v[0], utils.Int2Str(order.GoodsCount))
|
||||
// case "${门店名}":
|
||||
// template = strings.ReplaceAll(template, v[0], order.StoreName)
|
||||
// case "${门店电话}":
|
||||
// template = strings.ReplaceAll(template, v[0], storeTel)
|
||||
// case "${商品明细}":
|
||||
// skus := ""
|
||||
// skuParams := []interface{}{}
|
||||
// for i := 0; i < len(order.Skus); i++ {
|
||||
// skus += "%s<br>"
|
||||
// skus += "%8s%10s%10s<br><br>"
|
||||
// skuParams = append(skuParams, order.Skus[i].SkuName)
|
||||
// skuParams = append(skuParams, "x"+utils.Int2Str(order.Skus[i].Count))
|
||||
// skuParams = append(skuParams, jxutils.IntPrice2StandardCurrencyString(order.Skus[i].SalePrice))
|
||||
// skuParams = append(skuParams, jxutils.IntPrice2StandardCurrencyString(order.Skus[i].SalePrice*int64(order.Skus[i].Count)))
|
||||
// }
|
||||
// skus = fmt.Sprintf(skus, skuParams...)
|
||||
// template = strings.ReplaceAll(template, v[0], skus)
|
||||
// }
|
||||
//}
|
||||
//orderFmt += template
|
||||
//return strings.Replace(orderFmt, "\n", "", -1)
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
@@ -241,15 +240,15 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
|
||||
return
|
||||
}
|
||||
printData := ManagerOrderAndStore(order, store.Tel1, storeDetail)
|
||||
printData[BigFont] = "small"
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
|
||||
printData[BigFont] = "big"
|
||||
}
|
||||
// 打印次数
|
||||
printData[PrintNumber] = utils.Int2Str(model.YES)
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2 {
|
||||
printData[PrintNumber] = utils.Int2Str(2)
|
||||
}
|
||||
//printData[BigFont] = "small"
|
||||
//if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
|
||||
// printData[BigFont] = "big"
|
||||
//}
|
||||
//// 打印次数
|
||||
//printData[PrintNumber] = utils.Int2Str(model.YES)
|
||||
//if store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2 {
|
||||
// printData[PrintNumber] = utils.Int2Str(2)
|
||||
//}
|
||||
printData[AppID] = "1000" // 菜市应用
|
||||
printData[OrderStatus] = utils.Int2Str(order.Status) // 订单状态
|
||||
printData[WayBillStatus] = order.VendorStatus // 运单状态
|
||||
|
||||
@@ -38,8 +38,16 @@ const (
|
||||
BigFont = "bigFont" // 是否为大字体
|
||||
PrintNumber = "printNumber" // 打印次数
|
||||
AppID = "appId" // 应用id
|
||||
OrderStatus = "orderStatus" // 订单状态
|
||||
WayBillStatus = "wayBillStatus" // 运单状态
|
||||
// 状态对应打印设置的变化
|
||||
OrderStatus = "orderStatus" // 订单状态
|
||||
WayBillStatus = "wayBillStatus" // 运单状态
|
||||
StoreStatusPrint = "storeStatus" // 门店状态
|
||||
RiderVendorIdPrint = "riderVendorId" // 骑手所属平台id
|
||||
RiderNamePrint = "riderName" // 骑手名称
|
||||
RiderPhonePrint = "riderPhone" // 骑手电话
|
||||
RejectionReasonPrint = "rejectionReason" // 拒收原因
|
||||
CustcareRefundReasonPrint = "custcareRefundReason" // 客服退款理由
|
||||
EnterTheStorePrint = "enterTheStore" // 进店
|
||||
)
|
||||
|
||||
type SkuListPrintOrder struct {
|
||||
@@ -50,7 +58,27 @@ type SkuListPrintOrder struct {
|
||||
Upc string `json:"upc"` // 条形码
|
||||
}
|
||||
|
||||
// ManagerOrderAndStore 京西云参数组装
|
||||
// ManagerStore 送达提示数据组装
|
||||
func ManagerStore(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) map[string]string {
|
||||
printOrder := make(map[string]string, 0)
|
||||
// 获取品牌名称
|
||||
if storeDetail != nil && storeDetail.BrandIsPrint == model.NO {
|
||||
if order.VendorOrgCode == "34665" {
|
||||
printOrder[EBailOrderNo] = globals.StoreNameEbai2
|
||||
} else {
|
||||
printOrder[EBailOrderNo] = storeDetail.BrandName
|
||||
}
|
||||
}
|
||||
|
||||
printOrder[VendOrID] = utils.Int2Str(order.VendorID)
|
||||
printOrder[VendorName] = jxutils.GetVendorName(order.VendorID)
|
||||
printOrder[StoreName] = order.StoreName
|
||||
printOrder[StoreTel] = storeTel
|
||||
printOrder[OfficialName] = globals.StoreName
|
||||
return printOrder
|
||||
}
|
||||
|
||||
// ManagerOrderAndStore 京西云参数组装(订单参数)
|
||||
func ManagerOrderAndStore(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) map[string]string {
|
||||
printOrder := make(map[string]string, 0)
|
||||
skuList := make([]*SkuListPrintOrder, 0, 0)
|
||||
|
||||
Reference in New Issue
Block a user