50 lines
2.0 KiB
Go
50 lines
2.0 KiB
Go
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"
|
|
)
|
|
|
|
const (
|
|
JDDJ_BAD_COMMENTS_MAX_MODIFY_TIME = 72 // 小时
|
|
)
|
|
|
|
func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err error) {
|
|
intOrderID := utils.Str2Int64(msg.BillID)
|
|
result, err := getAPI("").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) {
|
|
if globals.ReallyReplyComment {
|
|
err = getAPI("").OrgReplyComment(utils.Str2Int64(orderComment.VendorOrderID), orderComment.VendorStoreID, replyComment, ctx.GetUserName())
|
|
}
|
|
return err
|
|
}
|