- refactor bad comment
This commit is contained in:
@@ -56,6 +56,7 @@ type IOrderManager interface {
|
||||
UpdateOrderStatusAndFlag(order *model.GoodsOrder) (err error)
|
||||
|
||||
LoadWaybill(vendorWaybillID string, waybillVendorID int) (bill *model.Waybill, err error)
|
||||
OnOrderComments(orderCommentList []*model.OrderComment) (err error)
|
||||
}
|
||||
|
||||
// purchase handler中
|
||||
@@ -99,6 +100,8 @@ type IPurchasePlatformHandler interface {
|
||||
DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error)
|
||||
GetVendorID() int
|
||||
RefreshRealMobile(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error)
|
||||
|
||||
ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error)
|
||||
}
|
||||
|
||||
// db *dao.DaoDB,
|
||||
|
||||
71
business/partner/purchase/ebai/order_comment.go
Normal file
71
business/partner/purchase/ebai/order_comment.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package ebai
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
RefreshCommentTime = 4 * time.Hour
|
||||
RefreshCommentTimeInterval = 10 * time.Minute
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) StartRefreshComment() {
|
||||
c.RefreshComment(time.Now().Add(-RefreshCommentTime), time.Now())
|
||||
time.AfterFunc(RefreshCommentTimeInterval, func() {
|
||||
c.StartRefreshComment()
|
||||
})
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) {
|
||||
globals.SugarLogger.Debugf("RefreshComment fromTime:%s, toTime:%s", utils.Time2Str(fromTime), utils.Time2Str(toTime))
|
||||
var orderCommentList []*model.OrderComment
|
||||
stepGap := 24 * time.Hour
|
||||
stepFromTime := fromTime
|
||||
for {
|
||||
stepToTime := stepFromTime.Add(stepGap - time.Second)
|
||||
if stepToTime.Sub(toTime) > 0 {
|
||||
stepToTime = toTime
|
||||
}
|
||||
resultList, err2 := api.EbaiAPI.GetEleCommentList(stepFromTime, stepToTime, "", "", ebaiapi.ReplyStatusAll, ebaiapi.CommentLevelAll, ebaiapi.CommentContentAll)
|
||||
if err = err2; err == nil {
|
||||
for _, result := range resultList {
|
||||
orderComment := &model.OrderComment{
|
||||
VendorOrderID: utils.Interface2String(result["order_id"]),
|
||||
VendorID: model.VendorIDEBAI,
|
||||
UserCommentID: utils.Interface2String(result["comment_id"]),
|
||||
VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["shop_id"])),
|
||||
TagList: "",
|
||||
Score: int8(utils.MustInterface2Int64(result["service_rating"])),
|
||||
Content: utils.Interface2String(result["content"]),
|
||||
CommentCreatedAt: utils.Str2Time(utils.Interface2String(result["create_time"])),
|
||||
IsReplied: int8(1 - utils.MustInterface2Int64(result["can_reply"])),
|
||||
ModifyDuration: 24,
|
||||
OriginalMsg: string(utils.MustMarshal(result)),
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("RefreshComment stepFromTime:%s, stepToTime:%s failed with error:%v", utils.Time2Str(stepFromTime), utils.Time2Str(stepToTime), err)
|
||||
break //?
|
||||
}
|
||||
if stepToTime.Sub(toTime) == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err == nil && len(orderCommentList) > 0 {
|
||||
err = partner.CurOrderManager.OnOrderComments(orderCommentList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
10
business/partner/purchase/elm/order_comment.go
Normal file
10
business/partner/purchase/elm/order_comment.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package elm
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
return err
|
||||
}
|
||||
43
business/partner/purchase/jd/order_comment.go
Normal file
43
business/partner/purchase/jd/order_comment.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err error) {
|
||||
intOrderID := utils.Str2Int64(msg.BillID)
|
||||
result, err := api.JdAPI.GetCommentByOrderId(intOrderID)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debugf("onOrderComment comment:%s", utils.Format4Output(result, true))
|
||||
orderCommend := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(utils.MustInterface2Int64(result["orderId"])),
|
||||
VendorID: model.VendorIDJD,
|
||||
UserCommentID: "",
|
||||
VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["storeId"])),
|
||||
TagList: string(utils.MustMarshal(result["venderTags"])),
|
||||
Score: int8(utils.MustInterface2Int64(result["score4"])),
|
||||
Content: utils.Interface2String(result["score4Content"]),
|
||||
CommentCreatedAt: utils.Timestamp2Time(utils.MustInterface2Int64(result["createTime"].(map[string]interface{})["time"]) / 1000),
|
||||
ModifyDuration: JDDJ_BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
OriginalMsg: string(utils.MustMarshal(result)),
|
||||
}
|
||||
if result["orgCommentContent"] != nil {
|
||||
orderCommend.IsReplied = 1
|
||||
}
|
||||
err = partner.CurOrderManager.OnOrderComments([]*model.OrderComment{orderCommend})
|
||||
}
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("onOrderComment orderID:%s failed with error:%v", msg.BillID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
return api.JdAPI.OrgReplyComment(utils.Str2Int64(orderComment.VendorOrderID), orderComment.VendorStoreID, replyComment, ctx.GetUserName())
|
||||
}
|
||||
@@ -72,6 +72,7 @@ var (
|
||||
func (c *PurchaseHandler) onOrderComment(msg *jdapi.CallbackOrderMsg) (err error) {
|
||||
globals.SugarLogger.Debugf("onOrderComment orderID:%s", msg.BillID)
|
||||
go func() error {
|
||||
c.onOrderComment2(msg)
|
||||
intOrderID := utils.Str2Int64(msg.BillID)
|
||||
result, err := api.JdAPI.GetCommentByOrderId(intOrderID)
|
||||
if err == nil {
|
||||
|
||||
10
business/partner/purchase/mtwm/order_comment.go
Normal file
10
business/partner/purchase/mtwm/order_comment.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package mtwm
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
return err
|
||||
}
|
||||
10
business/partner/purchase/weimob/wsc/order_comment.go
Normal file
10
business/partner/purchase/weimob/wsc/order_comment.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package wsc
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user