1
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -161,19 +162,6 @@ func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, orderStatus *model
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *model.OrderStatus) (err error) {
|
func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *model.OrderStatus) (err error) {
|
||||||
// 有些平台(比如美团外卖),在新订单事件没有成功返回,但在重发订单消息前,订单状态转换,则不会再重发新订单事件,特殊处理一下
|
|
||||||
if orderStatus != nil {
|
|
||||||
if orderStatus.Status == model.OrderStatusAccepted {
|
|
||||||
if _, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == ErrCanNotFindOrder {
|
|
||||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(orderStatus.VendorID); handler != nil {
|
|
||||||
if order, err2 := handler.GetOrder(vendorOrgCode, orderStatus.VendorOrderID, ""); err2 == nil && order != nil {
|
|
||||||
c.OnOrderNew(order, orderStatus)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -182,6 +170,24 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
|
|||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// 有些平台(比如美团外卖),在新订单事件没有成功返回,但在重发订单消息前,订单状态转换,则不会再重发新订单事件,特殊处理一下
|
||||||
|
if orderStatus != nil {
|
||||||
|
if orderStatus.Status == model.OrderStatusAccepted {
|
||||||
|
if loadOrder, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == ErrCanNotFindOrder {
|
||||||
|
if handler := partner.GetPurchaseOrderHandlerFromVendorID(orderStatus.VendorID); handler != nil {
|
||||||
|
if order, err2 := handler.GetOrder(vendorOrgCode, orderStatus.VendorOrderID, ""); err2 == nil && order != nil {
|
||||||
|
c.OnOrderNew(order, orderStatus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadOrder.Status = model.OrderStatusAccepted
|
||||||
|
loadOrder.VendorStatus = tao_vegetable.OrderStatusNew
|
||||||
|
c.UpdateOrderFields(loadOrder, []string{"Status", "VendorStatus"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isDuplicated, order, err := c.addOrderStatus(orderStatus, db)
|
isDuplicated, order, err := c.addOrderStatus(orderStatus, db)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dao.Commit(db, txDB)
|
dao.Commit(db, txDB)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package dao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -1156,8 +1155,6 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat
|
|||||||
sqlParams = append(sqlParams, pageSize, offset)
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
txDB, _ := Begin(db)
|
txDB, _ := Begin(db)
|
||||||
defer Commit(db, txDB)
|
defer Commit(db, txDB)
|
||||||
globals.SugarLogger.Debugf("===============sql2 := %s", sql)
|
|
||||||
globals.SugarLogger.Debugf("===============sql2 := %s", utils.Format4Output(sqlParams, false))
|
|
||||||
if err = GetRowsTx(txDB, &orders, sql, sqlParams...); err == nil {
|
if err = GetRowsTx(txDB, &orders, sql, sqlParams...); err == nil {
|
||||||
totalCount = GetLastTotalRowCount2(db, txDB)
|
totalCount = GetLastTotalRowCount2(db, txDB)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user