aa
This commit is contained in:
@@ -2023,11 +2023,11 @@ func RrefreshEbaiVendorAct() (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
actMap = struct {
|
||||
idMap map[int64]struct{}
|
||||
idMap map[int64]int
|
||||
*sync.RWMutex
|
||||
}{}
|
||||
)
|
||||
actMap.idMap = make(map[int64]struct{})
|
||||
actMap.idMap = make(map[int64]int)
|
||||
actMap.RWMutex = new(sync.RWMutex)
|
||||
//直接做删除,把新的加进来
|
||||
dao.ExecuteSQL(db, `TRUNCATE act_ebai_vendor`)
|
||||
@@ -2039,14 +2039,50 @@ func RrefreshEbaiVendorAct() (err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
actIDs, _ := api.EbaiAPI.ActMultiChannelQueryIDs("", utils.Str2Int64(storeMap.VendorStoreID), "2")
|
||||
for _, v := range actIDs {
|
||||
actMap.Lock()
|
||||
actMap.idMap[v] = struct{}{}
|
||||
actMap.Unlock()
|
||||
if result, err := api.EbaiAPI.ActMultiChannelQueryInfos(utils.Int64ToStr(v), "", utils.Str2Int64(storeMap.VendorStoreID)); err == nil {
|
||||
if result.Status < 2 {
|
||||
if actMap.idMap[v] == 0 {
|
||||
actMap.Lock()
|
||||
actMap.idMap[v] = 1
|
||||
actMap.Unlock()
|
||||
actVendor := &model.ActEbaiVendor{
|
||||
BeginAt: utils.Timestamp2Time(result.Starttime),
|
||||
EndAt: utils.Timestamp2Time(result.Endtime),
|
||||
ActType: model.ActSkuDirectDown,
|
||||
Status: result.Status,
|
||||
ActID: utils.Int64ToStr(result.Activityid),
|
||||
DayLimit: result.Limitruleapi.Userdaycountlimit,
|
||||
Period: result.Periodsandruleapilist[0].Periods[0].Opentime + "-" + result.Periodsandruleapilist[0].Periods[0].Closetime,
|
||||
WeeksTime: result.Periodsandruleapilist[0].Periods[0].Weekday,
|
||||
}
|
||||
dao.CreateEntity(db, actVendor)
|
||||
for _, sku := range result.Skulist {
|
||||
actVendorSku := &model.ActEbaiVendorSku{
|
||||
ActID: utils.Int64ToStr(result.Activityid),
|
||||
StoreID: storeMap.StoreID,
|
||||
EbaiID: sku.Skuid,
|
||||
VendorStoreID: storeMap.VendorStoreID,
|
||||
SkuName: sku.Upcname,
|
||||
ActPrice: jxutils.IntPrice2Standard(int64(sku.Periodsandruleapilist[0].Ruleapi.Discount)),
|
||||
}
|
||||
var storeSkuBind *model.StoreSkuBind
|
||||
sql := `
|
||||
SELECT * FROM store_sku_bind WHERE store_id = ? AND ebai_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{storeMap.StoreID, sku.Skuid}
|
||||
if err = dao.GetRow(db, &storeSkuBind, sql, sqlParams); err == nil && storeSkuBind != nil {
|
||||
actVendorSku.SkuID = storeSkuBind.SkuID
|
||||
actVendorSku.OriginPrice = jxutils.IntPrice2Standard(int64(storeSkuBind.Price))
|
||||
}
|
||||
dao.CreateEntity(db, actVendorSku)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, storeMaps)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
task.GetResult(0)
|
||||
fmt.Println("actmap", actMap.idMap)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user