|
|
|
package skycrane
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"git.oa00.com/supply-chain/service/client"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
TaskStatusIng = 1 // 进行中
|
|
|
|
TaskStatusFinish = 2 // 结束
|
|
|
|
)
|
|
|
|
|
|
|
|
type task struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull @Title 拉取商品
|
|
|
|
func (t *task) Pull(ctx context.Context) error {
|
|
|
|
a := 0
|
|
|
|
xClient, err := client.GetClient(t)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return xClient.Call(ctx, "Pull", 0, &a)
|
|
|
|
}
|
|
|
|
|
|
|
|
type TaskStatus struct {
|
|
|
|
ScrollId string `json:"scrollId"`
|
|
|
|
Total int64 `json:"total"`
|
|
|
|
Count int64 `json:"count"`
|
|
|
|
Status int `json:"status"` // 1=运行中 2=已完成
|
|
|
|
Msg string `json:"msg"`
|
|
|
|
StartTime time.Time `json:"startTime"`
|
|
|
|
LastTime time.Time `json:"lastTime"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPullStatus @Title 获取拉取状态
|
|
|
|
func (t *task) GetPullStatus(ctx context.Context) (reply TaskStatus, err error) {
|
|
|
|
xClient, err := client.GetClient(t)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = xClient.Call(ctx, "GetPullStatus", 0, &reply)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prices @Title 商品更新
|
|
|
|
func (t *task) Prices(ctx context.Context) error {
|
|
|
|
a := 0
|
|
|
|
xClient, err := client.GetClient(t)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return xClient.Call(ctx, "Prices", 0, &a)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPricesStatus @Title 获取拉取状态
|
|
|
|
func (t *task) GetPricesStatus(ctx context.Context) (reply TaskStatus, err error) {
|
|
|
|
xClient, err := client.GetClient(t)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = xClient.Call(ctx, "GetPricesStatus", 0, &reply)
|
|
|
|
return
|
|
|
|
}
|