1
This commit is contained in:
@@ -178,6 +178,9 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
comment2.VendorOrderId = orderComment.VendorOrderID2
|
||||
_, err = dao.UpdateEntity(db, comment2, "VendorOrderId")
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
|
||||
@@ -273,7 +273,7 @@ func Init() {
|
||||
orderman.UpdateJdsOrdersStatus(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -1), time.Now())
|
||||
}, 5*time.Second, 5*time.Minute)
|
||||
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
if beego.BConfig.RunMode == "020c0aa40371cd112eecc034bb3dc094907ff925" {
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
fromData := utils.Time2Date(time.Now())
|
||||
toData := time.Now()
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-print/dao"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -10,7 +13,7 @@ func GetBadCommentOrderId(jxStoreId int, startTime, endTime time.Time, foodNameL
|
||||
sqlParams := []interface{}{}
|
||||
sql := `
|
||||
SELECT count(vendor_order_id) count,vendor_order_id FROM
|
||||
order_sku_financial WHERE jx_store_id = ? AND created_at >= ? AND created_at <= ? AND name IN (` + dao.GenQuestionMarks(len(foodNameList)) + `) GROUP BY vendor_order_id LIMIT 0, 1000`
|
||||
order_sku_financial WHERE jx_store_id = ? AND created_at >= ? AND created_at <= ? AND name IN (` + dao.GenQuestionMarks(len(foodNameList)) + `) AND is_afs_order = 0 AND vendor_id = 1 GROUP BY vendor_order_id LIMIT 0, 1000`
|
||||
sqlParams = append(sqlParams, []interface{}{
|
||||
jxStoreId,
|
||||
endTime,
|
||||
@@ -24,16 +27,51 @@ func GetBadCommentOrderId(jxStoreId int, startTime, endTime time.Time, foodNameL
|
||||
}
|
||||
|
||||
// 全等于的话就是目标订单
|
||||
vendorOrderIdList := make([]string, 0, 0)
|
||||
for _, v := range commentOrder {
|
||||
if v.Count == len(foodNameList) {
|
||||
return v.VendorOrderId, nil
|
||||
} else if v.Count-1 == len(foodNameList) || v.Count-2 == len(foodNameList) {
|
||||
vendorOrderIdList = append(vendorOrderIdList, v.VendorOrderId)
|
||||
} else if v.Count+1 == len(foodNameList) || v.Count+2 == len(foodNameList) {
|
||||
vendorOrderIdList = append(vendorOrderIdList, v.VendorOrderId)
|
||||
}
|
||||
}
|
||||
|
||||
// 是在不行误差有一两个商品也行
|
||||
for _, v := range commentOrder {
|
||||
if v.Count == len(foodNameList)-1 || v.Count == len(foodNameList)+1 {
|
||||
return v.VendorOrderId, nil
|
||||
sql2 := `SELECT * FROM order_sku_financial WHERE vendor_order_id = ? AND is_afs_order = 0 AND vendor_id = 1 `
|
||||
mathProbability := make(map[string]float64, 0)
|
||||
for _, v := range vendorOrderIdList {
|
||||
skuFinancial := make([]*model.OrderSkuFinancial, 0, 0)
|
||||
if err := GetRows(GetDB(), skuFinancial, sql2, []interface{}{v}...); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var skuMatchingCount int = 0
|
||||
for _, sf := range skuFinancial {
|
||||
for _, fnl := range foodNameList {
|
||||
if sf.Name == fnl {
|
||||
skuMatchingCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mathProbability[v] = float64(skuMatchingCount) / float64(len(skuFinancial))
|
||||
}
|
||||
|
||||
var values []float64
|
||||
for _, v := range mathProbability {
|
||||
values = append(values, v)
|
||||
}
|
||||
sort.Slice(values, func(i, j int) bool {
|
||||
if values[i] > values[j] {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
for k, v := range mathProbability {
|
||||
if v == values[0] {
|
||||
globals.SugarLogger.Debugf("==========匹配概率=========mathProbability _vendor := %s", k)
|
||||
return k, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ type OrderComment struct {
|
||||
Status int8
|
||||
ModifyDuration int16 // 改评价的小时数
|
||||
|
||||
TagList string
|
||||
TagList string // 配送标签
|
||||
Score int8
|
||||
Content string
|
||||
CommentCreatedAt time.Time
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
@@ -330,20 +331,38 @@ func (c *StoreController) TmpGetJxBadComments() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 根据cookie获取美团差评订单id(多店)不一定准确
|
||||
// @Description 根据cookie获取美团差评订单id(多店)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorID query int false "厂商ID(缺省为全部)"
|
||||
// @Param userName query string true "平台账号id"
|
||||
// @Param appOrgCode query string true "平台号"
|
||||
// @Param fromTime query string true "创建起始时间"
|
||||
// @Param toTime query string true "创建结束时间"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetOrderID4Comment [get]
|
||||
func (c *StoreController) GetOrderID4Comment() {
|
||||
c.callGetOrderID4Comment(func(params *tStoreGetOrderID4CommentParams) (retVal interface{}, errCode string, err error) {
|
||||
err = mtwm.GetMtwmCommentList4ShanGou(params.UserName, params.AppOrgCode, params.FromTime, params.ToTime)
|
||||
return nil, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到门店快递映射信息
|
||||
// @Description 得到门店快递映射信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID query int true "门店ID"
|
||||
// @Param vendorID query int false "厂商ID(缺省为全部)"
|
||||
// @Param vendorId query int false "平台id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetStoreCourierMaps [get]
|
||||
func (c *StoreController) GetStoreCourierMaps() {
|
||||
c.callGetStoreCourierMaps(func(params *tStoreGetStoreCourierMapsParams) (retVal interface{}, errCode string, err error) {
|
||||
if c.GetString("vendorID") == "" {
|
||||
params.VendorID = -1
|
||||
params.VendorId = -1
|
||||
}
|
||||
retVal, err = cms.GetStoreCourierMaps(params.Ctx, nil, params.StoreID, params.VendorID)
|
||||
retVal, err = cms.GetStoreCourierMaps(params.Ctx, nil, params.StoreID, params.VendorId)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3009,6 +3009,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetOrderID4Comment",
|
||||
Router: `/GetOrderID4Comment`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
web.ControllerComments{
|
||||
Method: "TmpGetJxBadCommentsByStoreId",
|
||||
|
||||
Reference in New Issue
Block a user