diff --git a/app/hdl/hdl_add_friend.go b/app/hdl/hdl_add_friend.go index 78f1520..0aec774 100644 --- a/app/hdl/hdl_add_friend.go +++ b/app/hdl/hdl_add_friend.go @@ -7,14 +7,13 @@ import ( "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" - md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + enum "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" "encoding/json" "fmt" "github.com/gin-gonic/gin" "github.com/shopspring/decimal" "math" - "strconv" "strings" "time" ) @@ -126,51 +125,61 @@ func EggEnergyDetails(c *gin.Context) { totalEggEnergyPrice := totalEggEnergy * utils.StrToFloat64(coreData.NowPrice) transferTypeList := md.TransferTypeList{ - AvailableIntegralList: md.IntegralList{ + PersonalTransferTypeList: md.IntegralList{ IncomeList: []md.TransferTypeNode{ { - Value: strconv.Itoa(md3.EggPlantEggEnergySignInSettlementPersonalRewardForUserVirtualCoinFlow), - Name: md3.EggPlantEggEnergySignInSettlementPersonalReward, + // 浏览视频 + Value: utils.AnyToString(enum.EggEnergyWatchAdRewardPersonalActiveCoin), + Name: enum.EggEnergyWatchAdRewardPersonalActiveCoin.String(), }, { - Value: strconv.Itoa(md3.EggPlantBalanceExchangeForEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantBalanceExchangeForEggEnergy, + // 圈层奖励 + Value: utils.AnyToString(enum.EggEnergyWatchAdRewardTeamActiveCoin), + Name: enum.EggEnergyWatchAdRewardTeamActiveCoin.String(), }, { - Value: strconv.Itoa(md3.EggPlantPersonalActiveCoinExchangeEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantPersonalActiveCoinExchangeEggEnergy, + // 兑换到个人蛋蛋能量 + Value: utils.AnyToString(enum.PersonEggGetByEnergyEggPointCoin), + Name: enum.PersonEggGetByEnergyEggPointCoin.String(), }, { - Value: strconv.Itoa(md3.EggPlantSettlementEggEnergyExchangeEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantSettlementEggEnergyExchangeEggEnergy, + // 释放到个人蛋蛋能量 + Value: utils.AnyToString(enum.TeamEggEnergyReleaseToPersonEggEnergy), + Name: enum.TeamEggEnergyReleaseToPersonEggEnergy.String(), + }, + { + // 蛋蛋能量-社区分红 + Value: utils.AnyToString(enum.EggEnergyCommunityDividends), + Name: enum.EggEnergyCommunityDividends.String(), + }, + { + // 星级分红 + Value: utils.AnyToString(enum.SettlementStarLevelDividends), + Name: enum.SettlementStarLevelDividends.String(), }, }, ExpendList: []md.TransferTypeNode{ { - Value: strconv.Itoa(md3.EggPlantEggEnergyExchangeForBalanceForUserVirtualCoinFlow), - Name: md3.EggPlantEggEnergyExchangeForBalance, + // 个人蛋蛋能量兑换余额 + Value: utils.AnyToString(enum.EggEnergyToExchangeToAmount), + Name: enum.EggEnergyToExchangeToAmount.String(), }, }, }, - SettlementIntegralList: md.IntegralList{ + TeamTransferTypeList: md.IntegralList{ IncomeList: []md.TransferTypeNode{ { - Value: strconv.Itoa(md3.EggPlantEggEnergySignInSettlementTeamRewardForUserVirtualCoinFlow), - Name: md3.EggPlantEggEnergySignInSettlementTeamReward, - }, - { - Value: strconv.Itoa(md3.EggPlantTeamActiveCoinExchangeEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantTeamActiveCoinExchangeEggEnergy, - }, - { - Value: strconv.Itoa(md3.EggPlantSettlementStarLevelDividendsForUserVirtualCoinFlow), - Name: md3.EggPlantSettlementStarLevelDividends, + // 兑换到团队蛋蛋能量 + Value: utils.AnyToString(enum.TeamEggGetByEnergyEggPointCoin), + Name: enum.TeamEggGetByEnergyEggPointCoin.String(), }, }, ExpendList: []md.TransferTypeNode{ + { - Value: strconv.Itoa(md3.EggPlantSettlementEggEnergyExchangeTobeEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantSettlementEggEnergyExchangeEggEnergy, + // 团队蛋蛋能量释放 + Value: utils.AnyToString(enum.TeamEggEnergyReleaseToPersonEggEnergy), + Name: enum.TeamEggEnergyReleaseToPersonEggEnergy.String(), }, }, }, @@ -303,39 +312,23 @@ func EggPointDetails(c *gin.Context) { totalEggPointsAmount := totalEggPointsValue.Div(exchangeRatio).String() transferTypeList := md.TransferTypeList{ - AvailableIntegralList: md.IntegralList{ - IncomeList: []md.TransferTypeNode{ - { - Value: strconv.Itoa(md3.EggPlantWatchAdRewardPersonalActiveCoinForUserVirtualCoinFlow), - Name: md3.EggPlantWatchAdRewardPersonalActiveCoin, - }, - { - Value: strconv.Itoa(md3.EggPlantConsumeOrdersGiveEggEnergyToPersonForUserVirtualCoinFlow), - Name: md3.EggPlantConsumeOrdersGiveEggEnergyForPerson, - }, - }, + PersonalTransferTypeList: md.IntegralList{ + IncomeList: []md.TransferTypeNode{}, ExpendList: []md.TransferTypeNode{ { - Value: strconv.Itoa(md3.EggPlantPersonalActiveCoinExchangeToBeEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantPersonalActiveCoinExchangeToBeEggEnergy, + // 个人蛋蛋积分兑换 + Value: utils.AnyToString(enum.EggPointCoinToExchangeToPersonEggEnergy), + Name: enum.EggPointCoinToExchangeToPersonEggEnergy.String(), }, }, }, - SettlementIntegralList: md.IntegralList{ - IncomeList: []md.TransferTypeNode{ - { - Value: strconv.Itoa(md3.EggPlantWatchAdRewardTeamActiveCoinForUserVirtualCoinFlow), - Name: md3.EggPlantWatchAdRewardTeamActiveCoin, - }, - { - Value: strconv.Itoa(md3.EggPlantConsumeOrdersGiveEggEnergyToTeamForUserVirtualCoinFlow), - Name: md3.EggPlantConsumeOrdersGiveEggEnergyForTeam, - }, - }, + TeamTransferTypeList: md.IntegralList{ + IncomeList: []md.TransferTypeNode{}, ExpendList: []md.TransferTypeNode{ { - Value: strconv.Itoa(md3.EggPlantTeamActiveCoinExchangeToBeEggEnergyForUserVirtualCoinFlow), - Name: md3.EggPlantTeamActiveCoinExchangeToBeEggEnergy, + // 团队蛋蛋积分兑换 + Value: utils.AnyToString(enum.EggPointCoinToExchangeToTeamEggEnergy), + Name: enum.EggPointCoinToExchangeToTeamEggEnergy.String(), }, }, }, diff --git a/app/hdl/hdl_points_center.go b/app/hdl/hdl_points_center.go new file mode 100644 index 0000000..0563c30 --- /dev/null +++ b/app/hdl/hdl_points_center.go @@ -0,0 +1,305 @@ +package hdl + +import ( + "applet/app/cfg" + "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" + "code.fnuoos.com/EggPlanet/egg_system_rules.git" + "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" + md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + "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" + "fmt" + "github.com/gin-gonic/gin" + "github.com/shopspring/decimal" + "time" +) + +// PointsCenterGetBasic +// @Summary 蛋蛋星球-积分中心-基础信息(获取) +// @Tags 积分中心 +// @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] +func PointsCenterGetBasic(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() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + coinID := setting.PersonEggEnergyCoinId + + // 2. 获取可兑蛋蛋能量 + virtualAmountDb := implement.NewUserVirtualAmountDb(db.Db) + eggEnergyAmount, err := virtualAmountDb.GetUserVirtualWalletBySession(user.Id, coinID) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + // 3. 可用现金 + 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{ + AvailableEnergy: eggEnergyAmount.Amount, + AvailableCash: wallet.Amount, + } + + e.OutSuc(c, resp, nil) +} + +// GetPriceCurve +// @Summary 蛋蛋星球-积分中心-价格趋势(获取) +// @Tags 积分中心 +// @Description 价格趋势(获取) +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param kind query string false "1:按天 2:按小时 3:按周" +// @Success 200 {object} md.GetPriceCurveResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/pointsCenter/priceCurve [GET] +func GetPriceCurve(c *gin.Context) { + kind := c.DefaultQuery("kind", "1") + now := time.Now() + + priceDb := implement.NewEggEnergyPriceDb(db.Db) + m, has, err := priceDb.EggEnergyPriceGetLastOne() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if has == false { + e.OutErr(c, e.ERR_NO_DATA, "未查询到数据") + return + } + + var yData []interface{} + var xData []interface{} + switch kind { + case "1": + var date = now.AddDate(0, 0, -30).Format("2006-01-02") + var sql = fmt.Sprintf("SELECT price,date FROM `egg_energy_price` WHERE HOUR = 23 AND DATE >= \"%s\" AND DATE != \"%s\" ORDER BY DATE ASC ", date, now.Format("2006-01-02")) + results, _ := db.Db.QueryString(sql) + for _, v := range results { + tmpDate := utils.TimeParseStd(v["date"]) + yData = append(yData, v["price"]) + xData = append(xData, tmpDate.Format("01-02")) + } + yData = append(yData, m.Price) + tmpDate := utils.TimeParseStd(m.Date) + xData = append(xData, tmpDate.Format("01-02")) + break + case "2": + for i := 29; i >= 1; i-- { + date := now.Add(-time.Hour * 4 * time.Duration(i)).Format("2006-01-02") + hour := now.Add(-time.Hour * 4 * time.Duration(i)).Hour() + var sql = "SELECT price,date,hour FROM `egg_energy_price` WHERE HOUR = %d AND DATE = \"%s\" " + sql = fmt.Sprintf(sql, hour, date) + results, _ := db.Db.QueryString(sql) + if results != nil { + //if results[0]["date"] != now.Format("2006-01-02") { + // continue + //} + yData = append(yData, results[0]["price"]) + xData = append(xData, results[0]["hour"]+":00") + } + } + yData = append(yData, m.Price) + xData = append(xData, m.Hour+":00") + break + case "3": + var nums = 29 + for i := nums; i >= 1; i-- { + var date = now.AddDate(0, 0, -7*i).Format("2006-01-02") + var sql = "SELECT price, date FROM `egg_energy_price` WHERE HOUR = 23 AND DATE = \"%s\" " + sql = fmt.Sprintf(sql, date) + results, _ := db.Db.QueryString(sql) + if results != nil { + tmpDate := utils.TimeParseStd(results[0]["date"]) + yData = append(yData, results[0]["price"]) + xData = append(xData, tmpDate.Format("01-02")) + } + } + yData = append(yData, m.Price) + tmpDate := utils.TimeParseStd(m.Date) + xData = append(xData, tmpDate.Format("01-02")) + break + } + + e.OutSuc(c, md.GetPriceCurveResp{ + YData: yData, + XData: xData, + }, nil) + return +} + +// ExchangeEnergy +// @Summary 蛋蛋星球-积分中心-能量兑换 +// @Tags 积分中心 +// @Description 能量兑换 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.ExchangeEnergyReq true "需要兑换的能量值" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/pointsCenter/exchangeEnergy [POST] +func ExchangeEnergy(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 + } + + var req *md.ExchangeEnergyReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + + // 1. 获取蛋蛋能量货币类型 + settingDb := implement.NewEggEnergyBasicSettingDb(db.Db) + setting, err := settingDb.EggEnergyBasicSettingGetOne() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + coinID := setting.PersonEggEnergyCoinId + + session := db.Db.NewSession() + defer session.Close() + + // 2. 计算蛋蛋能量兑换的金额 + egg_system_rules.Init(cfg.RedisAddr) + eggEnergyCoreData, cb, err1 := svc.GetEggEnergyCoreData(db.Db) + if err1 != nil { + fmt.Println("EggEnergyAutoRecordPrices_ERR:::::", err1.Error()) + return + } + if cb != nil { + defer cb() // 释放锁 + } + energyAmount, err := decimal.NewFromString(req.EnergyAmount) + if err != nil { + e.OutErr(c, e.ERR_UNMARSHAL, err.Error()) + return + } + nowPrice, err := decimal.NewFromString(eggEnergyCoreData.NowPrice) + if err != nil { + e.OutErr(c, e.ERR_UNMARSHAL, err.Error()) + return + } + amount, ok := energyAmount.Div(nowPrice).Float64() + if !ok { + e.OutErr(c, e.ERR_UNMARSHAL, nil) + return + } + + // 3. 获取用户蛋蛋能量余额 + eggEnergyAmount, err := rule.GetUserCoinAmount(session, coinID, user.Id) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + // 4. 判断蛋蛋能量是否足够兑换 + if utils.StrToFloat64(eggEnergyAmount) < utils.StrToFloat64(req.EnergyAmount) { + e.OutErr(c, e.ERR_BALANCE_NOT_ENOUGH, nil) + } + + // 5. 调用降价公式 + err, calcPriceReductionFormula := egg_energy.CalcPriceReductionFormula(req.EnergyAmount, eggEnergyCoreData) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + // 6. 更改动态数据 + err = egg_energy.DealAvailableEggEnergyCoin(session, int(enum.EggEnergyExchangeAccountBalance), eggEnergyCoreData, md3.DealAvailableEggEnergyCoinReq{ + Amount: calcPriceReductionFormula.GetEggEnergyAmount, + AmountFee: "", + BeforePrice: calcPriceReductionFormula.BeforePrice, + AfterPrice: calcPriceReductionFormula.AfterPrice, + BeforePlanetTotalValue: calcPriceReductionFormula.BeforePlanetTotalValue, + AfterPlanetTotalValue: calcPriceReductionFormula.AfterPlanetTotalValue, + BeforeEnergyTotalNums: calcPriceReductionFormula.BeforeEnergyTotalNums, + AfterEnergyTotalNums: calcPriceReductionFormula.AfterEnergyTotalNums, + }) + if err != nil { + fmt.Println("ActivityCoinAutoExchangeEggPersonEnergy:::::err111:::", err) + _ = session.Rollback() + return + } + + // 7. 扣除蛋蛋能量 + dealUserVirtualCoinReq := md2.DealUserVirtualCoinReq{ + Kind: "sub", + Title: enum.EggEnergyToExchangeToAmount.String(), + TransferType: int(enum.EggEnergyToExchangeToAmount), + CoinId: coinID, + Uid: user.Id, + Amount: utils.StrToFloat64(req.EnergyAmount), + } + err = rule.DealUserVirtualCoin(session, dealUserVirtualCoinReq) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + session.Rollback() + return + } + + // 8. 增加账户余额 + dealUserWalletReq := md2.DealUserWalletReq{ + Direction: "add", + Kind: int(enum.EggEnergyExchangeAccountBalance), + Title: enum.EggEnergyExchangeAccountBalance.String(), + Uid: user.Id, + Amount: amount, + } + err = rule.DealUserWallet(session, dealUserWalletReq) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + session.Rollback() + return + } + + err = session.Commit() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) +} diff --git a/app/md/institutional_management/egg_energy/md_basic.go b/app/md/institutional_management/egg_energy/md_basic.go index e4ac5a9..a2d7eac 100644 --- a/app/md/institutional_management/egg_energy/md_basic.go +++ b/app/md/institutional_management/egg_energy/md_basic.go @@ -76,11 +76,6 @@ type GetEggCoreDataListResp struct { UserHoldTotalNums map[string]string `json:"user_hold_total_nums"` // 用户持有总量 } -type GetPriceCurveResp struct { - XData []interface{} `json:"x_data"` - YData []interface{} `json:"y_data"` -} - type GetFundDataListReq struct { Kind int `json:"kind"` // 数据类型 StartAt string `json:"start_at" example:"开始时间"` diff --git a/app/md/md_add_friend.go b/app/md/md_add_friend.go index 54056c4..030911b 100644 --- a/app/md/md_add_friend.go +++ b/app/md/md_add_friend.go @@ -20,8 +20,8 @@ type IntegralList struct { } type TransferTypeList struct { - AvailableIntegralList IntegralList `json:"available_integral_list"` // 可用积分列表 - SettlementIntegralList IntegralList `json:"settlement_integral_list"` // 结算积分列表 + PersonalTransferTypeList IntegralList `json:"personal_transfer_type_list"` // 个人积分变动列表 + TeamTransferTypeList IntegralList `json:"TeamTransferTypeList"` // 团队积分变动列表 } type EggEnergyDetailResp struct { diff --git a/app/md/md_points_center.go b/app/md/md_points_center.go new file mode 100644 index 0000000..1c07455 --- /dev/null +++ b/app/md/md_points_center.go @@ -0,0 +1,15 @@ +package md + +type GetPriceCurveResp struct { + XData []interface{} `json:"x_data"` + YData []interface{} `json:"y_data"` +} + +type PointsCenterGetBasicResp struct { + AvailableEnergy string `json:"available_energy"` // 可用能量 + AvailableCash string `json:"available_cash"` // 可用现金 +} + +type ExchangeEnergyReq struct { + EnergyAmount string `json:"energy_amount,required"` // 兑换能量数值 +} diff --git a/app/router/router.go b/app/router/router.go index 7f9b860..aaf30bf 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -83,6 +83,12 @@ func route(r *gin.RouterGroup) { { rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据 } + rPointsCenter := r.Group("/pointsCenter") // 积分中心 + { + rPointsCenter.GET("/getBasic", hdl.PointsCenterGetBasic) // 积分中-基础数据 + rPointsCenter.GET("/priceCurve", hdl.GetPriceCurve) // 积分中心-获取价格曲线 + rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换 + } } diff --git a/docs/docs.go b/docs/docs.go index 75ee109..c036ca6 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -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" @@ -695,6 +694,135 @@ const docTemplate = `{ } } }, + "/api/v1/pointsCenter/exchangeEnergy": { + "post": { + "description": "能量兑换", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "积分中心" + ], + "summary": "蛋蛋星球-积分中心-能量兑换", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "需要兑换的能量值", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.ExchangeEnergyReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/v1/pointsCenter/getBasic": { + "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/priceCurve": { + "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": "1:按天 2:按小时 3:按周", + "name": "kind", + "in": "query" + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.GetPriceCurveResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/register": { "post": { "description": "注册", @@ -794,9 +922,7 @@ const docTemplate = `{ "name": "req", "in": "body", "required": true, - "schema": { - "type": "object" - } + "schema": {} } ], "responses": { @@ -1102,6 +1228,15 @@ const docTemplate = `{ } } }, + "md.ExchangeEnergyReq": { + "type": "object", + "properties": { + "energy_amount": { + "description": "兑换能量数值", + "type": "string" + } + } + }, "md.FastLoginReq": { "type": "object", "properties": { @@ -1134,6 +1269,19 @@ const docTemplate = `{ } } }, + "md.GetPriceCurveResp": { + "type": "object", + "properties": { + "x_data": { + "type": "array", + "items": {} + }, + "y_data": { + "type": "array", + "items": {} + } + } + }, "md.HomePageResp": { "type": "object", "properties": { @@ -1386,6 +1534,19 @@ const docTemplate = `{ } } }, + "md.PointsCenterGetBasicResp": { + "type": "object", + "properties": { + "available_cash": { + "description": "可用现金", + "type": "string" + }, + "available_energy": { + "description": "可用能量", + "type": "string" + } + } + }, "md.RealTimePriceResp": { "type": "object", "properties": { @@ -1542,16 +1703,16 @@ const docTemplate = `{ "md.TransferTypeList": { "type": "object", "properties": { - "available_integral_list": { - "description": "可用积分列表", + "TeamTransferTypeList": { + "description": "团队积分变动列表", "allOf": [ { "$ref": "#/definitions/md.IntegralList" } ] }, - "settlement_integral_list": { - "description": "结算积分列表", + "personal_transfer_type_list": { + "description": "个人积分变动列表", "allOf": [ { "$ref": "#/definitions/md.IntegralList" @@ -1626,6 +1787,8 @@ var SwaggerInfo = &swag.Spec{ Description: "APP客户端-Api接口", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index ca3ed6a..45b346b 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -688,6 +688,135 @@ } } }, + "/api/v1/pointsCenter/exchangeEnergy": { + "post": { + "description": "能量兑换", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "积分中心" + ], + "summary": "蛋蛋星球-积分中心-能量兑换", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "需要兑换的能量值", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.ExchangeEnergyReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/v1/pointsCenter/getBasic": { + "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/priceCurve": { + "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": "1:按天 2:按小时 3:按周", + "name": "kind", + "in": "query" + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.GetPriceCurveResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/register": { "post": { "description": "注册", @@ -787,9 +916,7 @@ "name": "req", "in": "body", "required": true, - "schema": { - "type": "object" - } + "schema": {} } ], "responses": { @@ -1095,6 +1222,15 @@ } } }, + "md.ExchangeEnergyReq": { + "type": "object", + "properties": { + "energy_amount": { + "description": "兑换能量数值", + "type": "string" + } + } + }, "md.FastLoginReq": { "type": "object", "properties": { @@ -1127,6 +1263,19 @@ } } }, + "md.GetPriceCurveResp": { + "type": "object", + "properties": { + "x_data": { + "type": "array", + "items": {} + }, + "y_data": { + "type": "array", + "items": {} + } + } + }, "md.HomePageResp": { "type": "object", "properties": { @@ -1379,6 +1528,19 @@ } } }, + "md.PointsCenterGetBasicResp": { + "type": "object", + "properties": { + "available_cash": { + "description": "可用现金", + "type": "string" + }, + "available_energy": { + "description": "可用能量", + "type": "string" + } + } + }, "md.RealTimePriceResp": { "type": "object", "properties": { @@ -1535,16 +1697,16 @@ "md.TransferTypeList": { "type": "object", "properties": { - "available_integral_list": { - "description": "可用积分列表", + "TeamTransferTypeList": { + "description": "团队积分变动列表", "allOf": [ { "$ref": "#/definitions/md.IntegralList" } ] }, - "settlement_integral_list": { - "description": "结算积分列表", + "personal_transfer_type_list": { + "description": "个人积分变动列表", "allOf": [ { "$ref": "#/definitions/md.IntegralList" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 90b4909..eb07a7a 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -141,6 +141,12 @@ definitions: - $ref: '#/definitions/md.TransferTypeList' description: 转账类型列表 type: object + md.ExchangeEnergyReq: + properties: + energy_amount: + description: 兑换能量数值 + type: string + type: object md.FastLoginReq: properties: invite_code: @@ -163,6 +169,15 @@ definitions: required: - mobile type: object + md.GetPriceCurveResp: + properties: + x_data: + items: {} + type: array + y_data: + items: {} + type: array + type: object md.HomePageResp: properties: egg_energy_now_price: @@ -340,6 +355,15 @@ definitions: nickname: type: string type: object + md.PointsCenterGetBasicResp: + properties: + available_cash: + description: 可用现金 + type: string + available_energy: + description: 可用能量 + type: string + type: object md.RealTimePriceResp: properties: is_rises: @@ -450,14 +474,14 @@ definitions: type: object md.TransferTypeList: properties: - available_integral_list: + TeamTransferTypeList: allOf: - $ref: '#/definitions/md.IntegralList' - description: 可用积分列表 - settlement_integral_list: + description: 团队积分变动列表 + personal_transfer_type_list: allOf: - $ref: '#/definitions/md.IntegralList' - description: 结算积分列表 + description: 个人积分变动列表 type: object md.TransferTypeNode: properties: @@ -949,6 +973,91 @@ paths: summary: 蛋蛋星球-会员中心-基础数据(获取) tags: - 会员中心 + /api/v1/pointsCenter/exchangeEnergy: + post: + consumes: + - application/json + description: 能量兑换 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 需要兑换的能量值 + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.ExchangeEnergyReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 蛋蛋星球-积分中心-能量兑换 + tags: + - 积分中心 + /api/v1/pointsCenter/getBasic: + 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/priceCurve: + get: + consumes: + - application/json + description: 价格趋势(获取) + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 1:按天 2:按小时 3:按周 + in: query + name: kind + type: string + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + $ref: '#/definitions/md.GetPriceCurveResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 蛋蛋星球-积分中心-价格趋势(获取) + tags: + - 积分中心 /api/v1/register: post: consumes: @@ -1011,8 +1120,7 @@ paths: in: body name: req required: true - schema: - type: object + schema: {} produces: - application/json responses: diff --git a/go.mod b/go.mod index 6b075f4..d93a48f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 // replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models // -// replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules +replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( github.com/boombuler/barcode v1.0.1