micro-bundle/internal/logic/orderRecordsLogic.go

50 lines
1.5 KiB
Go
Raw Normal View History

2025-02-20 12:40:39 +00:00
package logic
import (
2025-02-22 13:20:19 +00:00
"fmt"
2025-02-20 12:40:39 +00:00
"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()
2025-02-22 12:02:50 +00:00
orderRecord.BundleUUID = req.BundleUuid
2025-02-22 13:20:19 +00:00
fmt.Printf("orderRecord %+v\n", orderRecord)
2025-02-20 12:40:39 +00:00
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})
2025-02-23 02:37:53 +00:00
orderRecord.UUID = req.Uuid
2025-02-23 02:38:15 +00:00
orderRecord.BundleUUID = req.BundleUuid
2025-02-20 12:40:39 +00:00
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)
2025-02-21 13:09:54 +00:00
res.OrderRecord, err = dao.OrderRecordDetail(req)
2025-02-20 12:40:39 +00:00
if err != nil {
res.Msg = err.Error()
}
return
}