package transfersys import ( "errors" "time" mermod "com.snow.auto_monitor/app/models/merchant" models "com.snow.auto_monitor/app/models/orders" promod "com.snow.auto_monitor/app/models/product" "com.snow.auto_monitor/app/utils/rdbdq" ) func GetOrder() (res *models.Orders, err error) { res, _, err = models.GetInstance().GetIdleOrder() return } func FinishOrder(orders *models.Orders) (affected int64, err error) { //验证商户是否存在 _, has, err := mermod.GetInstance().GetById(orders.MerchantId) if err != nil { return } if !has { err = errors.New("商户不存在") return } //验证产品是否存在 _, has, err = promod.GetInstance().GetById(orders.ProductId) if err != nil { return } if !has { err = errors.New("产品不存在") return } if orders.TransferStatus == 1 { orders.Status = 1 } if orders.TransferStatus == 4 || orders.TransferStatus == 5 { orders.Status = orders.TransferStatus - 1 } affected, err = models.GetInstance().SetDealingOrder(orders) return } func AddCallback(order_id string) (err error) { err = rdbdq.WriteOne("1_"+order_id, time.Now().Add(1*time.Second).Unix()) return } func SetOrderMobile(orders *models.Orders) (affected int64, err error) { //验证商户是否存在 _, has, err := mermod.GetInstance().GetById(orders.MerchantId) if err != nil { return } if !has { err = errors.New("商户不存在") return } //验证产品是否存在 _, has, err = promod.GetInstance().GetById(orders.ProductId) if err != nil { return } if !has { err = errors.New("产品不存在") return } affected, err = models.GetInstance().SetOrderMobile(orders) return }