diff --git a/business/jxutils/jxutils.go b/business/jxutils/jxutils.go
index 6b3934eb2..878f6d81a 100644
--- a/business/jxutils/jxutils.go
+++ b/business/jxutils/jxutils.go
@@ -987,6 +987,22 @@ func TranslateSoundSize(vendorID, soundPercentage int) (soundSize string) {
if soundPercentage > 66 && soundPercentage <= 100 {
soundSize = "0"
}
+ } else if vendorID == model.VendorIDTrendIT {
+ if soundPercentage >= 0 && soundPercentage <= 20 {
+ soundSize = "1"
+ }
+ if soundPercentage >= 21 && soundPercentage <= 40 {
+ soundSize = "2"
+ }
+ if soundPercentage >= 41 && soundPercentage <= 60 {
+ soundSize = "3"
+ }
+ if soundPercentage >= 61 && soundPercentage <= 80 {
+ soundSize = "4"
+ }
+ if soundPercentage >= 81 && soundPercentage <= 100 {
+ soundSize = "5"
+ }
}
return soundSize
}
diff --git a/business/model/api_config.go b/business/model/api_config.go
index 736cde8bb..cdb2bf2a9 100644
--- a/business/model/api_config.go
+++ b/business/model/api_config.go
@@ -44,6 +44,7 @@ const (
VendorIDZhongWu = 204 // 中午云打印
VendorIDJxprint = 205 // 京西打印
VendorIDXpYun = 206 // 芯烨云打印机
+ VendorIDTrendIT = 207 //大趋智能
VendorIDPrinterEnd = 300
VendorIDOthersBegin = 301
@@ -112,6 +113,7 @@ var (
VendorIDZhongWu: "ZhongWu",
VendorIDJxprint: "Jx",
VendorIDXpYun: "Xpyun",
+ VendorIDTrendIT: "TrendIT",
VendorIDQiNiuCloud: "Qiniu",
VendorIDJDWL: "Jdwl",
@@ -147,6 +149,7 @@ var (
VendorIDZhongWu: "中午云",
VendorIDJxprint: "京西云",
VendorIDXpYun: "芯烨云",
+ VendorIDTrendIT: "大趋智能",
VendorIDWXMP: "微信公众号",
VendorIDWXQRCode: "微信扫码",
diff --git a/business/model/const.go b/business/model/const.go
index a93c8100d..49b457930 100644
--- a/business/model/const.go
+++ b/business/model/const.go
@@ -196,6 +196,11 @@ var (
"打印机编号",
"不填",
},
+ VendorIDTrendIT: []string{
+ VendorChineseNames[VendorIDTrendIT],
+ "打印机编号",
+ "打印机密钥",
+ },
}
AfsReasonTypeName = map[int]string{
AfsReasonTypeGoodsQuality: "商品质量",
diff --git a/business/partner/printer/trendit/trendit.go b/business/partner/printer/trendit/trendit.go
index 6add06544..57c131071 100644
--- a/business/partner/printer/trendit/trendit.go
+++ b/business/partner/printer/trendit/trendit.go
@@ -1 +1,385 @@
package trendit
+
+import (
+ "fmt"
+ "time"
+
+ "git.rosy.net.cn/baseapi/platformapi/xpyunapi"
+
+ "git.rosy.net.cn/jx-callback/business/jxutils"
+
+ "git.rosy.net.cn/baseapi/platformapi/trenditapi"
+ "git.rosy.net.cn/baseapi/utils"
+ "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"
+)
+
+var (
+ CurPrinterHandler *PrinterHandler
+)
+
+type PrinterHandler struct {
+}
+
+func (p PrinterHandler) GetVendorID() int {
+ return model.VendorIDTrendIT
+}
+
+func init() {
+ CurPrinterHandler = new(PrinterHandler)
+ partner.RegisterPrinterPlatform(CurPrinterHandler)
+}
+
+func (p PrinterHandler) PrintMsg(ctx *jxcontext.Context, sn, copies, voice, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
+ if sn != "" {
+ if globals.EnableStoreWrite {
+ printOrderID, err1 := api.TrendITAPI.Print(sn, msgContent, voice)
+ if err1 == nil && printOrderID != "" {
+ printerStatus, err = p.GetPrinterStatus(ctx, sn, "")
+ }
+ }
+ } else {
+ printerStatus = &partner.PrinterStatus{
+ PrintResult: partner.PrintResultNoPrinter,
+ }
+ }
+ return printerStatus, err
+}
+
+func (p PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, sn, id2 string) (printerStatus *partner.PrinterStatus, err error) {
+ if onlineStatus, workStatus, err := api.TrendITAPI.GetDeviceStatus(sn); err == nil {
+ printerStatus = &partner.PrinterStatus{
+ PrintResult: partner.PrintResultSuccess,
+ }
+ tempOnline := utils.Float64TwoInt(onlineStatus)
+ tempWork := utils.Float64TwoInt(workStatus)
+ if tempOnline == trenditapi.OnlineStatus && tempWork == trenditapi.WorkStatusReady {
+ printerStatus.PrinterStatus = partner.PrinterStatusOnlineOK
+ } else if tempOnline == trenditapi.OfflineStatus {
+ printerStatus.PrinterStatus = partner.PrinterStatusOffline
+ } else if tempWork == trenditapi.WorkStatusPaperLack || tempWork == trenditapi.WorkStatusOverTemperature || tempWork == trenditapi.WorkStatusPrintFail {
+ printerStatus.PrinterStatus = partner.PrinterStatusOnlineAbnormal
+ } else {
+ printerStatus.PrinterStatus = partner.PrinterStatusUnknown
+ }
+ }
+ return printerStatus, err
+}
+
+func (p PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, sn, key, printerName string, soreId int64) (newID1, newID2 string, err error) {
+ if globals.EnableStoreWrite {
+ err = api.TrendITAPI.AddPrinter(sn, key, printerName)
+ }
+ //if strings.Contains(err.Error(), "设备已绑定") {
+ // return "", "", errors.New("")
+ //}
+ return "", "", err
+}
+
+func (p PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, sn, id2 string) (err error) {
+ if globals.EnableStoreWrite {
+ err = api.TrendITAPI.DelPrinter([]string{sn})
+ }
+ return err
+}
+
+func (p PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) {
+ return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDTrendIT])
+}
+
+func (p PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *partner.BindPrinterResult) (bindResult *partner.BindPrinterResult, err error) {
+ return nil, fmt.Errorf("%s打印机当前不支持扫码解绑", model.VendorChineseNames[model.VendorIDTrendIT])
+}
+
+func (p PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, asfOrder *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
+ if len(order.Skus) == 0 {
+ globals.SugarLogger.Debugf("order.sku为空")
+ return
+ }
+ content := ""
+ if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
+ content = p.getOrderContentBig(order, store.Tel1, storeDetail)
+ } else {
+ content = p.getOrderContent(order, store.Tel1, storeDetail)
+ }
+ count := 0
+ for {
+ printerStatus, err := p.PrintMsg(ctx, store.PrinterSN, "", trenditapi.VoiceNewShort, content)
+ if (store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2) && count < 1 {
+ count += 1
+ continue
+ } else {
+ return printerStatus, err
+ }
+ }
+}
+
+func (p PrinterHandler) PrintStore(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, vendorId int) (printerStatus *partner.PrinterStatus, err error) {
+ return nil, err
+}
+
+func (p PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
+ if len(order.Skus) == 0 {
+ return
+ }
+ content := ""
+ voiceType := ""
+ if printType == model.YES { // 取消订单
+ voiceType = trenditapi.VoiceCancel
+ } else { // 售后订单
+ voiceType = trenditapi.VoiceRefund
+ }
+ if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
+ content = p.getCancelOrRefundOrderContent(order, printType, storeDetail)
+ } else {
+ content = p.getCancelOrRefundOrderContentBig(order, printType, storeDetail)
+ }
+ if content == "" {
+ return nil, nil
+ }
+
+ return p.PrintMsg(ctx, store.PrinterSN, "", voiceType, content)
+}
+
+func (p PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, sn, id2 string) (err error) {
+ if globals.EnableStoreWrite {
+ err = api.TrendITAPI.CleanWaitingQueue(sn)
+ }
+ return err
+}
+
+func (p PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
+ return nil, err
+}
+
+func (p PrinterHandler) SetSound(ctx *jxcontext.Context, sn, id2, sound string) (err error) {
+ if globals.EnableStoreWrite {
+ err = api.TrendITAPI.SetVolume(sn, utils.Str2Int(sound))
+ }
+ return err
+}
+
+//正常尺寸打印模板
+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)
+ }
+ getCode := ""
+ if order.VendorID == model.VendorIDEBAI {
+ getCode = fmt.Sprintf("饿百取货码:%s", jxutils.GetEbaiOrderGetCode(order))
+ }
+ order.BuyerComment = ""
+ if order.BuyerComment == "" {
+ order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
+ }
+ orderParams := []interface{}{}
+ 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
+订单编号: %s
+%s#%d
+%s
+` + getCode + `--------------------------------
+客户地址: %s
+--------------------------------
+客户备注:%s
+--------------------------------
+商品列表
+商品名` + trenditapi.StrRepeat(" ", 2) + `数量` + trenditapi.StrRepeat(" ", 3) + `单价` + trenditapi.StrRepeat(" ", 5) + `小计
+` + trenditapi.StrRepeat("-", 32) + `
+`
+ orderParams = append(orderParams,
+ utils.Time2Str(order.OrderCreatedAt),
+ utils.Time2Str(expectedDeliveryTime),
+ order.ConsigneeName,
+ order.ConsigneeMobile,
+ order.VendorOrderID,
+ jxutils.GetVendorName(order.VendorID),
+ order.OrderSeq,
+ order.VendorOrderID,
+ order.ConsigneeAddress,
+ order.BuyerComment,
+ )
+
+ for _, sku := range order.Skus {
+ orderFmt += trenditapi.FormatPrintOrderItem(sku.SkuName, sku.Count, utils.Int64ToFloat64(sku.SalePrice))
+ }
+ orderFmt += `
+共%d种%d件商品
+实付金额: %s
+--------------#%d完-------------`
+ orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
+ return fmt.Sprintf(orderFmt, orderParams...)
+}
+
+//大尺寸打印模板
+func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (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("饿百取货码:%s", jxutils.GetEbaiOrderGetCode(order))
+ }
+ order.BuyerComment = ""
+ if order.BuyerComment == "" {
+ order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
+ }
+ orderParams := []interface{}{}
+ 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
+订单编号: %s
+%s#%d
+%s
+` + getCode + `--------------------------------
+客户地址: %s
+--------------------------------
+客户备注:%s
+--------------------------------
+商品列表
+商品名 数量 单价 小计
+--------------------------------
+`
+ orderParams = append(orderParams,
+ utils.Time2Str(order.OrderCreatedAt),
+ utils.Time2Str(expectedDeliveryTime),
+ order.ConsigneeName,
+ order.ConsigneeMobile,
+ order.VendorOrderID,
+ jxutils.GetVendorName(order.VendorID),
+ order.OrderSeq,
+ order.VendorOrderID,
+ order.ConsigneeAddress,
+ order.BuyerComment,
+ )
+
+ for k, sku := range order.Skus {
+ orderFmt += trenditapi.FormatPrintOrderItemBig(sku.SkuName, sku.Count, utils.Int64ToFloat64(sku.SalePrice))
+ if k != len(order.Skus) {
+ orderFmt += `
`
+ }
+ }
+ orderFmt += `
+共%d种%d件商品
+实付金额: %s
+--------------#%d完-------------`
+ orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
+ return fmt.Sprintf(orderFmt, orderParams...)
+}
+
+//取消/退货 正常尺寸模板
+func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) {
+ var orderParams []interface{}
+ 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)
+ }
+ }
+ }
+ title := ``
+ if printType == model.YES { // 取消订单
+ title = `取消订单详情`
+ } else { // 售后订单
+ title = `退款订单详情`
+ }
+
+ orderFmt +=
+ xpyunapi.StrRepeat("-", 32) + `
+下单时间: %s
+订单编号: %s
+%s#%d
+` + title
+ orderParams = append(orderParams,
+ utils.Time2Str(order.OrderCreatedAt),
+ order.VendorOrderID,
+ jxutils.GetVendorName(order.VendorID),
+ order.OrderSeq,
+ )
+ orderFmt += xpyunapi.StrRepeat("-", 32)
+ orderFmt += `共%d种%d件商品
+实付金额: %s
+--------------#%d完-------------`
+ orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
+ return fmt.Sprintf(orderFmt, orderParams...)
+}
+
+//取消/退货 大尺寸模板
+func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) {
+ var orderParams []interface{}
+ 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)
+ }
+ }
+ }
+ title := ``
+ if printType == model.YES { // 取消订单
+ title = `取消订单详情`
+ } else { // 售后订单
+ title = `退款订单详情`
+ }
+
+ orderFmt +=
+ xpyunapi.StrRepeat("-", 32) + `
+下单时间: %s
+订单编号: %s
+%s#%d
+` + title
+ orderParams = append(orderParams,
+ utils.Time2Str(order.OrderCreatedAt),
+ order.VendorOrderID,
+ jxutils.GetVendorName(order.VendorID),
+ order.OrderSeq,
+ )
+ orderFmt += xpyunapi.StrRepeat("-", 32)
+ orderFmt += `共%d种%d件商品
+实付金额: %s
+--------------#%d完-------------`
+ orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
+ return fmt.Sprintf(orderFmt, orderParams...)
+}
diff --git a/conf/app.conf b/conf/app.conf
index 48f8e4dca..3ed046f73 100644
--- a/conf/app.conf
+++ b/conf/app.conf
@@ -137,7 +137,8 @@ yilianyunClientSecret2 = "d5eedb40c99e6691b1ca2ba82a363d6a"
xpyunUserName="feng.shi@rosy.net.cn"
xpyunUserKey="20a24d4332954993b05876e7b3db2a96"
-
+trendIDAppID="1088834319474253824"
+trendIDAppSecret="79e3b918aeca427bbbf9d0503f9f9106"
zhongwuAppID = 8000192
zhongwuAppSecret = "29435497822f52f3cf659c65da548a79"
diff --git a/globals/api/api.go b/globals/api/api.go
index 81bfcb7bb..9b9194710 100644
--- a/globals/api/api.go
+++ b/globals/api/api.go
@@ -8,6 +8,7 @@ import (
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
"git.rosy.net.cn/baseapi/platformapi/tiktok"
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
+ "git.rosy.net.cn/baseapi/platformapi/trenditapi"
"git.rosy.net.cn/baseapi/platformapi/uinapp"
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
"git.rosy.net.cn/baseapi/platformapi/xpyunapi"
@@ -110,6 +111,7 @@ var (
YilianyunAPI *yilianyunapi.API
YilianyunAPI2 *yilianyunapi.API
XpyunAPI *xpyunapi.API
+ TrendITAPI *trenditapi.API
ZhongwuAPI *zhongwuapi.API
JxPrintAPI *jxprintapi.API
@@ -308,6 +310,7 @@ func Init() {
YilianyunAPI = yilianyunapi.New(beego.AppConfig.DefaultString("yilianyunClientID", ""), beego.AppConfig.DefaultString("yilianyunClientSecret", ""))
YilianyunAPI2 = yilianyunapi.New(beego.AppConfig.DefaultString("yilianyunClientID2", ""), beego.AppConfig.DefaultString("yilianyunClientSecret2", ""))
XpyunAPI = xpyunapi.New(beego.AppConfig.DefaultString("xpyunUserName", ""), beego.AppConfig.DefaultString("xpyunUserKey", ""))
+ TrendITAPI = trenditapi.New(beego.AppConfig.DefaultString("trendIDAppID", ""), beego.AppConfig.DefaultString("trendIDAppSecret", ""))
ZhongwuAPI = zhongwuapi.New(beego.AppConfig.DefaultInt("zhongwuAppID", 0), beego.AppConfig.DefaultString("zhongwuAppSecret", ""))
JxPrintAPI = jxprintapi.New(beego.AppConfig.DefaultString("jxPrintAppID", ""), beego.AppConfig.DefaultString("jxPrintAppKey", ""))
diff --git a/main.go b/main.go
index 0ecae86e0..457eca468 100644
--- a/main.go
+++ b/main.go
@@ -36,6 +36,7 @@ import (
_ "git.rosy.net.cn/jx-callback/business/partner/printer/feie"
_ "git.rosy.net.cn/jx-callback/business/partner/printer/jxprint"
+ _ "git.rosy.net.cn/jx-callback/business/partner/printer/trendit"
_ "git.rosy.net.cn/jx-callback/business/partner/printer/xiaowm"
_ "git.rosy.net.cn/jx-callback/business/partner/printer/xpyun"
_ "git.rosy.net.cn/jx-callback/business/partner/printer/yilianyun"