purchaseuserbalancelogic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyResourcesCenter/service"
  4. "context"
  5. "app.yhyue.com/moapp/jyResourcesCenter/rpc/internal/svc"
  6. "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
  7. "github.com/tal-tech/go-zero/core/logx"
  8. )
  9. type PurchaseUserBalanceLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewPurchaseUserBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PurchaseUserBalanceLogic {
  15. return &PurchaseUserBalanceLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. var balanceService = service.BalanceService{}
  22. // 根据账户标识购买资源
  23. func (l *PurchaseUserBalanceLogic) PurchaseUserBalance(in *resourcesCenter.Resources) (*resourcesCenter.Response, error) {
  24. // todo: add your logic here and delete this line
  25. balance := &resourcesCenter.Balance{
  26. AccountId: in.AccountId,
  27. CompanyId: in.CompanyId,
  28. DepartmentId: in.DepartmentId,
  29. Name: in.Name,
  30. ResourceType: in.ResourceType,
  31. Number: in.Number,
  32. Spec: in.Spec,
  33. AppId: in.AppId,
  34. Model: in.Model,
  35. EndTime: in.EndTime,
  36. }
  37. detailed := &resourcesCenter.Detailed{
  38. AccountId: in.AccountId,
  39. CompanyId: in.CompanyId,
  40. ResourceType: in.AccountId,
  41. ExportNum: in.Number,
  42. DepartmentId: in.DepartmentId,
  43. Name: in.Name,
  44. UserType: in.Model,
  45. Remarks: in.Remarks,
  46. }
  47. code, msg := balanceService.PurchaseUserBalance(balance,detailed)
  48. return &resourcesCenter.Response{
  49. Code: code,
  50. Message: msg,
  51. }, nil
  52. }