1
This commit is contained in:
@@ -372,7 +372,7 @@ func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResponse) {
|
func OnWaybillMsg(req *uuptapi.WaybillCallbackParam, good *model.GoodsOrder) (resp *uuptapi.CallbackResponse) {
|
||||||
param := &model.Waybill{
|
param := &model.Waybill{
|
||||||
VendorOrderID: req.OriginID,
|
VendorOrderID: req.OriginID,
|
||||||
VendorWaybillID: req.OrderCode,
|
VendorWaybillID: req.OrderCode,
|
||||||
@@ -383,11 +383,7 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
|||||||
StatusTime: time.Now(),
|
StatusTime: time.Now(),
|
||||||
Remark: req.StateText,
|
Remark: req.StateText,
|
||||||
}
|
}
|
||||||
var good *model.GoodsOrder
|
|
||||||
var reallyPrice int64
|
var reallyPrice int64
|
||||||
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
|
|
||||||
sqlParams := []interface{}{req.OriginID}
|
|
||||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
|
||||||
param.OrderVendorID = good.VendorID
|
param.OrderVendorID = good.VendorID
|
||||||
//查询运单价格
|
//查询运单价格
|
||||||
uuPrice, err := api.UuAPI.GetOrderDetail(req.OrderCode)
|
uuPrice, err := api.UuAPI.GetOrderDetail(req.OrderCode)
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/delivery/uupt"
|
"git.rosy.net.cn/jx-callback/business/partner/delivery/uupt"
|
||||||
@@ -13,19 +19,62 @@ type UuPtController struct {
|
|||||||
web.Controller
|
web.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var UUVendorStoreIDList = new(sync.Map)
|
||||||
|
|
||||||
//运单状态回调
|
//运单状态回调
|
||||||
func (c *UuPtController) UuWaybillCallback() {
|
func (c *UuPtController) UuWaybillCallback() {
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
resp, callbackResponse := api.UuAPI.WaybillCallback(c.Ctx.Request)
|
resp, data, callbackResponse := api.UuAPI.WaybillCallback(c.Ctx.Request)
|
||||||
if callbackResponse.ReturnCode == uuptapi.ReturnFail {
|
if callbackResponse.ReturnCode == uuptapi.ReturnFail {
|
||||||
c.Data["code"] = callbackResponse
|
c.Data["code"] = callbackResponse
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
callbackResponse = uupt.OnWaybillMsg(resp)
|
|
||||||
|
if good, err := dao.GetSimpleOrder(dao.GetDB(), resp.OriginID); err == nil && good != nil {
|
||||||
|
callbackResponse = uupt.OnWaybillMsg(resp, good)
|
||||||
|
} else {
|
||||||
|
switch web.BConfig.RunMode {
|
||||||
|
case model.ServerTypeVegetable:
|
||||||
|
callbackResponse = c.UuPtPush2FruitsOrPet(model.ServerTypeFruits, data)
|
||||||
|
case model.ServerTypeFruits:
|
||||||
|
callbackResponse = c.UuPtPush2FruitsOrPet(model.ServerTypePet, data)
|
||||||
|
case model.ServerTypePet:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.Data["code"] = callbackResponse
|
c.Data["code"] = callbackResponse
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
} else {
|
} else {
|
||||||
c.Abort("404")
|
c.Abort("404")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *UuPtController) UuPtPush2FruitsOrPet(serverType string, msg string) *uuptapi.CallbackResponse {
|
||||||
|
cl := http.Client{}
|
||||||
|
var request *http.Request
|
||||||
|
var err error
|
||||||
|
switch serverType {
|
||||||
|
case model.ServerTypeFruits:
|
||||||
|
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/uuPt/uuWaybillCallback", strings.NewReader(msg))
|
||||||
|
case model.ServerTypePet:
|
||||||
|
request, err = http.NewRequest(http.MethodPost, "http://callback-gblm.jxc4.com/uuPt/uuWaybillCallback", strings.NewReader(msg))
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return uuptapi.Err2CallbackResponse(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
request.Header.Set("accept", "application/json, text/plain, */*")
|
||||||
|
resp, err := cl.Do(request)
|
||||||
|
if err != nil {
|
||||||
|
return uuptapi.Err2CallbackResponse(err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
byteData, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
result := uuptapi.CallbackResponse{}
|
||||||
|
json.Unmarshal(byteData, &result)
|
||||||
|
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user