+ IPurchasePlatformPageActHandler
- 饿百IPurchasePlatformPageActHandler接口OK
This commit is contained in:
@@ -25,6 +25,11 @@ type IPurchasePlatformActHandler interface {
|
||||
SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSkuList []*model.ActStoreSku2) (err error)
|
||||
}
|
||||
|
||||
type IPurchasePlatformPageActHandler interface {
|
||||
GetPageActList(ctx *jxcontext.Context, createdFrom time.Time) (actList []*model.Act2, err error)
|
||||
GetPageActSkuList(ctx *jxcontext.Context, vendorPageActID string) (actStoreSkuList []*model.ActStoreSku2, err error)
|
||||
}
|
||||
|
||||
var (
|
||||
CurActManager IActManager
|
||||
)
|
||||
|
||||
115
business/partner/purchase/ebai/act_page.go
Normal file
115
business/partner/purchase/ebai/act_page.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package ebai
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
type tShowStatusAndTypeInfo struct {
|
||||
ShowStatus int
|
||||
ActivityType int
|
||||
}
|
||||
|
||||
func ebaiPageActType2Jx(activityType int) int {
|
||||
if activityType == ebaiapi.PageActivityTypeSkuDiscount || activityType == ebaiapi.PageActivityTypeSkuDirectDown {
|
||||
return model.ActSkuDirectDown
|
||||
} else if activityType == ebaiapi.PageActivityTypeSkuSpecialPrice {
|
||||
return model.ActSkuSecKill
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func ebaiPageActStatus2Jx(status int) int {
|
||||
if status == ebaiapi.PageActivityStatusWaiting || status == ebaiapi.PageActivityStatusOnGoing {
|
||||
return model.ActStatusCreated
|
||||
} else if status == ebaiapi.PageActivityStatusEnded {
|
||||
return model.ActStatusEnded
|
||||
}
|
||||
return model.ActStatusNA
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetPageActList(ctx *jxcontext.Context, createdFrom time.Time) (actList []*model.Act2, err error) {
|
||||
var typeAndStatusList []*tShowStatusAndTypeInfo
|
||||
for _, showStatus := range []int{
|
||||
ebaiapi.PageActivityStatusWaiting,
|
||||
ebaiapi.PageActivityStatusOnGoing,
|
||||
// ebaiapi.PageActivityStatusEnded,
|
||||
} {
|
||||
for _, activityType := range []int{
|
||||
ebaiapi.PageActivityTypeSkuDiscount,
|
||||
ebaiapi.PageActivityTypeSkuSpecialPrice,
|
||||
ebaiapi.PageActivityTypeSkuDirectDown,
|
||||
} {
|
||||
typeAndStatusList = append(typeAndStatusList, &tShowStatusAndTypeInfo{
|
||||
ShowStatus: showStatus,
|
||||
ActivityType: activityType,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
task := tasksch.NewParallelTask("ebai GetPageActList", tasksch.NewParallelConfig().SetParallelCount(10), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
info := batchItemList[0].(*tShowStatusAndTypeInfo)
|
||||
list, err := api.EbaiAPI.BegetActivityList(info.ShowStatus, info.ActivityType, 0, api.EbaiAPI.GetSupplierID())
|
||||
if err == nil {
|
||||
retVal = list
|
||||
}
|
||||
return retVal, err
|
||||
}, typeAndStatusList)
|
||||
task.Run()
|
||||
list, err := task.GetResult(0)
|
||||
if len(list) > 0 {
|
||||
for _, v := range list {
|
||||
ebaiAct := v.(*ebaiapi.PageActItem)
|
||||
if utils.Timestamp2Time(ebaiAct.CreateTime).Sub(createdFrom) > 0 {
|
||||
act := &model.Act2{
|
||||
Act: model.Act{
|
||||
Name: ebaiAct.ActivityName,
|
||||
Type: ebaiPageActType2Jx(ebaiAct.ActivityType),
|
||||
Status: ebaiPageActStatus2Jx(ebaiAct.Status),
|
||||
Source: ebaiAct.User,
|
||||
CreateType: model.ActCreateTypeSpider,
|
||||
BeginAt: utils.Timestamp2Time(ebaiAct.StartTime),
|
||||
EndAt: utils.Timestamp2Time(ebaiAct.EndTime),
|
||||
VendorMask: model.GetVendorMask(model.VendorIDEBAI),
|
||||
LimitUser: 1,
|
||||
},
|
||||
VendorID: model.VendorIDEBAI,
|
||||
VendorActID: ebaiAct.ActivityID,
|
||||
}
|
||||
actList = append(actList, act)
|
||||
}
|
||||
}
|
||||
}
|
||||
return actList, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetPageActSkuList(ctx *jxcontext.Context, vendorPageActID string) (actStoreSkuList []*model.ActStoreSku2, err error) {
|
||||
skus, err := api.EbaiAPI.BegetActSkuList(utils.Str2Int64(vendorPageActID), 0, api.EbaiAPI.GetSupplierID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range skus {
|
||||
actStoreSku := &model.ActStoreSku2{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
Stock: v.Stock,
|
||||
OriginalPrice: jxutils.StandardPrice2Int(v.OriginalPrice),
|
||||
},
|
||||
VendorStoreID: utils.Int64ToStr(v.Wid),
|
||||
VendorSkuID: v.SkuID,
|
||||
VendorActID: v.ActivityID,
|
||||
ActualActPrice: jxutils.StandardPrice2Int(v.PromotionPrice),
|
||||
}
|
||||
actStoreSkuList = append(actStoreSkuList, actStoreSku)
|
||||
}
|
||||
return actStoreSkuList, nil
|
||||
}
|
||||
28
business/partner/purchase/ebai/act_page_test.go
Normal file
28
business/partner/purchase/ebai/act_page_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package ebai
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
)
|
||||
|
||||
func TestGetPageActList(t *testing.T) {
|
||||
actList, err := new(PurchaseHandler).GetPageActList(jxcontext.AdminCtx, utils.DefaultTimeValue)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(actList, false))
|
||||
t.Log(len(actList))
|
||||
}
|
||||
|
||||
func TestGetPageActSkuList(t *testing.T) {
|
||||
actList, err := new(PurchaseHandler).GetPageActSkuList(jxcontext.AdminCtx, "3000000001477429")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(actList, false))
|
||||
}
|
||||
Reference in New Issue
Block a user