aa
This commit is contained in:
@@ -37,86 +37,86 @@ func (c *PurchaseHandler) refreshCommentOnce() {
|
||||
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
|
||||
}
|
||||
if stepToTime.Sub(stepFromTime) == 0 {
|
||||
break
|
||||
}
|
||||
storeIDs, _ := dao.GetOrderStoreIDs(dao.GetDB(), stepFromTime, stepToTime, model.VendorIDEBAI)
|
||||
for _, v := range storeIDs {
|
||||
if commentList, err := api.EbaiAPI.OrderCommetGet(utils.Int2Str(v), 0, stepToTime, stepToTime, 0); err == nil {
|
||||
for _, comment := range commentList {
|
||||
if comment.OrderID != 0 && comment.AnonymousRating == "0" && comment.CanReply == "1" {
|
||||
orderComment := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(comment.OrderID),
|
||||
VendorID: model.VendorIDEBAI,
|
||||
UserCommentID: utils.Int64ToStr(comment.OrderRateList[0].CommentID),
|
||||
TagList: "",
|
||||
Score: int8(comment.OrderRateList[0].ServiceRating),
|
||||
Content: comment.OrderRateList[0].RatingContent,
|
||||
CommentCreatedAt: utils.Timestamp2Time(comment.OrderRateList[0].RatingAt),
|
||||
IsReplied: int8(utils.Str2Int(comment.AnonymousRating)),
|
||||
ModifyDuration: EBAI_BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
OriginalMsg: string(utils.MustMarshal(comment)),
|
||||
}
|
||||
// 直接得到的订单是饿了么的,尝试统一成饿百
|
||||
if order, err := partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, model.VendorIDEBAI); err == nil {
|
||||
orderComment.VendorOrderID = order.VendorOrderID
|
||||
orderComment.VendorOrderID2 = order.VendorOrderID2
|
||||
orderComment.VendorID = model.VendorIDEBAI
|
||||
|
||||
orderComment.VendorStoreID = order.VendorStoreID
|
||||
orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
|
||||
orderComment.ConsigneeMobile = order.ConsigneeMobile
|
||||
} else {
|
||||
globals.SugarLogger.Infof("RefreshComment, load orderID:%s failed", orderComment.VendorOrderID)
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
//stepGap := 24 * time.Hour
|
||||
//stepFromTime := fromTime
|
||||
//for {
|
||||
//stepToTime := stepFromTime.Add(stepGap - time.Second)
|
||||
//if stepToTime.Sub(toTime) > 0 {
|
||||
// stepToTime = toTime
|
||||
//}
|
||||
//if stepToTime.Sub(stepFromTime) == 0 {
|
||||
// break
|
||||
//}
|
||||
storeIDs, _ := dao.GetOrderStoreIDs(dao.GetDB(), fromTime, toTime, model.VendorIDEBAI)
|
||||
for _, v := range storeIDs {
|
||||
if commentList, err := api.EbaiAPI.OrderCommetGet(utils.Int2Str(v), 0, fromTime, toTime, 0); err == nil {
|
||||
for _, comment := range commentList {
|
||||
if comment.OrderID != 0 && comment.AnonymousRating == "0" && comment.CanReply == "1" {
|
||||
orderComment := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(comment.OrderID),
|
||||
VendorID: model.VendorIDEBAI,
|
||||
UserCommentID: utils.Int64ToStr(comment.OrderRateList[0].CommentID),
|
||||
TagList: "",
|
||||
Score: int8(comment.OrderRateList[0].ServiceRating),
|
||||
Content: comment.OrderRateList[0].RatingContent,
|
||||
CommentCreatedAt: utils.Timestamp2Time(comment.OrderRateList[0].RatingAt),
|
||||
IsReplied: int8(utils.Str2Int(comment.AnonymousRating)),
|
||||
ModifyDuration: EBAI_BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
OriginalMsg: string(utils.MustMarshal(comment)),
|
||||
}
|
||||
// 直接得到的订单是饿了么的,尝试统一成饿百
|
||||
if order, err := partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, model.VendorIDEBAI); err == nil {
|
||||
orderComment.VendorOrderID = order.VendorOrderID
|
||||
orderComment.VendorOrderID2 = order.VendorOrderID2
|
||||
orderComment.VendorID = model.VendorIDEBAI
|
||||
|
||||
orderComment.VendorStoreID = order.VendorStoreID
|
||||
orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
|
||||
orderComment.ConsigneeMobile = order.ConsigneeMobile
|
||||
} else {
|
||||
globals.SugarLogger.Infof("RefreshComment, load orderID:%s failed", orderComment.VendorOrderID)
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
}
|
||||
}
|
||||
//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.VendorIDELM,
|
||||
// UserCommentID: utils.Int64ToStr(utils.MustInterface2Int64(result["comment_id"])),
|
||||
// // VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["shop_id"])), // 这个shop_id是饿了么ID,不是饿百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: EBAI_BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
// OriginalMsg: string(utils.MustMarshal(result)),
|
||||
// }
|
||||
// // 直接得到的订单是饿了么的,尝试统一成饿百
|
||||
// if order, err := partner.CurOrderManager.LoadOrder2(orderComment.VendorOrderID, model.VendorIDEBAI); err == nil {
|
||||
// orderComment.VendorOrderID = order.VendorOrderID
|
||||
// orderComment.VendorOrderID2 = order.VendorOrderID2
|
||||
// orderComment.VendorID = model.VendorIDEBAI
|
||||
//
|
||||
// orderComment.VendorStoreID = order.VendorStoreID
|
||||
// orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// orderComment.ConsigneeMobile = order.ConsigneeMobile
|
||||
// } else {
|
||||
// globals.SugarLogger.Infof("RefreshComment, load orderID:%s failed", orderComment.VendorOrderID)
|
||||
// }
|
||||
// orderCommentList = append(orderCommentList, orderComment)
|
||||
// }
|
||||
//}
|
||||
if stepToTime.Sub(toTime) == 0 {
|
||||
break
|
||||
}
|
||||
stepFromTime = stepToTime.Add(time.Second)
|
||||
}
|
||||
//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.VendorIDELM,
|
||||
// UserCommentID: utils.Int64ToStr(utils.MustInterface2Int64(result["comment_id"])),
|
||||
// // VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["shop_id"])), // 这个shop_id是饿了么ID,不是饿百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: EBAI_BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
// OriginalMsg: string(utils.MustMarshal(result)),
|
||||
// }
|
||||
// // 直接得到的订单是饿了么的,尝试统一成饿百
|
||||
// if order, err := partner.CurOrderManager.LoadOrder2(orderComment.VendorOrderID, model.VendorIDEBAI); err == nil {
|
||||
// orderComment.VendorOrderID = order.VendorOrderID
|
||||
// orderComment.VendorOrderID2 = order.VendorOrderID2
|
||||
// orderComment.VendorID = model.VendorIDEBAI
|
||||
//
|
||||
// orderComment.VendorStoreID = order.VendorStoreID
|
||||
// orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// orderComment.ConsigneeMobile = order.ConsigneeMobile
|
||||
// } else {
|
||||
// globals.SugarLogger.Infof("RefreshComment, load orderID:%s failed", orderComment.VendorOrderID)
|
||||
// }
|
||||
// orderCommentList = append(orderCommentList, orderComment)
|
||||
// }
|
||||
//}
|
||||
//if stepToTime.Sub(toTime) == 0 {
|
||||
// break
|
||||
//}
|
||||
//stepFromTime = stepToTime.Add(time.Second)
|
||||
//}
|
||||
if err == nil && len(orderCommentList) > 0 {
|
||||
err = partner.CurOrderManager.OnOrderComments(orderCommentList)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user