Browse Source

add wallet and points center

adv_callback
shenjiachi 1 month ago
parent
commit
31ec717853
13 changed files with 2241 additions and 41 deletions
  1. +1
    -1
      app/hdl/hdl_member_center.go
  2. +387
    -8
      app/hdl/hdl_points_center.go
  3. +94
    -0
      app/hdl/hdl_wallet.go
  4. +23
    -0
      app/md/md.wallet.go
  5. +1
    -0
      app/md/md_member_center.go
  6. +43
    -1
      app/md/md_points_center.go
  7. +9
    -1
      app/router/router.go
  8. +24
    -0
      app/svc/svc_common.go
  9. +136
    -0
      app/svc/svc_points_center.go
  10. +567
    -11
      docs/docs.go
  11. +564
    -9
      docs/swagger.json
  12. +390
    -8
      docs/swagger.yaml
  13. +2
    -2
      go.mod

+ 1
- 1
app/hdl/hdl_member_center.go View File

@@ -111,7 +111,7 @@ func MemberCenterGetBasic(c *gin.Context) {
eggEnergyValue := nowPrice.Mul(decimal.NewFromFloat(eggEnergy))

// 5. 查询蛋蛋分
now := time.Now().Add(-7 * time.Hour * 24)
now := time.Now()
esIndexName := es2.GetLatestEffectiveIndexFromAlias(now)
// 构建查询条件
boolQuery := elastic.NewBoolQuery()


+ 387
- 8
app/hdl/hdl_points_center.go View File

@@ -5,7 +5,9 @@ import (
"applet/app/db"
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"code.fnuoos.com/EggPlanet/egg_system_rules.git"
@@ -14,23 +16,26 @@ import (
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy"
md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/svc"
svc2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/svc"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/shopspring/decimal"
"time"
)

const PointsCenterCalcExchangeRedisKey = "Points_Center_Cache_Key"

// PointsCenterGetBasic
// @Summary 蛋蛋星球-积分中心-基础信息(获取)
// @Summary 蛋蛋星球-积分中心-上部分基础信息(获取)
// @Tags 积分中心
// @Description 基础信息(获取)
// @Description 上部分基础信息(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.PointsCenterGetBasicResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/getBasic [GET]
// @Router /api/v1/pointsCenter/basic [GET]
func PointsCenterGetBasic(c *gin.Context) {
val, exists := c.Get("user")
if !exists {
@@ -43,6 +48,238 @@ func PointsCenterGetBasic(c *gin.Context) {
return
}

settingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
setting, err := settingDb.EggEnergyBasicSettingGetOne()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}

virtualAmountDb := implement.NewUserVirtualAmountDb(db.Db)
// 蛋蛋能量 (个人 + 团队)
eggPersonalEnergy, err := virtualAmountDb.GetUserVirtualWalletBySession(user.Id, setting.PersonEggEnergyCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
eggTeamEnergy, err := virtualAmountDb.GetUserVirtualWalletBySession(user.Id, setting.TeamEggEnergyCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
eggEnergy := utils.StrToFloat64(eggPersonalEnergy.Amount) + utils.StrToFloat64(eggTeamEnergy.Amount)

// 蛋蛋能量价值
coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db)
coreData, err := coreDataDb.EggEnergyCoreDataGet()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
eggEnergyAmount := utils.StrToFloat64(coreData.NowPrice) * eggEnergy

// 活跃积分(蛋蛋积分 = 团队 + 个人)
eggPersonalPoint, err := virtualAmountDb.GetUserVirtualWalletBySession(user.Id, setting.PersonEggPointsCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
eggTeamPoint, err := virtualAmountDb.GetUserVirtualWalletBySession(user.Id, setting.TeamEggPointsCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
eggPoint := utils.StrToFloat64(eggPersonalPoint.Amount) + utils.StrToFloat64(eggTeamPoint.Amount)

// 蛋蛋积分价值
coinDb := implement.NewVirtualCoinDb(db.Db)
coin, err := coinDb.VirtualCoinGetOneByParams(map[string]interface{}{
"key": "id",
"value": setting.PersonEggPointsCoinId,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
var eggPointValue decimal.Decimal
if coin != nil {
ratio, _ := decimal.NewFromString(coin.ExchangeRatio)
eggPointValue = decimal.NewFromFloat(eggPoint).Div(ratio)
}
eggPointValue = decimal.NewFromInt(0)

// 账户余额
walletDb := implement.NewUserWalletDb(db.Db)
wallet, err := walletDb.GetUserVirtualWallet(user.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

resp := md.PointsCenterGetBasicResp{
Energy: utils.Float64ToStr(eggEnergy),
EnergyValue: utils.Float64ToStr(eggEnergyAmount),
WalletAmount: wallet.Amount,
EggPoint: utils.Float64ToStr(eggPoint),
EggPointValue: eggPointValue.String(),
}
e.OutSuc(c, resp, nil)
}

// InitialData
// @Summary 蛋蛋星球-积分中心-初始数据(获取)
// @Tags 积分中心
// @Description 初始数据(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.InitialDataResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/initialData [GET]
func InitialData(c *gin.Context) {
settingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
setting, err := settingDb.EggEnergyBasicSettingGetOne()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
resp := md.InitialDataResp{
InitialPrice: setting.InitialPrice,
TotalIssuanceAmount: setting.TotalIssuanceAmount,
TotalTechnologyTeam: setting.TotalTechnologyTeam,
TotalAngelInvestor: setting.TotalAngelInvestor,
TotalOperateFund: setting.TotalOperateFund,
TotalEcologicalDevelopment: setting.TotalEcologicalDevelopment,
}
e.OutSuc(c, resp, nil)
}

// DynamicData
// @Summary 蛋蛋星球-积分中心-动态数据(获取)
// @Tags 积分中心
// @Description 动态数据(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.DynamicDataResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/dynamicData [GET]
func DynamicData(c *gin.Context) {

settingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
setting, err := settingDb.EggEnergyBasicSettingGetOne()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}

// 1.用户持有总量
redisKey1 := PointsCenterCalcExchangeRedisKey + "_1"
redisValue1, err := cache.GetString(redisKey1)
if err != nil {
if err.Error() == "redigo: nil returned" {
amountDb := implement.NewUserVirtualAmountDb(db.Db)
total, err := amountDb.UserVirtualAmountGetSumByCoinKind(setting.PersonEggEnergyCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, nil)
return
}
//将获取到的余额值缓存至redis
redisValue1 = utils.Float64ToStr(total)
cache.SetEx(redisKey1, redisValue1, 60)
} else {
e.OutErr(c, e.ERR, err.Error())
return
}
}
// 2.星级分红
redisKey2 := PointsCenterCalcExchangeRedisKey + "_2"
redisValue2, err := cache.GetString(redisKey2)
if err != nil {
if err.Error() == "redigo: nil returned" {
coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db)
coreData, err := coreDataDb.EggEnergyCoreDataGet()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
redisValue2 = coreData.StarLevelDividends
cache.SetEx(redisKey2, redisValue2, 60)
} else {
e.OutErr(c, e.ERR, err.Error())
return
}
}

// 3.发展委员会
redisKey3 := PointsCenterCalcExchangeRedisKey + "_3"
redisValue3, err := cache.GetString(redisKey3)
if err != nil {
if err.Error() == "redigo: nil returned" {
coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db)
coreData, err := coreDataDb.EggEnergyCoreDataGet()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
redisValue3 = coreData.DevelopmentCommittee
cache.SetEx(redisKey3, redisValue3, 60)
} else {
e.OutErr(c, e.ERR, err.Error())
return
}
}
// 4.公益基金
redisKey4 := PointsCenterCalcExchangeRedisKey + "_4"
redisValue4, err := cache.GetString(redisKey4)
if err != nil {
if err.Error() == "redigo: nil returned" {
coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db)
coreData, err := coreDataDb.EggEnergyCoreDataGet()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
redisValue4 = coreData.PublicWelfareAndCharity
cache.SetEx(redisKey4, redisValue4, 60)
} else {
e.OutErr(c, e.ERR, err.Error())
return
}
}

resp := md.DynamicDataResp{
UserTotalHold: redisValue1,
StarLevelDividends: redisValue2,
DevelopmentCommittee: redisValue3,
PublicWelfareAndCharity: redisValue4,
}

e.OutSuc(c, resp, nil)
}

// PointsExchangeGetBasic
// @Summary 蛋蛋星球-积分中心-积分兑换基础信息(获取)
// @Tags 积分中心
// @Description 积分兑换基础信息(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.PointsExchangeGetBasicResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/pointsExchangeBasic [GET]
func PointsExchangeGetBasic(c *gin.Context) {
val, exists := c.Get("user")
if !exists {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}
user, ok := val.(*model.User)
if !ok {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}

// 1. 获取蛋蛋能量货币类型
settingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
setting, err := settingDb.EggEnergyBasicSettingGetOne()
@@ -68,7 +305,7 @@ func PointsCenterGetBasic(c *gin.Context) {
return
}

resp := md.PointsCenterGetBasicResp{
resp := md.PointsExchangeGetBasicResp{
AvailableEnergy: eggEnergyAmount.Amount,
AvailableCash: wallet.Amount,
}
@@ -205,7 +442,7 @@ func ExchangeEnergy(c *gin.Context) {

// 2. 计算蛋蛋能量兑换的金额
egg_system_rules.Init(cfg.RedisAddr)
eggEnergyCoreData, cb, err1 := svc.GetEggEnergyCoreData(db.Db)
eggEnergyCoreData, cb, err1 := svc2.GetEggEnergyCoreData(db.Db)
if err1 != nil {
fmt.Println("EggEnergyAutoRecordPrices_ERR:::::", err1.Error())
return
@@ -374,8 +611,8 @@ func GetContributionValue(c *gin.Context) {
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param limit query int true "每页大小"
// @Param page query int true "页数"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Success 200 {object} md.GetContributionValueFlowResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/contributionValueFlow [GET]
@@ -428,6 +665,148 @@ func GetContributionValueFlow(c *gin.Context) {
e.OutSuc(c, resp, nil)
}

// GetEggPointRecord
// @Summary 蛋蛋星球-积分中心-蛋蛋分明细(获取)
// @Tags 积分中心
// @Description 蛋蛋分明细(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Success 200 {object} md.GetEggPointRecordResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/record [GET]
func GetEggPointRecord(c *gin.Context) {
// todo 待补充
pageStr := c.DefaultQuery("page", "1")
limitStr := c.DefaultQuery("limit", "5")
page := utils.StrToInt(pageStr)
limit := utils.StrToInt(limitStr)
val, exists := c.Get("user")
if !exists {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}
user, ok := val.(*model.User)
if !ok {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}
now := time.Now()

list, nowScore, indexNum, err := svc.GetEggPointRecordBase(now, user.Id, page, limit)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

resp := md.GetEggPointRecordResp{
NowScore: nowScore,
List: list,
Paginate: md.Paginate{
Limit: limit,
Page: page,
Total: int64(indexNum),
},
}

e.OutSuc(c, resp, nil)
}

// GetEggEnergyFlow
// @Summary 蛋蛋星球-积分中心-收支明细(获取)
// @Tags 积分中心
// @Description 收支明细(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Param startAt query string false "开始时间"
// @Param endAt query string false "结束时间"
// @Param direction query string false "流水方向(1.收入 2.支出 0.全部)"
// @Success 200 {object} md.GetEggEnergyFlowResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/pointsCenter/energyFlow [GET]
func GetEggEnergyFlow(c *gin.Context) {
pageStr := c.DefaultQuery("page", "1")
limitStr := c.DefaultQuery("limit", "10")
startAt := c.Query("startAt")
endAt := c.Query("endAt")
directionStr := c.Query("direction")

val, exists := c.Get("user")
if !exists {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}
user, ok := val.(*model.User)
if !ok {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}

coinDb := implement.NewVirtualCoinDb(db.Db)
coins, err := coinDb.VirtualCoinFindAll()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if coins == nil {
e.OutErr(c, e.ERR_NO_DATA, errors.New("未初始化货币"))
return
}

coinsList := make([]map[string]interface{}, len(coins))
coinsMap := map[int]string{}
for i, coin := range coins {
coinsList[i] = map[string]interface{}{
"coinID": coin.Id,
"name": coin.Name,
}
coinsMap[coin.Id] = coin.Name
}

direction := 0
switch directionStr {
case "1":
direction = 1
case "2":
direction = 2
}

page := utils.StrToInt(pageStr)
limit := utils.StrToInt(limitStr)

flowDb := implement.NewUserVirtualCoinFlowDb(db.Db)
flows, total, err := flowDb.UserVirtualCoinFlowFindByCoinAndUser(page, limit, 0, user.Id, startAt, endAt, direction, false, 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

list := make([]md.EggEnergyFlowNode, len(flows))
for i, flow := range flows {
list[i].Title = flow.Title
list[i].Amount = flow.Amount
list[i].Direction = flow.Direction
list[i].CreateAt = flow.CreateAt
list[i].Id = flow.Id
list[i].BeforeAmount = flow.BeforeAmount
list[i].AfterAmount = flow.AfterAmount
list[i].CoinName = coinsMap[flow.CoinId]
list[i].SysFee = flow.SysFee
list[i].TransferType = enum.UserVirtualAmountFlowTransferType(flow.TransferType).String()
}

resp := md.GetEggEnergyFlowResp{
List: list,
Paginate: md.Paginate{
Limit: limit,
Page: page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

+ 94
- 0
app/hdl/hdl_wallet.go View File

@@ -0,0 +1,94 @@
package hdl

import (
"applet/app/db"
"applet/app/e"
"applet/app/md"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"github.com/gin-gonic/gin"
)

// GetAmountFlow
// @Summary 蛋蛋星球-钱包-余额明细(获取)
// @Tags 钱包
// @Description 余额明细(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Param startAt query string false "开始时间"
// @Param endAt query string false "结束时间"
// @Param direction query string false "流水方向(1.收入 2.支出 0.全部)"
// @Success 200 {object} md.GetAmountFlowResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/wallet/amountFlow [GET]
func GetAmountFlow(c *gin.Context) {
pageStr := c.DefaultQuery("page", "1")
limitStr := c.DefaultQuery("limit", "10")
startAt := c.Query("startAt")
endAt := c.Query("endAt")
directionStr := c.Query("direction")

val, exists := c.Get("user")
if !exists {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}
user, ok := val.(*model.User)
if !ok {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}

direction := 0
switch directionStr {
case "1":
direction = 1
case "2":
direction = 2
}

page := utils.StrToInt(pageStr)
limit := utils.StrToInt(limitStr)

flowDb := implement.NewUserWalletFlowDb(db.Db)
flows, total, err := flowDb.UserWalletFlowFindByCoinAndUser(page, limit, user.Id, startAt, endAt, direction, false, 0, 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

list := make([]md.WalletFlowNode, 0, len(flows))
for _, flow := range flows {
temp := md.WalletFlowNode{
Id: flow.Id,
Uid: flow.Uid,
Direction: flow.Direction,
Amount: flow.Amount,
BeforeAmount: flow.BeforeAmount,
AfterAmount: flow.AfterAmount,
SysFee: flow.SysFee,
OrdId: flow.OrdId,
Title: flow.Title,
Kind: flow.Kind,
State: flow.State,
Memo: flow.Memo,
CreateTime: flow.CreateAt,
UpdateTime: flow.UpdateAt,
}
list = append(list, temp)
}

resp := md.GetAmountFlowResp{
List: list,
Paginate: md.Paginate{
Limit: limit,
Page: page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

+ 23
- 0
app/md/md.wallet.go View File

@@ -0,0 +1,23 @@
package md

type WalletFlowNode struct {
Id int64 `json:"id"`
Uid int64 `json:"uid"` // 用户 ID
Direction int `json:"direction"` // 方向:1.收入 2.支出
Amount string `json:"amount"` // 变动金额
BeforeAmount string `json:"before_amount"` // 变动前金额
AfterAmount string `json:"after_amount"` // 变动后金额
SysFee string `json:"sys_fee"` // 手续费
OrdId string `json:"ord_id"` // 对应订单编号
Title string `json:"title"` // 标题
Kind int `json:"kind"` // 1:管理员操作增加余额 2:管理员操作扣除余额 3:蛋蛋能量兑换余额 4:余额兑换蛋蛋能量
State int `json:"state"` // 1未到账,2已到账
Memo string `json:"memo"` // 备注
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}

type GetAmountFlowResp struct {
List []WalletFlowNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

+ 1
- 0
app/md/md_member_center.go View File

@@ -31,4 +31,5 @@ type UserEggFlowReqRespList struct {
ViolateNums int `json:"violate_nums"` //违规次数
BrowseInterfaceNums int `json:"browse_interface_nums"` //浏览界面次数
PersonAddActivityValue int `json:"person_add_activity_value"` //个人活跃积分
UpdatedAt string `json:"updated_at"` //更新时间
}

+ 43
- 1
app/md/md_points_center.go View File

@@ -1,11 +1,35 @@
package md

type PointsCenterGetBasicResp struct {
Energy string `json:"energy"` // 蛋蛋能量值
EnergyValue string `json:"energy_amount"` // 能量价值
WalletAmount string `json:"wallet_amount"` // 账户余额
EggPoint string `json:"egg_point"` // 能量积分
EggPointValue string `json:"egg_point_amount"` // 能量积分价值
}

type InitialDataResp struct {
InitialPrice string `json:"initial_price"` // 初始价格
TotalIssuanceAmount string `json:"total_issuance_amount"` // 总发行量
TotalTechnologyTeam string `json:"total_technology_team"` // 技术团队
TotalAngelInvestor string `json:"total_angel_investor"` // 天使投资人
TotalOperateFund string `json:"total_operate_fund"` // 运营资金
TotalEcologicalDevelopment string `json:"total_ecological_development"` // 生态建设
}

type DynamicDataResp struct {
UserTotalHold string `json:"user_total_hold"` // 用户持有总量
StarLevelDividends string `json:"star_level_dividends"` // 星级分红
DevelopmentCommittee string `json:"development_committee"` // 发展委员会
PublicWelfareAndCharity string `json:"public_welfare_and_charity"` // 公益基金
}

type GetPriceCurveResp struct {
XData []interface{} `json:"x_data"`
YData []interface{} `json:"y_data"`
}

type PointsCenterGetBasicResp struct {
type PointsExchangeGetBasicResp struct {
AvailableEnergy string `json:"available_energy"` // 可用能量
AvailableCash string `json:"available_cash"` // 可用现金
}
@@ -44,3 +68,21 @@ type GetEggPointRecordResp struct {
List []EggPointRecordNode `json:"list"` // 分数明细列表
Paginate Paginate `json:"paginate"`
}

type EggEnergyFlowNode struct {
Id int64 `json:"id"`
CoinName string `json:"coin_name"` // 虚拟币名称
Direction int `json:"direction"` // 方向:1.收入 2.支出
Title string `json:"title"` // 标题
Amount string `json:"amount"` // 变更数量
BeforeAmount string `json:"before_amount"` // 变更前数量
AfterAmount string `json:"after_amount"` // 变更后数量
SysFee string `json:"sys_fee"` // 手续费
TransferType string `json:"transfer_type"` // 转账类型
CreateAt string `json:"create_at"` // 创建时间
}

type GetEggEnergyFlowResp struct {
List []EggEnergyFlowNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

+ 9
- 1
app/router/router.go View File

@@ -92,12 +92,20 @@ func route(r *gin.RouterGroup) {
}
rPointsCenter := r.Group("/pointsCenter") // 积分中心
{
rPointsCenter.GET("/getBasic", hdl.PointsCenterGetBasic) // 积分中-基础数据
rPointsCenter.GET("/basic", hdl.PointsCenterGetBasic) // 积分中心-基础信息
rPointsCenter.GET("/initialData", hdl.InitialData) // 积分中心-初始数据
rPointsCenter.GET("/dynamicData", hdl.DynamicData) // 积分中心-动态数据
rPointsCenter.GET("/pointsExchangeBasic", hdl.PointsExchangeGetBasic) // 积分中心-能量兑换基础数据
rPointsCenter.GET("/priceCurve", hdl.GetPriceCurve) // 积分中心-获取价格曲线
rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换
rPointsCenter.GET("/contributionValue", hdl.GetContributionValue) // 积分中心-贡献值
rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细
rPointsCenter.GET("/record", hdl.GetEggPointRecord) // 积分中心-蛋蛋分历史记录
rPointsCenter.GET("/energyFlow", hdl.GetEggEnergyFlow) // 积分中心-积分收支明细
}
rWallet := r.Group("/wallet") // 钱包
{
rWallet.GET("/amountFlow", hdl.GetAmountFlow) // 余额流水
}

}


+ 24
- 0
app/svc/svc_common.go View File

@@ -2,10 +2,12 @@ package svc

import (
"applet/app/db"
"applet/app/utils"
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"strings"
"time"
)

// 简单的recover
@@ -29,3 +31,25 @@ func GetSysCfgStr(key string) string {
return sysCfgDb.SysCfgGetWithDb(key)

}

// GetYearsAndWeekStr 获取年份和周数
func GetYearsAndWeekStr(esIndexName string) (string, string) {
parts := strings.Split(esIndexName, "_")
return parts[len(parts)-1][:4], parts[len(parts)-1][4:]
}

// GetWeekInfo 获取周数、开始时间、结束时间
func GetWeekInfo(dateStr string) (string, string, string, string) {
date := utils.TimeParseStd(dateStr)
year, week := date.ISOWeek()
location, _ := time.LoadLocation("Asia/Shanghai")
// 计算给定年份1月1日是星期几
startOfYear := time.Date(year, time.January, 1, 0, 0, 0, 0, location)
daysOffset := int(startOfYear.Weekday()) - int(time.Monday) + 1
// 计算给定年份的第一周的开始日期
firstWeekStart := startOfYear.AddDate(0, 0, -daysOffset+1)
// 计算给定周的开始日期
weekStart := firstWeekStart.AddDate(0, 0, (week-1)*7)
weekEnd := weekStart.AddDate(0, 0, 6)
return utils.IntToStr(year), utils.IntToStr(week), weekStart.Format("2006-01-02"), weekEnd.Format("2006-01-02")
}

+ 136
- 0
app/svc/svc_points_center.go View File

@@ -0,0 +1,136 @@
package svc

import (
"applet/app/md"
"applet/app/utils"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
es2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es"
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
"context"
"encoding/json"
"errors"
"github.com/olivere/elastic/v7"
"time"
)

func GetEggPointRecordBase(now time.Time, uid int64, page int, limit int) ([]md.EggPointRecordNode, string, int, error) {
aliasName := md2.EggEnergyUserEggScoreEsAlias
// 1. 判断当周分数是否生效
getLastWeek := true
if now.Weekday() > time.Wednesday || (now.Weekday() > time.Wednesday && now.Hour() > 14) {
getLastWeek = false
}

// 2. 计算有效周数数量
aliases, err := es.EsClient.Aliases().
Index(aliasName). // 指定别名
Do(context.Background())
if err != nil {
return nil, "", 0, err
}
indexNum := len(aliases.Indices)
if getLastWeek == true {
// 如果当期未生效 有效周数 - 1
indexNum--
}
if indexNum < 1 {
return nil, "", 0, errors.New("no data")
}
// 3. 获取最老有效索引及年份周数
oldestIndex := aliasName + "_" + "999999"
for key, _ := range aliases.Indices {
if key < oldestIndex {
oldestIndex = key
}
}
oldestYearStr, oldestWeekStr := GetYearsAndWeekStr(oldestIndex)
oldestYear := utils.StrToInt(oldestYearStr)
oldestWeek := utils.StrToInt(oldestWeekStr)

// 4. 获取当期有效蛋蛋分
nowIndex := es2.GetLatestEffectiveIndexFromAlias(now)
boolQuery := elastic.NewBoolQuery()
boolQuery.Filter(elastic.NewTermQuery("uid", uid))
searchResult, err := es.EsClient.Search().
Index(nowIndex).
Query(boolQuery).
Pretty(true).
Do(context.Background())
if searchResult == nil {
return nil, "", 0, errors.New("failed to get current egg score")
}

var results []md.UserEggFlowReqRespList
if searchResult.Hits.TotalHits.Value != 0 {
// 解析结果
for _, hit := range searchResult.Hits.Hits {
var doc md.UserEggFlowReqRespList
err = json.Unmarshal(hit.Source, &doc)
if err != nil {
return nil, "", 0, errors.New("failed to unmarshal")
}
results = append(results, doc)
}
}

nowScore := utils.Float64ToStr(results[0].ScoreValue)

indexes := make([]string, 0, limit)
// 5. 构造分页索引列表 查询历史蛋蛋分
for i := 0; i < limit; i++ {
var tempDays int
if getLastWeek {
tempDays = 7 * ((page-1)*limit + i + 1)
} else {
tempDays = 7 * ((page-1)*limit + i)
}
tempTime := now.AddDate(0, 0, -tempDays)
tempYear, tempWeek := tempTime.ISOWeek()
// 判断跳转到的时间是否大于最老索引时间
if tempYear == oldestYear {
if tempWeek < oldestWeek {
break
}
} else if tempYear < oldestYear {
break
}
tempIndex := es2.GetAppointIndexFromAlias(utils.IntToStr(tempYear), utils.IntToStr(tempWeek))
indexes = append(indexes, tempIndex)
}
// 构建查询条件
recordBoolQuery := elastic.NewBoolQuery()
recordBoolQuery.Filter(elastic.NewTermQuery("uid", uid))
searchRecordResult, err := es.EsClient.Search().
Index(indexes...).
Query(boolQuery).
Pretty(true).
Do(context.Background())
if searchRecordResult == nil {
return nil, "", 0, errors.New("failed to get egg score flows")
}
var recordResults []md.UserEggFlowReqRespList
// 检查是否有结果
if searchRecordResult.Hits.TotalHits.Value != 0 {
// 解析结果
for _, hit := range searchResult.Hits.Hits {
var doc md.UserEggFlowReqRespList
err = json.Unmarshal(hit.Source, &doc)
if err != nil {
return nil, "", 0, errors.New("failed to unmarshal")
}
recordResults = append(recordResults, doc)
}
}

list := make([]md.EggPointRecordNode, len(results))
for i, result := range recordResults {
year, week, startAt, endAt := GetWeekInfo(result.UpdatedAt)
list[i].Score = utils.Float64ToStr(result.ScoreValue)
list[i].Year = year
list[i].Week = week
list[i].StartAt = startAt
list[i].EndAt = endAt
}

return list, nowScore, indexNum, nil
}

+ 567
- 11
docs/docs.go View File

@@ -1,5 +1,4 @@
// Code generated by swaggo/swag. DO NOT EDIT.

// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"
@@ -832,6 +831,44 @@ const docTemplate = `{
}
}
},
"/api/v1/pointsCenter/basic": {
"get": {
"description": "上部分基础信息(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-上部分基础信息(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.PointsCenterGetBasicResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/contributionValue": {
"get": {
"description": "贡献值(获取)",
@@ -892,14 +929,14 @@ const docTemplate = `{
"required": true
},
{
"type": "integer",
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "integer",
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
@@ -922,6 +959,114 @@ const docTemplate = `{
}
}
},
"/api/v1/pointsCenter/dynamicData": {
"get": {
"description": "动态数据(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-动态数据(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.DynamicDataResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/energyFlow": {
"get": {
"description": "收支明细(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-收支明细(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
"required": true
},
{
"type": "string",
"description": "开始时间",
"name": "startAt",
"in": "query"
},
{
"type": "string",
"description": "结束时间",
"name": "endAt",
"in": "query"
},
{
"type": "string",
"description": "流水方向(1.收入 2.支出 0.全部)",
"name": "direction",
"in": "query"
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetEggEnergyFlowResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/exchangeEnergy": {
"post": {
"description": "能量兑换",
@@ -969,9 +1114,9 @@ const docTemplate = `{
}
}
},
"/api/v1/pointsCenter/getBasic": {
"/api/v1/pointsCenter/initialData": {
"get": {
"description": "基础信息(获取)",
"description": "初始数据(获取)",
"consumes": [
"application/json"
],
@@ -981,7 +1126,7 @@ const docTemplate = `{
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-基础信息(获取)",
"summary": "蛋蛋星球-积分中心-初始数据(获取)",
"parameters": [
{
"type": "string",
@@ -995,7 +1140,45 @@ const docTemplate = `{
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.PointsCenterGetBasicResp"
"$ref": "#/definitions/md.InitialDataResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/pointsExchangeBasic": {
"get": {
"description": "积分兑换基础信息(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-积分兑换基础信息(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.PointsExchangeGetBasicResp"
}
},
"400": {
@@ -1051,6 +1234,58 @@ const docTemplate = `{
}
}
},
"/api/v1/pointsCenter/record": {
"get": {
"description": "蛋蛋分明细(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-蛋蛋分明细(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetEggPointRecordResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/register": {
"post": {
"description": "注册",
@@ -1150,9 +1385,7 @@ const docTemplate = `{
"name": "req",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"schema": {}
}
],
"responses": {
@@ -1210,6 +1443,76 @@ const docTemplate = `{
}
}
},
"/api/v1/wallet/amountFlow": {
"get": {
"description": "余额明细(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"钱包"
],
"summary": "蛋蛋星球-钱包-余额明细(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
"required": true
},
{
"type": "string",
"description": "开始时间",
"name": "startAt",
"in": "query"
},
{
"type": "string",
"description": "结束时间",
"name": "endAt",
"in": "query"
},
{
"type": "string",
"description": "流水方向(1.收入 2.支出 0.全部)",
"name": "direction",
"in": "query"
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetAmountFlowResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/wechatLogin": {
"post": {
"description": "微信登陆",
@@ -1479,6 +1782,27 @@ const docTemplate = `{
}
}
},
"md.DynamicDataResp": {
"type": "object",
"properties": {
"development_committee": {
"description": "发展委员会",
"type": "string"
},
"public_welfare_and_charity": {
"description": "公益基金",
"type": "string"
},
"star_level_dividends": {
"description": "星级分红",
"type": "string"
},
"user_total_hold": {
"description": "用户持有总量",
"type": "string"
}
}
},
"md.EggEnergyDetailReq": {
"type": "object",
"properties": {
@@ -1555,6 +1879,50 @@ const docTemplate = `{
}
}
},
"md.EggEnergyFlowNode": {
"type": "object",
"properties": {
"after_amount": {
"description": "变更后数量",
"type": "string"
},
"amount": {
"description": "变更数量",
"type": "string"
},
"before_amount": {
"description": "变更前数量",
"type": "string"
},
"coin_name": {
"description": "虚拟币名称",
"type": "string"
},
"create_at": {
"description": "创建时间",
"type": "string"
},
"direction": {
"description": "方向:1.收入 2.支出",
"type": "integer"
},
"id": {
"type": "integer"
},
"sys_fee": {
"description": "手续费",
"type": "string"
},
"title": {
"description": "标题",
"type": "string"
},
"transfer_type": {
"description": "转账类型",
"type": "string"
}
}
},
"md.EggPointDetailsReq": {
"type": "object",
"properties": {
@@ -1631,6 +1999,31 @@ const docTemplate = `{
}
}
},
"md.EggPointRecordNode": {
"type": "object",
"properties": {
"end_at": {
"description": "结束时间",
"type": "string"
},
"score": {
"description": "分数",
"type": "string"
},
"start_at": {
"description": "开始时间",
"type": "string"
},
"week": {
"description": "周数",
"type": "string"
},
"year": {
"description": "年份",
"type": "string"
}
}
},
"md.ExchangeEnergyReq": {
"type": "object",
"properties": {
@@ -1672,6 +2065,20 @@ const docTemplate = `{
}
}
},
"md.GetAmountFlowResp": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/md.WalletFlowNode"
}
},
"paginate": {
"$ref": "#/definitions/applet_app_md.Paginate"
}
}
},
"md.GetContributionValueFlowResp": {
"type": "object",
"properties": {
@@ -1699,6 +2106,39 @@ const docTemplate = `{
}
}
},
"md.GetEggEnergyFlowResp": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/md.EggEnergyFlowNode"
}
},
"paginate": {
"$ref": "#/definitions/applet_app_md.Paginate"
}
}
},
"md.GetEggPointRecordResp": {
"type": "object",
"properties": {
"list": {
"description": "分数明细列表",
"type": "array",
"items": {
"$ref": "#/definitions/md.EggPointRecordNode"
}
},
"now_score": {
"description": "当前分数",
"type": "string"
},
"paginate": {
"$ref": "#/definitions/applet_app_md.Paginate"
}
}
},
"md.GetPriceCurveResp": {
"type": "object",
"properties": {
@@ -1786,6 +2226,35 @@ const docTemplate = `{
}
}
},
"md.InitialDataResp": {
"type": "object",
"properties": {
"initial_price": {
"description": "初始价格",
"type": "string"
},
"total_angel_investor": {
"description": "天使投资人",
"type": "string"
},
"total_ecological_development": {
"description": "生态建设",
"type": "string"
},
"total_issuance_amount": {
"description": "总发行量",
"type": "string"
},
"total_operate_fund": {
"description": "运营资金",
"type": "string"
},
"total_technology_team": {
"description": "技术团队",
"type": "string"
}
}
},
"md.IntegralList": {
"type": "object",
"properties": {
@@ -1977,6 +2446,31 @@ const docTemplate = `{
}
},
"md.PointsCenterGetBasicResp": {
"type": "object",
"properties": {
"egg_point": {
"description": "能量积分",
"type": "string"
},
"egg_point_amount": {
"description": "能量积分价值",
"type": "string"
},
"energy": {
"description": "蛋蛋能量值",
"type": "string"
},
"energy_amount": {
"description": "能量价值",
"type": "string"
},
"wallet_amount": {
"description": "账户余额",
"type": "string"
}
}
},
"md.PointsExchangeGetBasicResp": {
"type": "object",
"properties": {
"available_cash": {
@@ -2198,6 +2692,66 @@ const docTemplate = `{
}
}
},
"md.WalletFlowNode": {
"type": "object",
"properties": {
"after_amount": {
"description": "变动后金额",
"type": "string"
},
"amount": {
"description": "变动金额",
"type": "string"
},
"before_amount": {
"description": "变动前金额",
"type": "string"
},
"create_time": {
"description": "创建时间",
"type": "string"
},
"direction": {
"description": "方向:1.收入 2.支出",
"type": "integer"
},
"id": {
"type": "integer"
},
"kind": {
"description": "1:管理员操作增加余额 2:管理员操作扣除余额 3:蛋蛋能量兑换余额 4:余额兑换蛋蛋能量",
"type": "integer"
},
"memo": {
"description": "备注",
"type": "string"
},
"ord_id": {
"description": "对应订单编号",
"type": "string"
},
"state": {
"description": "1未到账,2已到账",
"type": "integer"
},
"sys_fee": {
"description": "手续费",
"type": "string"
},
"title": {
"description": "标题",
"type": "string"
},
"uid": {
"description": "用户 ID",
"type": "integer"
},
"update_time": {
"description": "更新时间",
"type": "string"
}
}
},
"md.WechatLoginReq": {
"type": "object",
"properties": {
@@ -2232,6 +2786,8 @@ var SwaggerInfo = &swag.Spec{
Description: "APP客户端-Api接口",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {


+ 564
- 9
docs/swagger.json View File

@@ -825,6 +825,44 @@
}
}
},
"/api/v1/pointsCenter/basic": {
"get": {
"description": "上部分基础信息(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-上部分基础信息(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.PointsCenterGetBasicResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/contributionValue": {
"get": {
"description": "贡献值(获取)",
@@ -885,14 +923,14 @@
"required": true
},
{
"type": "integer",
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "integer",
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
@@ -915,6 +953,114 @@
}
}
},
"/api/v1/pointsCenter/dynamicData": {
"get": {
"description": "动态数据(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-动态数据(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.DynamicDataResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/energyFlow": {
"get": {
"description": "收支明细(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-收支明细(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
"required": true
},
{
"type": "string",
"description": "开始时间",
"name": "startAt",
"in": "query"
},
{
"type": "string",
"description": "结束时间",
"name": "endAt",
"in": "query"
},
{
"type": "string",
"description": "流水方向(1.收入 2.支出 0.全部)",
"name": "direction",
"in": "query"
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetEggEnergyFlowResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/exchangeEnergy": {
"post": {
"description": "能量兑换",
@@ -962,9 +1108,9 @@
}
}
},
"/api/v1/pointsCenter/getBasic": {
"/api/v1/pointsCenter/initialData": {
"get": {
"description": "基础信息(获取)",
"description": "初始数据(获取)",
"consumes": [
"application/json"
],
@@ -974,7 +1120,7 @@
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-基础信息(获取)",
"summary": "蛋蛋星球-积分中心-初始数据(获取)",
"parameters": [
{
"type": "string",
@@ -988,7 +1134,45 @@
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.PointsCenterGetBasicResp"
"$ref": "#/definitions/md.InitialDataResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/pointsCenter/pointsExchangeBasic": {
"get": {
"description": "积分兑换基础信息(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-积分兑换基础信息(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.PointsExchangeGetBasicResp"
}
},
"400": {
@@ -1044,6 +1228,58 @@
}
}
},
"/api/v1/pointsCenter/record": {
"get": {
"description": "蛋蛋分明细(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"积分中心"
],
"summary": "蛋蛋星球-积分中心-蛋蛋分明细(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetEggPointRecordResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/register": {
"post": {
"description": "注册",
@@ -1143,9 +1379,7 @@
"name": "req",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"schema": {}
}
],
"responses": {
@@ -1203,6 +1437,76 @@
}
}
},
"/api/v1/wallet/amountFlow": {
"get": {
"description": "余额明细(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"钱包"
],
"summary": "蛋蛋星球-钱包-余额明细(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "每页大小",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "string",
"description": "页数",
"name": "page",
"in": "query",
"required": true
},
{
"type": "string",
"description": "开始时间",
"name": "startAt",
"in": "query"
},
{
"type": "string",
"description": "结束时间",
"name": "endAt",
"in": "query"
},
{
"type": "string",
"description": "流水方向(1.收入 2.支出 0.全部)",
"name": "direction",
"in": "query"
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetAmountFlowResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/wechatLogin": {
"post": {
"description": "微信登陆",
@@ -1472,6 +1776,27 @@
}
}
},
"md.DynamicDataResp": {
"type": "object",
"properties": {
"development_committee": {
"description": "发展委员会",
"type": "string"
},
"public_welfare_and_charity": {
"description": "公益基金",
"type": "string"
},
"star_level_dividends": {
"description": "星级分红",
"type": "string"
},
"user_total_hold": {
"description": "用户持有总量",
"type": "string"
}
}
},
"md.EggEnergyDetailReq": {
"type": "object",
"properties": {
@@ -1548,6 +1873,50 @@
}
}
},
"md.EggEnergyFlowNode": {
"type": "object",
"properties": {
"after_amount": {
"description": "变更后数量",
"type": "string"
},
"amount": {
"description": "变更数量",
"type": "string"
},
"before_amount": {
"description": "变更前数量",
"type": "string"
},
"coin_name": {
"description": "虚拟币名称",
"type": "string"
},
"create_at": {
"description": "创建时间",
"type": "string"
},
"direction": {
"description": "方向:1.收入 2.支出",
"type": "integer"
},
"id": {
"type": "integer"
},
"sys_fee": {
"description": "手续费",
"type": "string"
},
"title": {
"description": "标题",
"type": "string"
},
"transfer_type": {
"description": "转账类型",
"type": "string"
}
}
},
"md.EggPointDetailsReq": {
"type": "object",
"properties": {
@@ -1624,6 +1993,31 @@
}
}
},
"md.EggPointRecordNode": {
"type": "object",
"properties": {
"end_at": {
"description": "结束时间",
"type": "string"
},
"score": {
"description": "分数",
"type": "string"
},
"start_at": {
"description": "开始时间",
"type": "string"
},
"week": {
"description": "周数",
"type": "string"
},
"year": {
"description": "年份",
"type": "string"
}
}
},
"md.ExchangeEnergyReq": {
"type": "object",
"properties": {
@@ -1665,6 +2059,20 @@
}
}
},
"md.GetAmountFlowResp": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/md.WalletFlowNode"
}
},
"paginate": {
"$ref": "#/definitions/applet_app_md.Paginate"
}
}
},
"md.GetContributionValueFlowResp": {
"type": "object",
"properties": {
@@ -1692,6 +2100,39 @@
}
}
},
"md.GetEggEnergyFlowResp": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/md.EggEnergyFlowNode"
}
},
"paginate": {
"$ref": "#/definitions/applet_app_md.Paginate"
}
}
},
"md.GetEggPointRecordResp": {
"type": "object",
"properties": {
"list": {
"description": "分数明细列表",
"type": "array",
"items": {
"$ref": "#/definitions/md.EggPointRecordNode"
}
},
"now_score": {
"description": "当前分数",
"type": "string"
},
"paginate": {
"$ref": "#/definitions/applet_app_md.Paginate"
}
}
},
"md.GetPriceCurveResp": {
"type": "object",
"properties": {
@@ -1779,6 +2220,35 @@
}
}
},
"md.InitialDataResp": {
"type": "object",
"properties": {
"initial_price": {
"description": "初始价格",
"type": "string"
},
"total_angel_investor": {
"description": "天使投资人",
"type": "string"
},
"total_ecological_development": {
"description": "生态建设",
"type": "string"
},
"total_issuance_amount": {
"description": "总发行量",
"type": "string"
},
"total_operate_fund": {
"description": "运营资金",
"type": "string"
},
"total_technology_team": {
"description": "技术团队",
"type": "string"
}
}
},
"md.IntegralList": {
"type": "object",
"properties": {
@@ -1970,6 +2440,31 @@
}
},
"md.PointsCenterGetBasicResp": {
"type": "object",
"properties": {
"egg_point": {
"description": "能量积分",
"type": "string"
},
"egg_point_amount": {
"description": "能量积分价值",
"type": "string"
},
"energy": {
"description": "蛋蛋能量值",
"type": "string"
},
"energy_amount": {
"description": "能量价值",
"type": "string"
},
"wallet_amount": {
"description": "账户余额",
"type": "string"
}
}
},
"md.PointsExchangeGetBasicResp": {
"type": "object",
"properties": {
"available_cash": {
@@ -2191,6 +2686,66 @@
}
}
},
"md.WalletFlowNode": {
"type": "object",
"properties": {
"after_amount": {
"description": "变动后金额",
"type": "string"
},
"amount": {
"description": "变动金额",
"type": "string"
},
"before_amount": {
"description": "变动前金额",
"type": "string"
},
"create_time": {
"description": "创建时间",
"type": "string"
},
"direction": {
"description": "方向:1.收入 2.支出",
"type": "integer"
},
"id": {
"type": "integer"
},
"kind": {
"description": "1:管理员操作增加余额 2:管理员操作扣除余额 3:蛋蛋能量兑换余额 4:余额兑换蛋蛋能量",
"type": "integer"
},
"memo": {
"description": "备注",
"type": "string"
},
"ord_id": {
"description": "对应订单编号",
"type": "string"
},
"state": {
"description": "1未到账,2已到账",
"type": "integer"
},
"sys_fee": {
"description": "手续费",
"type": "string"
},
"title": {
"description": "标题",
"type": "string"
},
"uid": {
"description": "用户 ID",
"type": "integer"
},
"update_time": {
"description": "更新时间",
"type": "string"
}
}
},
"md.WechatLoginReq": {
"type": "object",
"properties": {


+ 390
- 8
docs/swagger.yaml View File

@@ -161,6 +161,21 @@ definitions:
description: 标题
type: string
type: object
md.DynamicDataResp:
properties:
development_committee:
description: 发展委员会
type: string
public_welfare_and_charity:
description: 公益基金
type: string
star_level_dividends:
description: 星级分红
type: string
user_total_hold:
description: 用户持有总量
type: string
type: object
md.EggEnergyDetailReq:
properties:
asc:
@@ -212,6 +227,38 @@ definitions:
- $ref: '#/definitions/md.TransferTypeList'
description: 转账类型列表
type: object
md.EggEnergyFlowNode:
properties:
after_amount:
description: 变更后数量
type: string
amount:
description: 变更数量
type: string
before_amount:
description: 变更前数量
type: string
coin_name:
description: 虚拟币名称
type: string
create_at:
description: 创建时间
type: string
direction:
description: 方向:1.收入 2.支出
type: integer
id:
type: integer
sys_fee:
description: 手续费
type: string
title:
description: 标题
type: string
transfer_type:
description: 转账类型
type: string
type: object
md.EggPointDetailsReq:
properties:
asc:
@@ -263,6 +310,24 @@ definitions:
- $ref: '#/definitions/md.TransferTypeList'
description: 转账类型列表
type: object
md.EggPointRecordNode:
properties:
end_at:
description: 结束时间
type: string
score:
description: 分数
type: string
start_at:
description: 开始时间
type: string
week:
description: 周数
type: string
year:
description: 年份
type: string
type: object
md.ExchangeEnergyReq:
properties:
energy_amount:
@@ -291,6 +356,15 @@ definitions:
required:
- mobile
type: object
md.GetAmountFlowResp:
properties:
list:
items:
$ref: '#/definitions/md.WalletFlowNode'
type: array
paginate:
$ref: '#/definitions/applet_app_md.Paginate'
type: object
md.GetContributionValueFlowResp:
properties:
list:
@@ -309,6 +383,28 @@ definitions:
description: 兑换比率(x 分兑换 1 人民币)
type: string
type: object
md.GetEggEnergyFlowResp:
properties:
list:
items:
$ref: '#/definitions/md.EggEnergyFlowNode'
type: array
paginate:
$ref: '#/definitions/applet_app_md.Paginate'
type: object
md.GetEggPointRecordResp:
properties:
list:
description: 分数明细列表
items:
$ref: '#/definitions/md.EggPointRecordNode'
type: array
now_score:
description: 当前分数
type: string
paginate:
$ref: '#/definitions/applet_app_md.Paginate'
type: object
md.GetPriceCurveResp:
properties:
x_data:
@@ -372,6 +468,27 @@ definitions:
description: 奖励X个活跃积分
type: string
type: object
md.InitialDataResp:
properties:
initial_price:
description: 初始价格
type: string
total_angel_investor:
description: 天使投资人
type: string
total_ecological_development:
description: 生态建设
type: string
total_issuance_amount:
description: 总发行量
type: string
total_operate_fund:
description: 运营资金
type: string
total_technology_team:
description: 技术团队
type: string
type: object
md.IntegralList:
properties:
expend_list:
@@ -505,6 +622,24 @@ definitions:
type: string
type: object
md.PointsCenterGetBasicResp:
properties:
egg_point:
description: 能量积分
type: string
egg_point_amount:
description: 能量积分价值
type: string
energy:
description: 蛋蛋能量值
type: string
energy_amount:
description: 能量价值
type: string
wallet_amount:
description: 账户余额
type: string
type: object
md.PointsExchangeGetBasicResp:
properties:
available_cash:
description: 可用现金
@@ -655,6 +790,50 @@ definitions:
phone:
type: string
type: object
md.WalletFlowNode:
properties:
after_amount:
description: 变动后金额
type: string
amount:
description: 变动金额
type: string
before_amount:
description: 变动前金额
type: string
create_time:
description: 创建时间
type: string
direction:
description: 方向:1.收入 2.支出
type: integer
id:
type: integer
kind:
description: 1:管理员操作增加余额 2:管理员操作扣除余额 3:蛋蛋能量兑换余额 4:余额兑换蛋蛋能量
type: integer
memo:
description: 备注
type: string
ord_id:
description: 对应订单编号
type: string
state:
description: 1未到账,2已到账
type: integer
sys_fee:
description: 手续费
type: string
title:
description: 标题
type: string
uid:
description: 用户 ID
type: integer
update_time:
description: 更新时间
type: string
type: object
md.WechatLoginReq:
properties:
avatar:
@@ -1215,6 +1394,31 @@ paths:
summary: 蛋蛋星球-会员中心-基础数据(获取)
tags:
- 会员中心
/api/v1/pointsCenter/basic:
get:
consumes:
- application/json
description: 上部分基础信息(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.PointsCenterGetBasicResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-积分中心-上部分基础信息(获取)
tags:
- 积分中心
/api/v1/pointsCenter/contributionValue:
get:
consumes:
@@ -1255,12 +1459,12 @@ paths:
in: query
name: limit
required: true
type: integer
type: string
- description: 页数
in: query
name: page
required: true
type: integer
type: string
produces:
- application/json
responses:
@@ -1275,6 +1479,78 @@ paths:
summary: 蛋蛋星球-积分中心-贡献值明细(获取)
tags:
- 积分中心
/api/v1/pointsCenter/dynamicData:
get:
consumes:
- application/json
description: 动态数据(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.DynamicDataResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-积分中心-动态数据(获取)
tags:
- 积分中心
/api/v1/pointsCenter/energyFlow:
get:
consumes:
- application/json
description: 收支明细(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 每页大小
in: query
name: limit
required: true
type: string
- description: 页数
in: query
name: page
required: true
type: string
- description: 开始时间
in: query
name: startAt
type: string
- description: 结束时间
in: query
name: endAt
type: string
- description: 流水方向(1.收入 2.支出 0.全部)
in: query
name: direction
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.GetEggEnergyFlowResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-积分中心-收支明细(获取)
tags:
- 积分中心
/api/v1/pointsCenter/exchangeEnergy:
post:
consumes:
@@ -1306,11 +1582,11 @@ paths:
summary: 蛋蛋星球-积分中心-能量兑换
tags:
- 积分中心
/api/v1/pointsCenter/getBasic:
/api/v1/pointsCenter/initialData:
get:
consumes:
- application/json
description: 基础信息(获取)
description: 初始数据(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
@@ -1323,12 +1599,37 @@ paths:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.PointsCenterGetBasicResp'
$ref: '#/definitions/md.InitialDataResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-积分中心-初始数据(获取)
tags:
- 积分中心
/api/v1/pointsCenter/pointsExchangeBasic:
get:
consumes:
- application/json
description: 积分兑换基础信息(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.PointsExchangeGetBasicResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-积分中心-基础信息(获取)
summary: 蛋蛋星球-积分中心-积分兑换基础信息(获取)
tags:
- 积分中心
/api/v1/pointsCenter/priceCurve:
@@ -1360,6 +1661,41 @@ paths:
summary: 蛋蛋星球-积分中心-价格趋势(获取)
tags:
- 积分中心
/api/v1/pointsCenter/record:
get:
consumes:
- application/json
description: 蛋蛋分明细(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 每页大小
in: query
name: limit
required: true
type: string
- description: 页数
in: query
name: page
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.GetEggPointRecordResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-积分中心-蛋蛋分明细(获取)
tags:
- 积分中心
/api/v1/register:
post:
consumes:
@@ -1422,8 +1758,7 @@ paths:
in: body
name: req
required: true
schema:
type: object
schema: {}
produces:
- application/json
responses:
@@ -1464,6 +1799,53 @@ paths:
summary: 用户信息
tags:
- 用户信息
/api/v1/wallet/amountFlow:
get:
consumes:
- application/json
description: 余额明细(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 每页大小
in: query
name: limit
required: true
type: string
- description: 页数
in: query
name: page
required: true
type: string
- description: 开始时间
in: query
name: startAt
type: string
- description: 结束时间
in: query
name: endAt
type: string
- description: 流水方向(1.收入 2.支出 0.全部)
in: query
name: direction
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.GetAmountFlowResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-钱包-余额明细(获取)
tags:
- 钱包
/api/v1/wechatLogin:
post:
consumes:


+ 2
- 2
go.mod View File

@@ -32,8 +32,8 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241123072806-2fc832067f77
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241123034858-48fbf35fcb21
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241123093254-20bf9e0d7fc0
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241123093218-87b65e51eea3
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible


Loading…
Cancel
Save