purchaseuserbalancelogic.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. }
  46. code, msg := balanceService.PurchaseUserBalance(balance,detailed)
  47. return &resourcesCenter.Response{
  48. Code: code,
  49. Message: msg,
  50. }, nil
  51. }