36 lines
1001 B
Go
36 lines
1001 B
Go
|
|
package crm
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"apps/backend/internal/svc"
|
||
|
|
"apps/backend/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type UpdateContactConversionLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewUpdateContactConversionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateContactConversionLogic {
|
||
|
|
return &UpdateContactConversionLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *UpdateContactConversionLogic) UpdateContactConversion(req *types.UpdateCrmConversionReq) (*types.CrmConversionData, error) {
|
||
|
|
uid, err := ownerUID(l.ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
c, outcomeID, err := l.svcCtx.Crm.UpdateConversion(l.ctx, uid, req.Id, req.Amount, req.Currency, req.Note)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.CrmConversionData{
|
||
|
|
ContactId: c.ID, OutcomeId: outcomeID, Stage: c.Stage,
|
||
|
|
Amount: req.Amount, Currency: req.Currency, Note: req.Note, UpdatedAt: c.UpdatedAt,
|
||
|
|
}, nil
|
||
|
|
}
|