fix(charge):基本完成用户充值功能部分的测试。
This commit is contained in:
parent
0c725e99a4
commit
7f43965f1c
|
@ -50,9 +50,9 @@ func createNewUserChargeRecord(c *fiber.Ctx) error {
|
|||
chargeLog.Error("无法解析创建充值记录的请求数据。", zap.Error(err))
|
||||
return result.Error(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
fee, _ := createionForm.Fee.Float64()
|
||||
discount, _ := createionForm.Discount.Float64()
|
||||
amount, _ := createionForm.Amount.Float64()
|
||||
fee, _ := createionForm.Fee.Decimal.Float64()
|
||||
discount, _ := createionForm.Discount.Decimal.Float64()
|
||||
amount, _ := createionForm.Amount.Decimal.Float64()
|
||||
ok, err := service.ChargeService.RecordUserCharge(
|
||||
createionForm.UserId,
|
||||
&fee,
|
||||
|
|
|
@ -24,9 +24,9 @@ type UserChargeDetail struct {
|
|||
}
|
||||
|
||||
type ChargeRecordCreationForm struct {
|
||||
UserId string `json:"userId"`
|
||||
Fee *decimal.Decimal `json:"fee"`
|
||||
Discount *decimal.Decimal `json:"discount"`
|
||||
Amount *decimal.Decimal `json:"amount"`
|
||||
ChargeTo types.Date `json:"chargeTo"`
|
||||
UserId string `json:"userId"`
|
||||
Fee decimal.NullDecimal `json:"fee"`
|
||||
Discount decimal.NullDecimal `json:"discount"`
|
||||
Amount decimal.NullDecimal `json:"amount"`
|
||||
ChargeTo types.Date `json:"chargeTo"`
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ func (ur _UserRepository) ChangeState(uid string, state bool) (bool, error) {
|
|||
}
|
||||
|
||||
// 检索条目数量有限的用户详细信息
|
||||
func (ur _UserRepository) SearchUsersWithLimit(userType *int16, keyword *string, limit uint) ([]*model.UserDetail, error) {
|
||||
func (ur _UserRepository) SearchUsersWithLimit(userType *int16, keyword *string, limit uint) ([]*model.UserWithDetail, error) {
|
||||
ur.log.Info("检索条目数量有限的用户详细信息。", zap.Int16p("user type", userType), zap.Uint("limit", limit), zap.Stringp("keyword", keyword))
|
||||
actualUserType := tools.DefaultTo(userType, model.USER_TYPE_ENT)
|
||||
cacheConditions := []string{
|
||||
|
@ -409,13 +409,13 @@ func (ur _UserRepository) SearchUsersWithLimit(userType *int16, keyword *string,
|
|||
tools.DefaultTo(keyword, ""),
|
||||
fmt.Sprintf("%d", limit),
|
||||
}
|
||||
if users, err := cache.RetrieveSearch[[]*model.UserDetail]("user_with_detail_limited", cacheConditions...); err == nil && users != nil {
|
||||
if users, err := cache.RetrieveSearch[[]*model.UserWithDetail]("user_with_detail_limited", cacheConditions...); err == nil && users != nil {
|
||||
return *users, nil
|
||||
}
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
|
||||
var users []*model.UserDetail
|
||||
var users = make([]*model.UserWithDetail, 0)
|
||||
userQuery := ur.ds.
|
||||
From(goqu.T("user").As("u")).
|
||||
Join(goqu.T("user_detail").As("ud"), goqu.On(goqu.Ex{"ud.id": goqu.I("u.id")})).
|
||||
|
@ -442,7 +442,7 @@ func (ur _UserRepository) SearchUsersWithLimit(userType *int16, keyword *string,
|
|||
userQuery.Order(goqu.I("u.created_at").Desc()).Limit(limit)
|
||||
|
||||
userSql, userParams, _ := userQuery.Prepared(true).ToSQL()
|
||||
if err := pgxscan.Select(ctx, global.DB, users, userSql, userParams...); err != nil {
|
||||
if err := pgxscan.Select(ctx, global.DB, &users, userSql, userParams...); err != nil {
|
||||
ur.log.Error("从数据库查询用户列表失败。", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user