1
This commit is contained in:
@@ -4,16 +4,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
"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/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -42,71 +35,73 @@ func formalizeTagList(mtwmTagList string) (outTagList string) {
|
||||
return outTagList
|
||||
}
|
||||
|
||||
// 获取评价信息
|
||||
func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) {
|
||||
//storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, "", "", "")
|
||||
////storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, "", "", "")
|
||||
////if err = err2; err != nil {
|
||||
//// return err
|
||||
////}
|
||||
//endDateStr := time.Now().Add(-24 * time.Hour).Format("20060102")
|
||||
//startDateStr := time.Now().Add(-RefreshCommentTime).Format("20060102")
|
||||
//storeIDs, _ := dao.GetOrderStoreIDs(dao.GetDB(), fromTime, toTime, model.VendorIDMTWM)
|
||||
//task := tasksch.NewParallelTask("mtwm RefreshComment", nil, jxcontext.AdminCtx,
|
||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// storeID := batchItemList[0].(int)
|
||||
// storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDMTWM, "")
|
||||
// commentList, err2 := getAPI(storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID).CommentQuery(storeDetail.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusNotReplied)
|
||||
// var orderCommentList []*model.OrderComment
|
||||
// if err = err2; err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// for _, mtwmComment := range commentList {
|
||||
// createdTime, err := utils.TryStr2Time(mtwmComment.CommentTime)
|
||||
// if err == nil {
|
||||
// orderComment := &model.OrderComment{
|
||||
// VendorOrderID: utils.Int64ToStr(mtwmComment.CommentID), // 美团评价不能得到订单号,以评价ID代替
|
||||
// VendorID: model.VendorIDMTWM,
|
||||
// UserCommentID: utils.Int64ToStr(mtwmComment.CommentID),
|
||||
// VendorStoreID: storeDetail.VendorStoreID,
|
||||
// TagList: formalizeTagList(mtwmComment.CommentLables),
|
||||
// Score: int8(mtwmComment.FoodCommentScore),
|
||||
// ModifyDuration: BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
// OriginalMsg: string(utils.MustMarshal(mtwmComment)),
|
||||
// IsReplied: int8(mtwmComment.ReplyStatus),
|
||||
// StoreID: storeDetail.ID,
|
||||
// }
|
||||
// if orderComment.IsReplied == 0 {
|
||||
// orderComment.Content = mtwmComment.CommentContent
|
||||
// orderComment.CommentCreatedAt = createdTime
|
||||
// } else {
|
||||
// orderComment.Content = mtwmComment.AddComment
|
||||
// if updatedTime, err := utils.TryStr2Time(mtwmComment.CommentTime); err == nil {
|
||||
// orderComment.CommentCreatedAt = updatedTime
|
||||
// }
|
||||
// }
|
||||
// orderCommentList = append(orderCommentList, orderComment)
|
||||
// }
|
||||
// }
|
||||
// return orderCommentList, nil
|
||||
// }, storeIDs)
|
||||
//task.Run()
|
||||
//resultList, err2 := task.GetResult(0)
|
||||
//if err = err2; err != nil {
|
||||
// return err
|
||||
//}
|
||||
endDateStr := time.Now().Add(-24 * time.Hour).Format("20060102")
|
||||
startDateStr := time.Now().Add(-RefreshCommentTime).Format("20060102")
|
||||
storeIDs, _ := dao.GetOrderStoreIDs(dao.GetDB(), fromTime, toTime, model.VendorIDMTWM)
|
||||
task := tasksch.NewParallelTask("mtwm RefreshComment", nil, jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeID := batchItemList[0].(int)
|
||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDMTWM, "")
|
||||
commentList, err2 := getAPI(storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID).CommentQuery(storeDetail.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusNotReplied)
|
||||
var orderCommentList []*model.OrderComment
|
||||
if err = err2; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, mtwmComment := range commentList {
|
||||
createdTime, err := utils.TryStr2Time(mtwmComment.CommentTime)
|
||||
if err == nil {
|
||||
orderComment := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(mtwmComment.CommentID), // 美团评价不能得到订单号,以评价ID代替
|
||||
VendorID: model.VendorIDMTWM,
|
||||
UserCommentID: utils.Int64ToStr(mtwmComment.CommentID),
|
||||
VendorStoreID: storeDetail.VendorStoreID,
|
||||
TagList: formalizeTagList(mtwmComment.CommentLables),
|
||||
Score: int8(mtwmComment.FoodCommentScore),
|
||||
ModifyDuration: BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
OriginalMsg: string(utils.MustMarshal(mtwmComment)),
|
||||
IsReplied: int8(mtwmComment.ReplyStatus),
|
||||
StoreID: storeDetail.ID,
|
||||
}
|
||||
if orderComment.IsReplied == 0 {
|
||||
orderComment.Content = mtwmComment.CommentContent
|
||||
orderComment.CommentCreatedAt = createdTime
|
||||
} else {
|
||||
orderComment.Content = mtwmComment.AddComment
|
||||
if updatedTime, err := utils.TryStr2Time(mtwmComment.CommentTime); err == nil {
|
||||
orderComment.CommentCreatedAt = updatedTime
|
||||
}
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
}
|
||||
return orderCommentList, nil
|
||||
}, storeIDs)
|
||||
task.Run()
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
var orderCommentList []*model.OrderComment
|
||||
for _, result := range resultList {
|
||||
orderComment := result.(*model.OrderComment)
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
if len(orderCommentList) > 0 {
|
||||
err = partner.CurOrderManager.OnOrderComments(orderCommentList)
|
||||
}
|
||||
//var orderCommentList []*model.OrderComment
|
||||
//for _, result := range resultList {
|
||||
// orderComment := result.(*model.OrderComment)
|
||||
// orderCommentList = append(orderCommentList, orderComment)
|
||||
//}
|
||||
//if len(orderCommentList) > 0 {
|
||||
// err = partner.CurOrderManager.OnOrderComments(orderCommentList)
|
||||
//}
|
||||
return err
|
||||
}
|
||||
|
||||
// ReplyOrderComment 评价回复
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, vendorOrgCode string, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = getAPI(vendorOrgCode, orderComment.StoreID, orderComment.VendorStoreID).CommentAddReply(orderComment.VendorStoreID, utils.Str2Int64(orderComment.UserCommentID), replyComment)
|
||||
}
|
||||
//if globals.EnableMtwmStoreWrite {
|
||||
// err = getAPI(vendorOrgCode, orderComment.StoreID, orderComment.VendorStoreID).CommentAddReply(orderComment.VendorStoreID, utils.Str2Int64(orderComment.UserCommentID), replyComment)
|
||||
//}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user