1
This commit is contained in:
@@ -72,7 +72,7 @@ func (c *PurchaseHandler) makeAfsOrderInfoReverseRefund(msg *ebaiapi.CallbackMsg
|
||||
return nil, err
|
||||
}
|
||||
for _, sku := range refundSkuList {
|
||||
if sku.SkuName == "配送费" {
|
||||
if sku.SkuName == "配送费" || sku.SkuName == "包装费" {
|
||||
continue
|
||||
}
|
||||
orderSku := &model.OrderSkuFinancial{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mtwm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -132,3 +133,125 @@ func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, vendorOrgCod
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetMtwmCommentList4ShanGou(key string, appOrgCode string, startTime, endTime string) error {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
now = time.Now()
|
||||
)
|
||||
end, _ := utils.TryStr2Time(endTime)
|
||||
if end.Year() == now.Year() && end.Month() == now.Month() && end.Day() == now.Day() {
|
||||
return fmt.Errorf("结束时间不能是当前时间")
|
||||
}
|
||||
configList, err := dao.QueryConfigs(db, key, "Cookie", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(configList) != model.YES {
|
||||
return fmt.Errorf("查询异常,请输入正确的key或者添加此key")
|
||||
}
|
||||
|
||||
param := map[string]interface{}{
|
||||
"wmPoiId": -1,
|
||||
"appType": 3,
|
||||
"pageNum": 1,
|
||||
"rate": 0,
|
||||
"reply": -1,
|
||||
"context": -1,
|
||||
"startDate": startTime,
|
||||
"endDate": endTime,
|
||||
"timeType": 4,
|
||||
}
|
||||
|
||||
commentList, err := getAPI(appOrgCode, 0, "").GetComment4ShanGou(param, true, configList[0].Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(commentList) == model.NO {
|
||||
return fmt.Errorf("查询参数暂未获取到数据")
|
||||
}
|
||||
// 差评订单数据
|
||||
orderCommentList := CommentListData(db, commentList, startTime, endTime)
|
||||
globals.SugarLogger.Debugf("orderCommentList := %s", utils.Format4Output(orderCommentList, false))
|
||||
if len(orderCommentList) > 0 {
|
||||
return partner.CurOrderManager.OnOrderComments(orderCommentList)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CommentListData(db *dao.DaoDB, skuList []*mtwmapi.CommentsList, startTime, endTime string) []*model.OrderComment {
|
||||
st, _ := utils.TryStr2Time(startTime)
|
||||
et, _ := utils.TryStr2Time(endTime)
|
||||
orderCommentList := make([]*model.OrderComment, 0, len(skuList))
|
||||
|
||||
for _, mtwmComment := range skuList {
|
||||
createdTime, _ := utils.TryStr2Time(mtwmComment.CreateTime)
|
||||
orderComment := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(mtwmComment.Id), // 美团评价不能得到订单号,以评价ID代替
|
||||
VendorID: model.VendorIDMTWM,
|
||||
UserCommentID: utils.Int64ToStr(mtwmComment.UserId),
|
||||
VendorStoreID: utils.Int2Str(mtwmComment.WmPoiId),
|
||||
TagList: "",
|
||||
Score: int8(mtwmComment.FoodCommentScore),
|
||||
ModifyDuration: BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
OriginalMsg: string(utils.MustMarshal(mtwmComment)),
|
||||
IsReplied: 0,
|
||||
StoreID: 0,
|
||||
}
|
||||
if len(mtwmComment.ECommentList) != 0 {
|
||||
orderComment.IsReplied = 1
|
||||
}
|
||||
|
||||
if orderComment.IsReplied == 0 {
|
||||
orderComment.Content = mtwmComment.MasterCleanComment
|
||||
orderComment.CommentCreatedAt = createdTime
|
||||
} else {
|
||||
orderComment.Content = mtwmComment.Comment
|
||||
orderComment.CommentCreatedAt = utils.Timestamp2Time(int64(mtwmComment.Utime))
|
||||
}
|
||||
|
||||
// 商品的名称集合
|
||||
foodNameList := make(map[string]int, 0)
|
||||
// 好评商品
|
||||
for _, fn := range mtwmComment.PraiseFoodList {
|
||||
foodNameList[fn] = 1
|
||||
}
|
||||
// 差评商品
|
||||
for _, fn := range mtwmComment.CriticFoodList {
|
||||
foodNameList[fn] = 1
|
||||
}
|
||||
// 列表商品
|
||||
for _, fn := range mtwmComment.SpuCommentList {
|
||||
foodNameList[fn.SpuName] = 1
|
||||
}
|
||||
// 包含()中文括号的商品
|
||||
for _, fn := range mtwmComment.OrderStatus.Details {
|
||||
if len(fn.FoodName)-strings.LastIndex(fn.FoodName, ")") > 3 {
|
||||
foodNameList[fn.FoodName] = 1
|
||||
} else {
|
||||
foodNameList[fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")]] = 1
|
||||
}
|
||||
}
|
||||
|
||||
store, err := dao.GetStoreDetail2(db, 0, orderComment.VendorStoreID, model.VendorIDMTWM)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("获取美团外卖差评列表,失败:%v", err)
|
||||
continue
|
||||
}
|
||||
orderComment.StoreID = store.ID
|
||||
|
||||
if len(foodNameList) > 0 {
|
||||
foodName := make([]string, 0, len(foodNameList))
|
||||
for fnl, _ := range foodNameList {
|
||||
foodName = append(foodName, fnl)
|
||||
}
|
||||
vendorOrderID, _ := dao.GetBadCommentOrderId(store.ID, st.AddDate(0, 0, -7), et.AddDate(0, 0, 7), foodName)
|
||||
if vendorOrderID != "" {
|
||||
orderComment.VendorOrderID2 = vendorOrderID
|
||||
}
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
|
||||
return orderCommentList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user