This commit is contained in:
邹宗楠
2024-08-05 09:57:51 +08:00
parent b3fb7884d7
commit 9cf69ecf0f
8 changed files with 203 additions and 11 deletions

View File

@@ -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
}
}

View File

@@ -369,7 +369,7 @@ type OrderComment struct {
Status int8
ModifyDuration int16 // 改评价的小时数
TagList string
TagList string // 配送标签
Score int8
Content string
CommentCreatedAt time.Time