Compare commits
27 Commits
2b9135903b
...
rsm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
637a878808 | ||
|
|
999c3d7ebe | ||
|
|
8a8f545656 | ||
|
|
ce6b120f23 | ||
|
|
3651bf0e1d | ||
|
|
2e261aab4b | ||
|
|
5d76781965 | ||
|
|
bf44d2b733 | ||
|
|
c8e1500892 | ||
|
|
4e1c338bec | ||
|
|
e3fdcd179a | ||
|
|
b4c5df3616 | ||
|
|
505e347939 | ||
|
|
1380b581bc | ||
|
|
f99ef659e0 | ||
|
|
829c546a52 | ||
|
|
f520b3e2e0 | ||
|
|
f74945fab9 | ||
|
|
88f6e70fc8 | ||
|
|
200cefcfb3 | ||
|
|
d5bea30024 | ||
|
|
a9e521eaf2 | ||
|
|
2055c4bb3b | ||
|
|
e0b26ea5b8 | ||
|
|
1f779012a2 | ||
|
|
2df383a788 | ||
|
|
1f40c96cfe |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
jx-callback
|
jx-callback
|
||||||
*.tmp
|
*.tmp
|
||||||
swagger/
|
|
||||||
debug
|
debug
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -268,6 +268,10 @@ func DelPrinter(appID int, printNos []string, storeId string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryPrintList(printNo, printKey string, status, isOnline int64, page, size int64) ([]*model.Printer, int, error) {
|
||||||
|
prints, count, err := dao.QueryPrintList(dao.GetDB(), printNo, printKey, status, isOnline, page, size)
|
||||||
|
return prints, count, err
|
||||||
|
}
|
||||||
func UpdatePrinter(appID int, printNo string, name, sim, sound *string, volume *int) (err error) {
|
func UpdatePrinter(appID int, printNo string, name, sim, sound *string, volume *int) (err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ func handleConn(c net.Conn) error {
|
|||||||
return errors.New("conn is nil")
|
return errors.New("conn is nil")
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
buffer, n, err := ConnRead(c)
|
||||||
printRemoteAddr := c.RemoteAddr().String()
|
printRemoteAddr := c.RemoteAddr().String()
|
||||||
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
||||||
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
|
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
|
||||||
buffer, n, err := ConnRead(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
fmt.Println("connection close")
|
fmt.Println("connection close")
|
||||||
@@ -78,6 +78,17 @@ func handleConn(c net.Conn) error {
|
|||||||
PrintObject.DelPrintObj(printNo)
|
PrintObject.DelPrintObj(printNo)
|
||||||
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
||||||
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
|
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
|
||||||
|
} else {
|
||||||
|
printStatusOff := make(map[string]int, 0)
|
||||||
|
for ip, pn := range PrintAddrAndIp.PrintObject {
|
||||||
|
if ip == printRemoteAddr {
|
||||||
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
|
||||||
|
PrintIpAndAddr.DelPrintIpAndAddr(pn)
|
||||||
|
PrintObject.DelPrintObj(printNo)
|
||||||
|
} else if pn != "" {
|
||||||
|
printStatusOff[pn] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -344,11 +355,11 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("-------close1 := %s", key)
|
|
||||||
t.getClients(key).C.Close()
|
t.getClients(key).C.Close()
|
||||||
close(t.MsgMap[key])
|
close(t.MsgMap[key])
|
||||||
close(t.CallBackMap[key])
|
close(t.CallBackMap[key])
|
||||||
t.delConn(key)
|
//t.delConn(key)
|
||||||
|
t.clear(key)
|
||||||
|
|
||||||
// 链接出错,彻底删除换成
|
// 链接出错,彻底删除换成
|
||||||
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ func (t *TcpClient) clear(key string) {
|
|||||||
t.Lock()
|
t.Lock()
|
||||||
defer t.Unlock()
|
defer t.Unlock()
|
||||||
t.Clients[key].C.Close()
|
t.Clients[key].C.Close()
|
||||||
globals.SugarLogger.Debugf("-------close3 := %s", key)
|
|
||||||
delete(t.Clients, key)
|
delete(t.Clients, key)
|
||||||
close(t.MsgMap[key])
|
close(t.MsgMap[key])
|
||||||
delete(t.MsgMap, key)
|
delete(t.MsgMap, key)
|
||||||
@@ -368,9 +367,6 @@ func getCallbackMsgInfo(data string) (orderNo int64, printNo string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func changePrinterStatus(printNo string, status int) {
|
func changePrinterStatus(printNo string, status int) {
|
||||||
if printNo == "120220915001467" {
|
|
||||||
globals.SugarLogger.Debugf("------------printStatus := %s,%d", printNo, status)
|
|
||||||
}
|
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -47,9 +47,11 @@ func (w *Worker) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Worker) Stop() {
|
func (w *Worker) Stop() {
|
||||||
go func() {
|
w.quit <- true
|
||||||
w.quit <- true
|
close(w.quit)
|
||||||
}()
|
//go func() {
|
||||||
|
// w.quit <- true
|
||||||
|
//}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPool(numWorkers int) *Pool {
|
func NewPool(numWorkers int) *Pool {
|
||||||
@@ -79,14 +81,24 @@ func (p *Pool) Stop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//func (p *Pool) AddJob(job Job) {
|
||||||
|
// p.wg.Add(1)
|
||||||
|
// p.jobChannel <- func() {
|
||||||
|
// job()
|
||||||
|
// p.wg.Done()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
func (p *Pool) AddJob(job Job) {
|
func (p *Pool) AddJob(job Job) {
|
||||||
p.wg.Add(1)
|
p.wg.Add(1)
|
||||||
p.jobChannel <- func() {
|
go func() {
|
||||||
job()
|
p.jobChannel <- func() {
|
||||||
p.wg.Done()
|
defer p.wg.Done()
|
||||||
}
|
job()
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) Wait() {
|
func (p *Pool) Wait() {
|
||||||
p.wg.Wait()
|
p.wg.Wait()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func SendSMSMsg(mobileList []string, signName, templateCode string, templatePara
|
|||||||
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
||||||
for _, mobileNum := range mobileList {
|
for _, mobileNum := range mobileList {
|
||||||
if mobileNum != "" {
|
if mobileNum != "" {
|
||||||
globals.SugarLogger.Debugf("SendSMSMsg mobileNum:%s, templateCode:%s", mobileNum, templateCode)
|
globals.SugarLogger.Debugf("SendSMSMsg 1 mobileNum:%s, templateCode:%s", mobileNum, templateCode)
|
||||||
if true { //globals.EnableStoreWrite {
|
if true { //globals.EnableStoreWrite {
|
||||||
if response, err := api.SMSClient.Execute(globals.AliKey, globals.AliSecret, mobileNum, signName, templateCode, string(utils.MustMarshal(templateParam))); err != nil {
|
if response, err := api.SMSClient.Execute(globals.AliKey, globals.AliSecret, mobileNum, signName, templateCode, string(utils.MustMarshal(templateParam))); err != nil {
|
||||||
globals.SugarLogger.Warnf("SendSMSMsg mobileNum:%s failed with error:%v", mobileNum, err)
|
globals.SugarLogger.Warnf("SendSMSMsg mobileNum:%s failed with error:%v", mobileNum, err)
|
||||||
|
|||||||
@@ -124,3 +124,39 @@ func DeletePrintMsg() {
|
|||||||
globals.SugarLogger.Debugf("定时删除超过一个月的打印信息:%d 条", num)
|
globals.SugarLogger.Debugf("定时删除超过一个月的打印信息:%d 条", num)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryPrintList(db *DaoDB, printNo, printKey string, status, isOnline int64, page, size int64) (print []*model.Printer, count int, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS * FROM printer WHERE 1=1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if printNo != "" {
|
||||||
|
sql += ` AND print_no = ?`
|
||||||
|
sqlParams = append(sqlParams, printNo)
|
||||||
|
}
|
||||||
|
if printKey != "" {
|
||||||
|
sql += ` AND print_key = ?`
|
||||||
|
sqlParams = append(sqlParams, printKey)
|
||||||
|
}
|
||||||
|
if status != model.PrintMsgAll {
|
||||||
|
sql += ` AND status = ?`
|
||||||
|
sqlParams = append(sqlParams, status)
|
||||||
|
}
|
||||||
|
if isOnline != model.PrintMsgAll {
|
||||||
|
sql += ` AND is_online = ?`
|
||||||
|
sqlParams = append(sqlParams, isOnline)
|
||||||
|
}
|
||||||
|
sql += ` AND deleted_at = ?`
|
||||||
|
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||||
|
sql += ` ORDER BY status desc,is_online desc LIMIT ? OFFSET ? `
|
||||||
|
sqlParams = append(sqlParams, size, page)
|
||||||
|
tx, _ := Begin(db)
|
||||||
|
if err = GetRowsTx(tx, &print, sql, sqlParams...); err != nil {
|
||||||
|
Rollback(db, tx)
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
count = GetLastTotalRowCountTx(tx)
|
||||||
|
defer Commit(db, tx)
|
||||||
|
|
||||||
|
return print, count, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -113,13 +113,13 @@ func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error)
|
|||||||
for i := 0; i < len(skuList); i++ {
|
for i := 0; i < len(skuList); i++ {
|
||||||
printMsg += userTempMap["skuName"]
|
printMsg += userTempMap["skuName"]
|
||||||
printMsg += userTempMap["skuNumber"]
|
printMsg += userTempMap["skuNumber"]
|
||||||
printMsg += userTempMap["skuPrice"]
|
//printMsg += userTempMap["skuPrice"]
|
||||||
printMsg += userTempMap["skuAllPrice"]
|
//printMsg += userTempMap["skuAllPrice"]
|
||||||
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuCount, skuList[i].SalePrice, skuList[i].TotalCountPrice)
|
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuCount /*skuList[i].SalePrice, skuList[i].TotalCountPrice*/)
|
||||||
if skuList[i].Upc != "" {
|
//if skuList[i].Upc != "" {
|
||||||
printMsg += userTempMap["skuUpc"]
|
// printMsg += userTempMap["skuUpc"]
|
||||||
printValue = append(printValue, skuList[i].Upc)
|
// printValue = append(printValue, skuList[i].Upc)
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
printMsg += userTempMap["allSkuTypeCount"]
|
printMsg += userTempMap["allSkuTypeCount"]
|
||||||
@@ -138,10 +138,18 @@ func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error)
|
|||||||
case "title":
|
case "title":
|
||||||
printMsg += userTempMap[v]
|
printMsg += userTempMap[v]
|
||||||
case "qrcOrder": // 老版打印机展示不要
|
case "qrcOrder": // 老版打印机展示不要
|
||||||
//printMsg += userTempMap[v]
|
//printMsg += `<b>%s #%s</b>`
|
||||||
//printValue = append(printValue, param[v])
|
//printValue = append(printValue, param["vendorName"], param["vendorOrderNo"])
|
||||||
printMsg += `<b>%s #%s</b>`
|
if param["vendorName"] == "京东到家" {
|
||||||
printValue = append(printValue, param["vendorName"], param["vendorOrderNo"])
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param[v])
|
||||||
|
}
|
||||||
|
case "vendorName":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param[v], param["vendorOrderNo"])
|
||||||
|
case "storeName2":
|
||||||
|
printMsg += userTempMap[v]
|
||||||
|
printValue = append(printValue, param["storeName"])
|
||||||
default:
|
default:
|
||||||
printMsg += userTempMap[v]
|
printMsg += userTempMap[v]
|
||||||
printValue = append(printValue, param[v])
|
printValue = append(printValue, param[v])
|
||||||
@@ -211,7 +219,7 @@ func PrinterOrderVoice(param map[string]string, setting *model.PrintSettingObj,
|
|||||||
// 订单状态
|
// 订单状态
|
||||||
switch param[model.OrderStatusPrint] {
|
switch param[model.OrderStatusPrint] {
|
||||||
// 新订单(待接单)
|
// 新订单(待接单)
|
||||||
case utils.Int2Str(model.OrderStatusNew): // utils.Int2Str(model.OrderStatusFinishedPickup), utils.Int2Str(model.OrderStatusAccepted)
|
case utils.Int2Str(model.OrderStatusNew), utils.Int2Str(model.OrderStatusAccepted): // utils.Int2Str(model.OrderStatusFinishedPickup), utils.Int2Str(model.OrderStatusAccepted)
|
||||||
//if param[model.OrderStatusPrint] != utils.Int2Str(model.OrderStatusNew) && param[model.VendorIDPrint] == utils.Int64ToStr(model.VendorIDMTWM) {
|
//if param[model.OrderStatusPrint] != utils.Int2Str(model.OrderStatusNew) && param[model.VendorIDPrint] == utils.Int64ToStr(model.VendorIDMTWM) {
|
||||||
// return "", err
|
// return "", err
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func TestQueryExpressPrice(t *testing.T) {
|
|||||||
SendPhone: "18981810340",
|
SendPhone: "18981810340",
|
||||||
ChannelType: 2,
|
ChannelType: 2,
|
||||||
}
|
}
|
||||||
data,err := QueryExpressPrice(param)
|
data, err := QueryExpressPrice(param)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
fmt.Println(data)
|
fmt.Println(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,43 @@ func (c *ApiController) AddPrinter(dataMap map[string]interface{}) (data, errCod
|
|||||||
return "", errCode, err
|
return "", errCode, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QueryPrintList struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ApiController) QueryPrintList(dataMap map[string]interface{}) (data map[string]interface{}, errCode string, err error) {
|
||||||
|
var (
|
||||||
|
printNo string
|
||||||
|
printKey string
|
||||||
|
status int64
|
||||||
|
isOnline int64
|
||||||
|
page int64
|
||||||
|
size int64
|
||||||
|
)
|
||||||
|
|
||||||
|
if printNoParam, ok := dataMap["print_no"].(string); !ok {
|
||||||
|
printNo = ""
|
||||||
|
} else {
|
||||||
|
printNo = printNoParam
|
||||||
|
}
|
||||||
|
if key, ok := dataMap["print_key"].(string); !ok {
|
||||||
|
printKey = ""
|
||||||
|
} else {
|
||||||
|
printKey = key
|
||||||
|
}
|
||||||
|
|
||||||
|
status = utils.Interface2Int64WithDefault(dataMap["status"], -9)
|
||||||
|
isOnline = utils.Interface2Int64WithDefault(dataMap["is_online"], -9)
|
||||||
|
page = utils.Interface2Int64WithDefault(dataMap["page"], 0)
|
||||||
|
size = utils.Interface2Int64WithDefault(dataMap["size"], 15)
|
||||||
|
|
||||||
|
list, count, err := cms.QueryPrintList(printNo, printKey, status, isOnline, page, size)
|
||||||
|
data = map[string]interface{}{
|
||||||
|
"printList": list,
|
||||||
|
"count": count,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//删除打印机绑定
|
//删除打印机绑定
|
||||||
func (c *ApiController) DelPrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
func (c *ApiController) DelPrinter(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -29,10 +29,10 @@ import (
|
|||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/jds"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/jds"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/mt"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/mt"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/taobao"
|
//_ "git.rosy.net.cn/jx-callback/business/jxstore/partner/taobao"
|
||||||
_ "git.rosy.net.cn/jx-callback/globals/api"
|
_ "git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
|
||||||
_ "git.rosy.net.cn/jx-callback/routers"
|
_ "git.rosy.net.cn/jx-callback/routers"
|
||||||
|
|||||||
16896
swagger/param_parser.go.txt
Normal file
16896
swagger/param_parser.go.txt
Normal file
File diff suppressed because it is too large
Load Diff
5818
swagger/swagger.json
Normal file
5818
swagger/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
3945
swagger/swagger.yml
Normal file
3945
swagger/swagger.yml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,6 @@ import (
|
|||||||
_ "git.rosy.net.cn/jx-callback/routers"
|
_ "git.rosy.net.cn/jx-callback/routers"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
. "github.com/smartystreets/goconvey/convey"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user