Files
baseapi/platformapi/feieapi/feieapi_test.go
2019-04-01 23:27:55 +08:00

91 lines
3.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package feieapi
import (
"testing"
"time"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
"go.uber.org/zap"
)
var (
api *API
sugarLogger *zap.SugaredLogger
)
func init() {
logger, _ := zap.NewDevelopment()
sugarLogger = logger.Sugar()
baseapi.Init(sugarLogger)
api = New("jianhua.xu@rosy.net.cn", "2JfKh8TyheQ9mwss")
}
func TestPrintMsg(t *testing.T) {
result, err := api.PrintMsg("218510310", "<CB>京西菜市</CB><BR><C>手机买菜上京西</C><BR><C>极速到家送惊喜</C>--------------------------------<BR>下单时间: 2018-09-28 06:27:52<BR>预计送达: 2018-09-28 09:00:00<BR>订单编号: 823351245000021<BR><BR><B>京东到家#2</B><BR><BR><QR>823351245000021</QR><BR>客户: 佛**<BR>电话: 18575789646,6168<BR>地址: 订单完结5小时后隐藏顾客地址。<BR><BR>客户备注: <BR><B>其他商品继续配送(缺货商品退款)</B><BR><BR><BOLD>实际支付:</BOLD>26.74<BR><BR>商品明细: <BR>品名 数量 单价 小计--------------------------------<BR>小葱约100g/份<BR> 1 1.44 1.44<BR>小白菜约250g/份<BR> 1 4.85 4.85<BR>紫鲜茄约400g/份<BR> 1 6.00 6.00<BR>散装泡姜约100g/份<BR> 1 3.12 3.12<BR>老姜约200g/份<BR> 1 5.20 5.20<BR>泡野山椒约100g/份<BR> 1 4.88 4.88<BR>[新鲜]刺黄瓜约300g/份<BR> 1 5.00 5.00<BR>薄皮青椒约250g/份<BR> 1 2.75 2.75<BR>[优]土豆约500g/份<BR> 1 1.00 1.00<BR><BR><BOLD>共9种9件商品</BOLD><BR>--------------------------------<BR><C><L><BOLD>商品质量问题请联系:</BOLD></L><BR></C><C><L><BOLD>京西菜市-乐从店:13600309530</BOLD></L><BR></C><BR><BR>官方服务热线: 18011516898<BR>更多信息请关注官方微信: 京西菜市<BR><BR><BR><BR>----------------------------------------------------------------<BR><BR>", 1)
if err != nil {
t.Fatalf("PrintMsg return error:%v", err)
}
baseapi.SugarLogger.Debug(result)
}
func TestPrinterAddList(t *testing.T) {
ok, no, err := api.PrinterAddList([]*PrinterInfo{
&PrinterInfo{
SN: "218510310",
Key: "ztdpveyg",
Name: "",
PhoneNum: "",
},
})
if err != nil {
t.Fatalf("PrinterAddList return error:%v", err)
}
baseapi.SugarLogger.Debug(utils.Format4Output(ok, false))
baseapi.SugarLogger.Debug(utils.Format4Output(no, false))
}
func TestPrinterDelList(t *testing.T) {
ok, no, err := api.PrinterDelList([]string{
"218510310",
})
if err != nil {
t.Fatalf("PrinterDelList return error:%v", err)
}
baseapi.SugarLogger.Debug(utils.Format4Output(ok, false))
baseapi.SugarLogger.Debug(utils.Format4Output(no, false))
}
func TestQueryOrderInfoByDate(t *testing.T) {
printed, waiting, err := api.QueryOrderInfoByDate("218510310", time.Now())
if err != nil {
t.Fatalf("QueryOrderInfoByDate return error:%v", err)
}
baseapi.SugarLogger.Debugf("print:%d, waiting:%d", printed, waiting)
}
func TestDelPrinterSqs(t *testing.T) {
err := api.DelPrinterSqs("218510310")
if err != nil {
t.Fatalf("DelPrinterSqs return error:%v", err)
}
}
func TestQueryPrinterStatus(t *testing.T) {
status, err := api.QueryPrinterStatus("218510310")
if err != nil {
t.Fatalf("QueryPrinterStatus return error:%v", err)
}
baseapi.SugarLogger.Debug(status)
}
func TestQueryOrderState(t *testing.T) {
status, err := api.QueryOrderState("218510310")
if err != nil {
t.Fatalf("QueryOrderState return error:%v", err)
}
baseapi.SugarLogger.Debug(status)
}