- add optional params fromTime and toTime for TmpGetJxBadCommentsByStoreId
This commit is contained in:
@@ -608,24 +608,44 @@ func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err
|
||||
return count, err
|
||||
}
|
||||
|
||||
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeID, page, size, commentType int) (retVal map[string]interface{}, err error) {
|
||||
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeID, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) {
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS *
|
||||
FROM jx_bad_comments
|
||||
WHERE jxstoreid = ?
|
||||
WHERE 1 = 1
|
||||
`
|
||||
if commentType == GET_BAD_COMMENTS_TYPE {
|
||||
sql += " AND status = 0"
|
||||
sqlParams := []interface{}{}
|
||||
if storeID > 0 {
|
||||
sql += " AND jxstoreid = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
}
|
||||
sql += " ORDER BY createtime DESC LIMIT ? OFFSET ?"
|
||||
if commentType == GET_BAD_COMMENTS_TYPE {
|
||||
sql += " AND status = ?"
|
||||
sqlParams = append(sqlParams, commentType)
|
||||
}
|
||||
if !utils.IsTimeZero(fromTime) {
|
||||
sql += " AND createtime >= ?"
|
||||
sqlParams = append(sqlParams, fromTime)
|
||||
}
|
||||
if !utils.IsTimeZero(toTime) {
|
||||
sql += " AND createtime < ?"
|
||||
sqlParams = append(sqlParams, toTime)
|
||||
}
|
||||
sql += " ORDER BY createtime DESC"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
var commentList []*legacymodel.JxBadComments
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
dao.Rollback(db)
|
||||
}()
|
||||
globals.SugarLogger.Debug(sql)
|
||||
if err = dao.GetRows(db, &commentList, sql, utils.Int2Str(storeID), size, (page-1)*size); err == nil {
|
||||
if err = dao.GetRows(db, &commentList, sql, sqlParams...); err == nil {
|
||||
retVal = map[string]interface{}{
|
||||
"total": dao.GetLastTotalRowCount(db),
|
||||
"list": commentList,
|
||||
|
||||
@@ -3,6 +3,7 @@ package tempop
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel2"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
@@ -23,6 +25,12 @@ import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
var innerDataPat *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
innerDataPat = regexp.MustCompile(`"result":(.*),"code":200`)
|
||||
}
|
||||
|
||||
func Convert2JDSPU(ctx *jxcontext.Context, count int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
@@ -772,3 +780,70 @@ func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isA
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func ReProcessJdBadComment(ctx *jxcontext.Context, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM jx_bad_comments
|
||||
`
|
||||
if !isForce {
|
||||
sql += " WHERE (createtime IS NULL OR createtime = '') OR (updatetime IS NULL OR updatetime = '')"
|
||||
}
|
||||
// sql += " LIMIT 1"
|
||||
db := dao.GetDB()
|
||||
var commentList []*legacymodel.JxBadComments
|
||||
if err = dao.GetRows(db, &commentList, sql); err == nil {
|
||||
if len(commentList) > 0 {
|
||||
rootTask := tasksch.NewParallelTask("ReProcessJdBadComment", nil, ctx.GetUserName(), func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
badComment := batchItemList[0].(*legacymodel.JxBadComments)
|
||||
comment1, _ := unmarshalCommentText(badComment.Msg)
|
||||
comment2, _ := unmarshalCommentText(badComment.UpdatedMsg)
|
||||
if len(comment1) > 0 {
|
||||
badComment.Createtime = utils.Timestamp2Str(utils.MustInterface2Int64(comment1["createTime"].(map[string]interface{})["time"]) / 1000)
|
||||
badComment.Msg = string(utils.MustMarshal(comment1))
|
||||
if len(comment2) > 0 {
|
||||
badComment.Updatetime = utils.Timestamp2Str(utils.MustInterface2Int64(comment2["createTime"].(map[string]interface{})["time"]) / 1000)
|
||||
badComment.UpdatedMsg = string(utils.MustMarshal(comment2))
|
||||
} else if badComment.UpdatedMsg != "" {
|
||||
badComment.OrderFlag = "1"
|
||||
}
|
||||
_, err = dao.UpdateEntity(db, badComment)
|
||||
}
|
||||
return nil, err
|
||||
}, commentList)
|
||||
tasksch.ManageTask(rootTask).Run()
|
||||
if !isAsync {
|
||||
_, err = rootTask.GetResult(0)
|
||||
} else {
|
||||
hint = rootTask.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func unmarshalCommentText(commentStr string) (retVal map[string]interface{}, isNeedUpdate bool) {
|
||||
var err error
|
||||
for {
|
||||
var retVal map[string]interface{} // 必须要用局部变量
|
||||
if commentStr == "" {
|
||||
return nil, false
|
||||
}
|
||||
if err = jxutils.Strings2Objs(commentStr, &retVal); err == nil {
|
||||
if retVal["data"] != nil {
|
||||
commentStr = retVal["data"].(string)
|
||||
} else if retVal["result"] != nil {
|
||||
return retVal["result"].(map[string]interface{}), true
|
||||
} else {
|
||||
return retVal, false
|
||||
}
|
||||
} else {
|
||||
strList := innerDataPat.FindStringSubmatch(commentStr)
|
||||
if strList[1] != "" {
|
||||
commentStr = strList[1]
|
||||
} else {
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ type JxBadComments struct {
|
||||
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" description:"评论的创建时间"`
|
||||
Updatetime string `json:"updateTime" orm:"column(updatetime);size(255);null" 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:"更改后的标签信息"`
|
||||
|
||||
@@ -115,7 +115,7 @@ func (c *PurchaseHandler) onOrderComment(msg *jdapi.CallbackOrderMsg) (err error
|
||||
}
|
||||
}
|
||||
} else {
|
||||
comment.Updatetime = utils.Timestamp2Str(utils.MustInterface2Int64(result["updateTime"].(map[string]interface{})["time"]) / 1000)
|
||||
comment.Updatetime = utils.Timestamp2Str(utils.MustInterface2Int64(result["createTime"].(map[string]interface{})["time"]) / 1000)
|
||||
comment.UpdatedMsg = string(utils.MustMarshal(result))
|
||||
comment.UpdatedScore = score
|
||||
comment.UpdatedScorecontent = utils.Interface2String(result["score4Content"])
|
||||
|
||||
Reference in New Issue
Block a user