- 只有在prod环境下才刷新易联云token
This commit is contained in:
@@ -198,7 +198,7 @@ func SaveWeimobToken(token *weimobapi.TokenInfo) (err error) {
|
|||||||
func RefreshYilianyunToken() error {
|
func RefreshYilianyunToken() error {
|
||||||
return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (string, string) {
|
return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (string, string) {
|
||||||
globals.SugarLogger.Debugf("RefreshYilianyunToken RunMode:%s", beego.BConfig.RunMode)
|
globals.SugarLogger.Debugf("RefreshYilianyunToken RunMode:%s", beego.BConfig.RunMode)
|
||||||
if true { //beego.BConfig.RunMode == "prod" {
|
if beego.BConfig.RunMode == "prod" {
|
||||||
if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil {
|
if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil {
|
||||||
return string(utils.MustMarshal(tokenInfo)), ""
|
return string(utils.MustMarshal(tokenInfo)), ""
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
149
business/partner/printer/zhongwu/zhongwu.go
Normal file
149
business/partner/printer/zhongwu/zhongwu.go
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
package zhongwu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/yilianyunapi"
|
||||||
|
"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/partner"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
CurPrinterHandler *PrinterHandler
|
||||||
|
)
|
||||||
|
|
||||||
|
type PrinterHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
CurPrinterHandler = new(PrinterHandler)
|
||||||
|
partner.RegisterPrinterPlatform(CurPrinterHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel string) (content string) {
|
||||||
|
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||||
|
if utils.IsTimeZero(expectedDeliveryTime) {
|
||||||
|
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||||
|
}
|
||||||
|
orderFmt := `
|
||||||
|
<CB>京西菜市</CB><BR>
|
||||||
|
<C>手机买菜上京西</C><BR>
|
||||||
|
<C>极速到家送惊喜</C><BR>
|
||||||
|
--------------------------------<BR>
|
||||||
|
下单时间: %s<BR>
|
||||||
|
预计送达: %s<BR>
|
||||||
|
订单编号: %s<BR>
|
||||||
|
<BR>
|
||||||
|
|
||||||
|
<B>%s#%d</B><BR><BR>
|
||||||
|
<QR>%s</QR>
|
||||||
|
<BR>
|
||||||
|
客户: %s<BR>
|
||||||
|
电话: %s<BR>
|
||||||
|
地址: %s<BR>
|
||||||
|
<BR>
|
||||||
|
客户备注: <BR>
|
||||||
|
<B>%s</B><BR>
|
||||||
|
<BR>
|
||||||
|
|
||||||
|
<BOLD>实际支付:</BOLD>%s<BR>
|
||||||
|
<BR>
|
||||||
|
商品明细: <BR>
|
||||||
|
品名 数量 单价 小计<BR>
|
||||||
|
--------------------------------<BR>`
|
||||||
|
orderParams := []interface{}{
|
||||||
|
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 += `%10s%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>
|
||||||
|
<BOLD>共%d种%d件商品</BOLD>
|
||||||
|
<BR>
|
||||||
|
--------------------------------<BR>
|
||||||
|
<C><L><BOLD>商品质量问题请联系:</BOLD></L><BR></C>
|
||||||
|
<C><L><BOLD>%s:%s</BOLD></L><BR></C><BR>
|
||||||
|
<BR>
|
||||||
|
官方服务热线: 18011516898<BR>
|
||||||
|
更多信息请关注官方微信: 京西菜市<BR>
|
||||||
|
<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)
|
||||||
|
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PrinterHandler) GetVendorID() int {
|
||||||
|
return model.VendorIDYiLianYun
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, machineCode, notUsed, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||||
|
globals.SugarLogger.Debugf("PrintMsg machineCode:%s", machineCode)
|
||||||
|
if machineCode != "" {
|
||||||
|
if err = api.YilianyunAPI.PrintMsg(machineCode, msgTitle, msgContent); err == nil {
|
||||||
|
printerStatus, err = c.GetPrinterStatus(ctx, machineCode, "")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printerStatus = &partner.PrinterStatus{
|
||||||
|
PrintResult: partner.PrintResultNoPrinter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return printerStatus, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, machineCode, notUsed string) (printerStatus *partner.PrinterStatus, err error) {
|
||||||
|
status, err := api.YilianyunAPI.GetPrintStatus(machineCode)
|
||||||
|
if err == nil {
|
||||||
|
printerStatus = &partner.PrinterStatus{
|
||||||
|
PrintResult: partner.PrintResultSuccess,
|
||||||
|
}
|
||||||
|
if status == yilianyunapi.PrintStatusOffline {
|
||||||
|
printerStatus.PrinterStatus = partner.PrinterStatusOffline
|
||||||
|
} else if status == yilianyunapi.PrintStatusOnline {
|
||||||
|
printerStatus.PrinterStatus = partner.PrinterStatusOnlineOK
|
||||||
|
} else {
|
||||||
|
printerStatus.PrinterStatus = partner.PrinterStatusOnlineAbnormal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return printerStatus, err
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
return c.PrintMsg(ctx, store.PrinterSN, "", order.VendorOrderID, content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, machineCode, secret, printerName string) (notUsed1, notUsed2 string, err error) {
|
||||||
|
err = api.YilianyunAPI.AddPrinter(machineCode, secret, printerName)
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, machineCode, notUsed string) (err error) {
|
||||||
|
err = api.YilianyunAPI.DeletePrinter(machineCode)
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -75,6 +75,9 @@ xiaoWMAppKey = "94337"
|
|||||||
yilianyunClientID = "1039586024"
|
yilianyunClientID = "1039586024"
|
||||||
yilianyunClientSecret = "4885d07c2997b661102e4b6099c0bf3b"
|
yilianyunClientSecret = "4885d07c2997b661102e4b6099c0bf3b"
|
||||||
|
|
||||||
|
zhongwuAppID = 8000192
|
||||||
|
zhongwuAppSecret = "29435497822f52f3cf659c65da548a79"
|
||||||
|
|
||||||
[dev]
|
[dev]
|
||||||
jdToken = "c8854ef2-f80a-45ee-aceb-dc8014d646f8"
|
jdToken = "c8854ef2-f80a-45ee-aceb-dc8014d646f8"
|
||||||
jdAppKey = "06692746f7224695ad4788ce340bc854"
|
jdAppKey = "06692746f7224695ad4788ce340bc854"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/xiaowmapi"
|
"git.rosy.net.cn/baseapi/platformapi/xiaowmapi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/yilianyunapi"
|
"git.rosy.net.cn/baseapi/platformapi/yilianyunapi"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/zhongwuapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
|
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ var (
|
|||||||
FeieAPI *feieapi.API
|
FeieAPI *feieapi.API
|
||||||
XiaoWMAPI *xiaowmapi.API
|
XiaoWMAPI *xiaowmapi.API
|
||||||
YilianyunAPI *yilianyunapi.API
|
YilianyunAPI *yilianyunapi.API
|
||||||
|
ZhongwuAPI *zhongwuapi.API
|
||||||
|
|
||||||
Cacher cache.ICacher
|
Cacher cache.ICacher
|
||||||
)
|
)
|
||||||
@@ -103,6 +105,7 @@ func Init() {
|
|||||||
FeieAPI = feieapi.New(beego.AppConfig.DefaultString("feieUser", ""), beego.AppConfig.DefaultString("feieKey", ""))
|
FeieAPI = feieapi.New(beego.AppConfig.DefaultString("feieUser", ""), beego.AppConfig.DefaultString("feieKey", ""))
|
||||||
XiaoWMAPI = xiaowmapi.New(beego.AppConfig.DefaultInt("xiaoWMAppID", 0), beego.AppConfig.DefaultString("xiaoWMAppKey", ""))
|
XiaoWMAPI = xiaowmapi.New(beego.AppConfig.DefaultInt("xiaoWMAppID", 0), beego.AppConfig.DefaultString("xiaoWMAppKey", ""))
|
||||||
YilianyunAPI = yilianyunapi.New(beego.AppConfig.DefaultString("yilianyunClientID", ""), beego.AppConfig.DefaultString("yilianyunClientSecret", ""))
|
YilianyunAPI = yilianyunapi.New(beego.AppConfig.DefaultString("yilianyunClientID", ""), beego.AppConfig.DefaultString("yilianyunClientSecret", ""))
|
||||||
|
ZhongwuAPI = zhongwuapi.New(beego.AppConfig.DefaultInt("zhongwuAppID", 0), beego.AppConfig.DefaultString("zhongwuAppSecret", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
func initElm() {
|
func initElm() {
|
||||||
|
|||||||
Reference in New Issue
Block a user