将菜市蜂鸟信息通知到果园去

This commit is contained in:
邹宗楠
2024-01-19 15:36:42 +08:00
parent b7100abe64
commit e523a00c91
5 changed files with 89 additions and 30 deletions

View File

@@ -2,6 +2,7 @@ package tasks
import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
"io/ioutil"
"net/http"
"time"
@@ -20,7 +21,6 @@ import (
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego/client/orm"
beego "github.com/astaxie/beego/server/web"
)
const (
@@ -159,14 +159,11 @@ func RefreshFnToken() (err error) {
dao.ExecuteSQL(dao.GetDB(), sql, []interface{}{
token, refreshToken, "fn",
})
//}
if beego.BConfig.RunMode == "jxgy" {
config := &legacymodel.Config{}
sql := `SELECT * FROM config WHERE thirdparty = 'fn'`
if err := dao.GetRow(dao.GetDB(), &config, sql, nil); err == nil {
token = config.Token
}
if _, err = fnpsapi.HttpToGuoYuanFN(map[string]interface{}{"token": curConfig.Token, "refresh_token": curConfig.RefreshToken}, fnpsapi.FengNiaoCallbackTypeToken); err != nil {
globals.SugarLogger.Debugf("菜市token通知到果园错误:%v", err)
}
return token, expireTimeStr, refreshToken
}, func(value, v2 string) {
api.FnAPI.SetToken(value)

View File

@@ -147,7 +147,14 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S
}
// 蜂鸟门店状态改变
func OnStoreStatus(msg *fnpsapi.ChainstoreStatusNotify) (retVal *fnpsapi.CallbackResponse) {
func OnStoreStatus(msg *fnpsapi.ChainstoreStatusNotify, reallyData *fnpsapi.ShortStatus) (retVal *fnpsapi.CallbackResponse) {
store, err := dao.GetStoreDetail2(dao.GetDB(), 0, msg.Param.OutShopCode, model.VendorIDFengNiao)
if store == nil || store.ID == model.NO || err != nil {
if _, err = fnpsapi.HttpToGuoYuanFN(utils.Struct2MapByJson(reallyData), fnpsapi.FengNiaoCallbackTypeStore); err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
return fnpsapi.Err2CallbackResponse(nil, "")
}
return CurDeliveryHandler.OnStoreStatus(msg)
}

View File

@@ -7,6 +7,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/partner/purchase/tao_vegetable"
"strconv"
"strings"
"time"
@@ -247,6 +248,15 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
if err := utils.Map2StructByJson(msg.Param, cc, true); err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
good, err := dao.GetSimpleOrder(dao.GetDB(), cc.PartnerOrderCode)
if good == nil || good.VendorOrderID == "" || err != nil {
if _, err = fnpsapi.HttpToGuoYuanFN(utils.Struct2MapByJson(resultParam), fnpsapi.FengNiaoCallbackTypeOrder); err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
return fnpsapi.Err2CallbackResponse(nil, "")
}
// 多次取消,只处理第一次
if cc.OrderStatus == fnpsapi.OrderStatusAcceptCacle {
bill, err := partner.CurOrderManager.LoadWaybill(utils.Int64ToStr(cc.OrderId), model.VendorIDFengNiao)
@@ -258,18 +268,6 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
}
}
var good *model.GoodsOrder
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
sqlParams := []interface{}{cc.PartnerOrderCode}
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
if good == nil || good.VendorOrderID == "" {
_, err := fnpsapi.HttpToGuoYuanFN(utils.Struct2MapByJson(resultParam), "order")
if err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
return fnpsapi.Err2CallbackResponse(nil, "")
}
order := &model.Waybill{
VendorWaybillID: utils.Int64ToStr(cc.OrderId),
VendorWaybillID2: cc.PartnerOrderCode,
@@ -375,7 +373,14 @@ func tiktokStatusPush(order *model.Waybill, orderStatus int64, lng, lat, vendorO
}
// 异常报备
func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) {
func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify, reallyData *fnpsapi.ShortStatus) (retVal *fnpsapi.CallbackResponse) {
order, err := dao.GetSimpleOrder(dao.GetDB(), msg.PartnerOrderCode)
if order == nil || order.VendorOrderID == "" || err != nil {
if _, err = fnpsapi.HttpToGuoYuanFN(utils.Struct2MapByJson(reallyData), fnpsapi.FengNiaoCallbackTypeAbnormal); err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
return fnpsapi.Err2CallbackResponse(nil, "")
}
return CurDeliveryHandler.OnWaybillExcept(msg)
}
@@ -385,7 +390,7 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (re
VendorWaybillID: msg.PartnerOrderCode,
VendorWaybillID2: utils.Int64ToStr(msg.OrderId),
WaybillVendorID: model.VendorIDFengNiao,
CourierName: string(msg.CarrierDriverId),
CourierName: strconv.FormatInt(msg.CarrierDriverId, 10),
CourierMobile: "",
Status: model.WaybillStatusUnknown, // todo 这里要再确定一下是否只要收到订单异常消息就只简单当成一个消息
VendorStatus: msg.AbnormalCode,

View File

@@ -131,7 +131,6 @@ func (p PrinterHandler) PrintStore(ctx *jxcontext.Context, store *model.Store, s
}
func (p PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
globals.SugarLogger.Debugf("==============storeDetail := %s", utils.Format4Output("=====================kkk", false))
if len(order.Skus) == 0 {
return
}
@@ -151,8 +150,6 @@ func (p PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printTy
return nil, nil
}
globals.SugarLogger.Debugf("=======PrintCancelOrRefundOrder== : %s , %s", utils.Format4Output(content, false), store.PrinterSN)
return p.PrintMsg(ctx, store.PrinterSN, "", voiceType, content)
}