micro-bundle/internal/logic/orderRecordsLogic.go
2025-02-20 20:40:39 +08:00

45 lines
1.4 KiB
Go

package logic
import (
"github.com/jinzhu/copier"
"micro-bundle/internal/dao"
"micro-bundle/internal/model"
"micro-bundle/pb/bundle"
"micro-bundle/pkg/app"
"micro-bundle/pkg/utils"
)
func CreateOrderRecord(req *bundle.OrderRecord) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
orderRecord := new(model.BundleOrderRecords)
_ = copier.CopyWithOption(&orderRecord, req, copier.Option{DeepCopy: true})
orderRecord.UUID = app.ModuleClients.SfNode.Generate().Base64()
orderRecord.OrderNo = utils.GetOrderNo()
res, err = dao.CreateOrderRecord(orderRecord)
return
}
func UpdateOrderRecord(req *bundle.OrderRecord) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
orderRecord := new(model.BundleOrderRecords)
_ = copier.CopyWithOption(&orderRecord, req, copier.Option{DeepCopy: true})
res, err = dao.UpdateOrderRecord(orderRecord)
return
}
func OrderRecordsList(req *bundle.OrderRecordsRequest) (res *bundle.OrderRecordsResponse, err error) {
res = new(bundle.OrderRecordsResponse)
res, err = dao.OrderRecordsList(req)
return
}
func OrderRecordsDetail(req *bundle.OrderRecordsDetailRequest) (res *bundle.OrderRecordsDetailResponse, err error) {
res = new(bundle.OrderRecordsDetailResponse)
res.OrderRecord = new(bundle.OrderRecord)
res.OrderRecord, err = dao.OrderRecordDetail(req.Uuid)
if err != nil {
res.Msg = err.Error()
}
return
}