feat:完善项目信息

This commit is contained in:
henry
2021-12-29 16:12:25 +08:00
parent 43dd770336
commit c3da1ebc51
8 changed files with 121 additions and 19 deletions

View File

@ -22,6 +22,11 @@ type (
ID string `json:"id"`
*model2.UserConsume
}
// ConsumePageInfo 消耗日志分页信息
ConsumePageInfo struct {
controller.ReturnPages
TotalConsume float64 `json:"total_consume"`
}
)
// Instance 列表信息
@ -65,6 +70,39 @@ func (c *Consume) Instance(source int, createdAt string, page, pageSize int) (*c
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Exchange 兑换信息
func (c *Consume) Exchange(orderNo string, createdAt string, page, pageSize int) (*ConsumePageInfo, error) {
mUserConsume := model.NewUserConsume()
where := []*model2.ModelWhere{
model2.NewWhere("uid", c.UID),
model2.NewWhereIn("source", []model2.UserConsumeSource{
model2.UserConsumeSourceForExchangeCoin,
}),
}
if orderNo != "" {
where = append(where, model2.NewWhereLike("order_no", orderNo))
}
if createdAt != "" {
where = append(where, model2.NewWhereSectionAt("created_at", strings.Split(createdAt, " ~ "))...)
}
out := new(ConsumePageInfo)
res, err := mUserConsume.Exchange(page, pageSize, &out.Count, &out.TotalConsume)
if err != nil {
return nil, err
}
list := make([]*ConsumeInfo, 0)
for _, v := range res {
list = append(list, &ConsumeInfo{ID: v.GetEncodeID(), UserConsume: v})
}
out.Data = list
return out, nil
}
// Delete 删除操作
func (c *Consume) Delete(id uint64) error {
mUserConsume := model.NewUserConsume()

View File

@ -2,6 +2,7 @@ package user
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"SciencesServer/config"
@ -16,12 +17,16 @@ type Withdrawal struct {
type WithdrawalHandle func(session *session.Enterprise) *Withdrawal
type (
// WithdrawalBasic 基本信息
WithdrawalBasic struct {
ID string `json:"id"`
*model.UserWithdrawalInfo
}
// WithdrawalInfo 提现数据信息
WithdrawalInfo struct {
Data []*model2.UserWithdrawal `json:"data"`
Amount float64 `json:"amount"`
ActualAmount float64 `json:"actual_amount"`
Count int64 `json:"count"`
controller.ReturnPages
TotalAmount float64 `json:"total_amount"`
TotalActualAmount float64 `json:"total_actual_amount"`
}
// WithdrawalTransferInfo 提现转账信息
WithdrawalTransferInfo struct {
@ -36,16 +41,23 @@ func (c *Withdrawal) Instance(status int, createdAt string, page, pageSize int)
out := new(WithdrawalInfo)
where := []*model2.ModelWhere{model2.NewWhere("uid", c.UID), model2.NewWhere("status", status)}
where := []*model2.ModelWhere{model2.NewWhere("w.uid", c.UID), model2.NewWhere("w.status", status)}
if createdAt != "" {
where = append(where, model2.NewWhereSectionAt("created_at", strings.Split(createdAt, " ~ "))...)
where = append(where, model2.NewWhereSectionAt("w.created_at", strings.Split(createdAt, " ~ "))...)
}
var err error
ret, err := mUserWithdrawal.Withdrawal(page, pageSize, &out.Count, &out.TotalAmount, &out.TotalActualAmount, where...)
if out.Data, err = mUserWithdrawal.Withdrawal(page, pageSize, &out.Count, &out.Amount, &out.ActualAmount, where...); err != nil {
if err != nil {
return nil, err
}
list := make([]*WithdrawalBasic, 0)
for _, v := range ret {
list = append(list, &WithdrawalBasic{ID: v.GetEncodeID(), UserWithdrawalInfo: v})
}
out.Data = list
return out, nil
}