增加美团差评是获取到真实订单号

This commit is contained in:
邹宗楠
2024-07-17 16:55:37 +08:00
parent 97b0ed93ef
commit d4bc6f1946
3 changed files with 81 additions and 17 deletions

View File

@@ -0,0 +1,46 @@
package dao
import (
"git.rosy.net.cn/jx-print/dao"
"time"
)
// GetBadCommentOrderId 根据差评商品列表获取订单号
func GetBadCommentOrderId(jxStoreId int, startTime, endTime time.Time, foodNameList []string) (string, error) {
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`
sqlParams = append(sqlParams, []interface{}{
jxStoreId,
startTime,
endTime,
foodNameList,
})
commentOrder := make([]*badCommentOrder, 0, 0)
if err := GetRows(GetDB(), &commentOrder, sql, sqlParams...); err != nil {
return "", err
}
// 全等于的话就是目标订单
for _, v := range commentOrder {
if v.Count == len(foodNameList) {
return v.VendorOrderId, nil
}
}
// 是在不行误差有一两个商品也行
for _, v := range commentOrder {
if v.Count == len(foodNameList)-1 {
return v.VendorOrderId, nil
}
}
return "", nil
}
type badCommentOrder struct {
Count int `json:"count"`
VendorOrderId string `json:"vendor_order_id"`
}