增加美团差评是获取到真实订单号

This commit is contained in:
邹宗楠
2024-07-17 16:55:37 +08:00
parent 97b0ed93ef
commit d4bc6f1946
3 changed files with 81 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
package mtwm
import (
"fmt"
"strings"
"time"
@@ -47,7 +48,9 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
//if err = err2; err != nil {
// return err
//}
endDateStr := time.Now().Add(-24 * time.Hour).Format("20060102")
startTime := time.Now().Add(-24 * time.Hour)
endTime := time.Now().Add(-RefreshCommentTime)
endDateStr := startTime.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,
@@ -55,6 +58,7 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
storeID := batchItemList[0].(int)
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDMTWM, "")
// 查询门店差评
commentList, _ := getAPI(storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID).CommentQuery(storeDetail.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusNotReplied)
var orderCommentList []*model.OrderComment
if len(commentList) == model.NO || commentList == nil {
@@ -84,6 +88,20 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
orderComment.CommentCreatedAt = updatedTime
}
}
if len(mtwmComment.CommentOrderDetail) > 0 {
foodNameList := make([]string, len(mtwmComment.CommentOrderDetail))
for _, fn := range mtwmComment.CommentOrderDetail {
if len(fn.FoodName)-strings.LastIndex(fn.FoodName, "") > 3 {
foodNameList = append(foodNameList, fn.FoodName)
} else {
foodNameList = append(foodNameList, fn.FoodName[0:strings.LastIndex(fn.FoodName, "")])
}
}
vendorOrderID, _ := dao.GetBadCommentOrderId(storeDetail.ID, startTime, endTime, foodNameList)
orderComment.VendorOrderID = fmt.Sprintf("%s:%s", vendorOrderID, orderComment.VendorOrderID)
}
orderCommentList = append(orderCommentList, orderComment)
}
}