Преглед изворни кода

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	go.mod
tmp
huangjiajun пре 4 недеља
родитељ
комит
284fc9aa87
9 измењених фајлова са 397 додато и 221 уклоњено
  1. +21
    -13
      app/hdl/hdl_add_friend.go
  2. +40
    -0
      app/hdl/hdl_guide_page.go
  3. +9
    -8
      app/md/md_add_friend.go
  4. +4
    -1
      app/router/router.go
  5. +33
    -18
      app/svc/svc_points_center.go
  6. +109
    -68
      docs/docs.go
  7. +106
    -66
      docs/swagger.json
  8. +71
    -44
      docs/swagger.yaml
  9. +4
    -3
      go.mod

+ 21
- 13
app/hdl/hdl_add_friend.go Прегледај датотеку

@@ -392,21 +392,21 @@ func BasalRate(c *gin.Context) {
now := time.Now()
nowStr := now.Format("2006-01-02 15:04:05")
signInDb := implement.NewEggSignInDb(db.Db)
has, eggSignIn, err := signInDb.EggSignINGetOneByTimeAndUid(nowStr, nowStr, user.Id, 0)
has, eggSignIn, err := signInDb.EggSignINGetOneByTimeAndUid("", nowStr, user.Id, 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if !has {
resp := md.BasalRateResp{
ConsumedTime: "",
ConsumedEggEnergy: "",
RemainingTime: "",
RemainingEggEnergy: "",
BasalRate: "",
ConsumedEggPoint: "",
EstimatedRevenue: "",
SignCountdown: "0000:00:00",
ConsumedTime: "0",
ConsumedEggEnergy: "0",
RemainingTime: "0",
RemainingEggEnergy: "0",
BasalRate: "0",
ConsumedEggPoint: "0",
EstimatedRevenue: "0",
SignCountdown: "00:00:00",
}
e.OutSuc(c, resp, nil)
return
@@ -444,11 +444,18 @@ func BasalRate(c *gin.Context) {
}
basalRate := basalRateDecimal.Mul(decimal.NewFromInt(60 * 60))
// 收益倒计时
var signCountdown string
var signTimeSecs float64
duration := utils.TimeParseStd(eggSignIn.EndTime).Sub(now) // 计算时间差值
hours := duration / time.Hour // 获取小时部分
minutes := duration % time.Hour / time.Minute // 获取分钟部分(先除去小时后再乘以60)
seconds := int64(duration/time.Second) % 60
signCountdown := fmt.Sprintf("%d:%d:%d", hours, minutes, seconds) //收益倒计时
if duration > 0 {
hours := duration / time.Hour // 获取小时部分
minutes := duration % time.Hour / time.Minute // 获取分钟部分(先除去小时后再乘以60)
seconds := int64(duration/time.Second) % 60
signCountdown = fmt.Sprintf("%d:%d:%d", hours, minutes, seconds) //收益倒计时
signTimeSecs = duration.Seconds()
} else {
signCountdown = fmt.Sprintf("00:00:00")
}

resp := md.BasalRateResp{
ConsumedTime: consumedTime.String(),
@@ -459,6 +466,7 @@ func BasalRate(c *gin.Context) {
ConsumedEggPoint: eggSignIn.TotalPersonEggPoints,
EstimatedRevenue: estimatedRevenue.String(),
SignCountdown: signCountdown,
SignTimeSecs: signTimeSecs,
}
e.OutSuc(c, resp, nil)
}


+ 40
- 0
app/hdl/hdl_guide_page.go Прегледај датотеку

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

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

// GetRunningTime
// @Summary 蛋蛋星球-引导页-运行时间
// @Tags 引导页
// @Description 运行时间
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {string} "运行时间"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/guidePage/runningTime [GET]
func GetRunningTime(c *gin.Context) {
basicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
setting, err := basicSettingDb.EggEnergyBasicSettingGetOne()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM)
return
}
startTime := utils.TimeParseStd(setting.CreateAt)
now := time.Now()
duration := now.Sub(startTime)
days := duration / time.Hour / 24 // 获取天数
hours := duration / time.Hour % 24 // 获取小时部分
minutes := duration % time.Hour / time.Minute // 获取分钟部分(先除去小时后再乘以60)
seconds := int64(duration/time.Second) % 60
runTime := fmt.Sprintf("%d:%d:%d:%d", days, hours, minutes, seconds) //收益倒计时

e.OutSuc(c, runTime, nil)
}

+ 9
- 8
app/md/md_add_friend.go Прегледај датотеку

@@ -87,14 +87,15 @@ type NineDimensionalSpaceResp struct {
}

type BasalRateResp struct {
ConsumedTime string `json:"consumed_time"` // 消耗时间/小时
ConsumedEggEnergy string `json:"consumed_egg_energy"` // 收益蛋蛋能量
RemainingTime string `json:"remaining_time"` // 剩余时间/小时
RemainingEggEnergy string `json:"remaining_egg_energy"` // 剩余蛋蛋能量
BasalRate string `json:"basal_rate"` // 基础速率
ConsumedEggPoint string `json:"consumed_egg_point"` // 消耗蛋蛋积分
EstimatedRevenue string `json:"estimated_revenue"` // 预估收益蛋蛋能量
SignCountdown string `json:"sign_countdown"` // 收益倒计时
ConsumedTime string `json:"consumed_time"` // 消耗时间/小时
ConsumedEggEnergy string `json:"consumed_egg_energy"` // 收益蛋蛋能量
RemainingTime string `json:"remaining_time"` // 剩余时间/小时
RemainingEggEnergy string `json:"remaining_egg_energy"` // 剩余蛋蛋能量
BasalRate string `json:"basal_rate"` // 基础速率
ConsumedEggPoint string `json:"consumed_egg_point"` // 消耗蛋蛋积分
EstimatedRevenue string `json:"estimated_revenue"` // 预估收益蛋蛋能量
SignCountdown string `json:"sign_countdown"` // 收益倒计时
SignTimeSecs float64 `json:"sign_time_secs"` // 收益倒计时秒数
}

type TotalRateResp struct {


+ 4
- 1
app/router/router.go Прегледај датотеку

@@ -80,6 +80,10 @@ func route(r *gin.RouterGroup) {
r.POST("/inviteCode/userInfo", hdl.InviteCodeUserInfo) //邀请码查用户
}
r.POST("/college/detail", hdl.CollegeDetail) // 文章详情
rGuidePage := r.Group("/guidePage")
{
rGuidePage.GET("/runningTime", hdl.GetRunningTime)
}

r.GET("/getModuleSetting", hdl.GetModuleSetting) // 获取页面样式
r.Use(mw.Auth) // 以下接口需要JWT验证
@@ -215,7 +219,6 @@ func rCircleFriends(r *gin.RouterGroup) {
}

func rComm(r *gin.RouterGroup) {

r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
r.GET("/accessRecords", comm.AccessRecords) // 访问记录
}

+ 33
- 18
app/svc/svc_points_center.go Прегледај датотеку

@@ -38,14 +38,21 @@ func GetEggPointRecordBase(now time.Time, uid int64, page int, limit int) ([]md.
}
// 3. 获取最老有效索引及年份周数
oldestIndex := aliasName + "_" + "999999"
newestIndex := aliasName + "_" + "000000"
for key, _ := range aliases.Indices {
if key < oldestIndex {
oldestIndex = key
}
if key > newestIndex {
newestIndex = key
}
}
oldestYearStr, oldestWeekStr := GetYearsAndWeekStr(oldestIndex)
oldestYear := utils.StrToInt(oldestYearStr)
oldestWeek := utils.StrToInt(oldestWeekStr)
newestYearStr, newestWeekStr := GetYearsAndWeekStr(newestIndex)
newestYear := utils.StrToInt(newestYearStr)
newestWeek := utils.StrToInt(newestWeekStr)

// 4. 获取当期有效蛋蛋分
nowIndex := md2.EggEnergyUserEggScoreEsAlias + "_" + es2.GetLatestEffectiveIndexFromAlias(now)
@@ -56,25 +63,26 @@ func GetEggPointRecordBase(now time.Time, uid int64, page int, limit int) ([]md.
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")
var nowScore string
if searchResult != nil {
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)
}
results = append(results, doc)
}
nowScore = utils.Float64ToStr(results[0].ScoreValue)
} else {
nowScore = "60"
}

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

indexes := make([]string, 0, limit)
// 5. 构造分页索引列表 查询历史蛋蛋分
for i := 0; i < limit; i++ {
@@ -94,6 +102,13 @@ func GetEggPointRecordBase(now time.Time, uid int64, page int, limit int) ([]md.
} else if tempYear < oldestYear {
break
}
// 判断是否超过最新索引时间
if tempYear > newestYear {
continue
}
if tempYear == newestYear && tempWeek > newestWeek {
continue
}
tempIndex := es2.GetAppointIndexFromAlias(utils.IntToStr(tempYear), utils.IntToStr(tempWeek))
indexes = append(indexes, tempIndex)
}
@@ -108,22 +123,22 @@ func GetEggPointRecordBase(now time.Time, uid int64, page int, limit int) ([]md.
if searchRecordResult == nil {
return nil, "", 0, errors.New("failed to get egg score flows")
}
var recordResults []md.UserEggFlowReqRespList
//var recordResults []md.UserEggFlowReqRespList
// 检查是否有结果
if searchRecordResult.Hits.TotalHits.Value != 0 {
// 解析结果
for _, hit := range searchResult.Hits.Hits {
for _, hit := range searchRecordResult.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)
results = append(results, doc)
}
}

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


+ 109
- 68
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"
@@ -1686,6 +1685,44 @@ const docTemplate = `{
}
}
},
"/api/v1/guidePage/runningTime": {
"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": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/adRule": {
"get": {
"description": "视频奖励规则(获取)",
@@ -3006,9 +3043,7 @@ const docTemplate = `{
"name": "req",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"schema": {}
}
],
"responses": {
@@ -3799,68 +3834,6 @@ const docTemplate = `{
}
}
},
"code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"comm.AccessRecordsReq": {
"type": "object",
"properties": {
@@ -4223,6 +4196,10 @@ const docTemplate = `{
"sign_countdown": {
"description": "收益倒计时",
"type": "string"
},
"sign_time_secs": {
"description": "收益倒计时秒数",
"type": "number"
}
}
},
@@ -5416,7 +5393,7 @@ const docTemplate = `{
"description": "红包详情信息",
"allOf": [
{
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd"
"$ref": "#/definitions/model.ImSendRedPackageOrd"
}
]
},
@@ -6098,6 +6075,68 @@ const docTemplate = `{
}
}
},
"model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"pb.SendRedPacketResp": {
"type": "object",
"properties": {
@@ -6120,6 +6159,8 @@ var SwaggerInfo = &swag.Spec{
Description: "APP客户端-Api接口",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {


+ 106
- 66
docs/swagger.json Прегледај датотеку

@@ -1679,6 +1679,44 @@
}
}
},
"/api/v1/guidePage/runningTime": {
"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": {
"type": "string"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/adRule": {
"get": {
"description": "视频奖励规则(获取)",
@@ -2999,9 +3037,7 @@
"name": "req",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"schema": {}
}
],
"responses": {
@@ -3792,68 +3828,6 @@
}
}
},
"code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"comm.AccessRecordsReq": {
"type": "object",
"properties": {
@@ -4216,6 +4190,10 @@
"sign_countdown": {
"description": "收益倒计时",
"type": "string"
},
"sign_time_secs": {
"description": "收益倒计时秒数",
"type": "number"
}
}
},
@@ -5409,7 +5387,7 @@
"description": "红包详情信息",
"allOf": [
{
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd"
"$ref": "#/definitions/model.ImSendRedPackageOrd"
}
]
},
@@ -6091,6 +6069,68 @@
}
}
},
"model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"pb.SendRedPacketResp": {
"type": "object",
"properties": {


+ 71
- 44
docs/swagger.yaml Прегледај датотеку

@@ -12,47 +12,6 @@ definitions:
description: 总数据量
type: integer
type: object
code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd:
properties:
amount:
type: string
create_time:
type: string
id:
type: integer
im_data:
type: string
im_uid:
type: integer
ord_no:
type: string
received_im_user_ids:
type: string
received_times:
type: string
received_user_amount:
type: string
received_user_ids:
type: string
red_packet_balance_amount:
type: string
red_packet_balance_nums:
type: integer
red_packet_nums:
type: integer
red_packet_type:
type: integer
state:
type: integer
uid:
type: integer
update_time:
type: string
wait_draw_im_user_ids:
type: string
wait_draw_user_ids:
type: string
type: object
comm.AccessRecordsReq:
properties:
index:
@@ -310,6 +269,9 @@ definitions:
sign_countdown:
description: 收益倒计时
type: string
sign_time_secs:
description: 收益倒计时秒数
type: number
type: object
md.BindAlipayAccountReq:
properties:
@@ -1136,7 +1098,7 @@ definitions:
properties:
detail:
allOf:
- $ref: '#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd'
- $ref: '#/definitions/model.ImSendRedPackageOrd'
description: 红包详情信息
list:
description: 领取红包用户列表
@@ -1606,6 +1568,47 @@ definitions:
description: 余额
type: string
type: object
model.ImSendRedPackageOrd:
properties:
amount:
type: string
create_time:
type: string
id:
type: integer
im_data:
type: string
im_uid:
type: integer
ord_no:
type: string
received_im_user_ids:
type: string
received_times:
type: string
received_user_amount:
type: string
received_user_ids:
type: string
red_packet_balance_amount:
type: string
red_packet_balance_nums:
type: integer
red_packet_nums:
type: integer
red_packet_type:
type: integer
state:
type: integer
uid:
type: integer
update_time:
type: string
wait_draw_im_user_ids:
type: string
wait_draw_user_ids:
type: string
type: object
pb.SendRedPacketResp:
properties:
seq:
@@ -2723,6 +2726,31 @@ paths:
summary: 页面样式
tags:
- 页面样式
/api/v1/guidePage/runningTime:
get:
consumes:
- application/json
description: 运行时间
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 运行时间
schema:
type: string
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-引导页-运行时间
tags:
- 引导页
/api/v1/homePage/adRule:
get:
consumes:
@@ -3590,8 +3618,7 @@ paths:
in: body
name: req
required: true
schema:
type: object
schema: {}
produces:
- application/json
responses:


+ 4
- 3
go.mod Прегледај датотеку

@@ -15,7 +15,7 @@ require (
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.20.0
github.com/go-redis/redis v6.15.9+incompatible
github.com/gomodule/redigo v1.9.2
github.com/gomodule/redigo v2.0.0+incompatible
github.com/jinzhu/copier v0.4.0
github.com/makiuchi-d/gozxing v0.0.0-20210324052758-57132e828831
github.com/qiniu/api.v7/v7 v7.8.2
@@ -32,11 +32,12 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241205080507-c27ed1ab5226
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241206071703-50c6d6499467
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241206061858-d583849c70ea
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205061938-91f42710d6cd
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
github.com/gin-contrib/sessions v1.0.1
github.com/go-pay/crypto v0.0.1
github.com/go-pay/gopay v1.5.101
github.com/go-pay/xlog v0.0.2


Loading…
Откажи
Сачувај