存储所有评价

3至4星评价发送中评提醒消息
This commit is contained in:
gazebo
2019-10-12 15:01:49 +08:00
parent 1a33fb4d8f
commit 637f22a887
5 changed files with 79 additions and 56 deletions

View File

@@ -19,7 +19,8 @@ const (
COMMENT_NOT_RESOLVED = 0 //未解决的差评状态 COMMENT_NOT_RESOLVED = 0 //未解决的差评状态
COMMENT_RESOLVED = 1 //已解决的差评状态 COMMENT_RESOLVED = 1 //已解决的差评状态
JX_BAD_COMMENTS_MAX_LEVEL = 2 JX_BAD_COMMENTS_MAX_LEVEL = 2 // 差评最大分
JX_MIDDLE_COMMENTS_MAX_LEVEL = 4 // 中评最大分
COMMENTS_SCORE_ONE_ORTWO_BEGIN_DELAY_TIME = 1 * 60 //评论回复一星或二星回复延迟开始时间区间 COMMENTS_SCORE_ONE_ORTWO_BEGIN_DELAY_TIME = 1 * 60 //评论回复一星或二星回复延迟开始时间区间
COMMENTS_SCORE_ONE_ORTWO_END_DELAY_TIME = 3 * 60 //评论回复一星或二星回复延迟结束时间区间 COMMENTS_SCORE_ONE_ORTWO_END_DELAY_TIME = 3 * 60 //评论回复一星或二星回复延迟结束时间区间
@@ -86,40 +87,36 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
c.replyOrderComment(orderComment) c.replyOrderComment(orderComment)
} }
} }
if isNewComment && orderComment.Score <= JX_BAD_COMMENTS_MAX_LEVEL || !isNewComment && orderComment.Score > JX_BAD_COMMENTS_MAX_LEVEL { // 如果是直接非差评,或补评仍然是差评,忽略 if isNewComment /*&& orderComment.Score <= JX_BAD_COMMENTS_MAX_LEVEL*/ || !isNewComment && orderComment.Score > JX_BAD_COMMENTS_MAX_LEVEL { // 如果是直接非差评,或补评仍然是差评,忽略
if isNewComment { if isNewComment {
comment2.Createtime = utils.Time2Str(orderComment.CommentCreatedAt) comment2.Createtime = utils.Time2Str(orderComment.CommentCreatedAt)
comment2.Msg = orderComment.OriginalMsg
comment2.Score = int(orderComment.Score) comment2.Score = int(orderComment.Score)
comment2.Scorecontent = orderComment.Content comment2.Scorecontent = orderComment.Content
comment2.Vendertags = orderComment.TagList comment2.Vendertags = orderComment.TagList
comment2.Msg = orderComment.OriginalMsg
comment2.Status = COMMENT_NOT_RESOLVED comment2.Status = COMMENT_NOT_RESOLVED
comment2.OrderFlag = utils.Int2Str(orderComment.VendorID) comment2.OrderFlag = utils.Int2Str(orderComment.VendorID)
comment2.LastPushTime = utils.Time2Str(time.Now())
comment2.PushNo = 1
comment2.Maxmodifytime = int(orderComment.ModifyDuration) comment2.Maxmodifytime = int(orderComment.ModifyDuration)
if orderComment.VendorID != model.VendorIDELM {
var order *model.GoodsOrder order, _ := partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, orderComment.VendorID)
if true /*orderComment.VendorID != model.VendorIDEBAI*/ { if order != nil {
order, _ = partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, orderComment.VendorID) orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
} if order.ConsigneeMobile2 != "" {
if order != nil { orderComment.ConsigneeMobile = order.ConsigneeMobile2
orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order) } else {
if order.ConsigneeMobile2 != "" { orderComment.ConsigneeMobile = order.ConsigneeMobile
orderComment.ConsigneeMobile = order.ConsigneeMobile2
} else {
orderComment.ConsigneeMobile = order.ConsigneeMobile
}
}
if orderComment.StoreID > 0 {
comment2.Jxstoreid = utils.Int2Str(orderComment.StoreID)
}
comment2.Userphone = orderComment.ConsigneeMobile
if orderComment.StoreID > 0 && orderComment.Score <= JX_BAD_COMMENTS_MAX_LEVEL && time.Now().Sub(orderComment.CommentCreatedAt) < MAX_REAPLY_TIME {
weixinmsg.PushJDBadCommentToWeiXin(comment2)
} }
} }
if orderComment.StoreID > 0 {
comment2.Jxstoreid = utils.Int2Str(orderComment.StoreID)
}
comment2.Userphone = orderComment.ConsigneeMobile
if comment2.Jxstoreid != "" && orderComment.Score <= JX_MIDDLE_COMMENTS_MAX_LEVEL && time.Now().Sub(orderComment.CommentCreatedAt) < MAX_REAPLY_TIME {
comment2.LastPushTime = utils.Time2Str(time.Now())
comment2.PushNo = 1
weixinmsg.PushJDBadCommentToWeiXin(comment2, orderComment.Score <= JX_BAD_COMMENTS_MAX_LEVEL)
}
} else { // 修改评价高于JX_BAD_COMMENTS_MAX_LEVEL } else { // 修改评价高于JX_BAD_COMMENTS_MAX_LEVEL
if orderComment.CommentCreatedAt.Sub(str2Time(comment2.Createtime)) == 0 || if orderComment.CommentCreatedAt.Sub(str2Time(comment2.Createtime)) == 0 ||
orderComment.CommentCreatedAt.Sub(str2Time(comment2.Updatetime)) == 0 { orderComment.CommentCreatedAt.Sub(str2Time(comment2.Updatetime)) == 0 {
@@ -131,6 +128,18 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
comment2.UpdatedScorecontent = orderComment.Content comment2.UpdatedScorecontent = orderComment.Content
comment2.UpdatedVendertags = orderComment.TagList comment2.UpdatedVendertags = orderComment.TagList
comment2.Status = COMMENT_RESOLVED comment2.Status = COMMENT_RESOLVED
if comment2.Jxstoreid != "" && orderComment.Score <= JX_MIDDLE_COMMENTS_MAX_LEVEL && time.Now().Sub(orderComment.CommentCreatedAt) < MAX_REAPLY_TIME {
comment2.LastPushTime = utils.Time2Str(time.Now())
comment2.PushNo++
comment3 := *comment2
comment3.Createtime = comment2.Updatetime
comment3.Score = comment2.UpdatedScore
comment3.Scorecontent = comment2.UpdatedScorecontent
comment3.Vendertags = comment2.UpdatedVendertags
weixinmsg.PushJDBadCommentToWeiXin(&comment3, orderComment.Score <= JX_BAD_COMMENTS_MAX_LEVEL)
}
} }
} }
if err == nil { if err == nil {

View File

@@ -10,6 +10,7 @@ import (
"time" "time"
"git.rosy.net.cn/jx-callback/business/authz/autils" "git.rosy.net.cn/jx-callback/business/authz/autils"
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
"git.rosy.net.cn/baseapi/platformapi/autonavi" "git.rosy.net.cn/baseapi/platformapi/autonavi"
"git.rosy.net.cn/baseapi/platformapi/baidunavi" "git.rosy.net.cn/baseapi/platformapi/baidunavi"
@@ -1024,12 +1025,17 @@ func DeleteStore(ctx *jxcontext.Context, storeID int) (num int64, err error) {
// return 0, errors.New("暂不支持删除京西门店") // return 0, errors.New("暂不支持删除京西门店")
} }
// 状态是未解决且初始是2星以下
func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err error) { func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err error) {
db := dao.GetDB() db := dao.GetDB()
var ctInfo struct { var ctInfo struct {
Ct int Ct int
} }
if err = dao.GetRow(db, &ctInfo, "SELECT COUNT(*) ct FROM jx_bad_comments WHERE status = 0 AND jxstoreid = ?", utils.Int2Str(storeID)); err == nil { if err = dao.GetRow(db, &ctInfo, `
SELECT COUNT(*) ct
FROM jx_bad_comments
WHERE status = ? AND jxstoreid = ? AND score <= ?
`, orderman.COMMENT_NOT_RESOLVED, utils.Int2Str(storeID), orderman.JX_BAD_COMMENTS_MAX_LEVEL); err == nil {
count = ctInfo.Ct count = ctInfo.Ct
} }
return count, err return count, err
@@ -1055,9 +1061,10 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset
if commentType != GET_ALL_COMMENTS_TYPE { if commentType != GET_ALL_COMMENTS_TYPE {
sql += " AND t1.status = ?" sql += " AND t1.status = ?"
if commentType == GET_BAD_COMMENTS_TYPE { if commentType == GET_BAD_COMMENTS_TYPE {
sqlParams = append(sqlParams, 0) sql += " AND t1.score <= ?"
sqlParams = append(sqlParams, orderman.COMMENT_NOT_RESOLVED, orderman.JX_BAD_COMMENTS_MAX_LEVEL)
} else { } else {
sqlParams = append(sqlParams, 1) sqlParams = append(sqlParams, orderman.COMMENT_RESOLVED)
} }
} }
if !utils.IsTimeZero(fromTime) { if !utils.IsTimeZero(fromTime) {

View File

@@ -397,7 +397,7 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
return err return err
} }
func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments) (err error) { func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments, isBadComment bool) (err error) {
globals.SugarLogger.Debugf("PushJDBadCommentToWeiXin orderID:%s", comment.OrderId) globals.SugarLogger.Debugf("PushJDBadCommentToWeiXin orderID:%s", comment.OrderId)
sb := new(strings.Builder) sb := new(strings.Builder)
@@ -405,7 +405,11 @@ func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments) (err error) {
sb.WriteString(comment.Userphone) sb.WriteString(comment.Userphone)
sb.WriteString(")的一条") sb.WriteString(")的一条")
sb.WriteString(utils.Int2Str(comment.Score)) sb.WriteString(utils.Int2Str(comment.Score))
sb.WriteString("星差评请商家在1小时内及时联系客户处理!") if isBadComment {
sb.WriteString("星差评请商家在1小时内及时联系客户处理!")
} else {
sb.WriteString("星中评如有必要请商家在1小时内及时联系客户处理!")
}
title := sb.String() title := sb.String()
data := map[string]interface{}{ data := map[string]interface{}{
"first": map[string]interface{}{ "first": map[string]interface{}{
@@ -604,9 +608,9 @@ func FormatDeliveryTime(order *model.GoodsOrder) string {
func genJdCommentRemark(comment *legacymodel.JxBadComments) string { func genJdCommentRemark(comment *legacymodel.JxBadComments) string {
sb := new(strings.Builder) sb := new(strings.Builder)
sb.WriteString("评标签:") sb.WriteString("评标签:")
sb.WriteString(comment.Vendertags) sb.WriteString(comment.Vendertags)
sb.WriteString(" 评内容:") sb.WriteString(" 评内容:")
sb.WriteString(comment.Scorecontent) sb.WriteString(comment.Scorecontent)
return sb.String() return sb.String()
} }

View File

@@ -3,26 +3,29 @@ package legacymodel
import "time" import "time"
type JxBadComments struct { type JxBadComments struct {
Id int `json:"id" orm:"column(id)"` Id int `json:"id" orm:"column(id)"`
CreatedAt time.Time `orm:"auto_now_add;type(datetime);null" json:"createdAt"` CreatedAt time.Time `orm:"auto_now_add;type(datetime);null" json:"createdAt"`
OrderId string `json:"order_id" orm:"column(order_id);size(25);unique" description:"订单ID"` OrderId string `json:"order_id" orm:"column(order_id);size(25);unique" description:"订单ID"`
Jxstoreid string `json:"jxstoreid" orm:"column(jxstoreid);size(11);index" description:"京西门店ID"` Jxstoreid string `json:"jxstoreid" orm:"column(jxstoreid);size(11);index" description:"京西门店ID"`
Userphone string `json:"userPhone" orm:"column(userphone);size(255);null" description:"评价的用户的联系方式"` Userphone string `json:"userPhone" orm:"column(userphone);size(255);null" description:"评价的用户的联系方式"`
Status int `json:"status" orm:"column(status)" description:"当前评论的状态(0:未解决 1:已解决)"` Status int `json:"status" orm:"column(status)" description:"当前评论的状态(0:未解决 1:已解决)"`
Createtime string `json:"createTime" orm:"column(createtime);size(255);null;index" description:"评论的创建时间"` Maxmodifytime int `json:"maxModifyTime" orm:"column(maxmodifytime);null" description:"评论可修改的最大时间"`
Maxmodifytime int `json:"maxModifyTime" orm:"column(maxmodifytime);null" description:"评论可修改的最大时间"` OrderFlag string `json:"order_flag" orm:"column(order_flag);size(255);null" description:"订单类别(0:京东 1:美团 2:饿了么)"`
Score int `json:"score4" orm:"column(score)" description:"评论的星级"`
Scorecontent string `json:"score4Content" orm:"column(scorecontent);size(255);null" description:"评论的内容"` Createtime string `json:"createTime" orm:"column(createtime);size(255);null;index" description:"评论的创建时间"`
Vendertags string `json:"venderTags" orm:"column(vendertags);size(255);null" description:"评论的标签"` Score int `json:"score4" orm:"column(score)" description:"评论的星级"`
Updatetime string `json:"updateTime" orm:"column(updatetime);size(255);null" description:"评论的修改时间"` Scorecontent string `json:"score4Content" orm:"column(scorecontent);size(255);null" description:"评论的内容"`
UpdatedScore int `json:"updatedScore" orm:"column(updated_score);null" description:"更改后的分数"` Vendertags string `json:"venderTags" orm:"column(vendertags);size(255);null" description:"评论的标签"`
UpdatedScorecontent string `json:"updatedScoreContent" orm:"column(updated_scorecontent);size(255);null" description:"更改后的评论信息"` Msg string `json:"-" orm:"column(msg);type(text)" description:"未解决差评的原始信息"`
UpdatedVendertags string `json:"updatedVenderTags" orm:"column(updated_vendertags);size(255);null" description:"更改后的标签信息"`
OrderFlag string `json:"order_flag" orm:"column(order_flag);size(255);null" description:"订单类别(0:京东 1:美团 2:饿了么)"` Updatetime string `json:"updateTime" orm:"column(updatetime);size(255);null" description:"评论的修改时间"`
Msg string `json:"-" orm:"column(msg);type(text)" description:"未解决差评的原始信息"` UpdatedScore int `json:"updatedScore" orm:"column(updated_score);null" description:"更改后的分数"`
UpdatedMsg string `json:"-" orm:"column(updated_msg);type(text);null" description:"解决后的差评的原始信息"` UpdatedScorecontent string `json:"updatedScoreContent" orm:"column(updated_scorecontent);size(255);null" description:"更改后的评论信息"`
LastPushTime string `json:"-" orm:"column(last_push_time);size(255);null" description:"上一次推送的时间"` UpdatedVendertags string `json:"updatedVenderTags" orm:"column(updated_vendertags);size(255);null" description:"更改后的标签信息"`
PushNo int `json:"-" orm:"column(push_no);null" description:"推送次数"` UpdatedMsg string `json:"-" orm:"column(updated_msg);type(text);null" description:"解决后的差评的原始信息"`
LastPushTime string `json:"-" orm:"column(last_push_time);size(255);null" description:"上一次推送的时间"`
PushNo int `json:"-" orm:"column(push_no);null" description:"推送次数"`
} }
func (*JxBadComments) TableName() string { func (*JxBadComments) TableName() string {

View File

@@ -218,8 +218,8 @@ func (c *StoreController) TmpGetJxBadCommentsNo() {
}) })
} }
// @Title 得到门店差评总数 // @Title 得到门店评价列表
// @Description 得到门店差评总数使用TmpGetJxBadComments替代 // @Description 得到门店评价列表
// @Param token header string true "认证token" // @Param token header string true "认证token"
// @Param jxStoreId query int true "门店ID" // @Param jxStoreId query int true "门店ID"
// @Param type query int true "评论类型0差评1所有" // @Param type query int true "评论类型0差评1所有"
@@ -242,8 +242,8 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() {
}) })
} }
// @Title 得到门店差评总数 // @Title 得到门店评价列表(多店)
// @Description 得到门店差评总数 // @Description 得到门店评价列表(多店)
// @Param token header string true "认证token" // @Param token header string true "认证token"
// @Param type query int true "评论类型0差评1所有2已解决" // @Param type query int true "评论类型0差评1所有2已解决"
// @Param storeIDs query string false "门店I列表" // @Param storeIDs query string false "门店I列表"