Files
jx-callback/business/jxstore/event/print_test.go
邹宗楠 d626fcf12d 1
2023-05-29 16:49:57 +08:00

85 lines
6.0 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 event
import (
"encoding/hex"
"fmt"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"strconv"
"strings"
"testing"
"unicode/utf8"
)
func TestPrintMsg(t *testing.T) {
msg := &model.PrintMsg{
ModelIDCULD: model.ModelIDCULD{},
PrintNo: "120220915001069",
Content: "<sound>64</sound><sound>6</sound><center><b>美团外卖</b></center>--------------------------------<br><left>下单时间2022-12-16 09:48:17</left><left>预计送达1970-01-01 00:00:00</left><left>订单编号1100330341689298103</left><left>客户名称:桃子(先生)</left><left>客户电话15680644242,5107</left><left><hb>客户地址:快递之家@#四川省成都市郫都区合作街道天辰路南晨风社区</hb></left>--------------------------------<br><left><b>客户备注:<br>收货人隐私号 15680644242_5107手机号 199****2903</b></left>--------------------------------<br><qrc>12</qrc><b>美团外卖 #12</b><br>商品列表<br>品名 数量 单价 小计<br>--------------------------------<br>满49.0元赠赠送当季新鲜水果250g*1<br> X1 ¥0.00 ¥0.00<br>【整果】补充vc精选黄柠檬一个100g/个<br> X3 ¥5.00 ¥15.00<br>【2022年新上市 】超甜砂糖桔/砂糖橘约500g/份<br> X1 ¥7.90 ¥7.90<br>【整果】福建三红蜜柚约1.1~1.2kg 1个1.1kg/个<br> X1 ¥17.00 ¥17.00<br>【手剥皮薄汁多】爱媛橙2个400g/个<br> X1 ¥7.80 ¥7.80<br>【整果】精选皇冠梨约600g/份<br> X1 ¥19.20 ¥19.20<br>【整果】轻畅 新鲜香蕉约500g/份(480~500g)<br> X1 ¥8.90 ¥8.90<br><br>共 7 种 9 件商品<br>实付金额¥76.40<br>--------------------------------<br><center>商品质量问题</center><center>18884056557</center><center>京西果园(果切·果捞·聚果堂)</center>--------------------------------",
OrderNo: "12", // 2147483648111
Status: 0,
Comment: "",
MsgID: "20221216175529_09440117",
}
data, err := buildMsg(msg)
fmt.Println("data=", string(data))
fmt.Println("err=", err)
}
// 十六进制转字符串
func TestDC(t *testing.T) {
str := "093c736f756e643e323009091b61011b2130bea9cef7b9fbd4b00a1b21000a1b61000a0a09091b6101cad6bbfac2f2b2cbc9cfbea9cef70a1b61000a1b6101bcabcbd9b5bdbcd2cbcdbeaacfb20a1b61000a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0acfc2b5a5cab1bce43a20323032312d30382d32372032313a35373a32360ad4a4bcc6cbcdb4ef3a20323032312d30382d32372032323a35373a32360ab6a9b5a5b1e0bac53a2039333135343434313733303231313130300a0a1b2130c3c0cdc5cde2c2f42331390a1b21000a1d58021b5a00010611003933313534343431373330323131313030000a1b400abfcdbba73a20c0eeb4f3c3ce28cfc8c9fa290ab5e7bbb03a2031353938373230303334300ab5d8d6b73a20b1b1c6d6ceb0d2b5b9e3b3a12d32bac5c2a52028ceb0d2b5b9e3b3a142c7f8294023d4c6c4cfcaa1b3fed0dbd2cdd7e5d7d4d6ced6ddb3fed0dbcad0c2b9b3c7d5f2ceb0d2b5b9e3b3a10a0abfcdbba7b1b8d7a23a200a1b2130a1bec8e7d3f6c8b1bbf5a1bfa3ba20c8b1bbf5cab1b5e7bbb0d3ebced2b9b5cda80a1b21000a0a0ac9ccc6b7c3f7cfb83a200ac6b7c3fb20202020cafdc1bf20202020b5a5bcdb20202020202020d0a1bcc60a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0aa1bed7d4d3c9c6b4a1bfcfb4bebbbaeccce1313630672fbad00a20202020202078312020202020a3a4392e32302020202020a3a4392e32300aa1beb9fbc7d0a1bf20c5a3c4ccc4beb9cfd4bc333030672fb7dd0a20202020202078312020202020a3a4392e37302020202020a3a4392e37300aa1bed7d4d3c9c6b4a1bfd1cfd1a1cfe3bdb6b9fbc7d0313830672fbad00a20202020202078312020202020a3a4382e38302020202020a3a4382e38300a5bcdf8baecb9fbc7d05dcedac3b7d0a1b7acc7d13235672fb8f60a20202020207831302020202020a3a4302e38302020202020a3a4382e30300a5bcfd6b0fe5dccf0caafc1f1d7d1d4bc323530672fb7dd2831b8f6290a20202020202078312020202020a3a4332e35302020202020a3a4332e35300aa1beb1acc6b7ccd8bbdda1bfd0c2cfcab4e0ccf0b0ebbdefb9fec3dcb9cf20b9fec3dbb9cfb9fbc7d0d2bbbad0323530672fbad0283233307e32363067290a20202020202078312020202020a3a4302e30312020202020a3a4302e30310aa1beb1acc6b7ccd8bbdda1bfd0c2cfcab4e0ccf0b0ebbdefb9fec3dcb9cf20b9fec3dbb9cfb9fbc7d0d2bbbad0323530672fbad0283233307e32363067290a20202020202078312020202020a3a4382e36302020202020a3a4382\ne36300a0ab9b237d6d63136bcfec9ccc6b70a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0a1b61011b2110c9ccc6b7d6cac1bfcecacce2c7ebc1aacfb53a0a1b21000a1b61000a1b61011b2110bea9cef7b9fbd4b0a1a4b9fbc7d0a1a4cbaeb9fbc0cca3a8b9fbb9fbceddb5eaa3a93a31353834313031313339370a1b21000a1b61000a0ab8fcb6e0d0c5cfa2c7ebb9d8d7a2b9d9b7bdcea2d0c53a20bea9cef7b2cbcad00a0a0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d0a0a0a"
str2, _ := hex.DecodeString(str)
fmt.Println(string(str2))
}
// 十进制字符串转十六进制
func Test10Two16(t *testing.T) {
//fmt.Println(strconv.FormatInt(11, 16)) // 2 to 10
//for _, v := range strings.Split("324c", "d") {
// fmt.Println(v)
//}
hexPrefix, _ := jxutils.Utf8ToGbk([]byte("[8]sounda14"))
hexPrefixStr := hex.EncodeToString(hexPrefix)
fmt.Println(hexPrefixStr)
}
func TestCheckSum(t *testing.T) {
soundNum, _ := hex.DecodeString("3130") // 十六进制转字符串
intSound, _ := strconv.ParseInt(string(soundNum), 10, 64)
int16Sound := strconv.FormatInt(intSound, 16)
b := strconv.FormatInt(16, 16)
if int16Sound < b {
fmt.Println("111111")
} else {
fmt.Println("22222")
}
fmt.Println("==========", int16Sound)
fmt.Println("======2====", utf8.RuneCountInString("64,65,66"))
}
func TestTen216(t *testing.T) {
aa := `
3c736f756e643e
312c322c33
3c2f736f756e643e
1b6101bed3d6d0cec4d7d60a1b6100
3c736f756e643e
342c352c36
3c2f736f756e643e
1b6101bed3d6d00a1b6100
`
bb := `1B59415501 1B59415502 1B59415503`
kk := `1B59415501 1B59415502 1B59415503 1b6101bed3d6d0cec4d7d60a1b6100 1b6101bed3d6d0cec4d7d60a1b6100 1B59415504 1B59415505 1B59415506 1b6101bed3d6d00a1b6100`
// 第一个语音字段
index1 := strings.Index(aa, "3c736f756e643e")
index2 := strings.Index(aa, "3c2f736f756e643e")
str := aa[index1:index2]
gg := strings.Replace(aa, str, bb, 1)
fmt.Println(gg)
fmt.Println(kk)
}