package account import ( "dashoo.cn/micro_libary/request" "fmt" "github.com/gogf/gf/os/gtime" dao "lims_adapter/dao/account" account "lims_adapter/model/account" "strconv" ) // Service 账号相关 type Service struct { Dao *dao.SettleAccountMainDao Tenant string } type AccountService struct { Dao *dao.BaseAccountDao Tenant string } func NewAccountSrv(tenant string) AccountService { return AccountService{Dao: dao.NewBaseAccountDao(tenant), Tenant: tenant} } // AddAccount 添加财务账号 func (s AccountService) Save(req *account.BaseAccount, user request.UserInfo) error { now := gtime.Now() if req.Id == 0 { req.CreateUserId = int(user.Id) req.CreateBy = user.RealName req.CreateOn = now } req.UpdateUserId = int(user.Id) req.UpdateBy = user.RealName req.UpdateOn = now _, err := s.Dao.Save(req) return err } // AccountList 财务账号分页查询 func (s AccountService) AccountList(req *account.AccountReq) (infos account.BaseAccountRsp, err error) { current := req.PageNun size := req.PageSize model := s.Dao.DB.Model("base_account a") if req.Account != "" { model = model.WhereLike("Account", "%" + req.Account + "%") } if req.RealName != "" { model = model.WhereLike("MainUser", "%" + req.RealName + "%") } if req.AccountName != "" { model = model.WhereLike("AccountName", "%" + req.AccountName + "%") } infos.Total, err = model.Count() if err != nil { return infos, err } err = model.Fields("a.*").Page(current, size).Scan(&infos.Records) return infos, nil } // DepositAccount 充值账户 func (s AccountService) DepositAccount(req *account.BaseAccountResp) error { _, err := s.Dao.M.Update(fmt.Sprintf("Surplus='%v',Available='%v'", req.Surplus, req.Available), "Id = "+strconv.Itoa(req.Id)) return err }