1
This commit is contained in:
@@ -3,15 +3,15 @@ package auto_delivery
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
@@ -91,42 +91,34 @@ func AutoSettingFakeDelivery() {
|
||||
return
|
||||
}
|
||||
|
||||
// todo 修改刷单门店配置 storeId-vendorId 指定刷单门店和平台 0京东/1美团/3饿了么/14抖音/99全部平台
|
||||
|
||||
// 获取刷单门店订单
|
||||
orderList, err := dao.GetOrderListByStoreList(db, utils.StringSlice2Int64(strings.Split(configList[0].Value, ",")))
|
||||
storeList := strings.Split(configList[0].Value, ",")
|
||||
for _, v := range storeList {
|
||||
storeIdAndVendorId := strings.Split(v, "-")
|
||||
orderList, err := dao.GetOrderListByStoreList(db, []int64{utils.Str2Int64(storeIdAndVendorId[0])}, utils.Str2Int(storeIdAndVendorId[1]))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("获取门店刷单记录错误")
|
||||
return
|
||||
continue
|
||||
}
|
||||
if len(orderList) == model.NO {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range orderList {
|
||||
// 1.根据订单客户地址获取骑手列表
|
||||
riderKey := ""
|
||||
if strings.Contains(v.ConsigneeAddress, "重庆") || strings.Contains(v.ConsigneeAddress, "上海") || strings.Contains(v.ConsigneeAddress, "北京") || strings.Contains(v.ConsigneeAddress, "天津") {
|
||||
riderKey = strings.Split(v.ConsigneeAddress, "市")[0]
|
||||
} else if strings.Contains(v.ConsigneeAddress, "省") {
|
||||
riderKey = strings.Split(v.ConsigneeAddress, "省")[0]
|
||||
} else {
|
||||
storeDetail, _ := dao.GetStoreDetail(db, v.JxStoreID, 0, "")
|
||||
if strings.Contains(storeDetail.Address, "重庆") || strings.Contains(storeDetail.Address, "上海") || strings.Contains(storeDetail.Address, "北京") || strings.Contains(storeDetail.Address, "天津") {
|
||||
riderKey = strings.Split(storeDetail.Address, "市")[0]
|
||||
} else {
|
||||
riderKey = strings.Split(storeDetail.Address, "省")[0]
|
||||
if riderKey == "" {
|
||||
storeDetail, _ := dao.GetStoreDetail(db, utils.Str2Int(storeIdAndVendorId[0]), 0, "")
|
||||
place, err := dao.GetParentCodeByCode(db, storeDetail.CityCode)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("根据门店的城市code获取省份code错误: %s", err)
|
||||
return
|
||||
}
|
||||
riderKey = place.Name[0 : len(place.Name)-3]
|
||||
}
|
||||
}
|
||||
if strings.Contains(place.Name, "省") {
|
||||
riderKey = strings.Split(place.Name, "省")[0]
|
||||
} else {
|
||||
riderKey = strings.Split(place.Name, "市")[0]
|
||||
}
|
||||
|
||||
for _, v := range orderList {
|
||||
if len(riderListInfo[riderKey]) == model.NO {
|
||||
// 骑手列表
|
||||
configRiderList, err := dao.QueryConfigs(db, "riderList", "Sys", "")
|
||||
@@ -139,8 +131,6 @@ func AutoSettingFakeDelivery() {
|
||||
return
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debug("==========%s,%d", riderKey, len(riderListInfo[riderKey]))
|
||||
globals.SugarLogger.Debug("==========%s", utils.Format4Output(riderListInfo[riderKey], false))
|
||||
randNumber, _ := rand.Int(rand.Reader, big.NewInt(int64(len(riderListInfo[riderKey]))))
|
||||
randTime := randNumber.Int64()
|
||||
if randTime < 0 {
|
||||
@@ -173,4 +163,7 @@ func AutoSettingFakeDelivery() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -210,9 +210,7 @@ func Init() {
|
||||
|
||||
// 抖音自动刷单(自动发单拣货,设置骑手)
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
if beego.BConfig.RunMode != "jxgy" {
|
||||
auto_delivery.AutoSettingFakeDelivery()
|
||||
}
|
||||
}, 10*time.Second, 3*time.Minute)
|
||||
|
||||
// 定时任务更新负责人信息
|
||||
|
||||
@@ -1906,9 +1906,9 @@ func GetOrderStoreIDs(db *DaoDB, beginAt, endAt time.Time, vendorID int) (storeI
|
||||
}
|
||||
|
||||
// GetOrderListByStoreList 根据门店id获取正在刷单的门店商品
|
||||
func GetOrderListByStoreList(db *DaoDB, storeId []int64) (order []*model.GoodsOrder, err error) {
|
||||
func GetOrderListByStoreList(db *DaoDB, storeId []int64, vendorId int) (order []*model.GoodsOrder, err error) {
|
||||
sql := `SELECT * FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? AND g.jx_store_id IN (` + GenQuestionMarks(len(storeId)) + `)` + `AND g.vendor_id IN (` + GenQuestionMarks(2) + `)` + `AND g.status < ?`
|
||||
sqlParam := []interface{}{time.Now().AddDate(0, 0, -5), time.Now().AddDate(0, 0, 1), storeId, []int{model.VendorIDDD, model.VendorIDEBAI}, model.OrderStatusDelivering}
|
||||
sqlParam := []interface{}{time.Now().AddDate(0, 0, -5), time.Now().AddDate(0, 0, 1), storeId, []int{vendorId}, model.OrderStatusDelivering}
|
||||
|
||||
if err := GetRows(db, &order, sql, sqlParam...); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user