package handler import ( "context" "github.com/caixw/lib.go/conv" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "youngee_m_api/consts" "youngee_m_api/db" "youngee_m_api/model/http_model" "youngee_m_api/service" ) func WrapCheckLogisticHandler(ctx *gin.Context) { handler := newCheckLogisticHandler(ctx) BaseRun(handler) } type CheckLogisticHandler struct { ctx *gin.Context req *http_model.CheckLogisticRequest resp *http_model.CommonResponse } func newCheckLogisticHandler(ctx *gin.Context) *CheckLogisticHandler { return &CheckLogisticHandler{ ctx: ctx, req: http_model.NewCheckLogisticRequest(), resp: http_model.NewCheckLogisticResponse(), } } func (c CheckLogisticHandler) getContext() *gin.Context { return c.ctx } func (c CheckLogisticHandler) getResponse() interface{} { return c.resp } func (c CheckLogisticHandler) getRequest() interface{} { return c.req } func (c CheckLogisticHandler) run() { logisticNums := db.GetLogisticsNum() for i := 0; i < len(logisticNums); i++ { logisticNum := logisticNums[i] status := service.GetKDStatus(consts.GetKD(logisticNum[0]), logisticNum[1]) if status == "1" { taskId := db.SignLogistic(conv.MustInt64(logisticNum[2], 0)) err := db.CreateTaskLog(context.Background(), taskId, "签收时间") if err != nil { logrus.WithContext(context.Background()).Errorf("[logistics service] call CreateTaskLog error,err:%+v", err) c.resp.Status = 40000 c.resp.Message = err.Error() return } } } c.resp.Status = 20000 c.resp.Message = "ok" } func (c CheckLogisticHandler) checkParam() error { return nil }