Files
lone-services/services/store/internal/logic/depositBackfillLogic.go
T
gjs 2b19937065
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 25s
CI / chore (push) Successful in 24s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 1s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 24s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
store and chore
2026-09-17 16:16:11 +08:00

84 lines
2.0 KiB
Go

package logic
import (
"context"
"lone-services/pkg/modelbase"
"lone-services/pkg/utils"
"lone-services/services/store/internal/dao"
"lone-services/services/store/internal/model"
"lone-services/services/store/validator"
"strconv"
"lone-services/rpc/store/pb"
"lone-services/services/store/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type DepositBackfillLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
BaseLogic
}
func NewDepositBackfillLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DepositBackfillLogic {
return &DepositBackfillLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DepositBackfillLogic) DepositBackfill(in *store.DepositBackfillRequest) (*store.Response, error) {
var v validator.DepositBackfillValidator
if fail := l.checkParams(in, &v); fail != nil {
return fail, nil
}
adminInfo := utils.GetUserFromCtx(l.ctx)
if adminInfo.ID < utils.NumberOne {
return l.fail(utils.ErrorNoLoginInfo)
}
var info dao.DepositStatus
w := modelbase.Params{Eq: map[string]string{
"id": strconv.FormatInt(in.Id, utils.NumberTen),
"status": strconv.Itoa(utils.StatusWaitPass)}}
modelObj := model.DepositModel{}.Init()
err := modelObj.GetOne(w, &info)
if err != nil {
l.Logger.Error(err)
return l.fail(utils.Fail)
}
if info.Id < utils.NumberOne {
return l.fail(utils.ErrorNotFund)
}
action := utils.ActionAdd{
OldContent: info,
Type: utils.LogActionTypeEdit,
ModuleName: utils.LogActionModuleStore,
}
info.Status = utils.StatusBackfill
info.AccountantId = adminInfo.ID
info.AccountantName = adminInfo.Name
info.AffirmAmount = info.Amount
if in.Amount > utils.NumberZero {
info.AffirmAmount = in.Amount
}
row, err := modelObj.Edit(w, &info)
if err != nil {
l.Logger.Error(err)
return l.fail(utils.Fail)
}
if row > utils.NumberZero {
action.NewContent = info
utils.SetActionLog(adminInfo, action)
}
return l.ok(utils.NumberOne)
}