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
|
||||
*.tmp
|
||||
swagger/
|
||||
debug
|
||||
.DS_Store
|
||||
*.log
|
||||
|
||||
@@ -268,6 +268,10 @@ func DelPrinter(appID int, printNos []string, storeId string) (err error) {
|
||||
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) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
|
||||
@@ -62,10 +62,10 @@ func handleConn(c net.Conn) error {
|
||||
return errors.New("conn is nil")
|
||||
}
|
||||
for {
|
||||
buffer, n, err := ConnRead(c)
|
||||
printRemoteAddr := c.RemoteAddr().String()
|
||||
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
||||
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
|
||||
buffer, n, err := ConnRead(c)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
fmt.Println("connection close")
|
||||
@@ -78,6 +78,17 @@ func handleConn(c net.Conn) error {
|
||||
PrintObject.DelPrintObj(printNo)
|
||||
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
||||
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
|
||||
}
|
||||
@@ -344,11 +355,11 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("-------close1 := %s", key)
|
||||
t.getClients(key).C.Close()
|
||||
close(t.MsgMap[key])
|
||||
close(t.CallBackMap[key])
|
||||
t.delConn(key)
|
||||
//t.delConn(key)
|
||||
t.clear(key)
|
||||
|
||||
// 链接出错,彻底删除换成
|
||||
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||
|
||||
@@ -159,7 +159,6 @@ func (t *TcpClient) clear(key string) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
t.Clients[key].C.Close()
|
||||
globals.SugarLogger.Debugf("-------close3 := %s", key)
|
||||
delete(t.Clients, key)
|
||||
close(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) {
|
||||
if printNo == "120220915001467" {
|
||||
globals.SugarLogger.Debugf("------------printStatus := %s,%d", printNo, status)
|
||||
}
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
|
||||
@@ -47,9 +47,11 @@ func (w *Worker) Start() {
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -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) {
|
||||
p.wg.Add(1)
|
||||
p.jobChannel <- func() {
|
||||
job()
|
||||
p.wg.Done()
|
||||
}
|
||||
go func() {
|
||||
p.jobChannel <- func() {
|
||||
defer p.wg.Done()
|
||||
job()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (p *Pool) Wait() {
|
||||
p.wg.Wait()
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func SendSMSMsg(mobileList []string, signName, templateCode string, templatePara
|
||||
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
||||
for _, mobileNum := range mobileList {
|
||||
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 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)
|
||||
|
||||
@@ -124,3 +124,39 @@ func DeletePrintMsg() {
|
||||
globals.SugarLogger.Debugf("定时删除超过一个月的打印信息:%d 条", num)
|
||||
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"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-print/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -113,13 +113,13 @@ func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error)
|
||||
for i := 0; i < len(skuList); i++ {
|
||||
printMsg += userTempMap["skuName"]
|
||||
printMsg += userTempMap["skuNumber"]
|
||||
printMsg += userTempMap["skuPrice"]
|
||||
printMsg += userTempMap["skuAllPrice"]
|
||||
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuCount, skuList[i].SalePrice, skuList[i].TotalCountPrice)
|
||||
if skuList[i].Upc != "" {
|
||||
printMsg += userTempMap["skuUpc"]
|
||||
printValue = append(printValue, skuList[i].Upc)
|
||||
}
|
||||
//printMsg += userTempMap["skuPrice"]
|
||||
//printMsg += userTempMap["skuAllPrice"]
|
||||
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuCount /*skuList[i].SalePrice, skuList[i].TotalCountPrice*/)
|
||||
//if skuList[i].Upc != "" {
|
||||
// printMsg += userTempMap["skuUpc"]
|
||||
// printValue = append(printValue, skuList[i].Upc)
|
||||
//}
|
||||
|
||||
}
|
||||
printMsg += userTempMap["allSkuTypeCount"]
|
||||
@@ -138,10 +138,18 @@ func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error)
|
||||
case "title":
|
||||
printMsg += userTempMap[v]
|
||||
case "qrcOrder": // 老版打印机展示不要
|
||||
//printMsg += userTempMap[v]
|
||||
//printValue = append(printValue, param[v])
|
||||
printMsg += `<b>%s #%s</b>`
|
||||
printValue = append(printValue, param["vendorName"], param["vendorOrderNo"])
|
||||
//printMsg += `<b>%s #%s</b>`
|
||||
//printValue = append(printValue, param["vendorName"], param["vendorOrderNo"])
|
||||
if param["vendorName"] == "京东到家" {
|
||||
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:
|
||||
printMsg += userTempMap[v]
|
||||
printValue = append(printValue, param[v])
|
||||
@@ -211,7 +219,7 @@ func PrinterOrderVoice(param map[string]string, setting *model.PrintSettingObj,
|
||||
// 订单状态
|
||||
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) {
|
||||
// return "", err
|
||||
//}
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestQueryExpressPrice(t *testing.T) {
|
||||
SendPhone: "18981810340",
|
||||
ChannelType: 2,
|
||||
}
|
||||
data,err := QueryExpressPrice(param)
|
||||
data, err := QueryExpressPrice(param)
|
||||
fmt.Println(err)
|
||||
fmt.Println(data)
|
||||
}
|
||||
|
||||
@@ -218,6 +218,43 @@ func (c *ApiController) AddPrinter(dataMap map[string]interface{}) (data, errCod
|
||||
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) {
|
||||
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/password"
|
||||
_ "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/mt"
|
||||
_ "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/jds"
|
||||
//_ "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/taobao"
|
||||
_ "git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
_ "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"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user