diff --git a/business/jxcallback/orderman/order_comment.go b/business/jxcallback/orderman/order_comment.go index 196e5f2fb..d5332f637 100644 --- a/business/jxcallback/orderman/order_comment.go +++ b/business/jxcallback/orderman/order_comment.go @@ -19,7 +19,8 @@ const ( COMMENT_NOT_RESOLVED = 0 //未解决的差评状态 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_END_DELAY_TIME = 3 * 60 //评论回复一星或二星回复延迟结束时间区间 @@ -86,40 +87,36 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.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 { comment2.Createtime = utils.Time2Str(orderComment.CommentCreatedAt) - comment2.Msg = orderComment.OriginalMsg comment2.Score = int(orderComment.Score) comment2.Scorecontent = orderComment.Content comment2.Vendertags = orderComment.TagList + comment2.Msg = orderComment.OriginalMsg + comment2.Status = COMMENT_NOT_RESOLVED comment2.OrderFlag = utils.Int2Str(orderComment.VendorID) - - comment2.LastPushTime = utils.Time2Str(time.Now()) - comment2.PushNo = 1 comment2.Maxmodifytime = int(orderComment.ModifyDuration) - if orderComment.VendorID != model.VendorIDELM { - var order *model.GoodsOrder - if true /*orderComment.VendorID != model.VendorIDEBAI*/ { - order, _ = partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, orderComment.VendorID) - } - if order != nil { - orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order) - if order.ConsigneeMobile2 != "" { - 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) + + order, _ := partner.CurOrderManager.LoadOrder(orderComment.VendorOrderID, orderComment.VendorID) + if order != nil { + orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order) + if order.ConsigneeMobile2 != "" { + orderComment.ConsigneeMobile = order.ConsigneeMobile2 + } else { + orderComment.ConsigneeMobile = order.ConsigneeMobile } } + 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 if orderComment.CommentCreatedAt.Sub(str2Time(comment2.Createtime)) == 0 || orderComment.CommentCreatedAt.Sub(str2Time(comment2.Updatetime)) == 0 { @@ -131,6 +128,18 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) ( comment2.UpdatedScorecontent = orderComment.Content comment2.UpdatedVendertags = orderComment.TagList 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 { diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 85582cbee..1468b01be 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -10,6 +10,7 @@ import ( "time" "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/baidunavi" @@ -1024,12 +1025,17 @@ func DeleteStore(ctx *jxcontext.Context, storeID int) (num int64, err error) { // return 0, errors.New("暂不支持删除京西门店") } +// 状态是未解决,且初始是2星以下 func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err error) { db := dao.GetDB() var ctInfo struct { 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 } return count, err @@ -1055,9 +1061,10 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset if commentType != GET_ALL_COMMENTS_TYPE { sql += " AND t1.status = ?" 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 { - sqlParams = append(sqlParams, 1) + sqlParams = append(sqlParams, orderman.COMMENT_RESOLVED) } } if !utils.IsTimeZero(fromTime) { diff --git a/business/jxutils/weixinmsg/weixinmsg.go b/business/jxutils/weixinmsg/weixinmsg.go index a47fd3d2d..048c207a4 100644 --- a/business/jxutils/weixinmsg/weixinmsg.go +++ b/business/jxutils/weixinmsg/weixinmsg.go @@ -397,7 +397,7 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) { 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) sb := new(strings.Builder) @@ -405,7 +405,11 @@ func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments) (err error) { sb.WriteString(comment.Userphone) sb.WriteString(")的一条") sb.WriteString(utils.Int2Str(comment.Score)) - sb.WriteString("星差评,请商家在1小时内及时联系客户处理!") + if isBadComment { + sb.WriteString("星差评,请商家在1小时内及时联系客户处理!") + } else { + sb.WriteString("星中评,如有必要,请商家在1小时内及时联系客户处理!") + } title := sb.String() data := map[string]interface{}{ "first": map[string]interface{}{ @@ -604,9 +608,9 @@ func FormatDeliveryTime(order *model.GoodsOrder) string { func genJdCommentRemark(comment *legacymodel.JxBadComments) string { sb := new(strings.Builder) - sb.WriteString("差评标签:") + sb.WriteString("评价标签:") sb.WriteString(comment.Vendertags) - sb.WriteString(" 差评内容:") + sb.WriteString(" 评价内容:") sb.WriteString(comment.Scorecontent) return sb.String() } diff --git a/business/model/legacymodel/jxbadcomments.go b/business/model/legacymodel/jxbadcomments.go index dfde18ec7..b5ab82c35 100644 --- a/business/model/legacymodel/jxbadcomments.go +++ b/business/model/legacymodel/jxbadcomments.go @@ -3,26 +3,29 @@ package legacymodel import "time" type JxBadComments struct { - Id int `json:"id" orm:"column(id)"` - 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"` - Jxstoreid string `json:"jxstoreid" orm:"column(jxstoreid);size(11);index" description:"京西门店ID"` - Userphone string `json:"userPhone" orm:"column(userphone);size(255);null" description:"评价的用户的联系方式"` - 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:"评论可修改的最大时间"` - Score int `json:"score4" orm:"column(score)" description:"评论的星级"` - Scorecontent string `json:"score4Content" orm:"column(scorecontent);size(255);null" description:"评论的内容"` - Vendertags string `json:"venderTags" orm:"column(vendertags);size(255);null" description:"评论的标签"` - Updatetime string `json:"updateTime" orm:"column(updatetime);size(255);null" description:"评论的修改时间"` - UpdatedScore int `json:"updatedScore" orm:"column(updated_score);null" description:"更改后的分数"` - UpdatedScorecontent string `json:"updatedScoreContent" orm:"column(updated_scorecontent);size(255);null" 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:饿了么)"` - Msg string `json:"-" orm:"column(msg);type(text)" 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:"推送次数"` + Id int `json:"id" orm:"column(id)"` + 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"` + Jxstoreid string `json:"jxstoreid" orm:"column(jxstoreid);size(11);index" description:"京西门店ID"` + Userphone string `json:"userPhone" orm:"column(userphone);size(255);null" description:"评价的用户的联系方式"` + Status int `json:"status" orm:"column(status)" description:"当前评论的状态(0:未解决 1:已解决)"` + 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:饿了么)"` + + Createtime string `json:"createTime" orm:"column(createtime);size(255);null;index" description:"评论的创建时间"` + Score int `json:"score4" orm:"column(score)" description:"评论的星级"` + Scorecontent string `json:"score4Content" orm:"column(scorecontent);size(255);null" description:"评论的内容"` + Vendertags string `json:"venderTags" orm:"column(vendertags);size(255);null" description:"评论的标签"` + Msg string `json:"-" orm:"column(msg);type(text)" description:"未解决差评的原始信息"` + + Updatetime string `json:"updateTime" orm:"column(updatetime);size(255);null" description:"评论的修改时间"` + UpdatedScore int `json:"updatedScore" orm:"column(updated_score);null" description:"更改后的分数"` + UpdatedScorecontent string `json:"updatedScoreContent" orm:"column(updated_scorecontent);size(255);null" description:"更改后的评论信息"` + UpdatedVendertags string `json:"updatedVenderTags" orm:"column(updated_vendertags);size(255);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 { diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 7f1ae40d0..b21bbad7c 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -218,8 +218,8 @@ func (c *StoreController) TmpGetJxBadCommentsNo() { }) } -// @Title 得到门店差评总数 -// @Description 得到门店差评总数(使用TmpGetJxBadComments替代) +// @Title 得到门店评价列表 +// @Description 得到门店评价列表 // @Param token header string true "认证token" // @Param jxStoreId query int true "门店ID" // @Param type query int true "评论类型,0:差评,1:所有" @@ -242,8 +242,8 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() { }) } -// @Title 得到门店差评总数 -// @Description 得到门店差评总数 +// @Title 得到门店评价列表(多店) +// @Description 得到门店评价列表(多店) // @Param token header string true "认证token" // @Param type query int true "评论类型,0:差评,1:所有,2:已解决" // @Param storeIDs query string false "门店I列表"