55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/services/store/internal/dao"
|
|
"lone-services/services/store/internal/model"
|
|
"lone-services/services/store/validator"
|
|
|
|
store "lone-services/rpc/store/pb"
|
|
"lone-services/services/store/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type WebDepositCreateLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewWebDepositCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebDepositCreateLogic {
|
|
return &WebDepositCreateLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *WebDepositCreateLogic) WebDepositCreate(in *store.WebDepositCreateRequest) (*store.Response, error) {
|
|
var v validator.DepositCreateValidator
|
|
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)
|
|
}
|
|
|
|
info := dao.DepositCreate{
|
|
StoreId: adminInfo.BizId,
|
|
Amount: in.Amount,
|
|
Bill: in.Bill,
|
|
Status: utils.StatusWaitPass,
|
|
}
|
|
|
|
err := model.DepositModel{}.Init().Create(&info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.Fail)
|
|
}
|
|
return l.ok(utils.NumberOne)
|
|
}
|