com.snow.auto_monitor/app/services/transfersys/transfersys.go

40 lines
815 B
Go

package transfersys
import (
"errors"
mermod "com.snow.auto_monitor/app/models/merchant"
models "com.snow.auto_monitor/app/models/orders"
promod "com.snow.auto_monitor/app/models/product"
)
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
}
affected, err = models.GetInstance().SetDealingOrder(orders)
return
}