package db import ( "applet/app/db/model" "applet/app/md" "applet/app/utils" "github.com/gin-gonic/gin" "xorm.io/xorm" ) func GetOrderByOid(eg *xorm.Engine, oid string) *model.CommunityTeamOrder { var data model.CommunityTeamOrder get, err := eg.Where("oid=?", oid).Get(&data) if get == false || err != nil { return nil } return &data } func GetOrderEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrder { var data model.CommunityTeamOrder get, err := eg.Where("oid=?", oid).Get(&data) if get == false || err != nil { return nil } return &data } func GetOrderPayEg(eg *xorm.Engine, oid string) *model.CommunityTeamPayOrder { var data model.CommunityTeamPayOrder get, err := eg.Where("oid=?", oid).Get(&data) if get == false || err != nil { return nil } return &data } func GetOrderPay(sess *xorm.Session, oid string) *model.CommunityTeamPayOrder { var data model.CommunityTeamPayOrder get, err := sess.Where("oid=?", oid).Get(&data) if get == false || err != nil { return nil } return &data } func GetOrder(sess *xorm.Session, oid string) *model.CommunityTeamOrder { var data model.CommunityTeamOrder get, err := sess.Where("oid=?", oid).Get(&data) if get == false || err != nil { return nil } return &data } func GetOrderInfo(sess *xorm.Session, oid string) *[]model.CommunityTeamOrderInfo { var data []model.CommunityTeamOrderInfo err := sess.Where("oid=?", oid).Find(&data) if err != nil { return nil } return &data } func GetOrderInfoAllEg(eg *xorm.Engine, oid string) *[]model.CommunityTeamOrderInfo { var data []model.CommunityTeamOrderInfo err := eg.Where("oid=?", oid).Find(&data) if err != nil { return nil } return &data } func GetOrderInfoFirstEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrderInfo { var data model.CommunityTeamOrderInfo get, err := eg.Where("oid=?", oid).Get(&data) if err != nil || get == false { return nil } return &data } func GetOrderInfoEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrderInfo { var data model.CommunityTeamOrderInfo get, err := eg.Where("oid=?", oid).Asc("id").Get(&data) if get == false || err != nil { return nil } return &data } func GetOrderList(c *gin.Context, eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamOrder { var data []model.CommunityTeamOrder sess := eg.Where("1=1") if arg["uid"] != "" { sess.And("uid=?", arg["uid"]) } if arg["state"] != "" { sess.And("state=?", arg["state"]) } if arg["store_uid"] != "" { sess.And("store_uid=?", arg["store_uid"]) } if arg["code"] != "" { sess.And("code=?", arg["code"]) } if arg["start_time"] != "" { sess.And("create_at>=?", arg["start_time"]) } if arg["end_time"] != "" { sess.And("create_at 0 { sess.And("parent_uid=?", parent_uid) } if req.StartTime != "" { sess.And("create_at>=?", req.StartTime) } if req.EndTime != "" { sess.And("create_at<=?", req.EndTime) } if req.ConfirmStartTime != "" { sess.And("confirm_at>=?", req.ConfirmStartTime) } if req.ConfirmEndTime != "" { sess.And("confirm_at<=?", req.ConfirmEndTime) } size := utils.StrToInt(req.Size) start := (utils.StrToInt(req.P) - 1) * size count, err := sess.Limit(size, start).OrderBy("create_at desc,id desc").FindAndCount(&data) if err != nil { return nil, 0, err } return &data, count, nil }