This commit is contained in:
邹宗楠
2023-02-15 14:09:51 +08:00
parent 076139e600
commit eab817817f
6 changed files with 105 additions and 36 deletions

View File

@@ -7,7 +7,7 @@ import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
"github.com/astaxie/beego/server/web"
"io/ioutil"
"time"
@@ -58,8 +58,32 @@ func (c *LogisticsController) LogisticsRegister() {
}
// 查询订单的运单是否存在
data, err := dao.GetWayBillsByWayBillId(dao.GetDB(), register.TrackNo)
if err != nil {
globals.SugarLogger.Debugf("根据单号查询运单数据错误:%s", err)
// 此订单可能是果园订单
if web.BConfig.RunMode != "jxgy" && (len(data) == 0 || err != nil) {
resp, err := tiktok_store.HttpToGuoYuan(utils.Struct2Map(register, "", true), tiktok_store.CaiShiPushGyTagDeliveryRegister)
if err != nil {
c.Data["json"] = LogisticsRegisterResp{
Result: false,
ReturnCode: "1002",
Message: "单号不存在",
}
c.ServeJSON()
return
}
gyData := &LogisticsRegisterResp{}
gyBody, _ := ioutil.ReadAll(resp.Body)
if err := json.Unmarshal(gyBody, gyData); err != nil {
c.Data["json"] = LogisticsRegisterResp{
Result: false,
ReturnCode: "1002",
Message: "单号不存在",
}
c.ServeJSON()
return
}
c.Data["json"] = gyData
c.ServeJSON()
}
if len(data) == 0 || err != nil {
@@ -156,14 +180,30 @@ func (c *LogisticsController) LogisticsQuery() {
// 查询订单的运单是否存在
data, err := dao.GetWayBillsByWayBillId(dao.GetDB(), param.TrackNo)
if err != nil || len(data) == 0 {
c.Data["json"] = LogisticsQueryRest{
Result: false,
ReturnCode: "1002",
Message: "运单账号不存在",
if (err != nil || len(data) == 0) && web.BConfig.RunMode != "jxgy" {
resp, err := tiktok_store.HttpToGuoYuan(utils.Struct2Map(param, "", true), tiktok_store.CaiShiPushGyTagDeliveryDetail)
if err != nil {
c.Data["json"] = LogisticsQueryRest{
Result: false,
ReturnCode: "1002",
Message: "运单账号不存在",
}
c.ServeJSON()
return
}
wayBillDetail := &LogisticsQueryRest{}
gyBody, _ := ioutil.ReadAll(resp.Body)
if err := json.Unmarshal(gyBody, wayBillDetail); err != nil {
c.Data["json"] = LogisticsQueryRest{
Result: false,
ReturnCode: "1002",
Message: "json unmarshal",
}
c.ServeJSON()
return
}
c.Data["json"] = wayBillDetail
c.ServeJSON()
return
}
returnParam := &LogisticsQueryRest{