@@ -11,6 +11,7 @@ import ( | |||
"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" | |||
rule2 "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" | |||
@@ -27,6 +28,7 @@ import ( | |||
"github.com/gin-gonic/gin" | |||
"github.com/olivere/elastic/v7" | |||
"github.com/shopspring/decimal" | |||
"strconv" | |||
"time" | |||
) | |||
@@ -865,3 +867,58 @@ func GetEggEnergyFlow(c *gin.Context) { | |||
} | |||
e.OutSuc(c, resp, nil) | |||
} | |||
// PointsCenterCalcExchange | |||
// @Summary 蛋蛋星球-积分中心-预估积分兑换 | |||
// @Tags 积分中心 | |||
// @Description 蛋蛋分明细(获取) | |||
// @Accept json | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Param amount query string true "需要兑换能量值" | |||
// @Success 200 {object} md.PointsCenterCalcExchangeResp "具体数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/v1/pointsCenter/calcExchange [GET] | |||
func PointsCenterCalcExchange(c *gin.Context) { | |||
amount := c.DefaultQuery("amount", "") | |||
user := svc.GetUser(c) | |||
engine := db.Db | |||
rule2.Init(cfg.RedisAddr) | |||
eggEnergyCoreData, cb, err1 := svc2.GetEggEnergyCoreData(engine) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
if cb != nil { | |||
defer cb() // 释放锁 | |||
} | |||
eggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(engine) | |||
eggEnergyBasicSetting, err1 := eggEnergyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{ | |||
"key": "is_open", | |||
"value": 1, | |||
}) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
if eggEnergyBasicSetting == nil { | |||
err1 = errors.New("蛋蛋能量设置未开启!") | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
//能量兑换余额 | |||
err, exchangeResp := egg_energy.CalcPriceReductionFormula(amount, eggEnergyCoreData, strconv.Itoa(user.Level), *eggEnergyBasicSetting) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
resp := md.PointsCenterCalcExchangeResp{ | |||
Value: exchangeResp.GetEggEnergyAmount, | |||
} | |||
e.OutSuc(c, resp, nil) | |||
return | |||
} |
@@ -86,3 +86,7 @@ type GetEggEnergyFlowResp struct { | |||
List []EggEnergyFlowNode `json:"list"` | |||
Paginate Paginate `json:"paginate"` | |||
} | |||
type PointsCenterCalcExchangeResp struct { | |||
Value string `json:"value"` // 预估可兑换的金额 | |||
} |
@@ -140,6 +140,7 @@ func route(r *gin.RouterGroup) { | |||
rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细 | |||
rPointsCenter.GET("/record", hdl.GetEggPointRecord) // 积分中心-蛋蛋分历史记录 | |||
rPointsCenter.GET("/energyFlow", hdl.GetEggEnergyFlow) // 积分中心-积分收支明细 | |||
rPointsCenter.GET("/calcExchange", hdl.PointsCenterCalcExchange) // 积分中心-计算兑换 | |||
} | |||
rWallet := r.Group("/wallet") // 钱包 | |||
{ | |||
@@ -2806,6 +2806,51 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"/api/v1/pointsCenter/calcExchange": { | |||
"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": "amount", | |||
"in": "query", | |||
"required": true | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "具体数据", | |||
"schema": { | |||
"$ref": "#/definitions/md.PointsCenterCalcExchangeResp" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/pointsCenter/contributionValue": { | |||
"get": { | |||
"description": "贡献值(获取)", | |||
@@ -4093,6 +4138,46 @@ const docTemplate = `{ | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/wechatRegister": { | |||
"post": { | |||
"description": "注册", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"登录注册" | |||
], | |||
"summary": "注册", | |||
"parameters": [ | |||
{ | |||
"description": "注册参数", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/md.RegisterReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "登录成功返回", | |||
"schema": { | |||
"$ref": "#/definitions/md.LoginResponse" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"definitions": { | |||
@@ -4113,68 +4198,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": { | |||
@@ -5760,6 +5783,15 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"md.PointsCenterCalcExchangeResp": { | |||
"type": "object", | |||
"properties": { | |||
"value": { | |||
"description": "预估可兑换的金额", | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"md.PointsCenterGetBasicResp": { | |||
"type": "object", | |||
"properties": { | |||
@@ -5864,7 +5896,7 @@ const docTemplate = `{ | |||
"description": "红包详情信息", | |||
"allOf": [ | |||
{ | |||
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd" | |||
"$ref": "#/definitions/model.ImSendRedPackageOrd" | |||
} | |||
] | |||
}, | |||
@@ -6598,6 +6630,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": { | |||
@@ -2800,6 +2800,51 @@ | |||
} | |||
} | |||
}, | |||
"/api/v1/pointsCenter/calcExchange": { | |||
"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": "amount", | |||
"in": "query", | |||
"required": true | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "具体数据", | |||
"schema": { | |||
"$ref": "#/definitions/md.PointsCenterCalcExchangeResp" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/pointsCenter/contributionValue": { | |||
"get": { | |||
"description": "贡献值(获取)", | |||
@@ -4087,6 +4132,46 @@ | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/wechatRegister": { | |||
"post": { | |||
"description": "注册", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"登录注册" | |||
], | |||
"summary": "注册", | |||
"parameters": [ | |||
{ | |||
"description": "注册参数", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/md.RegisterReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "登录成功返回", | |||
"schema": { | |||
"$ref": "#/definitions/md.LoginResponse" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"definitions": { | |||
@@ -4107,68 +4192,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": { | |||
@@ -5754,6 +5777,15 @@ | |||
} | |||
} | |||
}, | |||
"md.PointsCenterCalcExchangeResp": { | |||
"type": "object", | |||
"properties": { | |||
"value": { | |||
"description": "预估可兑换的金额", | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"md.PointsCenterGetBasicResp": { | |||
"type": "object", | |||
"properties": { | |||
@@ -5858,7 +5890,7 @@ | |||
"description": "红包详情信息", | |||
"allOf": [ | |||
{ | |||
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd" | |||
"$ref": "#/definitions/model.ImSendRedPackageOrd" | |||
} | |||
] | |||
}, | |||
@@ -6592,6 +6624,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": { | |||
@@ -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: | |||
@@ -1161,6 +1120,12 @@ definitions: | |||
num: | |||
type: string | |||
type: object | |||
md.PointsCenterCalcExchangeResp: | |||
properties: | |||
value: | |||
description: 预估可兑换的金额 | |||
type: string | |||
type: object | |||
md.PointsCenterGetBasicResp: | |||
properties: | |||
egg_point: | |||
@@ -1232,7 +1197,7 @@ definitions: | |||
properties: | |||
detail: | |||
allOf: | |||
- $ref: '#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd' | |||
- $ref: '#/definitions/model.ImSendRedPackageOrd' | |||
description: 红包详情信息 | |||
list: | |||
description: 领取红包用户列表 | |||
@@ -1737,6 +1702,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: | |||
@@ -3590,6 +3596,36 @@ paths: | |||
summary: 蛋蛋星球-积分中心-上部分基础信息(获取) | |||
tags: | |||
- 积分中心 | |||
/api/v1/pointsCenter/calcExchange: | |||
get: | |||
consumes: | |||
- application/json | |||
description: 蛋蛋分明细(获取) | |||
parameters: | |||
- description: 验证参数Bearer和token空格拼接 | |||
in: header | |||
name: Authorization | |||
required: true | |||
type: string | |||
- description: 需要兑换能量值 | |||
in: query | |||
name: amount | |||
required: true | |||
type: string | |||
produces: | |||
- application/json | |||
responses: | |||
"200": | |||
description: 具体数据 | |||
schema: | |||
$ref: '#/definitions/md.PointsCenterCalcExchangeResp' | |||
"400": | |||
description: 具体错误 | |||
schema: | |||
$ref: '#/definitions/md.Response' | |||
summary: 蛋蛋星球-积分中心-预估积分兑换 | |||
tags: | |||
- 积分中心 | |||
/api/v1/pointsCenter/contributionValue: | |||
get: | |||
consumes: | |||
@@ -4441,4 +4477,30 @@ paths: | |||
summary: 微信登陆 | |||
tags: | |||
- 登录注册 | |||
/api/v1/wechatRegister: | |||
post: | |||
consumes: | |||
- application/json | |||
description: 注册 | |||
parameters: | |||
- description: 注册参数 | |||
in: body | |||
name: req | |||
required: true | |||
schema: | |||
$ref: '#/definitions/md.RegisterReq' | |||
produces: | |||
- application/json | |||
responses: | |||
"200": | |||
description: 登录成功返回 | |||
schema: | |||
$ref: '#/definitions/md.LoginResponse' | |||
"400": | |||
description: 具体错误 | |||
schema: | |||
$ref: '#/definitions/md.Response' | |||
summary: 注册 | |||
tags: | |||
- 登录注册 | |||
swagger: "2.0" |