purchaseuserbalancelogic.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.ResourceType,
  41. ExportNum: in.Number,
  42. DepartmentId: in.DepartmentId,
  43. Name: in.Name,
  44. UserType: in.Model,
  45. Remarks: in.Remarks,
  46. UserId: in.UserId,
  47. }
  48. code, msg := balanceService.PurchaseUserBalance(balance, detailed)
  49. return &resourcesCenter.Response{
  50. Code: code,
  51. Message: msg,
  52. }, nil
  53. }