Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -153,6 +153,21 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
|||||||
ActualFee: utils.Float64TwoInt64(sfReallyPrice),
|
ActualFee: utils.Float64TwoInt64(sfReallyPrice),
|
||||||
}
|
}
|
||||||
delivery.OnWaybillCreated(bill)
|
delivery.OnWaybillCreated(bill)
|
||||||
|
//todo 模拟新运单回调
|
||||||
|
OnWaybillMsg(sfps2.UrlIndexRiderStatus, sfps2.RiderStatus{
|
||||||
|
ShopId: utils.Str2Float64(sfps2.SFShopStoreID),
|
||||||
|
SFOrderID: sfOrderID,
|
||||||
|
ShopOrderID: order.VendorOrderID,
|
||||||
|
UrlIndex: sfps2.UrlIndexRiderStatus,
|
||||||
|
OperatorName: "",
|
||||||
|
OperatorPhone: "",
|
||||||
|
RiderLng: 0,
|
||||||
|
RiderLat: 0,
|
||||||
|
OrderStatus: sfps2.OrderStatusNewOrder,
|
||||||
|
StatusDesc: sfps2.OrderStatusNewOrderDesc,
|
||||||
|
SFUCode: "",
|
||||||
|
PushTime: int(time.Now().Unix()),
|
||||||
|
})
|
||||||
return bill, err
|
return bill, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,16 +301,6 @@ func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode
|
|||||||
// OnWaybillMsg 配送状态更改回调
|
// OnWaybillMsg 配送状态更改回调
|
||||||
func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackResponse) {
|
func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackResponse) {
|
||||||
order := GetWaybillByStatus(urlIndex, msg)
|
order := GetWaybillByStatus(urlIndex, msg)
|
||||||
//order := &model.Waybill{
|
|
||||||
// VendorWaybillID: msg.SFOrderID,
|
|
||||||
// WaybillVendorID: model.VendorIDSFPS,
|
|
||||||
// VendorOrderID: msg.ShopOrderID,
|
|
||||||
// CourierName: msg.OperatorName,
|
|
||||||
// CourierMobile: msg.OperatorPhone,
|
|
||||||
// VendorStatus: utils.Int2Str(msg.OrderStatus),
|
|
||||||
// StatusTime: utils.Timestamp2Time(int64(msg.PushTime)),
|
|
||||||
// Remark: msg.StatusDesc,
|
|
||||||
//}
|
|
||||||
|
|
||||||
//获取实时订单信息
|
//获取实时订单信息
|
||||||
sfOrder, err := api.SfPsAPI.GetOrderStatus(order.VendorWaybillID)
|
sfOrder, err := api.SfPsAPI.GetOrderStatus(order.VendorWaybillID)
|
||||||
@@ -406,7 +411,7 @@ func OnWaybillExceptSF(msg *sfps2.RiderException) (retVal *sfps2.CallbackRespons
|
|||||||
CourierName: msg.OperatorName,
|
CourierName: msg.OperatorName,
|
||||||
CourierMobile: "",
|
CourierMobile: "",
|
||||||
Status: model.WaybillStatusUnknown, // todo 这里要再确定一下是否只要收到订单异常消息就只简单当成一个消息
|
Status: model.WaybillStatusUnknown, // todo 这里要再确定一下是否只要收到订单异常消息就只简单当成一个消息
|
||||||
VendorStatus: utils.Int2Str(msg.OrderStatus),
|
VendorStatus: utils.Float64ToStr(msg.OrderStatus),
|
||||||
StatusTime: utils.Timestamp2Time(int64(msg.PushTime)),
|
StatusTime: utils.Timestamp2Time(int64(msg.PushTime)),
|
||||||
}
|
}
|
||||||
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(msg.ShopOrderID)
|
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(msg.ShopOrderID)
|
||||||
@@ -427,7 +432,7 @@ func GetWaybillByStatus(urlIndex string, msg interface{}) *model.Waybill {
|
|||||||
VendorOrderID: retVal.ShopOrderID,
|
VendorOrderID: retVal.ShopOrderID,
|
||||||
CourierName: retVal.OperatorName,
|
CourierName: retVal.OperatorName,
|
||||||
CourierMobile: retVal.OperatorPhone,
|
CourierMobile: retVal.OperatorPhone,
|
||||||
VendorStatus: utils.Int2Str(retVal.OrderStatus),
|
VendorStatus: utils.Float64ToStr(retVal.OrderStatus),
|
||||||
StatusTime: utils.Timestamp2Time(int64(retVal.PushTime)),
|
StatusTime: utils.Timestamp2Time(int64(retVal.PushTime)),
|
||||||
Remark: retVal.StatusDesc,
|
Remark: retVal.StatusDesc,
|
||||||
}
|
}
|
||||||
@@ -440,7 +445,7 @@ func GetWaybillByStatus(urlIndex string, msg interface{}) *model.Waybill {
|
|||||||
VendorWaybillID: retVal.SFOrderID,
|
VendorWaybillID: retVal.SFOrderID,
|
||||||
WaybillVendorID: model.VendorIDSFPS,
|
WaybillVendorID: model.VendorIDSFPS,
|
||||||
VendorOrderID: retVal.ShopOrderID,
|
VendorOrderID: retVal.ShopOrderID,
|
||||||
VendorStatus: utils.Int2Str(retVal.OrderStatus),
|
VendorStatus: utils.Float64ToStr(retVal.OrderStatus),
|
||||||
StatusTime: utils.Timestamp2Time(int64(retVal.PushTime)),
|
StatusTime: utils.Timestamp2Time(int64(retVal.PushTime)),
|
||||||
Remark: retVal.StatusDesc,
|
Remark: retVal.StatusDesc,
|
||||||
}
|
}
|
||||||
@@ -454,7 +459,7 @@ func GetWaybillByStatus(urlIndex string, msg interface{}) *model.Waybill {
|
|||||||
WaybillVendorID: model.VendorIDSFPS,
|
WaybillVendorID: model.VendorIDSFPS,
|
||||||
VendorOrderID: retVal.ShopOrderID,
|
VendorOrderID: retVal.ShopOrderID,
|
||||||
CourierName: retVal.OperatorName,
|
CourierName: retVal.OperatorName,
|
||||||
VendorStatus: utils.Int2Str(retVal.OrderStatus),
|
VendorStatus: utils.Float64ToStr(retVal.OrderStatus),
|
||||||
StatusTime: utils.Timestamp2Time(int64(retVal.PushTime)),
|
StatusTime: utils.Timestamp2Time(int64(retVal.PushTime)),
|
||||||
Remark: retVal.StatusDesc,
|
Remark: retVal.StatusDesc,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,10 +79,7 @@ func PingTimer() {
|
|||||||
go func() {
|
go func() {
|
||||||
ticker := time.NewTicker(heartbeatInterval)
|
ticker := time.NewTicker(heartbeatInterval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
//测试用
|
|
||||||
//i := 0
|
|
||||||
for {
|
for {
|
||||||
//i++
|
|
||||||
<-ticker.C
|
<-ticker.C
|
||||||
for clientId, conn := range Manager.AllClient() {
|
for clientId, conn := range Manager.AllClient() {
|
||||||
if conn.ClientType == ClientTypeJx {
|
if conn.ClientType == ClientTypeJx {
|
||||||
@@ -93,12 +90,14 @@ func PingTimer() {
|
|||||||
if err := ConnRender(conn.Socket, renderData{ClientId: clientId}); err != nil {
|
if err := ConnRender(conn.Socket, renderData{ClientId: clientId}); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("PingTimer jx clientID ")
|
||||||
} else {
|
} else {
|
||||||
if err := conn.Socket.WriteMessage(websocket.TextMessage, []byte(HeartCheckMsg)); err != nil {
|
if err := conn.Socket.WriteMessage(websocket.TextMessage, []byte(HeartCheckMsg)); err != nil {
|
||||||
fmt.Printf("PingTimer mtHeartBeat err:%v", err)
|
fmt.Printf("PingTimer mtHeartBeat err:%v", err)
|
||||||
//对美团重新建立连接
|
//对美团重新建立连接
|
||||||
MtInit()
|
MtInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,7 +158,7 @@ func (c *Client) Read() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("Client Read:receive: %s\n", string(msg))
|
fmt.Printf("Client Read:receive: %s\n", string(msg))
|
||||||
SendToVendor(msg)
|
//SendToVendor(msg)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/im"
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/im"
|
||||||
"github.com/astaxie/beego/server/web"
|
"github.com/astaxie/beego/server/web"
|
||||||
@@ -78,12 +80,17 @@ func (c *IMController) SetImMsgRead() {
|
|||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /SendToVendor [post]
|
// @router /SendToVendor [post]
|
||||||
//func (c *IMController) SendToVendor() {
|
func (c *IMController) SendToVendor() {
|
||||||
// c.callSendToVendor(func(params *tImSendToVendorParams) (retVal interface{}, errCode string, err error) {
|
c.callSendToVendor(func(params *tImSendToVendorParams) (retVal interface{}, errCode string, err error) {
|
||||||
// var sendData im.SendData
|
var sendData im.SendData
|
||||||
// if err = json.Unmarshal([]byte(params.SendData), &sendData); err == nil {
|
b := bytes.NewBufferString(params.SendData)
|
||||||
// im.SendToVendor(sendData)
|
decoder := json.NewDecoder(b)
|
||||||
// }
|
_ = decoder.Decode(&sendData)
|
||||||
// return nil, "", err
|
fmt.Println(sendData)
|
||||||
// })
|
|
||||||
//}
|
if dataStr, err := json.Marshal(sendData); err == nil {
|
||||||
|
im.SendToVendor(dataStr)
|
||||||
|
}
|
||||||
|
return nil, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -4393,6 +4393,14 @@ func init() {
|
|||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
|
||||||
|
web.ControllerComments{
|
||||||
|
Method: "SendToVendor",
|
||||||
|
Router: `/SendToVendor`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
|
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
|
||||||
web.ControllerComments{
|
web.ControllerComments{
|
||||||
Method: "StartWebSocket",
|
Method: "StartWebSocket",
|
||||||
|
|||||||
Reference in New Issue
Block a user