This commit is contained in:
parent
d4e2d2d00a
commit
43b0b0a5fa
|
|
@ -28,7 +28,8 @@ type OrderBo struct {
|
|||
CreateTime *time.Time
|
||||
UpdateTime *time.Time
|
||||
|
||||
MiniMum int32
|
||||
MiniMum int32
|
||||
CouponValue int32
|
||||
}
|
||||
|
||||
type OrderCreateReqBo struct {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ type BBToWechatRequest struct {
|
|||
// 微信为发券方商户分配的公众账号ID
|
||||
AppId string `protobuf:"bytes,11,opt,name=appId,proto3" json:"appId,omitempty"`
|
||||
// 批次创建方商户号
|
||||
StockCreatorMhId string `protobuf:"bytes,12,opt,name=stockCreatorMhId,json=stockCreatorMchid,proto3" json:"stockCreatorMhId,omitempty"`
|
||||
StockCreatorMhId string `protobuf:"bytes,12,opt,name=stockCreatorMchid,json=stockCreatorMchid,proto3" json:"stockCreatorMchid,omitempty"`
|
||||
// 券面额,单位:分
|
||||
CouponValue int32 `protobuf:"bytes,13,opt,name=couponValue,proto3" json:"couponValue,omitempty"`
|
||||
// 面额发券批次门槛,单位:分
|
||||
|
|
|
|||
|
|
@ -31,47 +31,38 @@ func (v *VoucherBiz) CmbOrder(ctx context.Context, request *v1.CmbRequest) (*v1.
|
|||
return reply, nil
|
||||
}
|
||||
|
||||
func (c *VoucherBiz) cmbOrder(ctx context.Context, request *v1.CmbRequest) (*bo.OrderBo, error) {
|
||||
func (v *VoucherBiz) cmbOrder(ctx context.Context, request *v1.CmbRequest) (*bo.OrderBo, error) {
|
||||
|
||||
bizContent, err := c.CmbMixRepo.OrderVerify(ctx, request)
|
||||
bizContent, err := v.CmbMixRepo.OrderVerify(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
boReq := &bo.OrderCreateReqBo{
|
||||
OutBizNo: bizContent.TransactionId,
|
||||
ProductNo: bizContent.ActivityId,
|
||||
Account: bizContent.CmbUid,
|
||||
AppID: bizContent.AppId,
|
||||
Attach: bizContent.Attach,
|
||||
AccountType: vo.OrderAccountTypeOpenId,
|
||||
Type: vo.OrderTypeCmb,
|
||||
NotifyUrl: c.bc.Cmb.NotifyUrl,
|
||||
product, err3 := v.ProductRepo.GetByProductNo(ctx, bizContent.ActivityId)
|
||||
if err3 != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
order, err := c.Order(ctx, boReq, bizContent)
|
||||
order, err := v.Order(ctx, product, bizContent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
order.MiniMum = product.MiniMum
|
||||
order.CouponValue = product.Amount
|
||||
|
||||
return order, nil
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) Order(ctx context.Context, req *bo.OrderCreateReqBo, cmbReq *v1.CmbOrderRequest) (order *bo.OrderBo, err error) {
|
||||
func (v *VoucherBiz) Order(ctx context.Context, product *bo.ProductBo, bizContent *v1.CmbOrderRequest) (order *bo.OrderBo, err error) {
|
||||
|
||||
product, err3 := v.ProductRepo.GetByProductNo(ctx, req.ProductNo)
|
||||
if err3 != nil {
|
||||
return order, err3
|
||||
}
|
||||
|
||||
order, err = v.OrderRepo.GetByOutBizNo(ctx, vo.OrderTypeCmb, req.OutBizNo)
|
||||
order, err = v.OrderRepo.GetByOutBizNo(ctx, vo.OrderTypeCmb, bizContent.TransactionId)
|
||||
if err != nil && !err2.IsDbNotFound(err) {
|
||||
return order, err
|
||||
}
|
||||
|
||||
if order != nil {
|
||||
|
||||
order.MiniMum = product.MiniMum
|
||||
if order.Status.IsFail() {
|
||||
|
||||
if err4 := v.orderRetry(ctx, order); err4 != nil {
|
||||
|
|
@ -82,23 +73,33 @@ func (v *VoucherBiz) Order(ctx context.Context, req *bo.OrderCreateReqBo, cmbReq
|
|||
return order, err
|
||||
}
|
||||
|
||||
order, err = v.order(ctx, req, product, cmbReq)
|
||||
order, err = v.order(ctx, product, bizContent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
order.MiniMum = product.MiniMum
|
||||
return order, nil
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) order(ctx context.Context, req *bo.OrderCreateReqBo, product *bo.ProductBo, cmbReq *v1.CmbOrderRequest) (*bo.OrderBo, error) {
|
||||
func (v *VoucherBiz) order(ctx context.Context, product *bo.ProductBo, bizContent *v1.CmbOrderRequest) (*bo.OrderBo, error) {
|
||||
|
||||
req := &bo.OrderCreateReqBo{
|
||||
OutBizNo: bizContent.TransactionId,
|
||||
ProductNo: bizContent.ActivityId,
|
||||
Account: bizContent.CmbUid,
|
||||
AppID: bizContent.AppId,
|
||||
Attach: bizContent.Attach,
|
||||
AccountType: vo.OrderAccountTypeOpenId,
|
||||
Type: vo.OrderTypeCmb,
|
||||
NotifyUrl: v.bc.Cmb.NotifyUrl,
|
||||
}
|
||||
|
||||
order, err := v.create(ctx, req, product)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = v.cmbToBB(ctx, cmbReq)
|
||||
_ = v.cmbToBB(ctx, bizContent)
|
||||
|
||||
if err = v.registerNotifyTag(ctx, order.MerchantNo, order.BatchNo); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ func (this *KxMixRepoImpl) Request(ctx context.Context, req *kog.Notice) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//fmt.Printf("请求kx,url:%s,reqBody:%s", url, string(body))
|
||||
|
||||
_, bodyBytes, err := request.POST(ctx, url, body, this.options)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue