cmb
This commit is contained in:
parent
8d421a8adc
commit
df9d7d0b59
|
|
@ -92,20 +92,23 @@ func (v *Cmb) fail(ctx context.Context, order *bo.OrderBo, orderWechat *bo.Order
|
||||||
return v.OrderRepo.Fail(ctx, order.ID)
|
return v.OrderRepo.Fail(ctx, order.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Cmb) NotifyConsume(ctx context.Context, order *bo.OrderBo, orderOutRequestNo string) error {
|
func (v *Cmb) orderWechat(ctx context.Context, order *bo.OrderBo, orderOutRequestNo string) (*bo.OrderWechatBo, error) {
|
||||||
|
|
||||||
orderWechat, err := v.OrderWechatRepo.GetByOutRequestNo(ctx, orderOutRequestNo)
|
orderWechat, err := v.OrderWechatRepo.GetByOutRequestNo(ctx, orderOutRequestNo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !orderWechat.Status.CanNotify() {
|
if !orderWechat.Status.CanNotify() {
|
||||||
return fmt.Errorf("微信订单状态错误,不能通知:%s", order.Status.GetText())
|
return nil, fmt.Errorf("微信订单状态错误,不能通知:%s", order.Status.GetText())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return orderWechat, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Cmb) bizContent(_ context.Context, orderWechat *bo.OrderWechatBo) (string, error) {
|
||||||
status, err := orderWechat.Status.GetCmbStatusText()
|
status, err := orderWechat.Status.GetCmbStatusText()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &v1.CmbNotifyRequest{
|
req := &v1.CmbNotifyRequest{
|
||||||
|
|
@ -115,14 +118,30 @@ func (v *Cmb) NotifyConsume(ctx context.Context, order *bo.OrderBo, orderOutRequ
|
||||||
OrgNo: v.bc.Cmb.OrgNo,
|
OrgNo: v.bc.Cmb.OrgNo,
|
||||||
Ext: "",
|
Ext: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
bizJsonBytes, err := json.Marshal(req)
|
bizJsonBytes, err := json.Marshal(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(bizJsonBytes), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Cmb) NotifyConsume(ctx context.Context, order *bo.OrderBo, orderOutRequestNo string) error {
|
||||||
|
|
||||||
|
orderWechat, err := v.orderWechat(ctx, order, orderOutRequestNo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
bizContent, err := v.bizContent(ctx, orderWechat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
request, err := v.CmbMixRepo.GetRequest(ctx, &bo.CmbRequestBo{
|
request, err := v.CmbMixRepo.GetRequest(ctx, &bo.CmbRequestBo{
|
||||||
FuncName: vo.CmbNotifyFuncName,
|
FuncName: vo.CmbNotifyFuncName,
|
||||||
BizContent: string(bizJsonBytes),
|
BizContent: bizContent,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -134,7 +153,7 @@ func (v *Cmb) NotifyConsume(ctx context.Context, order *bo.OrderBo, orderOutRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
orderNotify, err := v.OrderNotifyRepo.Create(ctx, &bo.OrderNotifyBo{
|
orderNotify, err := v.OrderNotifyRepo.Create(ctx, &bo.OrderNotifyBo{
|
||||||
OrderNo: order.OrderNo,
|
OrderNo: orderWechat.OrderNo,
|
||||||
OutRequestNo: orderWechat.OutRequestNo,
|
OutRequestNo: orderWechat.OutRequestNo,
|
||||||
Request: string(requestBytes),
|
Request: string(requestBytes),
|
||||||
NotifyUrl: order.NotifyUrl,
|
NotifyUrl: order.NotifyUrl,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue