purchaseuserbalancelogic.go 1.7 KB

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