- refactor order comment

This commit is contained in:
gazebo
2019-03-14 09:37:48 +08:00
parent 7234520503
commit 227f485691
3 changed files with 37 additions and 28 deletions

View File

@@ -26,7 +26,7 @@ const (
COMMENTS_SCORE_FOUR_ORFIVE_BEGIN_DELAY_TIME = 2 * 60 //评论回复四星或五星回复延迟开始时间区间
COMMENTS_SCORE_FOUR_ORFIVE_END_DELAY_TIME = 5 * 60 //评论回复四星或五星回复延迟结束时间区间
MAX_REAPLY_TIME = 4 * time.Hour
MAX_REAPLY_TIME = 2 * time.Hour
)
type tReplyConfig struct {
@@ -71,18 +71,6 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
db := dao.GetDB()
for _, orderComment := range orderCommentList {
globals.SugarLogger.Debugf("OnOrderComments, orderID:%s", orderComment.VendorOrderID)
var order *model.GoodsOrder
if orderComment.VendorID == model.VendorIDEBAI {
if realVendorID := jxutils.GetPossibleVendorIDFromVendorOrderID(orderComment.VendorOrderID); realVendorID == model.VendorIDELM {
if order, err = partner.CurOrderManager.LoadOrder2(orderComment.VendorOrderID, model.VendorIDEBAI); err == nil {
orderComment.VendorOrderID = order.VendorOrderID
} else {
globals.SugarLogger.Infof("OnOrderComments, load orderID:%s failed", orderComment.VendorOrderID)
err = nil
continue
}
}
}
comment2 := &legacymodel.JxBadComments2{
OrderId: orderComment.VendorOrderID,
}
@@ -110,11 +98,15 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
comment2.LastPushTime = utils.Time2Str(time.Now())
comment2.PushNo = 1
comment2.Maxmodifytime = int(orderComment.ModifyDuration)
if order == nil {
order, err = partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, orderComment.VendorID)
}
if err == nil {
orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
if orderComment.VendorID != model.VendorIDELM {
var order *model.GoodsOrder
if orderComment.VendorID != model.VendorIDEBAI {
order, err = partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, orderComment.VendorID)
}
if order != nil {
orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
orderComment.ConsigneeMobile = order.ConsigneeMobile
}
if orderComment.StoreID > 0 {
comment2.Jxstoreid = utils.Int2Str(orderComment.StoreID)
}

View File

@@ -216,14 +216,16 @@ func (o *OrderStatus) GetStatusTime() time.Time {
type OrderComment struct {
ModelIDCUL
VendorOrderID string `orm:"column(vendor_order_id);size(48);unique" json:"vendorOrderID"`
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid
UserCommentID string `orm:"column(user_comment_id);size(48)" json:"userCommentID"`
IsReplied int8
Status int8
ModifyDuration int8 // 改评价的小时数
VendorOrderID string `orm:"column(vendor_order_id);size(48);unique" json:"vendorOrderID"`
VendorOrderID2 string `orm:"column(vendor_order_id2);size(48);unique" json:"vendorOrderID2"`
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
UserCommentID string `orm:"column(user_comment_id);size(48)" json:"userCommentID"`
IsReplied int8
Status int8
ModifyDuration int8 // 改评价的小时数
TagList string
Score int8

View File

@@ -5,6 +5,7 @@ import (
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner"
@@ -42,7 +43,7 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
for _, result := range resultList {
orderComment := &model.OrderComment{
VendorOrderID: utils.Interface2String(result["order_id"]),
VendorID: model.VendorIDEBAI,
VendorID: model.VendorIDELM,
UserCommentID: utils.Int64ToStr(utils.MustInterface2Int64(result["comment_id"])),
VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["shop_id"])),
TagList: "",
@@ -53,6 +54,17 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
ModifyDuration: 24,
OriginalMsg: string(utils.MustMarshal(result)),
}
// 直接得到的订单是饿了么的,尝试统一成饿百
if order, err := partner.CurOrderManager.LoadOrder2(orderComment.VendorOrderID, model.VendorIDELM); err == nil {
orderComment.VendorOrderID2 = orderComment.VendorOrderID
orderComment.VendorOrderID = order.VendorOrderID
orderComment.VendorID = model.VendorIDEBAI
orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
orderComment.ConsigneeMobile = order.ConsigneeMobile
} else {
globals.SugarLogger.Infof("RefreshComment, load orderID:%s failed", orderComment.VendorOrderID)
}
orderCommentList = append(orderCommentList, orderComment)
}
} else {
@@ -71,5 +83,8 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
}
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
return api.EbaiAPI.OrderRatesReply("", utils.Str2Int64(orderComment.VendorStoreID), orderComment.UserCommentID, replyComment)
if orderComment.VendorStoreID != "" && orderComment.UserCommentID != "" {
err = api.EbaiAPI.OrderRatesReply("", utils.Str2Int64(orderComment.VendorStoreID), orderComment.UserCommentID, replyComment)
}
return err
}