71 lines
1.4 KiB
Go
71 lines
1.4 KiB
Go
package cmb
|
|
|
|
import (
|
|
"context"
|
|
"github.com/pkg/errors"
|
|
"gorm.io/gorm"
|
|
"voucher/internal/biz/bo"
|
|
"voucher/internal/biz/vo"
|
|
"voucher/internal/pkg/uid"
|
|
)
|
|
|
|
func (v *Cmb) Order(ctx context.Context, req *bo.OrderCreateReqBo) (orderNo string, err error) {
|
|
|
|
orderNo, err = v.order(ctx, req)
|
|
|
|
return
|
|
}
|
|
|
|
func (v *Cmb) order(ctx context.Context, req *bo.OrderCreateReqBo) (orderNo string, err error) {
|
|
|
|
order, err := v.OrderRepo.GetByOutBizNo(ctx, req.OutBizNo)
|
|
|
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
return
|
|
}
|
|
|
|
if order != nil {
|
|
orderNo = order.OrderNo
|
|
return
|
|
}
|
|
|
|
product, err := v.ProductRepo.GetByPNO(ctx, req.ProductNo)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
orderNo, err = v.GenerateMixRepo.GeneratorString(ctx, uid.Order)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
o := &bo.OrderBo{
|
|
OrderNo: orderNo,
|
|
OutBizNo: req.OutBizNo,
|
|
ProductNo: req.ProductNo,
|
|
Account: req.Account,
|
|
AppID: product.AppID,
|
|
MerchantNo: product.MerchantNo,
|
|
Channel: product.Channel,
|
|
AccountType: vo.OrderAccountTypeOpenId,
|
|
Type: vo.OrderTypeCmb,
|
|
Status: vo.OrderStatusWait,
|
|
}
|
|
|
|
order, err = v.OrderRepo.Create(ctx, o)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (v *Cmb) Query(ctx context.Context, productNo string) (reps *bo.OrderCreateRepBo, err error) {
|
|
|
|
return
|
|
}
|
|
|
|
func (v *Cmb) Notify(ctx context.Context, order *bo.OrderBo) (err error) {
|
|
return
|
|
}
|