Bläddra i källkod

Merge branch 'yhg_250102' into debug

jimmyyem 2 månader sedan
förälder
incheckning
2f5da1fdba

+ 8 - 1
internal/logic/credit_balance/create_credit_balance_logic.go

@@ -3,6 +3,8 @@ package credit_balance
 import (
 	"context"
 	"github.com/alibabacloud-go/tea/tea"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
+	"github.com/zeromicro/go-zero/core/errorx"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -28,7 +30,12 @@ func NewCreateCreditBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext
 }
 
 func (l *CreateCreditBalanceLogic) CreateCreditBalance(req *types.CreditBalanceInfo) (*types.BaseMsgResp, error) {
-	_, err := l.svcCtx.DB.CreditBalance.Create().
+	_, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: *req.OrganizationId})
+	if err != nil {
+		return nil, errorx.NewAlreadyExistsError("租户不存在")
+	}
+
+	_, err = l.svcCtx.DB.CreditBalance.Create().
 		SetNotNilUserID(req.UserId).
 		SetNotNilBalance(req.Balance).
 		SetNotNilStatus(tea.Int(1)).

+ 6 - 0
internal/logic/credit_balance/operate_credit_balance_logic.go

@@ -3,6 +3,7 @@ package credit_balance
 import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"github.com/zeromicro/go-zero/core/errorx"
 	"wechat-api/ent/creditbalance"
 
@@ -30,6 +31,11 @@ func (l *OperateCreditBalanceLogic) OperateCreditBalance(req *types.CreditBalanc
 		return nil, errorx.NewInvalidArgumentError("Number参数非法")
 	}
 
+	_, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: *req.OrganizationId})
+	if err != nil {
+		return nil, errorx.NewAlreadyExistsError("租户不存在")
+	}
+
 	creditBalance, err := l.svcCtx.DB.CreditBalance.Query().Where(creditbalance.OrganizationID(*req.OrganizationId)).Only(l.ctx)
 	if err != nil {
 		l.Logger.Errorf("query credit_balance error:%v\n", err)