commit
a1c60eb29d
192 changed files with 14159 additions and 0 deletions
-
22.gitignore
-
36README.en.md
-
37README.md
-
5build.bat
-
8config.json
-
63controllers/author.go
-
219controllers/base.go
-
72controllers/client/activity.go
-
179controllers/client/auction.go
-
69controllers/client/barrage.go
-
105controllers/client/bully_screen.go
-
83controllers/client/calorie.go
-
88controllers/client/invite_envelope.go
-
184controllers/client/login.go
-
83controllers/client/login_test.go
-
24controllers/client/lottery.go
-
228controllers/client/order_entry.go
-
104controllers/client/reward.go
-
164controllers/client/shake_red_envelope.go
-
96controllers/client/sign.go
-
211controllers/client/tug_war.go
-
86controllers/client/upper_wall.go
-
128controllers/client/vote.go
-
80controllers/client/wx.go
-
41controllers/common/annex.go
-
BINcontrollers/common/test/123.gif
-
43controllers/common/test/annex_test.go
-
96controllers/common/wechat_oauth.go
-
150controllers/pc/activity.go
-
31controllers/pc/area_store.go
-
264controllers/pc/auction.go
-
48controllers/pc/barrage.go
-
242controllers/pc/bully_screen.go
-
178controllers/pc/calorie.go
-
130controllers/pc/login.go
-
390controllers/pc/lottery_draw.go
-
451controllers/pc/order_draw.go
-
221controllers/pc/reward.go
-
213controllers/pc/shake_red_envelope.go
-
87controllers/pc/sign.go
-
221controllers/pc/tug_war.go
-
181controllers/pc/upper_wall.go
-
164controllers/pc/vote.go
-
83controllers/pc/ws.go
-
596docs/docs.go
-
544docs/swagger.json
-
360docs/swagger.yaml
-
34go.mod
-
412go.sum
-
3goxorm/config
-
20goxorm/struct.go.tpl
-
0html/annex/1559027799707464500.ncx
-
67libs/jwt/jwt_go.go
-
8libs/jwt/jwt_test.go
-
139libs/qq/qq.go
-
32libs/wx/code.go
-
135libs/wx/order.go
-
287libs/wx/params.go
-
272libs/wx/pay.go
-
151libs/wx/wx.go
-
48logger/logger.go
-
78main.go
-
36models/CalorieUser.go
-
47models/activity.go
-
50models/activity_module_service.go
-
23models/annex.go
-
40models/area_store.go
-
15models/auction_activity.go
-
13models/auction_deal.go
-
63models/auction_history.go
-
29models/auction_player.go
-
42models/auction_result_record.go
-
28models/auction_rule.go
-
19models/bahe_activity.go
-
18models/bahe_history.go
-
16models/bahe_rule.go
-
31models/bahe_team.go
-
43models/bahe_team_member.go
-
22models/barrage_history.go
-
67models/base.go
-
43models/bully_screen_history.go
-
34models/bully_screen_server.go
-
24models/bully_screen_wallet.go
-
25models/bully_screen_wallet_hisotry.go
-
47models/calorie.go
-
71models/customer.go
-
32models/customer_goods.go
-
60models/customer_operation.go
-
39models/customer_order.go
-
37models/customer_order_option.go
-
32models/dan_mu_server.go
-
87models/init_models.go
-
25models/invitation.go
-
37models/invitation_letter.go
-
31models/lottery_draw_activity.go
-
15models/lottery_draw_envelope_wallet.go
-
32models/lottery_draw_record.go
-
40models/lottery_draw_rule.go
-
37models/lottery_draw_rule_ladder.go
-
16models/lottery_draw_wallet_history.go
@ -0,0 +1,22 @@ |
|||
# Binaries for programs and plugins |
|||
*.exe |
|||
*.exe~ |
|||
*.dll |
|||
*.so |
|||
*.dylib |
|||
|
|||
# Test binary, built with `go test -c` |
|||
*.test |
|||
|
|||
# Output of the go coverage tool, specifically when used with LiteIDE |
|||
*.out |
|||
|
|||
.idea |
|||
hudongzhuanjia-go-build |
|||
hudongzhuanjia |
|||
go_build_main_go |
|||
.vscode |
|||
.log |
|||
|
|||
|
|||
services/pay/bindata.go |
@ -0,0 +1,36 @@ |
|||
# 互动专家 |
|||
|
|||
#### Description |
|||
欧轩网络互动专家 |
|||
|
|||
#### Software Architecture |
|||
Software architecture description |
|||
|
|||
#### Installation |
|||
|
|||
1. xxxx |
|||
2. xxxx |
|||
3. xxxx |
|||
|
|||
#### Instructions |
|||
|
|||
1. xxxx |
|||
2. xxxx |
|||
3. xxxx |
|||
|
|||
#### Contribution |
|||
|
|||
1. Fork the repository |
|||
2. Create Feat_xxx branch |
|||
3. Commit your code |
|||
4. Create Pull Request |
|||
|
|||
|
|||
#### Gitee Feature |
|||
|
|||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md |
|||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com) |
|||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) |
|||
4. The most valuable open source project [GVP](https://gitee.com/gvp) |
|||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) |
|||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) |
@ -0,0 +1,37 @@ |
|||
# 互动专家 |
|||
|
|||
#### 介绍 |
|||
欧轩网络互动专家 |
|||
|
|||
#### 软件架构 |
|||
软件架构说明 |
|||
|
|||
|
|||
#### 安装教程 |
|||
|
|||
1. xxxx |
|||
2. xxxx |
|||
3. xxxx |
|||
|
|||
#### 使用说明 |
|||
|
|||
1. xxxx |
|||
2. xxxx |
|||
3. xxxx |
|||
|
|||
#### 参与贡献 |
|||
|
|||
1. Fork 本仓库 |
|||
2. 新建 Feat_xxx 分支 |
|||
3. 提交代码 |
|||
4. 新建 Pull Request |
|||
|
|||
|
|||
#### 码云特技 |
|||
|
|||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md |
|||
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) |
|||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 |
|||
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 |
|||
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) |
|||
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) |
@ -0,0 +1,5 @@ |
|||
SET CGO_ENABLED=0 |
|||
SET GOOS=linux |
|||
SET GOARCH=amd64 |
|||
|
|||
go build main.go |
@ -0,0 +1,8 @@ |
|||
{ |
|||
"port": "20181", |
|||
"host": "127.0.0.1", |
|||
"cross_domain": "*", |
|||
"post_max_memory": 1024000, |
|||
"api_router": "/PcClient/*", |
|||
"update_path": "./" |
|||
} |
@ -0,0 +1,63 @@ |
|||
package controllers |
|||
|
|||
import ( |
|||
"hudongzhuanjia/libs/jwt" |
|||
"hudongzhuanjia/utils/define" |
|||
) |
|||
|
|||
//执行路由方法前校验登陆态,并且解析page、pageSize
|
|||
type AuthorCtl struct { |
|||
BaseCtl |
|||
claims *jwt.JwtClaims |
|||
} |
|||
|
|||
func (t *AuthorCtl) Prepare() { |
|||
t.BaseCtl.Prepare() |
|||
token := "" |
|||
if tokenStr, ok := t.Request.SESSION[define.TOKEN]; ok { |
|||
token = tokenStr |
|||
} else if tokenStr, ok := t.Request.REQUEST[define.TOKEN]; ok { |
|||
token = tokenStr |
|||
} else if tokenStr, ok := t.Request.HEADER[define.TOKEN]; ok { |
|||
token = tokenStr |
|||
} else { |
|||
var param = make(map[string]interface{}, 0) |
|||
err := t.RequestToStruct(¶m) |
|||
t.CheckErr(err) |
|||
if tokenStr, ok := param[define.TOKEN]; ok { |
|||
token = tokenStr.(string) |
|||
} |
|||
} |
|||
claims, err := jwt.ParseAccessToken(token) |
|||
t.CheckErr(err) |
|||
t.claims = claims |
|||
// 最后多地区:子账号的area_id = area_id, 但是主账号的area_id 需要通过activity_id 进行获取
|
|||
} |
|||
|
|||
func (t *AuthorCtl) MustGetUID() int64 { |
|||
return t.claims.AccountId |
|||
} |
|||
|
|||
// token 应该携带某个主活动i
|
|||
func (t *AuthorCtl) MustGetActivityId() int64 { |
|||
return t.MustGetInt64("activity_id") |
|||
} |
|||
|
|||
func (t *AuthorCtl) MustGetName() string { |
|||
return t.claims.Username |
|||
} |
|||
|
|||
func (t *AuthorCtl) MustGetCustomerId() int64 { |
|||
return t.claims.CustomerId |
|||
} |
|||
|
|||
func (t *AuthorCtl) MustGetCustomerPid() int64 { |
|||
return t.claims.CustomerPid |
|||
} |
|||
|
|||
func (t *AuthorCtl) MustGetAreaId() int64 { |
|||
return t.claims.AreaId |
|||
} |
|||
|
|||
// 对各种角色进行不同的接口权限限定
|
|||
// role: main sub entry user : 主账号 子账号 录入人员 用户
|
@ -0,0 +1,219 @@ |
|||
package controllers |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/logger" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"runtime" |
|||
"strconv" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
//解析page、pageSize
|
|||
type BaseCtl struct { |
|||
core.Controller |
|||
Page int |
|||
PageSize int |
|||
Limit int // page * pagesize
|
|||
} |
|||
|
|||
func (t *BaseCtl) Prepare() { |
|||
t.OriginResponseWriter.Header().Set("Access-Control-Allow-Origin", "*") |
|||
t.Page, _ = t.GetInt("page") |
|||
t.PageSize, _ = t.GetInt("page_size") |
|||
t.Limit = t.Page * t.PageSize |
|||
} |
|||
|
|||
type M map[string]interface{} |
|||
|
|||
func (t *BaseCtl) Get(key string) (value string, exist bool) { |
|||
value, exist = t.Request.REQUEST[key] |
|||
return |
|||
} |
|||
|
|||
func (t *BaseCtl) MustGet(key string) string { |
|||
value, exist := t.Get(key) |
|||
t.Assert(exist, code.MSG_ERR_Param, fmt.Sprintf("%s不能为空", key)) |
|||
return value |
|||
} |
|||
|
|||
func (t *BaseCtl) Default(key string, def string) string { |
|||
value, exist := t.Get(key) |
|||
if exist { |
|||
return value |
|||
} |
|||
return def |
|||
} |
|||
|
|||
func (t *BaseCtl) GetInt64(key string) (int64, bool) { |
|||
v, ok := t.Get(key) |
|||
if !ok { |
|||
return 0, false |
|||
} |
|||
value, err := strconv.ParseInt(v, 10, 64) |
|||
if err != nil { |
|||
logger.Sugar.Infof("get int64 from request error", err) |
|||
t.ERROR(fmt.Sprintf("%v的数据类型不为int", key), code.MSG_ERR_Param) |
|||
} |
|||
|
|||
return value, true |
|||
} |
|||
|
|||
func (t *BaseCtl) MustGetInt64(key string) int64 { |
|||
value, exist := t.GetInt64(key) |
|||
t.Assert(exist, code.MSG_ERR_Param, fmt.Sprintf("%v不能为空", key)) |
|||
return value |
|||
} |
|||
|
|||
func (t *BaseCtl) DefaultInt64(key string, def int64) int64 { |
|||
value, exist := t.GetInt64(key) |
|||
if exist { |
|||
return value |
|||
} |
|||
return def |
|||
} |
|||
|
|||
func (t *BaseCtl) GetInt(key string) (int, bool) { |
|||
value, exist := t.GetInt64(key) |
|||
return int(value), exist |
|||
} |
|||
|
|||
func (t *BaseCtl) MustGetInt(key string) int { |
|||
value, exist := t.GetInt(key) |
|||
t.Assert(exist, code.MSG_ERR_Param, fmt.Sprintf("%s不能为空", key)) |
|||
return value |
|||
} |
|||
|
|||
func (t *BaseCtl) DefaultInt(key string, def int) int { |
|||
value, exist := t.GetInt(key) |
|||
if exist { |
|||
return value |
|||
} |
|||
return def |
|||
} |
|||
|
|||
func (t *BaseCtl) GetBool(key string) (bool, bool) { |
|||
v, ok := t.Get(key) |
|||
if !ok { |
|||
return false, false |
|||
} |
|||
value, err := strconv.ParseBool(v) |
|||
if err != nil { |
|||
logger.Sugar.Infof("get bool from request error", err) |
|||
t.ERROR(fmt.Sprintf("%v的数据类型不为bool", key), code.MSG_ERR_Param) |
|||
} |
|||
return value, true |
|||
} |
|||
|
|||
func (t *BaseCtl) MustGetBool(key string) bool { |
|||
value, exist := t.GetBool(key) |
|||
t.Assert(exist, code.MSG_ERR_Param, fmt.Sprintf("%s不能为空", key)) |
|||
return value |
|||
} |
|||
|
|||
func (t *BaseCtl) DefaultBool(key string, def bool) bool { |
|||
value, exist := t.GetBool(key) |
|||
if exist { |
|||
return value |
|||
} |
|||
return def |
|||
} |
|||
|
|||
func (t *BaseCtl) GetDouble(key string) (float64, bool) { |
|||
v, ok := t.Get(key) |
|||
if !ok { |
|||
return 0, false |
|||
} |
|||
value, err := strconv.ParseFloat(v, 64) |
|||
if err != nil { |
|||
logger.Sugar.Infof("get double from request error", err) |
|||
t.ERROR(fmt.Sprintf("%v的数据类型不为double", key), code.MSG_ERR_Param) |
|||
} |
|||
return value, true |
|||
} |
|||
|
|||
func (t *BaseCtl) MustGetDouble(key string) float64 { |
|||
value, exist := t.GetDouble(key) |
|||
t.Assert(exist, code.MSG_ERR_Param, fmt.Sprintf("%s不能为空", key)) |
|||
return value |
|||
} |
|||
|
|||
func (t *BaseCtl) DefaultDouble(key string, def float64) float64 { |
|||
value, exist := t.GetDouble(key) |
|||
if exist { |
|||
return value |
|||
} |
|||
return def |
|||
} |
|||
|
|||
func (t *BaseCtl) GetFloat(key string) (float32, bool) { |
|||
value, exist := t.GetDouble(key) |
|||
return float32(value), exist |
|||
} |
|||
|
|||
func (t *BaseCtl) MustGetFloat(key string) float32 { |
|||
value, exist := t.GetFloat(key) |
|||
t.Assert(exist, code.MSG_ERR_Param, fmt.Sprintf("%s不能为空", key)) |
|||
return value |
|||
} |
|||
|
|||
func (t *BaseCtl) DefaultFloat(key string, def float32) float32 { |
|||
value, exist := t.GetFloat(key) |
|||
if exist { |
|||
return value |
|||
} |
|||
return def |
|||
} |
|||
|
|||
func (t *BaseCtl) JSON(m map[string]interface{}) { |
|||
t.DisplayByData(m) |
|||
} |
|||
|
|||
func (t BaseCtl) XML(data []byte) { |
|||
t.OriginResponseWriter.Header().Add("Content-Type", "application/xml; charset=utf-8") |
|||
t.OriginResponseWriter.Write(data) |
|||
panic(nil) |
|||
} |
|||
|
|||
func (t *BaseCtl) ERROR(errStr string, code int, data ...string) { |
|||
t.DisplayByError(errStr, code, data...) |
|||
} |
|||
|
|||
func (t *BaseCtl) CheckInSuccess(str string) { |
|||
t.DisplayByError(str, 1) |
|||
} |
|||
|
|||
func (t *BaseCtl) SUCCESS(str string) { |
|||
t.DisplayByError(str, 0) |
|||
} |
|||
|
|||
func (t *BaseCtl) STRING(str string) { |
|||
t.Display(nil, str, 0) |
|||
} |
|||
func (t *BaseCtl) RAW(data interface{}) { |
|||
t.DisplayByData(data) |
|||
} |
|||
|
|||
func (t *BaseCtl) CheckErr(err error) { |
|||
if err != nil { |
|||
pc, file, line, ok := runtime.Caller(1) |
|||
logger.Sugar.Debugf("error:%v, pc: %v, file: %v, line:%v, ok: %v", err, pc, file, line, ok) |
|||
t.CheckErrDisplayByError(err) |
|||
} |
|||
} |
|||
|
|||
// false
|
|||
func (t *BaseCtl) Assert(b bool, errcode int, errmsg string) { |
|||
if !b { |
|||
t.ERROR(errmsg, errcode) |
|||
} |
|||
return |
|||
} |
|||
|
|||
func (t *BaseCtl) CheckRunning(status string) { |
|||
if status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", status), code.MSG_MODULE_STATUS_NOT_RUNNING) |
|||
} |
|||
} |
@ -0,0 +1,72 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
activity_service "hudongzhuanjia/services/activity" |
|||
auction_service "hudongzhuanjia/services/auction" |
|||
bahe_service "hudongzhuanjia/services/bahe" |
|||
bully_screen_service "hudongzhuanjia/services/bully_screen" |
|||
calorie_service "hudongzhuanjia/services/calorie" |
|||
red_envelope_service "hudongzhuanjia/services/red_envelope" |
|||
vote_service "hudongzhuanjia/services/vote" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
) |
|||
|
|||
type ActivityCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
func (t *ActivityCtl) ModuleStatus() { |
|||
activityId := t.MustGetActivityId() |
|||
moduleName := t.MustGet("module_name") |
|||
exist, err := activity_service.ExistModuleByActivityId(activityId, moduleName) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"status": exist, |
|||
}) |
|||
} |
|||
|
|||
// 某个模块的活动状态
|
|||
func (t *ActivityCtl) ModuleCurrent() { |
|||
activityId := t.MustGetActivityId() |
|||
moduleName := t.MustGet("module_name") |
|||
uid := t.MustGetUID() |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
switch moduleName { |
|||
case define.MODULE_TUGWAR: // 拔河
|
|||
data, err := bahe_service.GetCurrentTugWar(activityId, uid, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.JSON(data) |
|||
case define.MODULE_CALORIE: // 卡路里
|
|||
data, err := calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.JSON(data) |
|||
case define.MODULE_SHAKRB: // 摇红包
|
|||
// 没有初始状态 // 记下参与人数
|
|||
data, err := red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.JSON(data) |
|||
case define.MODULE_AUCTION: |
|||
// 竞拍
|
|||
data, err := auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID()) |
|||
t.CheckErr(err) |
|||
t.JSON(data) |
|||
case define.MODULE_VOTE: |
|||
data, err := vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.JSON(data) |
|||
case define.MODULE_BULLYS: |
|||
data, err := bully_screen_service.GetCurrentBullyScreen(activityId) |
|||
t.CheckErr(err) |
|||
t.JSON(data) |
|||
default: |
|||
t.ERROR("不存在该模块", code.MSG_MODULE_NOT_EXIST) |
|||
} |
|||
} |
@ -0,0 +1,179 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
auction_service "hudongzhuanjia/services/auction" |
|||
ws_send_service "hudongzhuanjia/services/ws_send" |
|||
"hudongzhuanjia/utils/code" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type AuctionCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// 竞拍动作
|
|||
func (t *AuctionCtl) Auction() { |
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
totalMoney := t.MustGetDouble("total_money") |
|||
uid := t.MustGetUID() |
|||
|
|||
if totalMoney < 0 { |
|||
t.ERROR("金额不能为0", code.MSG_ERR) |
|||
} |
|||
|
|||
auction := new(models.NewAuctionActivity) |
|||
exist, err := models.GetById(auction, auctionId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") |
|||
t.CheckRunning(auction.Status) |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, auction.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
area := new(models.AreaStore) |
|||
exist, err = models.GetById(area, user.AreaId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
player := new(models.AuctionPlayer) |
|||
exist, err = player.GetByAuctionIdAndUid(auction.Id, uid, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍编号不存在") |
|||
|
|||
history := new(models.AuctionHistory) |
|||
history.AuctionActivityId = auction.Id |
|||
history.AuctionGoodsName = auction.AuctionGoodsName |
|||
history.ActivityId = activity.Id |
|||
history.RehearsalId = activity.RehearsalId |
|||
history.UserId = uid |
|||
history.AreaId = user.AreaId |
|||
history.UserName = user.Nickname |
|||
history.AreaName = area.Name |
|||
history.UserPhone = user.Phone |
|||
history.Money = totalMoney |
|||
history.Unit = auction.Unit |
|||
history.PlayerCode = player.Code |
|||
history.UserId = uid |
|||
history.IsDelete = false |
|||
history.CreatedAt = time.Now() |
|||
history.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(history) |
|||
t.CheckErr(err) |
|||
|
|||
if auction.AuctionModel == "加价竞拍" { |
|||
maxHistory := new(models.AuctionHistory) |
|||
exist, err := maxHistory.GetHighestMoney(activity.RehearsalId, auction.Id) |
|||
t.CheckErr(err) |
|||
if exist && (history.Money < maxHistory.Money || history.UserId != maxHistory.UserId) { |
|||
_, err = history.SoftDelete() |
|||
t.CheckErr(err) |
|||
t.ERROR("加价失败, 价格低于当前最高价", code.MSG_ERR) |
|||
return |
|||
} |
|||
|
|||
go ws_send_service.SendAuction(fmt.Sprintf("%d", activity.Id), |
|||
"", 0, map[string]interface{}{ |
|||
"type": "auction", |
|||
"data": map[string]interface{}{ |
|||
"max_money": maxHistory.Money, |
|||
"avatar": user.Avatar, |
|||
"nickname": user.Nickname, |
|||
"num": 0, |
|||
"user_id": user.Id, |
|||
"status": "进行中", |
|||
"model": "加价竞拍", |
|||
}, |
|||
}) |
|||
// 成功
|
|||
|
|||
} else { // 减价竞拍
|
|||
record := new(models.AuctionResultRecord) |
|||
count, err := record.CountHistory(activity.RehearsalId, auction.Id) |
|||
t.CheckErr(err) |
|||
if int(count) >= auction.GoodsNum { |
|||
t.ERROR("所有商品已经竞拍完毕", code.MSG_ERR) |
|||
} |
|||
|
|||
record.AuctionActivityId = auctionId |
|||
record.AuctionGoodsName = auction.AuctionGoodsName |
|||
record.ActivityId = auction.ActivityId |
|||
record.UserId = uid |
|||
record.UserPhone = user.Phone |
|||
record.UserName = user.Nickname |
|||
record.AreaId = user.AreaId |
|||
record.AreaName = user.AreaName |
|||
record.DealPrice = totalMoney |
|||
record.RehearsalId = activity.RehearsalId |
|||
record.PlayerCode = player.Code |
|||
record.Unit = auction.Unit |
|||
record.UpdatedAt = time.Now() |
|||
record.CreatedAt = time.Now() |
|||
record.IsDelete = false |
|||
_, err = core.GetXormAuto().InsertOne(record) |
|||
t.CheckErr(err) |
|||
|
|||
go ws_send_service.SendAuction(fmt.Sprintf("%d", activity.Id), |
|||
"", 0, map[string]interface{}{ |
|||
"type": "auction", |
|||
"data": map[string]interface{}{ |
|||
"max_money": 0, |
|||
"avatar": user.Avatar, |
|||
"nickname": user.Nickname, |
|||
"user_id": user.Id, |
|||
"status": "进行中", |
|||
"num": auction.GoodsNum - int(count) - 1, |
|||
"model": "减价竞拍", |
|||
}, |
|||
}) |
|||
} |
|||
// 加价
|
|||
t.STRING("加价成功") |
|||
} |
|||
|
|||
func (t *AuctionCtl) ExistRecord() { |
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
uid := t.MustGetUID() |
|||
|
|||
auction := new(models.NewAuctionActivity) |
|||
exist, err := models.GetById(auction, auctionId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍活动不存在") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, auction.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
record := new(models.AuctionResultRecord) |
|||
exist, err = core.GetXormAuto().Where("is_delete=0 and user_id=? and auction_activity_id=? and rehearsal_id=?", uid, auctionId, activity.RehearsalId).Get(record) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"show": exist, |
|||
}) |
|||
} |
|||
|
|||
// 已经竞拍到了
|
|||
func (t *AuctionCtl) UserAuctions() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
|
|||
records, err := auction_service.GetUserAuctions(activityId, uid) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"list": records, |
|||
"total": len(records), |
|||
}) |
|||
} |
@ -0,0 +1,69 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
ws_send_service "hudongzhuanjia/services/ws_send" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
) |
|||
|
|||
//弹幕
|
|||
type BarrageCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//发送弹幕
|
|||
func (t *BarrageCtl) Send() { |
|||
uid := t.MustGetUID() |
|||
customerId := t.MustGetCustomerId() |
|||
activityId := t.MustGetActivityId() |
|||
content := t.MustGet("content") |
|||
|
|||
//检查内容是否包含敏感
|
|||
if models.IsSensitive(content) { |
|||
t.ERROR("内容包含敏感字", code.MSG_ERR) |
|||
} |
|||
|
|||
//查询该活动的所属客户
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
//查询当前的用户信息
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
//插入弹幕消息
|
|||
_, err = core.GetXormAuto().InsertOne(&models.BarrageHistory{ |
|||
ActivityId: activityId, |
|||
UserId: uid, |
|||
Content: content, |
|||
CreateAt: time.Now(), |
|||
UpdateAt: time.Now(), |
|||
}) |
|||
t.CheckErr(err) |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err = models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
go ws_send_service.SendBarrage(fmt.Sprintf("%d", activity.Id), |
|||
define.TYPE_CUSTOMER, 0, map[string]interface{}{ |
|||
"type": "barrage", |
|||
"customer_id": 0, |
|||
"data": map[string]interface{}{ |
|||
"avatar": user.Avatar, |
|||
"content": content, |
|||
}, |
|||
}) |
|||
|
|||
t.SUCCESS("发送成功") |
|||
} |
@ -0,0 +1,105 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
bully_screen_service "hudongzhuanjia/services/bully_screen" |
|||
"hudongzhuanjia/services/pay" |
|||
"hudongzhuanjia/utils/code" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
//霸屏
|
|||
type BullyScreenCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//用户霸屏
|
|||
// todo: 支付接口
|
|||
func (t *BullyScreenCtl) PaScreen() { |
|||
activityId := t.MustGetActivityId() |
|||
uid := t.MustGetUID() |
|||
content := t.MustGet("content") |
|||
second := t.MustGetDouble("second") |
|||
style := t.MustGetInt("style") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
//检查内容是否包含敏感
|
|||
if models.IsSensitive(content) { |
|||
t.ERROR("内容包含敏感字", code.MSG_ERR) |
|||
} |
|||
|
|||
//查询该活动的的霸屏服务id
|
|||
bullyScreenServer := new(models.BullyScreenServer) |
|||
exist, err = bullyScreenServer.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在") |
|||
|
|||
//查询用户信息
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
//扣除用户的金额
|
|||
// todo:微信直接付款
|
|||
// 调用微信统一下单接口
|
|||
amount := bullyScreenServer.Price * second |
|||
ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":") |
|||
res, err := pay_service.Order("欧轩互动-霸屏支付", ip[0], user.Openid, int(amount*100), 1, user.Id, activityId) |
|||
t.CheckErr(err) |
|||
|
|||
history := &models.BullyScreenHistory{ |
|||
UserOrderId: res["user_order_id"].(int64), |
|||
BullyScreenServerId: bullyScreenServer.Id, |
|||
ActivityId: activityId, |
|||
UserId: user.Id, |
|||
Nickname: user.Nickname, |
|||
CustomerId: t.MustGetCustomerId(), |
|||
RehearsalId: activity.RehearsalId, |
|||
Second: int(second), |
|||
Amount: amount, |
|||
Style: style, |
|||
ReviewTime: 0, |
|||
Status: -1, |
|||
Content: content, |
|||
IsDelete: false, |
|||
CreatedAt: time.Now(), |
|||
UpdatedAt: time.Now(), |
|||
} |
|||
_, err = core.GetXormAuto().InsertOne(history) |
|||
t.CheckErr(err) |
|||
delete(res, "out_trade_no") |
|||
delete(res, "user_order_id") |
|||
t.JSON(res) |
|||
} |
|||
|
|||
// 审核列表 [未审核,未通过,已通过]
|
|||
func (t *BullyScreenCtl) List() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
|
|||
bss := new(models.BullyScreenServer) |
|||
exist, err := bss.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在") |
|||
|
|||
// 查询是否已经付款
|
|||
t.CheckErr(pay_service.BatchQueryByUserId(uid)) |
|||
t.CheckErr(pay_service.BatchQueryRefundByUserId(uid)) |
|||
|
|||
list, err := bully_screen_service.GetReviewList(uid, bss.Id) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(list), |
|||
"list": list, |
|||
}) |
|||
} |
@ -0,0 +1,83 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
) |
|||
|
|||
type CalorieCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// h5 1/s
|
|||
func (t *CalorieCtl) Shake() { |
|||
calorieId := t.MustGetInt64("calorie_id") |
|||
score := t.DefaultInt("score", 0) |
|||
uid := t.MustGetUID() |
|||
|
|||
calorie := new(models.Calorie) |
|||
exist, err := models.GetById(calorie, calorieId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里不存在") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, calorie.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
calorieUser := new(models.CalorieUser) |
|||
exist, err = calorieUser.GetByCalorieIdAndUserId(calorieId, uid, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "您尚未参与卡路里活动") |
|||
|
|||
// 增加score
|
|||
if calorie.Status == define.StatusRunning && score > 0 { |
|||
_, err = calorieUser.IncrScore(score) |
|||
t.CheckErr(err) |
|||
calorieUser.Score += int64(score) // 增加
|
|||
} |
|||
|
|||
count, err := core.GetXormAuto().Where("is_delete=0 and calorie_id=? and rehearsal_id=?", calorie.Id, activity.RehearsalId).Count(new(models.CalorieUser)) |
|||
t.CheckErr(err) |
|||
|
|||
users := make([]*models.CalorieUser, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and calorie_id=? and rehearsal_id=? and score<=?", |
|||
calorie.Id, activity.RehearsalId, calorieUser.Score).Desc("score").Asc("join_time").Find(&users) |
|||
t.CheckErr(err) |
|||
|
|||
var rank int |
|||
for index, user := range users { |
|||
if user.Id == calorieUser.Id { |
|||
rank = int(count) - len(users) + index + 1 |
|||
break |
|||
} |
|||
} |
|||
|
|||
// 活动时长
|
|||
//duration := calorie.GameDuration - (time.Now().Unix() - calorie.StartTime) + 6 // 加上倒计时的6s
|
|||
//if calorie.StartTime == 0 {
|
|||
// duration = calorie.GameDuration
|
|||
//}
|
|||
// 3s 倒计时
|
|||
//var countDown float64 = 0
|
|||
//if duration-calorie.GameDuration > 0 {
|
|||
// countDown = math.Ceil(float64(duration-calorie.GameDuration) / 2.0)
|
|||
//}
|
|||
|
|||
//// 活动结束
|
|||
//if calorie.Status == define.StatusEnding || duration <= 0 {
|
|||
// duration = 0
|
|||
//}
|
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"rank": rank, |
|||
"score": calorieUser.Score, // 分数
|
|||
//"time": duration - 2*int64(countDown), //时长
|
|||
//"count_down": countDown, // 倒计时
|
|||
//"status": calorie.Status, // 状态
|
|||
}) |
|||
} |
@ -0,0 +1,88 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
"time" |
|||
) |
|||
|
|||
type InvitationLetterCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// InviteEnvelope doc
|
|||
// @Summary InviteEnvelope
|
|||
// @Description 填写要求信息
|
|||
// @Tags invite envelope
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param activity_id query int true "邀请函内容"
|
|||
// @Success 0 {string} string "success"
|
|||
// @Failure 404 {string} string "参数不存在"
|
|||
// @Failure 405 {string} string "用户不存在"
|
|||
// @Router /Client/InviteEnvelopeCtl/invite [post]
|
|||
func (t *InvitationLetterCtl) Invite() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
invitationId := t.MustGetInt64("invitation_id") |
|||
answer := t.MustGet("answer") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
letter := new(models.InvitationLetter) |
|||
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请") |
|||
|
|||
letter.UserId = uid |
|||
letter.ActivityId = activityId |
|||
letter.InvitationId = invitationId |
|||
letter.RehearsalId = activity.RehearsalId |
|||
letter.ExtraData = answer |
|||
letter.IsDelete = false |
|||
letter.CreatedAt = time.Now() |
|||
letter.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(letter) |
|||
t.CheckErr(err) |
|||
|
|||
t.STRING("success") |
|||
} |
|||
|
|||
// InviteEnvelope doc
|
|||
// @Summary InviteEnvelope
|
|||
// @Description get invite envelope setting
|
|||
// @Tags invite envelope
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param activity_id query int true "Activity ID"
|
|||
// @Success 0 {object} models.Invitation
|
|||
// @Failure 404 {string} string "参数不存在"
|
|||
// @Failure 405 {string} string "用户不存在"
|
|||
// @Router /Client/InviteEnvelopeCtl/setting [get]
|
|||
func (t *InvitationLetterCtl) Setting() { |
|||
activityId := t.MustGetActivityId() |
|||
uid := t.MustGetUID() |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
letter := new(models.InvitationLetter) |
|||
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请") |
|||
|
|||
invitation := new(models.Invitation) |
|||
exist, err = invitation.GetInvitationByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_INVITE_SETTING_NOT_EXIST, "邀请函设置不存在") |
|||
t.JSON(map[string]interface{}{ |
|||
"setting": invitation, |
|||
}) |
|||
} |
@ -0,0 +1,184 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/libs/jwt" |
|||
"hudongzhuanjia/libs/wx" |
|||
"hudongzhuanjia/models" |
|||
activity_service "hudongzhuanjia/services/activity" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
//用户
|
|||
type UserCtl struct { |
|||
controllers.BaseCtl |
|||
} |
|||
|
|||
// 录入登录
|
|||
func (t *UserCtl) EntryLogin() { |
|||
account := t.MustGet("account") |
|||
password := t.MustGet("password") |
|||
activityId := t.MustGetInt64("activity_id") // 需要获取
|
|||
|
|||
entryPeople := new(models.OrderEntryPerson) |
|||
exist, err := core.GetXormAuto().Where("is_delete=0 and account = ? and password = ? and activity_id = ?", |
|||
account, password, activityId).Get(entryPeople) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在") |
|||
|
|||
area := new(models.AreaStore) |
|||
exist, err = models.GetById(area, entryPeople.AreaId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err = models.GetById(customer, entryPeople.Pid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
// 怎讲activity
|
|||
token, err := jwt.GenJwtToken("entry", entryPeople.Id, customer.Id, customer.Pid, entryPeople.AreaId, entryPeople.ActivityId, entryPeople.Name) |
|||
t.CheckErr(err) |
|||
t.SetSession(define.TOKEN, token) |
|||
entryPeople.Token = token |
|||
entryPeople.AreaName = area.Name |
|||
entryPeople.ActivityName = activity.Name |
|||
t.JSON(map[string]interface{}{ |
|||
"people": entryPeople, |
|||
}) |
|||
} |
|||
|
|||
func (t *UserCtl) WxLogin() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
wxcode := t.MustGet("code") |
|||
|
|||
activity, exist, err := activity_service.GetActivityById(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
customerId := t.DefaultInt64("customer_id", activity.CustomerId) |
|||
customer := new(models.Customer) |
|||
exist, err = models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
area := new(models.AreaStore) |
|||
if customer.Pid == 0 { |
|||
exist, err = area.GetMainAreaById(activityId) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(customer.AreaId) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
token, err := wx.GetToken(wxcode) |
|||
t.CheckErr(err) |
|||
if token.AccessToken == "" || token.Openid == "" { |
|||
t.ERROR("code无效", code.MSG_ERR) |
|||
} |
|||
info, err := wx.GetUserInfo(token.AccessToken, token.Openid) |
|||
t.CheckErr(err) |
|||
user := new(models.User) |
|||
exist, err = user.GetUserByOpenid(info.Openid) |
|||
t.CheckErr(err) |
|||
user.Nickname = info.Nickname |
|||
user.Openid = info.Openid |
|||
user.Gender = func() string { |
|||
if info.Sex == 1 { |
|||
return "男" |
|||
} |
|||
return "女" |
|||
}() |
|||
user.ActivityId = activityId |
|||
user.AreaId = area.Id |
|||
user.AreaName = area.Name |
|||
user.Avatar = info.Headimgurl |
|||
user.Unionid = info.Unionid |
|||
user.City = info.City |
|||
user.Province = info.Province |
|||
user.Country = info.Country |
|||
user.CreatedAt = time.Now() |
|||
user.UpdatedAt = time.Now() |
|||
if exist { |
|||
core.GetXormAuto().Id(user.Id).AllCols().Update(user) |
|||
} else { |
|||
core.GetXormAuto().InsertOne(user) |
|||
} |
|||
t.CheckErr(err) |
|||
|
|||
signIn := "未签到" |
|||
history := new(models.SignHistory) |
|||
exist, err = history.GetByUserId(activityId, user.Id, activity.RehearsalId, area.Id) |
|||
t.CheckErr(err) |
|||
if exist { // 存在数据
|
|||
signIn = "已签到" |
|||
} |
|||
|
|||
jwtToken, err := jwt.GenJwtToken(define.TYPE_USER, user.Id, customer.Id, customer.Pid, area.Id, activityId, user.Nickname) |
|||
t.CheckErr(err) |
|||
t.SetSession(define.TOKEN, jwtToken) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"user": user, |
|||
"token": jwtToken, |
|||
"activity": activity, |
|||
"sign_in": signIn, |
|||
"tag": "activity", |
|||
}) |
|||
} |
|||
|
|||
// 模拟wx login
|
|||
func (t *UserCtl) DebugLogin() { |
|||
uid := t.DefaultInt64("user_id", 19) |
|||
customerId := t.DefaultInt64("customer_id", 125) |
|||
activityId := t.DefaultInt64("activity_id", 592) |
|||
|
|||
user := new(models.User) |
|||
exist, err := models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err = models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
area := new(models.AreaStore) |
|||
if customer.Pid == 0 { |
|||
exist, err = area.GetMainAreaById(activityId) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(customer.AreaId) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
jwtToken, err := jwt.GenJwtToken("user", user.Id, customer.Id, customer.Pid, |
|||
area.Id, activityId, user.Nickname) |
|||
t.CheckErr(err) |
|||
t.SetSession(define.TOKEN, jwtToken) |
|||
t.JSON(map[string]interface{}{ |
|||
"user": user, |
|||
"token": jwtToken, |
|||
}) |
|||
} |
|||
|
|||
type UserAuthCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//退出
|
|||
func (t *UserAuthCtl) Logout() { |
|||
if _, ok := t.Request.SESSION[define.TOKEN]; !ok { |
|||
t.ERROR("未登录", code.MSG_ERR_Authority) |
|||
} |
|||
t.DeleteSession(define.TOKEN) |
|||
t.SUCCESS("退出成功") |
|||
} |
@ -0,0 +1,83 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
. "github.com/smartystreets/goconvey/convey" |
|||
"hudongzhuanjia/libs/jwt" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/test" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"net/http" |
|||
"testing" |
|||
) |
|||
|
|||
func TestEntryLogin(t *testing.T) { |
|||
type Data struct { |
|||
People *models.OrderEntryPerson `json:"people"` |
|||
} |
|||
|
|||
type Result struct { |
|||
core.ResponseData |
|||
Data Data `json:"data"` |
|||
} |
|||
|
|||
conf := test.GetConfig() |
|||
Convey("测试录入人员登录", t, func() { |
|||
path := test.ApiUrl("PcClient/Client/UserCtl/entryLogin") |
|||
// 正确登录
|
|||
param := map[string]interface{}{ |
|||
"account": conf.EntryAccount, |
|||
"password": conf.EntryPwd, |
|||
"activity_id": conf.ActivityId, |
|||
} |
|||
resp, err := test.Api("").Get(path, param) // 并不需要token
|
|||
So(err, ShouldBeNil) // 检测是否请求出错
|
|||
So(resp.StatusCode(), ShouldEqual, http.StatusOK) // 检测请求连接是否正确
|
|||
res := new(Result) |
|||
err = resp.Json(res) |
|||
So(err, ShouldBeNil) // 检测json 解析是否正确
|
|||
So(res.Code, ShouldEqual, 0) // 返回code是否为0
|
|||
So(res.Data.People, ShouldNotBeNil, nil) // 检测返回数据是否为空
|
|||
So(res.Data.People.ActivityId, ShouldEqual, conf.ActivityId) |
|||
So(res.Data.People.Account, ShouldEqual, conf.EntryAccount) |
|||
So(res.Data.People.Password, ShouldEqual, conf.EntryPwd) |
|||
So(res.Data.People.Token, ShouldNotBeEmpty) |
|||
// 校验token
|
|||
claims, err := jwt.ParseAccessToken(res.Data.People.Token) |
|||
So(err, ShouldNotBeNil) |
|||
So(claims.ActivityId, ShouldEqual, conf.ActivityId) |
|||
So(claims.AccountType, ShouldEqual, define.TYPE_ENTRY) |
|||
So(claims.Username, ShouldEqual, conf.EntryAccount) |
|||
|
|||
// 登录失败的场景
|
|||
// 录入人员不存在
|
|||
param = map[string]interface{}{ |
|||
"account": "tommy", |
|||
"password": conf.EntryPwd, |
|||
"activity_id": conf.ActivityId, |
|||
} |
|||
resp, err = test.Api("").Get(path) |
|||
So(err, ShouldBeNil) |
|||
So(resp.StatusCode(), ShouldEqual, http.StatusOK) |
|||
res = new(Result) |
|||
err = resp.Json(res) |
|||
So(err, ShouldBeNil) |
|||
So(res.Code, ShouldEqual, code.MSG_ENTRYPEOPLE_NOT_EXIST) |
|||
|
|||
// 互动不存在
|
|||
param = map[string]interface{}{ |
|||
"account": conf.EntryAccount, |
|||
"password": conf.EntryPwd, |
|||
"activity_id": 0, |
|||
} |
|||
resp, err = test.Api("").Get(path) |
|||
So(err, ShouldBeNil) |
|||
So(resp.StatusCode(), ShouldEqual, http.StatusOK) |
|||
res = new(Result) |
|||
err = resp.Json(res) |
|||
So(err, ShouldBeNil) |
|||
So(res.Code, ShouldEqual, code.MSG_ACTIVITY_NOT_EXIST) |
|||
// done
|
|||
}) |
|||
} |
@ -0,0 +1,24 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
) |
|||
|
|||
type LotteryCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
func (t *LotteryCtl) UserLotteries() { |
|||
uid := t.MustGetUID() |
|||
|
|||
userPrizes := make([]*models.UserPrize, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and user_id=? ", uid).Desc("created_at").Find(&userPrizes) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"list": userPrizes, |
|||
"total": len(userPrizes), |
|||
}) |
|||
} |
@ -0,0 +1,228 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
invitation_service "hudongzhuanjia/services/invitation" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"github.com/ouxuanserver/osmanthuswine/src/helper" |
|||
) |
|||
|
|||
type OrderEntryCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// 商品 == > 用户查看所有商品
|
|||
func (t *OrderEntryCtl) List() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
goods := make([]*models.CustomerGoods, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId). |
|||
Asc("created_at").Find(&goods) |
|||
t.CheckErr(err) |
|||
for index := range goods { |
|||
url := fmt.Sprintf("%s/PcClient/Client/OrderEntryCtl/order?"+ |
|||
"user_id=%d&activity_id=%d&good_id=%d", define.HOST, uid, activityId, goods[index].Id) |
|||
qrcode, err := utils.Qrcode2Base64(url) |
|||
t.CheckErr(err) |
|||
goods[index].Qrcode = qrcode |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"list": goods, |
|||
"total": len(goods), |
|||
}) |
|||
} |
|||
|
|||
// 下订单 == > 二维码跳转
|
|||
func (t *OrderEntryCtl) Order() { |
|||
userId := t.MustGetInt64("user_id") |
|||
activityId := t.MustGetInt64("activity_id") |
|||
goodId := t.MustGetInt64("good_id") |
|||
entryId := t.MustGetUID() |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
entryPerson := new(models.OrderEntryPerson) |
|||
exist, err = models.GetById(entryPerson, entryId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在") |
|||
|
|||
area := new(models.AreaStore) |
|||
exist, err = area.GetAreaStoreById(entryPerson.AreaId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
good := new(models.CustomerGoods) |
|||
exist, err = models.GetById(good, goodId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "商品不存在") |
|||
|
|||
orderGift := new(models.OrderGift) |
|||
exist, err = orderGift.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
userPrize := new(models.UserPrize) |
|||
userPrize.UserId = userId |
|||
userPrize.ActivityId = activityId |
|||
userPrize.RehearsalId = activity.RehearsalId |
|||
userPrize.ActivityName = activity.Name |
|||
userPrize.PrizeName = orderGift.GiftName |
|||
userPrize.PrizeImg = orderGift.GiftPicUrl |
|||
userPrize.PrizeType = 3 |
|||
userPrize.IsDelete = false |
|||
userPrize.CreatedAt = time.Now() |
|||
userPrize.UpdatedAt = time.Now() |
|||
if exist && orderGift.Num == 0 { // 存在无限制
|
|||
_, err := core.GetXormAuto().Insert(userPrize) |
|||
t.CheckErr(err) |
|||
} |
|||
|
|||
order := new(models.CustomerOrder) |
|||
order.UserPrizeId = userPrize.Id |
|||
order.AreaId = entryPerson.AreaId |
|||
order.AreaName = area.Name |
|||
order.RehearsalId = activity.RehearsalId |
|||
order.BuyerId = userId |
|||
order.GoodsId = goodId |
|||
order.ActivityId = activityId |
|||
order.OrderEntryPersonId = entryPerson.Id |
|||
order.GoodsName = good.Name |
|||
order.TotalAmount = good.Price |
|||
order.OutTradeNo = helper.CreateUUID() |
|||
order.IsDelete = false |
|||
order.UpdatedAt = time.Now() |
|||
order.CreatedAt = time.Now() |
|||
_, err = core.GetXormAuto().Insert(order) |
|||
t.CheckErr(err) |
|||
|
|||
// 查出这个订单多少名
|
|||
// 防止并发出现错误
|
|||
if exist && orderGift.Num > 0 { |
|||
count, err := core.GetXormAuto().Where("created_at >= ? and activity_id=? and rehearsal_id=? and is_delete=0", |
|||
order.CreatedAt, activityId, activity.RehearsalId).Count(new(models.CustomerOrder)) |
|||
t.CheckErr(err) |
|||
if orderGift.Num >= int(count) { |
|||
_, err = core.GetXormAuto().InsertOne(userPrize) |
|||
t.CheckErr(err) |
|||
order.UserPrizeId = userPrize.Id |
|||
_, err := core.GetXormAuto().Id(order.Id).Cols("user_prize_id").Update(order) |
|||
t.CheckErr(err) |
|||
} |
|||
} |
|||
|
|||
t.SUCCESS("success") |
|||
} |
|||
|
|||
func (t *OrderEntryCtl) DeleteOrder() { |
|||
orderId := t.MustGetInt64("order_id") |
|||
order := new(models.CustomerOrder) |
|||
exist, err := core.GetXormAuto().Where("is_delete=0 and id=?", orderId).Get(order) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "订单不存在") |
|||
_, err = new(models.CustomerOrder).SoftDeleteById(orderId) |
|||
t.CheckErr(err) |
|||
if order.UserPrizeId != 0 { |
|||
_, err = new(models.UserPrize).SoftDeleteById(order.UserPrizeId) |
|||
t.CheckErr(err) |
|||
} |
|||
t.SUCCESS("删除成功") |
|||
} |
|||
|
|||
type OrderListResult struct { |
|||
OrderId int64 `json:"order_id"` |
|||
UserId int64 `json:"user_id"` |
|||
EntryName string `json:"entry_name"` |
|||
GoodName string `json:"good_name"` |
|||
OrderTime string `json:"order_time"` |
|||
OrderMoney float64 `json:"order_money"` |
|||
Extra []map[string]interface{} `json:"extra"` // 额外信息
|
|||
ExtraData string `json:"-"` |
|||
} |
|||
|
|||
func (t *OrderEntryCtl) EntryOrders() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
list := make([]*OrderListResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o"). |
|||
Select("l.extra_data as extra_data, g.name as good_name, o.buyer_id as user_id, o.total_amount as order_money, "+ |
|||
" o.id as order_id, DATE_FORMAT(o.created_at, '%Y-%m-%d %H:%i:%S') AS order_time"). |
|||
Join("LEFT", new(models.CustomerGoods).Alias("g"), |
|||
"o.goods_id=g.id and o.activity_id=g.activity_id and g.is_delete=0"). |
|||
Join("LEFT", new(models.InvitationLetter).Alias("l"), |
|||
"l.user_id = o.buyer_id and o.activity_id=l.activity_id and l.is_delete=0"). |
|||
Where("o.activity_id=? and o.order_entry_person_id=? and o.rehearsal_id=? and o.is_delete=0", |
|||
activityId, uid, activity.RehearsalId).Desc("o.created_at").Find(&list) |
|||
t.CheckErr(err) |
|||
|
|||
// 添加邀请函的内容
|
|||
optionItems, err := invitation_service.GetOptionItem(activityId) |
|||
t.CheckErr(err) |
|||
for i := range list { |
|||
data, err := invitation_service.GetOptionValue(optionItems, list[i].ExtraData) |
|||
t.CheckErr(err) |
|||
list[i].Extra = data |
|||
list[i].EntryName = t.MustGetName() |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"list": list, |
|||
"total": len(list), |
|||
}) |
|||
} |
|||
|
|||
// 用户订单列表
|
|||
type UserOrdersResult struct { |
|||
models.CustomerOrder `xorm:"extends"` |
|||
Good *models.CustomerGoods `json:"good" xorm:"extends"` |
|||
} |
|||
|
|||
// 用户查看订单列表
|
|||
func (t *OrderEntryCtl) UserOrders() { |
|||
uid := t.MustGetUID() |
|||
|
|||
orders := make([]UserOrdersResult, 0) |
|||
s := core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o"). |
|||
Join("LEFT", new(models.CustomerGoods).Alias("g"), "o.goods_id=g.id and g.is_delete=0"). |
|||
Desc("o.created_at").Where("o.buyer_id=? and o.is_delete=0", uid) |
|||
|
|||
if t.PageSize > 0 { |
|||
s = s.Limit(t.PageSize, t.Page*t.PageSize) |
|||
} |
|||
total, err := s.Desc("o.created_at").FindAndCount(&orders) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"list": orders, |
|||
"total": total, |
|||
}) |
|||
} |
|||
|
|||
// 二维码
|
|||
func (t *OrderEntryCtl) Qrcode() { |
|||
userId := t.MustGetInt64("user_id") |
|||
activityId := t.MustGetInt64("activity_id") |
|||
goodId := t.MustGetInt64("good_id") |
|||
Url := fmt.Sprintf("%s/PcClient/Client/OrderEntryCtl/order?user_id=%d&activity_id=%d&good_id=%d", |
|||
define.HOST, userId, activityId, goodId) |
|||
qr, err := utils.Qrcode2Base64(Url) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qr, |
|||
}) |
|||
} |
@ -0,0 +1,104 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
pay_service "hudongzhuanjia/services/pay" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
//打赏
|
|||
type RewardCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// todo: 支付接口
|
|||
func (t *RewardCtl) Reward() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
content := t.MustGet("content") |
|||
amount := t.MustGetDouble("amount") |
|||
uid := t.MustGetUID() |
|||
if amount <= 0 { |
|||
t.ERROR("打赏金额不能小于0", code.MSG_ERR_Param) |
|||
} |
|||
//检查内容是否包含敏感
|
|||
if models.IsSensitive(content) { |
|||
t.ERROR("内容包含敏感字", code.MSG_ERR) |
|||
} |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
//查询该活动的的打赏服务id
|
|||
rewardServer := new(models.RewardServer) |
|||
exist, err = rewardServer.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
amount = utils.Float64CusDecimal(amount, 2) |
|||
|
|||
//查询用户信息
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":") |
|||
res, err := pay_service.Order("欧轩互动-打赏支付", ip[0], user.Openid, int(amount*100), 2, user.Id, activityId) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = core.GetXormAuto().InsertOne(&models.RewardHistory{ |
|||
UserOrderId: res["user_order_id"].(int64), |
|||
RewardServerId: rewardServer.Id, |
|||
CustomerId: t.MustGetCustomerId(), |
|||
UserId: user.Id, |
|||
Amount: amount, |
|||
Content: content, |
|||
RehearsalId: activity.RehearsalId, |
|||
Status: -1, |
|||
ReviewTime: 0, |
|||
IsDelete: false, |
|||
CreatedAt: time.Now(), |
|||
UpdatedAt: time.Now(), |
|||
}) |
|||
t.CheckErr(err) |
|||
delete(res, "user_order_id") |
|||
delete(res, "out_trade_no") |
|||
t.JSON(res) |
|||
} |
|||
|
|||
type RWListResult struct { |
|||
Id int64 `json:"id"` |
|||
Content string `json:"content"` |
|||
Amount float64 `json:"amount"` |
|||
Status int `json:"status"` |
|||
} |
|||
|
|||
func (t *RewardCtl) List() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
|
|||
rs := new(models.RewardServer) |
|||
exist, err := rs.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
t.CheckErr(pay_service.BatchQueryByUserId(uid)) |
|||
t.CheckErr(pay_service.BatchQueryRefundByUserId(uid)) |
|||
|
|||
list := make([]*RWListResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.RewardHistory)).Select("id, content, amount, status"). |
|||
Where("is_delete=0 and user_id=? and reward_server_id=? and status <> -1", uid, rs.Id). |
|||
Desc("created_at").Find(&list) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(list), |
|||
"list": list, |
|||
}) |
|||
} |
@ -0,0 +1,164 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/libs/wx" |
|||
"hudongzhuanjia/models" |
|||
activity_service "hudongzhuanjia/services/activity" |
|||
pay_service "hudongzhuanjia/services/pay" |
|||
ws_send_service "hudongzhuanjia/services/ws_send" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"math/rand" |
|||
"time" |
|||
) |
|||
|
|||
type ShakeRedEnvelopeCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
func (t *ShakeRedEnvelopeCtl) Status() { |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
rule := new(models.ShakeRedEnvelopeRule) |
|||
exist, err := models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SHAKERB_RECORD_NOT_EXIST, "摇红包规则不存在") |
|||
t.JSON(map[string]interface{}{ |
|||
"status": rule.ShakeRedEnvelopeStatus, |
|||
}) |
|||
} |
|||
|
|||
// todo:调用支付接口
|
|||
func (t *ShakeRedEnvelopeCtl) Shake() { |
|||
customerId := t.MustGetInt64("customer_id") |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
userId := t.MustGetUID() |
|||
|
|||
// 查询摇红包规则
|
|||
rule := new(models.ShakeRedEnvelopeRule) |
|||
exist, err := models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "摇红包规则不存在") |
|||
t.CheckRunning(rule.ShakeRedEnvelopeStatus) |
|||
|
|||
area := new(models.AreaStore) |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SHAKERB_NOT_EXIST, "摇红包不存在") |
|||
|
|||
// 查询摇红包活动主id, is_pay=1给钱了,给摇
|
|||
envelope := new(models.ShakeRedEnvelopeActivity) |
|||
exist, err = envelope.GetPayedById(rule.ShakeRedEnvelopeActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SHAKERB_NOT_EXIST, "摇红包不存在") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, envelope.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
moduleService, exist, err := activity_service.GetModuleService(define.MODULE_SHAKRB, activity.Id) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "活动模块不存在") |
|||
|
|||
record := new(models.ShakeRedEnvelopeRecord) /// 之后使用, 存入乐观锁
|
|||
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { // 剔除摇过红包的用户
|
|||
exist, err := record.ExistRecord(activity.RehearsalId, activity.Id, rule.Id, envelope.Id, userId) |
|||
t.CheckErr(err) |
|||
t.Assert(!exist, code.MSG_SHAKERB_RECORD_NOT_EXIST, "您已经摇过红包了,请等待下一轮.") // 不存在继续往下走
|
|||
} |
|||
// done: 增加概率, 修改概率
|
|||
r := rand.New(rand.NewSource(time.Now().UnixNano())) |
|||
t.Assert(r.Float64()*100 <= rule.Probability, code.MSG_ERR, "您与红包擦肩而过") // 必须在红包概率以内才能获取
|
|||
|
|||
// 增加session 或者乐观锁
|
|||
exist, err = record.GetByRuleId(ruleId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SHAKERB_RECORD_NOT_EXIST, "红包已经派发完毕") |
|||
|
|||
// 查询用户
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, userId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
|
|||
record.IsDraw = 0 |
|||
// 记录红包 ---> 非彩排才能
|
|||
if activity.RehearsalId == 0 { |
|||
res, err := pay_service.SendRedPack("欧轩互动", user.Openid, fmt.Sprintf("感谢您参加%s", activity.Name), |
|||
"", rule.Model, "摇得越快抢得越多", int(record.Amount * 100), 1, 1) |
|||
t.CheckErr(err) |
|||
record.MchBillno = res.MchBillno |
|||
record.Reason = fmt.Sprintf("%s:%s", res.ErrCode, res.ErrCodeDes) |
|||
record.Status = res.ResultCode |
|||
record.ReOpenid = user.Openid |
|||
if res.ResultCode == wx.CODE_SUCCESS && res.ErrCode == wx.CODE_SUCCESS { |
|||
record.IsDraw = 1 |
|||
} |
|||
} |
|||
|
|||
record.UserId = user.Id |
|||
record.UserName = user.Nickname |
|||
record.UserPhone = user.Phone |
|||
record.AreaName = area.Name |
|||
record.Name = activity.Name |
|||
row, err := record.UpdateAllColsById(record.Id) |
|||
t.CheckErr(err) |
|||
t.Assert(row == 1, code.MSG_ERR, "您与红包擦肩而过") // 那么 row == 1 为已经成功抢到
|
|||
|
|||
// 通知大屏
|
|||
total, err := new(models.ShakeRedEnvelopeRecord).Total(activity.Id, activity.RehearsalId, envelope.Id, rule.Id) |
|||
remaining, err := new(models.ShakeRedEnvelopeRecord).Count(activity.Id, activity.RehearsalId, envelope.Id, rule.Id, -1) |
|||
t.CheckErr(err) |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err = models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id), |
|||
define.TYPE_USER, userId, map[string]interface{}{ |
|||
"customer_id": customer.Id, |
|||
"user_id": user.Id, |
|||
"type": "shake_rb", |
|||
"data": map[string]interface{}{ |
|||
"amount": record.Amount, |
|||
"nickname": user.Nickname, |
|||
"avatar": user.Avatar, |
|||
"total": total - remaining, //
|
|||
"remaining": remaining, //
|
|||
}, |
|||
}) |
|||
|
|||
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id), |
|||
define.TYPE_CUSTOMER, customerId, map[string]interface{}{ |
|||
"customer_id": customer.Id, |
|||
"user_id": user.Id, |
|||
"type": "shake_rb", |
|||
"data": map[string]interface{}{ |
|||
"amount": record.Amount, |
|||
"nickname": user.Nickname, |
|||
"avatar": user.Avatar, |
|||
"total": total - remaining, //
|
|||
"remaining": remaining, //
|
|||
}, |
|||
}) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"amount": record.Amount, |
|||
"shake_red_envelope_record_id": record.Id, |
|||
}) |
|||
} |
|||
|
|||
// 用户红包
|
|||
func (t *ShakeRedEnvelopeCtl) UserRedEnvelopes() { |
|||
records, err := models.GetRedEnvelopesByUserId(t.MustGetUID()) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"list": records, |
|||
"total": len(records), |
|||
}) |
|||
} |
@ -0,0 +1,96 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
ws_send_service "hudongzhuanjia/services/ws_send" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
) |
|||
|
|||
//签到
|
|||
type SignCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//签到动作
|
|||
func (t *SignCtl) Sign() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetInt64("activity_id") |
|||
customerId := t.MustGetInt64("customer_id") |
|||
|
|||
//根据activity_id查找主活动的信息
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err = models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
//根据activity_id查找副活动的规则信息
|
|||
signUp := new(models.SignUp) |
|||
exist, err = signUp.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "签到规则不存在") |
|||
|
|||
if signUp.OnlyInvitation == 1 { //
|
|||
// 邀请函才能签到
|
|||
letter := new(models.InvitationLetter) |
|||
exist, err := letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "您没收到邀请函") |
|||
} |
|||
//检查是否已经签到了
|
|||
signHistory := new(models.SignHistory) |
|||
exist, err = signHistory.GetByUserId(activityId, uid, activity.RehearsalId, t.MustGetAreaId()) |
|||
t.CheckErr(err) |
|||
t.Assert(!exist, code.MSG_SIGN_HISTORY_EXIST, "您已经签到过了") // 存在判断
|
|||
|
|||
// 签到人数
|
|||
signTotal, err := core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and rehearsal_id=? and activity_id=?", |
|||
signUp.Id, activity.RehearsalId, activity.Id).Count(signHistory) |
|||
t.CheckErr(err) |
|||
|
|||
signUpTotal, err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activity.Id).Count(new(models.InvitationLetter)) |
|||
t.CheckErr(err) |
|||
|
|||
if activity.RehearsalId != 0 && signTotal >= 10 { |
|||
t.ERROR("彩排人数不能超过10人", code.MSG_SIGN_UP_REHEARSAL_LIMIT) |
|||
} |
|||
|
|||
signHistory = new(models.SignHistory) |
|||
signHistory.UserId = uid |
|||
signHistory.RehearsalId = activity.RehearsalId |
|||
signHistory.ActivityId = activityId |
|||
signHistory.SignRuleId = signUp.Id |
|||
signHistory.AreaId = user.AreaId |
|||
signHistory.IsDelete = false |
|||
signHistory.UpdatedAt = time.Now() |
|||
signHistory.CreatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(signHistory) |
|||
t.CheckErr(err) |
|||
|
|||
go ws_send_service.SendSign(fmt.Sprintf("%d", activity.Id), |
|||
define.TYPE_CUSTOMER, customerId, map[string]interface{}{ |
|||
"type": "sign_up", |
|||
"customer_id": customer.Id, |
|||
"data": map[string]interface{}{ |
|||
"avatar": user.Avatar, |
|||
"sign_total": signTotal + 1, |
|||
"sign_up_total": signUpTotal, |
|||
}, |
|||
}) |
|||
t.SUCCESS("签到成功") |
|||
} |
@ -0,0 +1,211 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
bahe_service "hudongzhuanjia/services/bahe" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type TugOfWarCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// 获取当前状态(废弃)
|
|||
// @Summary client tug war
|
|||
// @Description get current status
|
|||
// @Tags client tug war
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param bahe_activity_id query int true "Bahe Activity ID"
|
|||
// @Success 0 {object} models.TugOfWar
|
|||
// @Failure 503 {string} string "参数不存在"
|
|||
// @Failure 504 {object} string "用户不存在"
|
|||
// @Router /Client/TugOfWarCtl/status [get]
|
|||
func (t *TugOfWarCtl) Status() { |
|||
// 获取此次活动的状态
|
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
uid := t.MustGetUID() |
|||
// 找到活动
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_TUGWAR_NOT_EXIST, "拔河不存在") |
|||
|
|||
// 主活动
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, bahe.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存") |
|||
|
|||
// 找到用户
|
|||
member := new(models.BaheTeamMember) |
|||
exist, err = member.GetMemberByBaheIdAndUserId(uid, bahe.Id, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_TUGWAR_MEMBER_NOT_EXIST, "队员不存在") |
|||
|
|||
score, err := bahe_service.GetScoreByTeamId(member.TeamId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
rank := 1 |
|||
team := new(models.BaheTeam) |
|||
exist, err = models.GetById(team, member.TeamId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_TUGWAR_TEAM_NOT_EXIST, "队伍不存在") |
|||
|
|||
otherTeam := new(models.BaheTeam) |
|||
exist, err = otherTeam.GetOtherTeam(member.TeamId, team.BaheActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_TUGWAR_TEAM_NOT_EXIST, "队伍不存在") |
|||
|
|||
otherScore, err := bahe_service.GetScoreByTeamId(otherTeam.Id, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
if otherScore > score { |
|||
rank = 2 |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"status": bahe.Status, |
|||
"score": score, |
|||
"rank": rank, |
|||
}) |
|||
} |
|||
|
|||
// tug_war doc
|
|||
// @Summary tug war
|
|||
// @Description shake bahe activity
|
|||
// @Tags tug war
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param bahe_activity_id query int true "Bahe Activity ID"
|
|||
// @Success 0 {object} models.TugOfWar
|
|||
// @Success 0 {object} models.BaheTeamMember
|
|||
// @Success 0 {object} models.BaheTeam
|
|||
// @Failure 404 {string} string "参数不存在"
|
|||
// @Failure 405 {object} string "用户不存在"
|
|||
// @Router /Client/TugOfWarCtl/shake [get]
|
|||
func (t *TugOfWarCtl) Shake() { |
|||
uid := t.MustGetUID() |
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
score := t.MustGetInt64("score") // 增加的分数
|
|||
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河活动不存在") |
|||
t.CheckRunning(bahe.Status) |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, bahe.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
member := new(models.BaheTeamMember) |
|||
exist, err = member.GetMemberByBaheIdAndUserId(uid, baheId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ERR, "该用户尚未加入队伍") |
|||
|
|||
if score != 0 { |
|||
_, err = member.IncrScoreById(member.Id, score) |
|||
t.CheckErr(err) |
|||
member.Score += score |
|||
} |
|||
|
|||
// 根据team_id 获取所有成员的分数
|
|||
members := make([]*models.BaheTeamMember, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=?", |
|||
member.TeamId, member.RehearsalId).Desc("score").Asc("sort_time").Find(&members) |
|||
t.CheckErr(err) |
|||
|
|||
var rank int |
|||
for index, m := range members { |
|||
if m.Id == member.Id { |
|||
rank = index + 1 |
|||
break |
|||
} |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"rank": rank, // 队内排名
|
|||
"score": member.Score, // 人员分数
|
|||
}) |
|||
} |
|||
|
|||
type JoinTeamResult struct { |
|||
Number int |
|||
TeamId int64 |
|||
TeamName string |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) JoinTeam() { |
|||
teamId := t.MustGetInt64("bahe_team_id") |
|||
baheActivityId := t.MustGetInt64("bahe_activity_id") |
|||
uid := t.MustGetUID() |
|||
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_TUGWAR_TEAM_OVER_LIMIT, "拔河不存在") |
|||
if bahe.Status == define.StatusEnding { |
|||
t.ERROR("该拔河活动已结束", code.MSG_MODULE_STATUS_END) |
|||
} |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, bahe.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
// 判斷是否已經存在该用户
|
|||
member := new(models.BaheTeamMember) |
|||
exist, err = member.GetMemberByBaheIdAndUserId(uid, bahe.Id, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
if exist { // 存在改用户
|
|||
t.JSON(map[string]interface{}{ |
|||
"member": member, |
|||
}) |
|||
return |
|||
} |
|||
|
|||
team := new(JoinTeamResult) |
|||
session := core.GetXormAuto().Table(new(models.BaheTeam)).Alias("t"). |
|||
Select("t.id as team_id, t.bahe_team_name as team_name, count(m.id) as number"). |
|||
Join("LEFT", new(models.BaheTeamMember).Alias("m"), |
|||
"m.team_id=t.id and m.is_delete=0 and m.rehearsal_id=?", activity.RehearsalId) |
|||
if teamId == 0 { // 人数最少的一队
|
|||
session = session.Where("t.is_delete=0 and t.bahe_activity_id=? ", bahe.Id). |
|||
GroupBy("t.id").Asc("number") |
|||
} else { |
|||
session = session.Where("t.is_delete=0 and t.id=?", teamId).GroupBy("t.id") |
|||
} |
|||
exist, err = session.Get(team) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ERR, "队伍信息错误, 请重新扫码") |
|||
t.Assert(team.Number < bahe.Number, code.MSG_TUGWAR_TEAM_OVER_LIMIT, "队伍满人,请等待下一轮") |
|||
|
|||
// done: 均等分配 + 人数限制
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
member.TeamId = team.TeamId |
|||
member.TeamName = team.TeamName |
|||
member.MemberId = uid |
|||
member.Avatar = user.Avatar |
|||
member.NickName = user.Nickname |
|||
member.BaheActivityId = baheActivityId |
|||
member.RehearsalId = activity.RehearsalId |
|||
member.SortTime = time.Now().UnixNano() |
|||
member.CreatedAt = time.Now() |
|||
member.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(member) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"member": member, |
|||
}) |
|||
} |
@ -0,0 +1,86 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type UpperWallCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//发送上墙消息
|
|||
// todo: 支付接口
|
|||
func (t *UpperWallCtl) Send() { |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
category := t.MustGetInt("category") |
|||
content, _ := t.Get("content") |
|||
img, _ := t.Get("img") |
|||
|
|||
//获取主活动信息
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
msgWall := new(models.MsgWallServer) |
|||
exist, err = msgWall.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
if !exist || msgWall.UpWallStatus == "关闭" { |
|||
t.ERROR("上墙活动尚未开启", code.MSG_ERR) |
|||
} |
|||
|
|||
//获取用信息
|
|||
user := new(models.User) |
|||
exist, err = models.GetById(user, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|||
|
|||
uw := new(models.UpperWall) |
|||
uw.RehearsalId = activity.RehearsalId |
|||
uw.ActivityId = activityId |
|||
uw.Category = fmt.Sprintf("%v", category) |
|||
uw.UserId = user.Id |
|||
uw.Content = content |
|||
uw.Img = img |
|||
uw.Status = 0 |
|||
uw.CreatedAt = time.Now() |
|||
uw.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().Insert(uw) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("成功") |
|||
} |
|||
|
|||
type UWListResult struct { |
|||
Id int64 `json:"id"` |
|||
Content string `json:"content"` |
|||
Img string `json:"img"` |
|||
Category string `json:"category"` |
|||
Status int `json:"status"` |
|||
} |
|||
|
|||
func (t *UpperWallCtl) List() { |
|||
activityId := t.MustGetActivityId() |
|||
uid := t.MustGetUID() |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
list := make([]*UWListResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.UpperWall)).Select("id, content, img, category, status"). |
|||
Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=?", uid, activityId, activity.RehearsalId). |
|||
OrderBy("created_at desc").Find(&list) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"list": list, |
|||
"total": len(list), |
|||
}) |
|||
} |
@ -0,0 +1,128 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
"time" |
|||
) |
|||
|
|||
type VoteCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//投票
|
|||
func (t *VoteCtl) Vote() { |
|||
uid := t.MustGetUID() |
|||
ladderId := t.MustGetInt64("vote_activity_ladder_id") |
|||
|
|||
//检查是否可以投票
|
|||
ladder := new(models.NewVoteActivityLadder) |
|||
exist, err := models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_VOTE_LADDER_NOT_EXIST, "投票人不存在") |
|||
|
|||
vote := new(models.NewVoteActivity) |
|||
exist, err = models.GetById(vote, ladder.VoteActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") |
|||
t.CheckRunning(vote.VoteStatus) |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, vote.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
history := new(models.NewVoteActivityHistory) |
|||
exist, err = history.ExistByLadderId(uid, ladderId, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(!exist, code.MSG_VOTE_HISTORY_EXIST, "您已经投过票了") |
|||
|
|||
if vote.Model == "单选" { |
|||
//检查是否已经投过票了
|
|||
exist, err = history.ExistByVoteId(uid, vote.Id, activity.RehearsalId) |
|||
t.CheckErr(err) |
|||
t.Assert(!exist, code.MSG_VOTE_HISTORY_EXIST, "您已经投过票了") |
|||
} else { |
|||
num, err := history.CountUser(uid, activity.RehearsalId, vote.Id) |
|||
t.CheckErr(err) |
|||
if num >= vote.ModelNum { |
|||
t.ERROR(fmt.Sprintf("您投票人数已超过%d人", vote.ModelNum), code.MSG_ERR) |
|||
} |
|||
} |
|||
// done: 增加人数限制
|
|||
history.UserId = uid |
|||
history.RehearsalId = activity.RehearsalId |
|||
history.VoteActivityId = vote.Id |
|||
history.VoteActivityLadderId = ladderId |
|||
history.IsDelete = false |
|||
history.CreatedAt = time.Now() |
|||
history.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(history) |
|||
t.CheckErr(err) |
|||
|
|||
// vote ladder total_number + 1
|
|||
_, err = ladder.Incr(ladderId, 1) |
|||
t.CheckErr(err) |
|||
|
|||
t.SUCCESS("投票成功") |
|||
} |
|||
|
|||
// 投票活动列表
|
|||
func (t *VoteCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
// 该活动是否进行中
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
votes := make([]*models.NewVoteActivity, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).Desc("created_at").Find(&votes) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(votes), |
|||
"votes": votes, |
|||
}) |
|||
} |
|||
|
|||
func (t *VoteCtl) Detail() { |
|||
voteActivityId := t.MustGetInt64("vote_activity_id") |
|||
uid := t.MustGetUID() |
|||
activityId := t.MustGetActivityId() |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
ladders := make([]*models.NewVoteActivityLadder, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and vote_activity_id=?", voteActivityId). |
|||
Desc("total_number").Asc("updated_at").Find(&ladders) |
|||
t.CheckErr(err) |
|||
|
|||
histories := make([]*models.NewVoteActivityHistory, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and vote_activity_id=?", |
|||
uid, activity.RehearsalId, voteActivityId).Find(&histories) |
|||
t.CheckErr(err) |
|||
|
|||
for i := range ladders { |
|||
for j := range histories { |
|||
if ladders[i].Id == histories[j].VoteActivityLadderId { |
|||
ladders[i].IsVote = true |
|||
break |
|||
} |
|||
} |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(ladders), |
|||
"members": ladders, |
|||
}) |
|||
} |
@ -0,0 +1,80 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/helper" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/libs/wx" |
|||
"hudongzhuanjia/utils" |
|||
"time" |
|||
) |
|||
|
|||
type WxCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
const SignUrl = "jsapi_ticket=%s&noncestr=%s×tamp=%d&url=%s" |
|||
|
|||
type TicketCache struct { |
|||
Url string `json:"url" xorm:"not null comment('路径')"` |
|||
Token string `json:"-" xorm:"not null comment('token')"` |
|||
TokenExpired int64 `json:"ticket_expired" xorm:"not null default(0) comment('token过期时间')"` |
|||
Ticket string `json:"ticket" xorm:"not null comment('ticket')"` |
|||
TicketExpired int64 `json:"ticket_expired" xorm:"not null default(0) comment('ticket 过期时间')"` |
|||
} |
|||
|
|||
var cache TicketCache |
|||
|
|||
// 检测token是否过期
|
|||
// 检测ticket是否过期
|
|||
func (t *WxCtl) Ticket() { |
|||
url := t.MustGet("url") |
|||
nonceStr := helper.CreateUUID() |
|||
timestamp := time.Now().Unix() |
|||
|
|||
if cache.TokenExpired <= time.Now().Unix() { |
|||
token, err := wx.GetTicketToken() |
|||
t.CheckErr(err) |
|||
if token.ErrCode != 0 { |
|||
t.ERROR(token.ErrMsg, token.ErrCode) |
|||
} |
|||
cache.Token = token.AccessToken |
|||
cache.TokenExpired = token.ExpiresIn + 7200 |
|||
} |
|||
if cache.TicketExpired <= time.Now().Unix() { |
|||
ticket, err := wx.GetTicket(cache.Token) |
|||
t.CheckErr(err) |
|||
if ticket.ErrCode != 0 { |
|||
t.ERROR(ticket.ErrMsg, ticket.ErrCode) |
|||
} |
|||
cache.TicketExpired = ticket.ExpiresIn + 7200 |
|||
cache.Ticket = ticket.Ticket |
|||
} |
|||
query := fmt.Sprintf(SignUrl, cache.Ticket, nonceStr, timestamp, url) |
|||
signature := utils.Sha1(query) |
|||
t.JSON(map[string]interface{}{ |
|||
"signature": signature, |
|||
"noncestr": nonceStr, |
|||
"timestamp": timestamp, |
|||
"ticket": cache.Ticket, |
|||
"appid": wx.Appid, |
|||
}) |
|||
} |
|||
|
|||
type WechatPay struct { |
|||
} |
|||
|
|||
//func (t *WxCtl) Order() {
|
|||
// userId := t.MustGetUID()
|
|||
// content := t.MustGet("content")
|
|||
// amount := t.MustGetInt("amount")
|
|||
//
|
|||
// user := new(models.User)
|
|||
// exist, err := models.GetById(user, userId)
|
|||
// t.CheckErr(err)
|
|||
// t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
|
|||
//
|
|||
// ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":")
|
|||
// res, err := pay_service.Order(content, ip[0], user.Openid, amount, 1, user.Id)
|
|||
// t.JSON(res)
|
|||
//}
|
@ -0,0 +1,41 @@ |
|||
package common |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/helper" |
|||
"context" |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"net/http" |
|||
"net/url" |
|||
"path" |
|||
"time" |
|||
|
|||
"github.com/tencentyun/cos-go-sdk-v5" |
|||
) |
|||
|
|||
const upload_base_path = "html/annex" |
|||
|
|||
type AnnexCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//上传
|
|||
func (t *AnnexCtl) Upload() { |
|||
//计算文件得md5
|
|||
uploadFile, err := t.Request.FILE.Open() |
|||
u, _ := url.Parse("https://hudongzhuanjia-1251209212.cos.ap-guangzhou.myqcloud.com") |
|||
b := &cos.BaseURL{BucketURL: u} |
|||
client := cos.NewClient(b, &http.Client{ |
|||
Transport: &cos.AuthorizationTransport{ |
|||
SecretID: "AKIDo2B9WqpvkSKQPPpplVAdv65QdpDfMRIz", |
|||
SecretKey: "fEcu35xdCbpU3azFLH2lU2f8UpAOQHZs", |
|||
}, |
|||
}) |
|||
picName := fmt.Sprintf("hdzj/upload/%d%s%s", time.Now().UnixNano(), helper.CreateUUID(), path.Ext(t.Request.FILE.Filename)) |
|||
_, err = client.Object.Put(context.Background(), picName, uploadFile, nil) |
|||
t.CheckErrDisplayByError(err) |
|||
|
|||
t.DisplayByData(map[string]interface{}{ |
|||
"url": fmt.Sprintf("%s/%s", u.String(), picName), |
|||
}) |
|||
} |
After Width: 72 | Height: 72 | Size: 6.5 KiB |
@ -0,0 +1,43 @@ |
|||
package test |
|||
|
|||
import ( |
|||
"context" |
|||
"fmt" |
|||
"github.com/tencentyun/cos-go-sdk-v5" |
|||
"net/http" |
|||
"net/url" |
|||
"os" |
|||
"path" |
|||
"testing" |
|||
"time" |
|||
) |
|||
|
|||
func TestAnnexUpload(t *testing.T) { |
|||
u, _ := url.Parse("https://hudongzhuanjia-1251209212.cos.ap-guangzhou.myqcloud.com") |
|||
b := &cos.BaseURL{BucketURL: u} |
|||
client := cos.NewClient(b, &http.Client{ |
|||
Transport: &cos.AuthorizationTransport{ |
|||
SecretID: "AKIDo2B9WqpvkSKQPPpplVAdv65QdpDfMRIz", |
|||
SecretKey: "fEcu35xdCbpU3azFLH2lU2f8UpAOQHZs", |
|||
}, |
|||
}) |
|||
gifFile, err := os.OpenFile("123.gif", os.O_RDONLY, os.ModePerm) |
|||
if err != nil { |
|||
t.Fatal(err) |
|||
} |
|||
|
|||
picName := fmt.Sprintf("hdzj/upload/%d%s", time.Now().UnixNano(), path.Ext(gifFile.Name())) |
|||
_, err = client.Object.Put(context.Background(), picName, gifFile, nil) |
|||
if err != nil { |
|||
t.Fatal(err) |
|||
} |
|||
fmt.Println("上传成功,路径:", fmt.Sprintf("%s/%s", u.String(), picName)) |
|||
objs := []cos.Object{cos.Object{Key: picName}} |
|||
odmo := new(cos.ObjectDeleteMultiOptions) |
|||
odmo.Objects = objs |
|||
odmr, _, err := client.Object.DeleteMulti(context.Background(), odmo) |
|||
if err != nil { |
|||
t.Fatal(err) |
|||
} |
|||
fmt.Println(odmr) |
|||
} |
@ -0,0 +1,96 @@ |
|||
package common |
|||
|
|||
import ( |
|||
"crypto/sha1" |
|||
"encoding/xml" |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/logger" |
|||
"hudongzhuanjia/services/pay" |
|||
"time" |
|||
) |
|||
|
|||
var Now = time.Now() |
|||
|
|||
type WeChatOauthCtl struct { |
|||
controllers.BaseCtl |
|||
} |
|||
|
|||
const token = "hd_oauth" |
|||
|
|||
// 验证服务器资源配置
|
|||
func (t *WeChatOauthCtl) Oauth() { |
|||
signature := t.MustGet("signature") |
|||
timestamp := t.MustGet("timestamp") |
|||
nonce := t.MustGet("nonce") |
|||
echoStr := t.MustGet("echostr") |
|||
tokenStr := fmt.Sprintf("%s%s%s", token, timestamp, nonce) |
|||
s := fmt.Sprintf("%s", sha1.New().Sum([]byte(tokenStr))) |
|||
if s == signature { |
|||
t.OriginResponseWriter.Write([]byte(echoStr)) |
|||
} |
|||
t.OriginResponseWriter.Write([]byte("failed")) |
|||
} |
|||
|
|||
func (t *WeChatOauthCtl) Checkin() { |
|||
t.JSON(map[string]interface{}{ |
|||
"success": "你好, tommy黄梓健", |
|||
"version": Now, |
|||
"ip": t.Request.OriginRequest.RemoteAddr, |
|||
}) |
|||
} |
|||
|
|||
//
|
|||
//func init() {
|
|||
// ticker := time.NewTicker(5 * time.Second)
|
|||
// go func() {
|
|||
// fmt.Println("循环查询订单数据")
|
|||
// for range ticker.C {
|
|||
// pay_service.BatchQuery()
|
|||
// }
|
|||
// }()
|
|||
//
|
|||
//}
|
|||
|
|||
type CallbackParam struct { |
|||
XMLName xml.Name `xml:"xml"` |
|||
ReturnCode string `xml:"return_code"` |
|||
ReturnMsg string `xml:"return_msg"` |
|||
} |
|||
|
|||
func (t *WeChatOauthCtl) CallbackOrder() { |
|||
// 搜索支付的order表, 查找到某条记录
|
|||
logger.Sugar.Infof("%s", t.Request.OriginRequest.RemoteAddr) |
|||
t.CheckErr(pay_service.CallbackOrder(t.Request.OriginRequest)) |
|||
param := new(CallbackParam) |
|||
param.ReturnCode = "SUCCESS" |
|||
param.ReturnMsg = "OK" |
|||
xmlRes, _ := xml.Marshal(param) |
|||
t.XML(xmlRes) |
|||
} |
|||
|
|||
func (t *WeChatOauthCtl) CallbackRefund() { |
|||
logger.Sugar.Infof("%s", t.Request.OriginRequest.RemoteAddr) |
|||
t.CheckErr(pay_service.CallbackRefund(t.Request.OriginRequest)) |
|||
param := new(CallbackParam) |
|||
param.ReturnCode = "SUCCESS" |
|||
param.ReturnMsg = "OK" |
|||
xmlRes, _ := xml.Marshal(param) |
|||
t.XML(xmlRes) |
|||
} |
|||
|
|||
//func (t *WeChatOauthCtl) SendRedPack() {
|
|||
// user := new(models.User)
|
|||
// exist, err := models.GetById(user, 234)
|
|||
// t.CheckErr(err)
|
|||
// if !exist {
|
|||
// t.ERROR(fmt.Sprintf("error occur: %s", err), 120)
|
|||
// }
|
|||
// res, err := pay_service.SendRedPack("欧轩互动", user.Openid, "测试", "123.207.246.51",
|
|||
// "测试", "测试", 100, 1, 1, user.Id, 1)
|
|||
// t.CheckErr(err)
|
|||
// fmt.Printf("%+v", res)
|
|||
// t.JSON(map[string]interface{}{
|
|||
// "result": res,
|
|||
// })
|
|||
//}
|
@ -0,0 +1,150 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
) |
|||
|
|||
//活动
|
|||
type ActivityCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// 废弃
|
|||
func (t *ActivityCtl) List() { |
|||
customerId := t.MustGetUID() |
|||
list := make([]*models.Activity, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and customer_id=? and status<>?", |
|||
customerId, define.StatusEnding).Find(&list) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"list": list, |
|||
"total": len(list), |
|||
}) |
|||
} |
|||
|
|||
func (t *ActivityCtl) StartActivity() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
mode := t.MustGetInt("mode") // 标识彩排 mode=0正式 mode=1彩排
|
|||
uid := t.MustGetUID() |
|||
limit := t.DefaultInt64("limit", 10) |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
// 检测活动状态 ==》 必须为未开始
|
|||
if activity.Status != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动状态%s", activity.Status), code.MSG_ERR) |
|||
} |
|||
|
|||
// 检测彩排活动是否进行中
|
|||
if activity.RehearsalId != 0 { |
|||
t.ERROR("该活动在彩排中", code.MSG_ERR) |
|||
} |
|||
|
|||
var rehearsalId int64 = 0 |
|||
if mode == 1 { |
|||
rehearsal := new(models.Rehearsal) |
|||
rehearsal.Status = 1 |
|||
rehearsal.ActivityId = activityId |
|||
rehearsal.CustomerId = uid |
|||
rehearsal.LimitNumber = limit |
|||
rehearsal.IsDelete = false |
|||
rehearsal.UpdatedAt = time.Now() |
|||
rehearsal.CreatedAt = time.Now() |
|||
_, err := core.GetXormAuto().InsertOne(rehearsal) |
|||
t.CheckErr(err) |
|||
rehearsalId = rehearsal.Id |
|||
} |
|||
|
|||
activity.Status = define.StatusRunning |
|||
activity.RehearsalId = rehearsalId |
|||
activity.UpdatedAt = time.Now() |
|||
// todo: 校验
|
|||
err = models.Save(map[string]interface{}{ |
|||
"id=": activityId, |
|||
"is_delete=": 0, |
|||
}, activity, "status", "rehearsal_id", "updated_at") |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"rehearsal_id": rehearsalId, |
|||
}) |
|||
} |
|||
|
|||
func (t *ActivityCtl) StopActivity() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
if activity.Status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", activity.Status), code.MSG_ERR) |
|||
} |
|||
|
|||
if activity.RehearsalId != 0 { // 彩排回归最初结果
|
|||
// todo:其他的活动也要回复到最初的状态
|
|||
// 竞拍
|
|||
_, err = models.UpdateAuctionStatusByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
// 抽奖
|
|||
lotteryIds, err := models.GetLDActivityIdsByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
//_, err = models.UpdateLDRuleStatusByLDActiviytIds(lotteryIds)
|
|||
lotteryRuleIds, err := models.GetLDRuleIdsByLDActivityId(lotteryIds) |
|||
t.CheckErr(err) |
|||
_, err = models.UpdateLDLadderStatusByLDRuleIds(lotteryRuleIds) |
|||
t.CheckErr(err) |
|||
|
|||
// 订单抽奖
|
|||
orderIds, err := models.GetODActivityIdsByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
//_, err = models.UpdateODRuleStatusByODActivityIds(orderIds)
|
|||
orderRuleIds, err := models.GetODRuleIdsByODActivityIds(orderIds) |
|||
t.CheckErr(err) |
|||
_, err = models.UpdateODLadderStatusByODRuleIds(orderRuleIds) |
|||
t.CheckErr(err) |
|||
|
|||
// 摇红包
|
|||
shakeRbIds, err := models.GetSREActivityIdsByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
_, err = models.UpdateSRERuleStatusBySREActivityIds(shakeRbIds) |
|||
t.CheckErr(err) |
|||
|
|||
// 拔河
|
|||
_, err = models.UpdateTOWStatusByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
// 投票
|
|||
_, err = models.UpdateVoteStatusByActiviytId(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
// 卡路里
|
|||
_, err = models.UpdateCalorieStatusByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
// 订单开启
|
|||
_, err = new(models.CustomerOrderOption).Switch(activityId, 0) |
|||
t.CheckErr(err) |
|||
|
|||
activity.Status = define.StatusNotBegin |
|||
} else { |
|||
activity.Status = define.StatusEnding |
|||
} |
|||
activity.UpdatedAt = time.Now() |
|||
activity.RehearsalId = 0 |
|||
models.Save(map[string]interface{}{ |
|||
"id=": activity.Id, |
|||
}, activity, "status", "rehearsal_id", "updated_at") |
|||
t.SUCCESS("success") |
|||
} |
@ -0,0 +1,31 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
) |
|||
|
|||
//地区店铺
|
|||
type AreaStoreCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// all area store doc
|
|||
// @Summary activity
|
|||
// @Description get all area store
|
|||
// @Tags pc
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Success 200 {string} string "success"
|
|||
// @Router /Pc/ActivityCtl/list [get]
|
|||
func (t *AreaStoreCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
list, err := models.GetAreaStoresByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(list), |
|||
"list": list, |
|||
}) |
|||
} |
@ -0,0 +1,264 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
ws_send_service "hudongzhuanjia/services/ws_send" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"strconv" |
|||
"time" |
|||
) |
|||
|
|||
//竞拍
|
|||
type AuctionCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// 竞拍准备状态
|
|||
func (t *AuctionCtl) ReadyAuction() { |
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
auction := new(models.NewAuctionActivity) |
|||
exist, err := models.GetById(auction, auctionId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") |
|||
if auction.Status != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", auction.Status), code.MSG_ERR) |
|||
} |
|||
_, err = auction.UpdateToStatusByAid(auction.ActivityId, define.StatusReady, define.StatusNotBegin) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = auction.UpdateStatusById(auction.Id, define.StatusReady) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("success") |
|||
} |
|||
|
|||
//开始竞拍
|
|||
// auction doc
|
|||
// @Summary auction
|
|||
// @Description 开始竞拍
|
|||
// @Tags pc
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param auction_activity_id query int true "竞拍id"
|
|||
// @Success 200 {string} string "success"
|
|||
// @Router /Pc/AuctionCtl/startAuction [get]
|
|||
func (t *AuctionCtl) StartAuction() { |
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
|
|||
auction := new(models.NewAuctionActivity) |
|||
exist, err := models.GetById(auction, auctionId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") |
|||
//彩排
|
|||
if auction.Status != define.StatusReady { |
|||
t.ERROR(fmt.Sprintf("该活动%s", auction.Status), code.MSG_ERR) |
|||
} |
|||
auction.Status = define.StatusRunning |
|||
auction.UpdatedAt = time.Now() |
|||
duration, _ := strconv.ParseInt(auction.AuctionDuration, 10, 64) |
|||
auction.AuctionEndTime = time.Now().Unix() + duration |
|||
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", auctionId). |
|||
Cols("status", "auction_end_time", "updated_at").Update(auction) |
|||
t.CheckErr(err) |
|||
|
|||
t.STRING("操作成功") |
|||
} |
|||
|
|||
//停止竞拍
|
|||
// auction doc
|
|||
// @Summary auction
|
|||
// @Description 结束竞拍
|
|||
// @Tags pc
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param auction_activity_id query int true "竞拍id"
|
|||
// @Success 200 {string} string "success"
|
|||
// @Router /Pc/AuctionCtl/stopAuction [get]
|
|||
func (t *AuctionCtl) StopAuction() { |
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
auction := new(models.NewAuctionActivity) |
|||
exist, err := models.GetById(auction, auctionId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") |
|||
|
|||
if auction.Status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", auction.Status), code.MSG_ERR) |
|||
} |
|||
auction.Status = define.StatusEnding |
|||
auction.UpdatedAt = time.Now() |
|||
auction.AuctionEndTime = 0 // 消除结束时间计时
|
|||
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", auctionId). |
|||
Cols("status", "auction_end_time", "updated_at").Update(auction) |
|||
t.CheckErr(err) |
|||
|
|||
// todo: 记录用户最高价
|
|||
if auction.AuctionModel == define.INCR_AUCTION { |
|||
history := new(models.AuctionHistory) |
|||
_, err := history.GetHighestMoney(rehearsalId, auction.Id) // 区分彩排数据
|
|||
t.CheckErr(err) |
|||
|
|||
user := new(models.User) |
|||
exist, err := models.GetById(user, history.UserId) |
|||
t.CheckErr(err) |
|||
if exist { |
|||
record := new(models.AuctionResultRecord) |
|||
record.AuctionActivityId = auctionId |
|||
record.RehearsalId = rehearsalId // 彩排
|
|||
record.AuctionGoodsName = auction.AuctionGoodsName |
|||
record.ActivityId = auction.ActivityId |
|||
record.UserId = history.UserId |
|||
record.UserPhone = user.Phone |
|||
record.UserName = user.Nickname |
|||
record.Unit = history.Unit |
|||
record.DealPrice = history.Money |
|||
record.PlayerCode = history.PlayerCode |
|||
record.UpdatedAt = time.Now() |
|||
record.CreatedAt = time.Now() |
|||
record.IsDelete = false |
|||
|
|||
go ws_send_service.SendAuction(fmt.Sprintf("%d", record.ActivityId), |
|||
"", 0, map[string]interface{}{ |
|||
"type": "auction", |
|||
"data": map[string]interface{}{ |
|||
"auction_activity_id": auction.Id, |
|||
"activity_id": auction.ActivityId, |
|||
"max_money": history.Money, |
|||
"user_id": user.Id, |
|||
"avatar": user.Avatar, |
|||
"nickname": user.Nickname, |
|||
"num": 0, |
|||
"status": "已结束", |
|||
"model": auction.AuctionModel, |
|||
}, |
|||
}) |
|||
_, err = core.GetXormAuto().InsertOne(record) |
|||
t.CheckErr(err) |
|||
} |
|||
} else { |
|||
go ws_send_service.SendAuction(fmt.Sprintf("%d", auction.ActivityId), |
|||
"", 0, map[string]interface{}{ |
|||
"type": "auction", |
|||
"customer_id": 0, |
|||
"user_id": 0, |
|||
"data": map[string]interface{}{ |
|||
"auction_activity_id": auction.Id, |
|||
"activity_id": auction.ActivityId, |
|||
"max_money": 0, |
|||
"user_id": 0, |
|||
"avatar": "", |
|||
"nickname": "", |
|||
"num": 0, |
|||
"status": "已结束", |
|||
"model": auction.AuctionModel, |
|||
}, |
|||
}) |
|||
} |
|||
|
|||
t.STRING("操作成功") |
|||
} |
|||
|
|||
// 增加数据
|
|||
func (t *AuctionCtl) History() { |
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
auction := new(models.NewAuctionActivity) |
|||
exist, err := models.GetById(auction, auctionId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍不存在") |
|||
|
|||
orderBy := "money asc" |
|||
if auction.AuctionModel == "加价竞拍" { |
|||
orderBy = "money desc" |
|||
} |
|||
|
|||
histories, err := models.GetAuctionHistoriesByAuctionId(auctionId, rehearsalId, orderBy) |
|||
t.CheckErr(err) |
|||
|
|||
userIdMap := make(map[int64]struct{}, 0) // 去重操作
|
|||
for u := range histories { |
|||
if _, ok := userIdMap[histories[u].UserId]; ok { |
|||
//去掉重复的
|
|||
continue |
|||
} else { |
|||
userIdMap[histories[u].UserId] = struct{}{} // 增加,下次进行检测
|
|||
} |
|||
auction.Histories = append(auction.Histories, histories[u]) |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"auction": auction, |
|||
}) |
|||
} |
|||
|
|||
func (t *AuctionCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
auctions, err := models.GetAuctionsByActivityId(activityId, "created_at asc") |
|||
t.CheckErr(err) |
|||
// 更具某个数据进行
|
|||
upIds := make([]int64, 0) |
|||
for _, item := range auctions { |
|||
if item.AuctionModel == "加价竞拍" { |
|||
upIds = append(upIds, item.Id) |
|||
} |
|||
} |
|||
upH, err := models.GetAuctionHistoriesByAuctionIds(upIds, rehearsalId, "money desc") |
|||
t.CheckErr(err) |
|||
|
|||
for i := range auctions { |
|||
if auctions[i].AuctionModel == "加价竞拍" { |
|||
userIdMap := make(map[int64]struct{}, 0) // 去重操作
|
|||
for u := range upH { |
|||
if _, ok := userIdMap[upH[u].UserId]; ok { |
|||
//去掉重复的
|
|||
continue |
|||
} |
|||
|
|||
if auctions[i].Id == upH[u].AuctionActivityId && len(auctions[i].Histories) <= 3 { |
|||
auctions[i].Histories = append(auctions[i].Histories, upH[u]) |
|||
userIdMap[upH[u].UserId] = struct{}{} // 增加,下次进行检测
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(auctions), |
|||
"list": auctions, |
|||
}) |
|||
} |
|||
|
|||
// 成交记录
|
|||
func (t *AuctionCtl) Records() { |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") // 彩排
|
|||
auctionId := t.MustGetInt64("auction_activity_id") |
|||
|
|||
records, err := models.GetAuctionRecordsByAuctionId(auctionId, rehearsalId, "created_at desc") |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"records": records, |
|||
"total": len(records), |
|||
}) |
|||
} |
|||
|
|||
//获取二维码
|
|||
func (t *AuctionCtl) Qrcode() { |
|||
//将服务器得地址和activity_id,动态生成二维码
|
|||
qrcode, err := utils.GenH5Qrcode(define.H5Auction, map[string]interface{}{ |
|||
"activity_id": t.MustGetInt64("activity_id"), |
|||
"customer_id": t.MustGetUID(), |
|||
"auction_id": t.MustGetInt64("auction_activity_id"), |
|||
"rehearsal_id": t.MustGetInt64("rehearsal_id"), |
|||
}) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qrcode, |
|||
}) |
|||
} |
@ -0,0 +1,48 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
) |
|||
|
|||
//弹幕
|
|||
type BarrageCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//获取活动的详情
|
|||
func (t *BarrageCtl) Details() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
server := new(models.DanMuServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BARRAGE_SERVER_NOT_EXIST, "弹幕不存在") |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"server": server, |
|||
}) |
|||
} |
|||
|
|||
func (t *BarrageCtl) SaveSetting() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
danmuId := t.MustGetInt64("danmu_server_id") |
|||
server := new(models.DanMuServer) |
|||
server.DanmuFontSize = t.MustGet("font_size") |
|||
server.DanmuOpacity = t.MustGetInt("opacity") |
|||
server.DanmuPosition = t.MustGet("position") |
|||
server.DanmuSpeed = t.MustGetInt("speed") |
|||
server.ServerDisplay = t.MustGet("display") |
|||
models.Save(map[string]interface{}{ |
|||
"is_delete=": 0, |
|||
"id=": danmuId, |
|||
}, server, "danmu_font_size", "danmu_opacity", "danmu_position", "danmu_speed", "server_display") |
|||
t.CheckErr(err) |
|||
t.SUCCESS("success") |
|||
} |
@ -0,0 +1,242 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/services/pay" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type BullyScreenCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
type BullyScreenBaseResult struct { |
|||
models.BullyScreenHistory `xorm:"extends"` |
|||
User *models.User `json:"user" xorm:"extends"` |
|||
} |
|||
|
|||
//获取待审核列表
|
|||
func (t *BullyScreenCtl) WaitReview() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
//获取霸屏服务得id
|
|||
bullyScreenServer := new(models.BullyScreenServer) |
|||
exist, err = bullyScreenServer.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在") |
|||
|
|||
t.CheckErr(pay_service.BatchQueryByActivityId(activityId)) |
|||
t.CheckErr(pay_service.BatchQueryRefundByActivityId(activityId)) |
|||
|
|||
//根据霸屏服务得id获取待审核得霸屏列表
|
|||
result := make([]*BullyScreenBaseResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.BullyScreenHistory)).Alias("h"). |
|||
Join("LEFT", "ox_user as u", "h.user_id=u.id and u.is_delete=0"). |
|||
Where("h.bully_screen_server_id=? and h.is_delete=0 and h.status=0 and h.rehearsal_id=?", |
|||
bullyScreenServer.Id, activity.RehearsalId).Desc("h.created_at").Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//审核操作
|
|||
func (t *BullyScreenCtl) Review() { |
|||
idList := t.MustGet("ids") |
|||
status := t.MustGetBool("status") |
|||
ids := strings.Split(idList, "|") |
|||
//rehearsalId := t.MustGetInt64("rehearsal_id")
|
|||
|
|||
//将金额退回给用户
|
|||
result := make([]*models.BullyScreenHistory, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0").In("id", ids).Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
for _, v := range result { |
|||
if v.Status != 0 { |
|||
t.ERROR("该霸屏已处理", code.MSG_USER_DATA_ERROR) |
|||
} |
|||
if status { // true 失败 、、 false 成功
|
|||
_, err := v.UpdateStatus(v.Id, 1) |
|||
t.CheckErr(err) |
|||
|
|||
//if rehearsalId != 0 { // 彩排
|
|||
// continue
|
|||
//}
|
|||
|
|||
//todo: 回退金额给用户 ==> 直接微信退款
|
|||
// 1. 提请微信退款
|
|||
// 2. 查询退款是否成功
|
|||
// 3. 退款成功设置状态
|
|||
// 4. 写入金额流水记录
|
|||
order := new(models.UserOrder) |
|||
exist, err := models.GetById(order, v.UserOrderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_ORDER_NOT_EXIST, "用户支付订单不存在") |
|||
|
|||
_, err = pay_service.Refund("欧轩互动-霸屏拉黑", order.OutTradeNo, order.OpenId, order.GoodType, order.TotalFee, order.TotalFee, order.UserId, order.ActivityId) |
|||
t.CheckErr(err) |
|||
|
|||
} else { |
|||
_, err := v.UpdateStatus(v.Id, 2) |
|||
t.CheckErr(err) |
|||
// todo: 审核成功
|
|||
// 1. 金额打入主账号的打赏钱包里面
|
|||
// 2. 记录金额流水
|
|||
|
|||
//if rehearsalId != 0 {
|
|||
// continue
|
|||
//}
|
|||
|
|||
uid := t.MustGetUID() |
|||
customer := new(models.Customer) |
|||
exist, err := models.GetById(customer, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
wallet := new(models.BullyScreenWallet) |
|||
_, err = wallet.IncrBalance(customer.Id, v.Amount) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = core.GetXormAuto().InsertOne(&models.BullyScreenWalletHistory{ |
|||
CustomerId: customer.Id, |
|||
UserId: v.UserId, |
|||
Money: v.Amount, |
|||
Type: "霸屏", |
|||
Status: "交易成功", |
|||
Mark: "霸屏金额", |
|||
CreatedAt: time.Now(), |
|||
UpdatedAt: time.Now(), |
|||
}) |
|||
t.CheckErr(err) |
|||
} |
|||
} |
|||
t.SUCCESS("审核成功") |
|||
} |
|||
|
|||
//获取黑名单列表
|
|||
func (t *BullyScreenCtl) Blacklist() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
//获取霸屏服务得id
|
|||
bullyScreenServer := new(models.BullyScreenServer) |
|||
exist, err = bullyScreenServer.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏活动不存在") |
|||
|
|||
//根据霸屏服务得id获取待审核得霸屏列表
|
|||
result := make([]*BullyScreenBaseResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.BullyScreenHistory)).Alias("h"). |
|||
Join("LEFT", new(models.User).Alias("u"), "u.id=h.user_id and u.is_delete=0"). |
|||
Where("h.is_delete=0 and h.bully_screen_server_id=? and h.status=1 and h.rehearsal_id=?", |
|||
bullyScreenServer.Id, activity.RehearsalId).Desc("review_time").Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.DisplayByData(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//获取目前霸屏得总金额
|
|||
func (t *BullyScreenCtl) Amount() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
//获取霸屏服务得id
|
|||
bullyScreenServer := new(models.BullyScreenServer) |
|||
exist, err := bullyScreenServer.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在") |
|||
|
|||
totalSecond, err := core.GetXormAuto().Where("bully_screen_server_id=? and status=3 and "+ |
|||
" is_delete=false and rehearsal_id=?", bullyScreenServer.Id, rehearsalId). |
|||
Sum(new(models.BullyScreenHistory), "second") |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"amount": utils.Float64CusDecimal(totalSecond*bullyScreenServer.Price, 2), |
|||
}) |
|||
} |
|||
|
|||
type ModuleService struct { |
|||
models.ActivityModuleService `xorm:"extends"` |
|||
History models.ModuleServiceHistory `xorm:"extends"` |
|||
} |
|||
|
|||
//获取最新得霸屏记录
|
|||
func (t *BullyScreenCtl) Latest() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
//获取霸屏服务得id
|
|||
bullyScreenServer := new(models.BullyScreenServer) |
|||
exist, err = bullyScreenServer.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在") |
|||
|
|||
result := new(BullyScreenBaseResult) |
|||
exist, err = core.GetXormAuto().Table(new(models.BullyScreenHistory)).Alias("h"). |
|||
Join("LEFT", new(models.User).Alias("u"), "u.id=h.user_id and u.is_delete=0"). |
|||
Where("h.bully_screen_server_id=? and h.status=2 and h.rehearsal_id=? and h.is_delete=0", |
|||
bullyScreenServer.Id, activity.RehearsalId).Desc("review_time").Get(result) |
|||
t.CheckErr(err) |
|||
if !exist { |
|||
t.RAW(result) |
|||
} |
|||
|
|||
//根据主活动得id获取所有得模块列表
|
|||
module := new(ModuleService) |
|||
exist, err = core.GetXormAuto().Table(new(models.ActivityModuleService)).Alias("s"). |
|||
Join("LEFT", new(models.ModuleServiceHistory).Alias("h"), |
|||
"s.service_module_history_id=h.id and h.is_delete=0 and h.name=?", define.MODULE_BULLYS). |
|||
Where("s.activity_id=? and s.is_delete=0", bullyScreenServer.ActivityId). |
|||
Get(module) |
|||
t.CheckErr(err) |
|||
if !exist { |
|||
t.ERROR("该服务模块尚未开通", code.MSG_ERR_Param) |
|||
} |
|||
|
|||
//更改推送状态
|
|||
result.BullyScreenHistory.Status = 3 |
|||
result.BullyScreenHistory.UpdatedAt = time.Now() |
|||
t.CheckErr(models.Save(map[string]interface{}{ |
|||
"id =": result.BullyScreenHistory.Id, |
|||
}, &result.BullyScreenHistory, "status", "updated_at")) |
|||
t.RAW(result) |
|||
} |
|||
|
|||
// 霸屏服务器开关
|
|||
func (t *BullyScreenCtl) Details() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
server := new(models.BullyScreenServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在") |
|||
t.JSON(map[string]interface{}{ |
|||
"server": server, |
|||
}) |
|||
} |
@ -0,0 +1,178 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
) |
|||
|
|||
type CalorieCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
func (t *CalorieCtl) Ready() { |
|||
calorieId := t.MustGetInt64("calorie_id") |
|||
|
|||
calorie := new(models.Calorie) |
|||
exist, err := models.GetById(calorie, calorieId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里活动不存在") |
|||
if calorie.Status != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", calorie.Status), code.MSG_MODULE_STATUS_ERROR) |
|||
} |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, calorie.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
_, err = calorie.UpdateToStatusByActivityId(calorie.ActivityId, define.StatusReady, define.StatusNotBegin) |
|||
t.CheckErr(err) |
|||
|
|||
calorie.StartTime = 0 |
|||
_, err = calorie.UpdateStatusById(calorieId, define.StatusReady) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
// 开始, 加一个开始时间
|
|||
func (t *CalorieCtl) Start() { |
|||
calorieId := t.MustGetInt64("calorie_id") |
|||
|
|||
calorie := new(models.Calorie) |
|||
exist, err := models.GetById(calorie, calorieId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里活动不存在") |
|||
if calorie.Status != define.StatusReady { |
|||
t.ERROR(fmt.Sprintf("该活动%s", calorie.Status), code.MSG_MODULE_STATUS_ERROR) |
|||
} |
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, calorie.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
calorie.StartTime = time.Now().Unix() |
|||
_, err = calorie.UpdateStatusById(calorieId, define.StatusRunning) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
// 彩排活动需要恢复
|
|||
func (t *CalorieCtl) Stop() { |
|||
calorieId := t.MustGetInt64("calorie_id") |
|||
|
|||
calorie := new(models.Calorie) |
|||
exist, err := models.GetById(calorie, calorieId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里活动不存在") |
|||
if calorie.Status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", calorie.Status), code.MSG_MODULE_STATUS_ERROR) |
|||
} |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, calorie.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
_, err = calorie.UpdateStatusById(calorieId, define.StatusEnding) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
// 列出轮次, 包括倒计时
|
|||
func (t *CalorieCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
calories := make([]*models.Calorie, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).Find(&calories) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"list": calories, |
|||
"count": len(calories), |
|||
}) |
|||
} |
|||
|
|||
// 二维码
|
|||
func (t *CalorieCtl) Qrcode() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
uid := t.MustGetUID() |
|||
calorieId := t.MustGetInt64("calorie_id") |
|||
|
|||
qrcode, err := utils.GenH5Qrcode(define.H5Calorie, map[string]interface{}{ |
|||
"activity_id": activityId, |
|||
"customer_id": uid, |
|||
"calorie_id": calorieId, |
|||
}) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qrcode, |
|||
}) |
|||
} |
|||
|
|||
type CalorieCountResult struct { |
|||
Id int64 `json:"id"` |
|||
ActivityId int64 `json:"activity_id"` |
|||
CalorieId int64 `json:"calorie_id"` |
|||
UserId int64 `json:"user_id"` |
|||
Avatar string `json:"avatar"` |
|||
Nickname string `json:"nickname"` |
|||
Score int64 `json:"score"` |
|||
} |
|||
|
|||
// 统计一些数据, 包括参与人数, 包括当前排名
|
|||
func (t *CalorieCtl) Count() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
calorieId := t.MustGetInt64("calorie_id") |
|||
limit := t.DefaultInt("limit", 10) |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
calorie := new(models.Calorie) |
|||
exist, err = models.GetById(calorie, calorieId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "卡路里不存在") |
|||
|
|||
// 统计人数
|
|||
count, err := core.GetXormAuto().Where("is_delete=0 and calorie_id=? and rehearsal_id=?", |
|||
calorieId, activity.RehearsalId).Count(new(models.CalorieUser)) |
|||
t.CheckErr(err) |
|||
|
|||
// 统计排名
|
|||
result := make([]*CalorieCountResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.CalorieUser)).Alias("c"). |
|||
Select("c.id, c.activity_id, c.calorie_id, c.user_id, u.avatar, u.nickname, c.score, c.join_time"). |
|||
Join("LEFT", new(models.User).Alias("u"), "c.user_id=u.id and u.is_delete=0"). |
|||
Where("c.is_delete=0 and c.calorie_id=? and c.rehearsal_id=?", calorieId, activity.RehearsalId). |
|||
Limit(limit).Desc("c.score").Asc("c.join_time").Find(&result) |
|||
t.CheckErr(err) |
|||
//duration := calorie.GameDuration - (time.Now().Unix() - calorie.StartTime) + 6 // 增加6s 倒计时
|
|||
//if calorie.StartTime == 0 {
|
|||
// duration = calorie.GameDuration
|
|||
//}
|
|||
|
|||
// 3s 倒计时
|
|||
//var countDown float64 = 0
|
|||
//if duration-calorie.GameDuration > 0 {
|
|||
// countDown = math.Ceil(float64(duration-calorie.GameDuration) / 2.0)
|
|||
//}
|
|||
|
|||
//if calorie.Status == define.StatusEnding || duration <= 0 {
|
|||
//duration = 0
|
|||
//}
|
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"list": result, // 排名统计
|
|||
"count": count, // 人数统计
|
|||
//"time": duration - 2*int64(countDown), // 时长
|
|||
//"count_down": countDown, //倒计时
|
|||
//"status": calorie.Status, // 状态
|
|||
}) |
|||
} |
@ -0,0 +1,130 @@ |
|||
/* |
|||
* @Description: In User Settings Edit |
|||
* @Author: your name |
|||
* @Date: 2019-08-22 09:26:48 |
|||
* @LastEditTime: 2019-08-23 18:04:40 |
|||
* @LastEditors: Please set LastEditors |
|||
*/ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/libs/jwt" |
|||
"hudongzhuanjia/libs/qq" |
|||
"hudongzhuanjia/libs/wx" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/services/activity" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
) |
|||
|
|||
//用户
|
|||
type UserCtl struct { |
|||
controllers.BaseCtl |
|||
} |
|||
|
|||
//登陆
|
|||
// 子账号需要接收父级账号的控制,同步数据,
|
|||
func (t *UserCtl) Login() { |
|||
username := t.MustGet("username") |
|||
password := t.MustGet("password") |
|||
customer := new(models.Customer) |
|||
|
|||
err := customer.Author(username, password) |
|||
t.CheckErr(err) |
|||
// 获取用户拥有的activity
|
|||
activities, err := activity_service.GetActivitiesByCustomerId(customer.Id) |
|||
t.CheckErr(err) |
|||
|
|||
// 主账号无法确定
|
|||
token, err := jwt.GenJwtToken("customer", customer.Id, customer.Id, customer.Pid, customer.AreaId, customer.ActivityId, customer.Username) |
|||
t.CheckErr(err) |
|||
t.SetSession(define.TOKEN, token) |
|||
customer.Token = token |
|||
customer.Activities = activities |
|||
pid := customer.Pid |
|||
if pid == 0 { |
|||
pid = customer.Id |
|||
} |
|||
customer.Tag = "activity" |
|||
t.RAW(customer) |
|||
} |
|||
|
|||
//检查是否已经登陆
|
|||
func (t *UserCtl) Checkin() { |
|||
_, exist := t.Get(define.TOKEN) |
|||
if exist { |
|||
t.SUCCESS("已登录") |
|||
} |
|||
t.ERROR("未登录", code.MSG_ERR) |
|||
} |
|||
|
|||
// debug
|
|||
func (t *UserCtl) DebugLogin() { |
|||
customerId := t.DefaultInt64("customer_id", 19) |
|||
customer := new(models.Customer) |
|||
exist, err := models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
token, err := jwt.GenJwtToken("customer", customer.Id, customer.Id, customer.Pid, customer.AreaId, customer.ActivityId, customer.Username) |
|||
t.CheckErr(err) |
|||
t.SetSession(define.TOKEN, token) |
|||
t.JSON(map[string]interface{}{ |
|||
"customer": customer, |
|||
"token": token, |
|||
}) |
|||
} |
|||
|
|||
//退出
|
|||
func (t *UserCtl) Logout() { |
|||
if _, ok := t.Request.SESSION[define.TOKEN]; !ok { |
|||
t.DisplayByError("未登录", code.MSG_ERR_Authority) |
|||
} |
|||
t.DeleteSession(define.TOKEN) |
|||
t.DisplayByData("退出成功") |
|||
} |
|||
|
|||
// 微信登陆 callback
|
|||
func (t *UserCtl) WXLogin() { |
|||
//state := t.MustGet("state")
|
|||
wxcode := t.MustGet("code") |
|||
token, err := wx.GetToken(wxcode) |
|||
t.CheckErr(err) |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err := customer.GetByOpenid(token.Openid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
t.SetSession(define.TOKEN, fmt.Sprintf("%d", customer.Id)) |
|||
activities, err := activity_service.GetActivitiesByCustomerId(customer.Id) |
|||
t.CheckErr(err) |
|||
customer.Activities = activities |
|||
t.RAW(customer) |
|||
} |
|||
|
|||
// 手机验证码登陆
|
|||
func (t *UserCtl) QQLogin() { |
|||
//state := t.MustGet("state")
|
|||
qqcode := t.MustGet("code") |
|||
|
|||
token, err := qq.GetToken(qqcode) |
|||
t.CheckErr(err) |
|||
open, err := qq.GetPcOpenid(token.AccessToken) |
|||
t.CheckErr(err) |
|||
|
|||
customer := new(models.Customer) |
|||
customer.GetByQQOpenid(open.Openid) |
|||
t.CheckErr(err) |
|||
t.SetSession(define.TOKEN, fmt.Sprintf("%d", customer.Id)) |
|||
activities, err := activity_service.GetActivitiesByCustomerId(customer.Id) |
|||
t.CheckErr(err) |
|||
customer.Activities = activities |
|||
t.RAW(customer) |
|||
} |
|||
|
|||
func (t *UserCtl) QQCodeUrl() { |
|||
t.DisplayByData(qq.GetCodeUrl()) |
|||
} |
@ -0,0 +1,390 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
activity_service "hudongzhuanjia/services/activity" |
|||
lottery_service "hudongzhuanjia/services/lottery" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
//抽奖
|
|||
type LotteryDrawCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//开始抽奖
|
|||
func (t *LotteryDrawCtl) Start() { |
|||
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|||
|
|||
ladder := new(models.LotteryDrawRuleLadder) |
|||
exist, err := models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|||
|
|||
if ladder.Status != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|||
} |
|||
ladder.Status = define.StatusRunning |
|||
ladder.UpdatedAt = time.Now() |
|||
t.CheckErr(models.Save(map[string]interface{}{ |
|||
"id=": ladderId, |
|||
}, ladder, "status", "updated_at")) |
|||
|
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
//停止抽奖
|
|||
func (t *LotteryDrawCtl) Stop() { |
|||
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|||
|
|||
ladder := new(models.LotteryDrawRuleLadder) |
|||
exist, err := models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|||
|
|||
if ladder.Status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|||
} |
|||
|
|||
ladder.Status = define.StatusEnding |
|||
ladder.UpdatedAt = time.Now() |
|||
t.CheckErr(models.Save(map[string]interface{}{ |
|||
"id=": ladderId, |
|||
}, ladder, "status", "updated_at")) |
|||
|
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
type LotteryListResult struct { |
|||
LotteryDrawActivityId int64 `json:"lottery_draw_activity_id"` |
|||
LotteryDrawRuleId int64 `json:"lottery_draw_rule_id"` |
|||
LotteryDrawActivityName string `json:"lottery_draw_name"` |
|||
LotteryDrawLadders []*LotteryLadderResult `json:"lottery_draw_ladders"` |
|||
PrizeNumber int64 `json:"prize_number"` |
|||
} |
|||
|
|||
type LotteryLadderResult struct { |
|||
LotteryDrawRuleId int64 `json:"-"` |
|||
LotteryDrawLadderId int64 `json:"lottery_draw_ladder_id"` |
|||
Status string `json:"status"` |
|||
PrizeName string `json:"prize_name"` |
|||
PrizeImg string `json:"prize_img"` |
|||
PrizeNumber int64 `json:"prize_number"` |
|||
} |
|||
|
|||
//获取所有抽奖活动列表
|
|||
func (t *LotteryDrawCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
result := make([]*LotteryListResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.LotteryDrawActivity)).Alias("a"). |
|||
Select("a.id as lottery_draw_activity_id, r.id as lottery_draw_rule_id, a.lottery_draw_activity_name"). |
|||
Join("LEFT", models.AliasTableName(new(models.LotteryDrawRule), "r"), |
|||
"a.id=r.lottery_draw_activity_id and r.is_delete=0"). |
|||
Where("a.is_delete=0 and a.activity_id=?", activityId).Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
// 多地区的一个坑:分配给主会场的area_id不是主账号的area_id
|
|||
area := new(models.AreaStore) |
|||
if t.MustGetCustomerPid() == 0 { |
|||
exist, err = area.GetMainAreaById(activityId) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
ruleIds := make([]int64, 0) |
|||
for _, v := range result { |
|||
ruleIds = append(ruleIds, v.LotteryDrawRuleId) |
|||
} |
|||
ladders := make([]*LotteryLadderResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.LotteryDrawRuleLadder)). |
|||
Select("id as lottery_draw_ladder_id, prize_name, prize_img, prize_number, lottery_draw_rule_id, status"). |
|||
Where("is_delete=0").In("lottery_draw_rule_id", ruleIds).Find(&ladders) |
|||
t.CheckErr(err) |
|||
|
|||
ladderIds := make([]int64, 0) |
|||
for _, ladder := range ladders { |
|||
ladderIds = append(ladderIds, ladder.LotteryDrawLadderId) |
|||
} |
|||
|
|||
records := make([]map[string]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Alias("r"). |
|||
Select("r.lottery_draw_rule_ladder_id as ladder_id, count(r.id) as num"). |
|||
Where("is_delete=0 and rehearsal_id=?", activity.RehearsalId). |
|||
In("r.lottery_draw_rule_ladder_id", ladderIds).GroupBy("ladder_id").Find(&records) |
|||
t.CheckErr(err) |
|||
for i := range ladders { |
|||
for j := range records { |
|||
if ladders[i].LotteryDrawLadderId == records[j]["ladder_id"] { |
|||
ladders[i].PrizeNumber = ladders[i].PrizeNumber - records[j]["num"] |
|||
} |
|||
} |
|||
} |
|||
|
|||
for i := range result { |
|||
for j := range ladders { |
|||
if result[i].LotteryDrawRuleId == ladders[j].LotteryDrawRuleId { |
|||
result[i].PrizeNumber += ladders[j].PrizeNumber |
|||
result[i].LotteryDrawLadders = append(result[i].LotteryDrawLadders, ladders[j]) |
|||
} |
|||
} |
|||
} |
|||
|
|||
core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Select("count()") |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//抽奖奖品
|
|||
func (t *LotteryDrawCtl) Prize() { |
|||
ruleId := t.MustGetInt64("lottery_draw_rule_id") |
|||
|
|||
list := make([]*models.LotteryDrawRuleLadder, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and lottery_draw_rule_id=?", ruleId).Find(&list) |
|||
t.CheckErr(err) |
|||
|
|||
for index := range list { |
|||
list[index].Des = "在该活动的所有用户中随机抽奖品数量的用户" |
|||
} |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(list), |
|||
"lise": list, |
|||
}) |
|||
} |
|||
|
|||
type LotteryUsersResult struct { |
|||
UserId int64 `json:"user_id"` |
|||
Username string `json:"username"` |
|||
Avatar string `json:"avatar"` |
|||
} |
|||
|
|||
// 抽奖用户
|
|||
func (t *LotteryDrawCtl) Users() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
ruleId := t.MustGetInt64("lottery_draw_rule_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
area := new(models.AreaStore) |
|||
if t.MustGetCustomerPid() == 0 { |
|||
exist, err = area.GetMainAreaById(activityId) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
result := make([]*LotteryUsersResult, 0) |
|||
session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h"). |
|||
Select("h.user_id, u.nickname as username, u.avatar").Distinct("h.user_id"). |
|||
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete = 0"). |
|||
Where("h.is_delete=0 and h.area_id=? and h.activity_id=? and h.rehearsal_id=?", |
|||
area.Id, activityId, activity.RehearsalId) |
|||
|
|||
moduleService, exist, err := activity_service.GetModuleService(define.MODULE_LOTTERY, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "活动模块不存在") |
|||
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { |
|||
// 去重标志
|
|||
recordIds := make([]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Select("user_id"). |
|||
Where("lottery_draw_rule_id=? and rehearsal_id=? and area_id=? and is_delete=0", |
|||
ruleId, activity.RehearsalId, area.Id).Find(&recordIds) |
|||
t.CheckErr(err) |
|||
session = session.NotIn("h.user_id", recordIds) |
|||
} |
|||
err = session.Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//抽奖动作
|
|||
func (t *LotteryDrawCtl) Lottery() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
ruleId := t.MustGetInt64("lottery_draw_rule_id") |
|||
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|||
number := t.MustGetInt("number") // 奖品数量
|
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
// 多地区设置
|
|||
area := new(models.AreaStore) |
|||
if t.MustGetCustomerPid() == 0 { |
|||
exist, err = area.GetMainAreaById(activity.Id) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") |
|||
|
|||
rule := new(models.LotteryDrawRule) |
|||
exist, err = models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "抽奖规则不存在") |
|||
//t.CheckRunning(rule.LotteryDrawStatus)
|
|||
|
|||
// 查询奖品
|
|||
ladder := new(models.LotteryDrawRuleLadder) |
|||
exist, err = models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "抽奖等级不存在") |
|||
t.CheckRunning(ladder.Status) |
|||
|
|||
count, err := core.GetXormAuto().Where("lottery_draw_rule_id=? and lottery_draw_rule_ladder_id=? "+ |
|||
"and rehearsal_id=? and area_id=? and is_delete=0", ruleId, ladderId, activity.RehearsalId, area.Id). |
|||
Count(new(models.LotteryDrawRecord)) |
|||
t.CheckErr(err) |
|||
|
|||
prizeNum := ladder.PrizeNumber - int(count) |
|||
if prizeNum <= 0 || prizeNum < number { // 需要抽奖的数量比数据库存在数量多
|
|||
t.ERROR("奖品数量不足", code.MSG_LOTTERY_PRIZE_NOT_ENOUGH) |
|||
} |
|||
|
|||
//根据主活动id和地区id获取所有的用户
|
|||
signUpIds := make([]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.SignUp)).Select("id").Where("activity_id=? and is_delete=0", |
|||
activityId).Find(&signUpIds) |
|||
t.CheckErr(err) |
|||
if len(signUpIds) <= 0 { |
|||
t.ERROR("暂无签到用户", code.MSG_DATA_NOT_EXIST) |
|||
} |
|||
|
|||
moduleService, exist, err := activity_service.GetModuleService(define.MODULE_LOTTERY, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "活动模块不存在") |
|||
// 取设置
|
|||
lotteryUsers := make([]*lottery_service.LotteryUser, 0) |
|||
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { |
|||
// 去除同规则中将用户
|
|||
recordIds := make([]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Select("user_id"). |
|||
Where("lottery_draw_rule_id=? and rehearsal_id=? and area_id=? and is_delete=0", |
|||
ruleId, activity.RehearsalId, area.Id).Find(&recordIds) |
|||
t.CheckErr(err) |
|||
|
|||
//查询已经中奖的用户,剔除已经中奖的用户
|
|||
err = core.GetXormAuto().Table(new(models.SignHistory)).Select("user_id"). |
|||
Where("is_delete=0 and rehearsal_id=? and area_id=?", |
|||
activity.RehearsalId, area.Id).In("sign_rule_id", signUpIds). |
|||
NotIn("user_id", recordIds).Find(&lotteryUsers) |
|||
t.CheckErr(err) |
|||
} else { |
|||
err = core.GetXormAuto().Table(new(models.SignHistory)).Select("user_id"). |
|||
Where("is_delete=0 and rehearsal_id=? and area_id=?", |
|||
activity.RehearsalId, area.Id).In("sign_rule_id", signUpIds).Find(&lotteryUsers) |
|||
t.CheckErr(err) |
|||
} |
|||
if len(lotteryUsers) < number { |
|||
t.ERROR("抽奖人数不足", code.MSG_LOTTERY_PEOPLE_NOT_ENOUGH) |
|||
} |
|||
lottery_service.RandLotteryUser(lotteryUsers) // 打乱需要中奖人员
|
|||
winners := lotteryUsers[:number] |
|||
userIds := make([]int64, 0) |
|||
for _, winner := range winners { |
|||
userIds = append(userIds, winner.UserId) |
|||
} |
|||
users := make([]*models.User, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0").In("id", userIds).Find(&users) |
|||
t.CheckErr(err) |
|||
for i := range winners { |
|||
// 补全信息
|
|||
for j := range users { |
|||
if winners[i].UserId == users[j].Id { |
|||
winners[i].Username = users[j].Nickname |
|||
winners[i].Avatar = users[j].Avatar |
|||
winners[i].UserPhone = users[j].Phone |
|||
winners[i].PrizeName = ladder.PrizeName |
|||
winners[i].LadderId = ladder.Id |
|||
winners[i].PrizeImg = ladder.PrizeImg |
|||
break |
|||
} |
|||
} |
|||
// 普通抽奖
|
|||
userPrize := new(models.UserPrize) |
|||
userPrize.ActivityId = activityId |
|||
userPrize.RehearsalId = activity.RehearsalId |
|||
userPrize.ActivityName = activity.Name |
|||
userPrize.UserId = winners[i].UserId |
|||
userPrize.PrizeImg = ladder.PrizeImg |
|||
userPrize.PrizeName = ladder.PrizeName |
|||
userPrize.PrizeType = 1 |
|||
userPrize.IsDelete = false |
|||
userPrize.CreatedAt = time.Now() |
|||
userPrize.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().Insert(userPrize) |
|||
t.CheckErr(err) |
|||
|
|||
record := new(models.LotteryDrawRecord) |
|||
record.UserPrizeId = userPrize.Id |
|||
record.ActivityId = activityId |
|||
record.RehearsalId = activity.RehearsalId |
|||
record.LotteryDrawActivityId = rule.LotteryDrawActivityId |
|||
record.LotteryDrawRuleId = rule.Id |
|||
record.UserId = winners[i].UserId |
|||
record.UserName = winners[i].Username |
|||
record.UserPhone = winners[i].UserPhone |
|||
record.LotteryDrawRuleLadderId = ladder.Id |
|||
record.PrizeName = ladder.PrizeName |
|||
record.AreaId = area.Id |
|||
record.AreaName = area.Name |
|||
record.IsDelete = false |
|||
record.CreatedAt = time.Now() |
|||
record.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(record) |
|||
t.CheckErr(err) |
|||
} |
|||
|
|||
t.RAW(winners) |
|||
} |
|||
|
|||
type WinnersResult struct { |
|||
UserId int64 `json:"user_id"` |
|||
UserName string `json:"user_name"` |
|||
UserPhone string `json:"user_phone"` |
|||
Avatar string `json:"avatar"` |
|||
PrizeName string `json:"prize_name"` |
|||
} |
|||
|
|||
//获取中奖名单
|
|||
func (t *LotteryDrawCtl) ListOfWinners() { |
|||
ruleId := t.MustGetInt64("lottery_draw_rule_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
result := make([]*WinnersResult, 0) |
|||
err := core.GetXormAuto().Table("ox_lottery_draw_record").Alias("record"). |
|||
Join("LEFT", new(models.User).Alias("user"), "user.id=record.user_id and user.is_delete=0"). |
|||
Where("record.is_delete=0 and record.lottery_draw_rule_id=? and record.rehearsal_id=?", ruleId, rehearsalId). |
|||
Find(&result) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
@ -0,0 +1,451 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
activity_service "hudongzhuanjia/services/activity" |
|||
invitation_service "hudongzhuanjia/services/invitation" |
|||
lottery_service "hudongzhuanjia/services/lottery" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
// 订单
|
|||
type OrderDrawCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// 开启订单活动
|
|||
func (t *OrderDrawCtl) Switch() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
status := t.MustGetInt("status") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
option := new(models.CustomerOrderOption) |
|||
exist, err = option.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "订单活动不存在") |
|||
|
|||
if option.Status == status { |
|||
t.SUCCESS("操作成功") |
|||
return |
|||
} |
|||
|
|||
_, err = option.Switch(activityId, status) |
|||
t.CheckErr(err) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
// ===================== 订单抽奖
|
|||
|
|||
// 开始抽奖
|
|||
func (t *OrderDrawCtl) Start() { |
|||
ladderId := t.MustGetInt64("order_draw_ladder_id") |
|||
|
|||
ladder := new(models.OrderDrawRuleLadder) |
|||
exist, err := models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在") |
|||
|
|||
if ladder.Status != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|||
} |
|||
ladder.Status = define.StatusRunning |
|||
ladder.UpdatedAt = time.Now() |
|||
err = models.Save(map[string]interface{}{ |
|||
"id=": ladder.Id, |
|||
"is_delete=": 0, |
|||
}, ladder, "status", "updated_at") |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
// 开始抽奖
|
|||
func (t *OrderDrawCtl) Stop() { |
|||
ladderId := t.MustGetInt64("order_draw_ladder_id") |
|||
|
|||
ladder := new(models.OrderDrawRuleLadder) |
|||
exist, err := models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在") |
|||
|
|||
if ladder.Status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|||
} |
|||
|
|||
ladder.Status = define.StatusEnding |
|||
ladder.UpdatedAt = time.Now() |
|||
err = models.Save(map[string]interface{}{ |
|||
"id=": ladder.Id, |
|||
"is_delete=": 0, |
|||
}, ladder, "status", "updated_at") |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
type OrderListResult struct { |
|||
OrderDrawActivityId int64 `json:"order_draw_activity_id"` |
|||
OrderDrawRuleId int64 `json:"order_draw_rule_id"` |
|||
OrderDrawActivityName string `json:"order_draw_activity_name"` |
|||
OrderDrawLadders []*OrderLadderResult `json:"order_draw_ladders"` |
|||
PrizeNumber int64 `json:"prize_number"` |
|||
} |
|||
type OrderLadderResult struct { |
|||
OrderDrawRuleId int64 `json:"order_draw_rule_id"` |
|||
OrderDrawLadderId int64 `json:"order_draw_ladder_id"` |
|||
PrizeName string `json:"prize_name"` |
|||
Status string `json:"status"` |
|||
PrizeImg string `json:"prize_img"` |
|||
PrizeNumber int64 `json:"prize_number"` |
|||
} |
|||
|
|||
//获取所有订单奖品
|
|||
func (t *OrderDrawCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
// 订单的开启或关闭
|
|||
order := new(models.CustomerOrderOption) |
|||
exist, err = order.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "订单活动不存在") |
|||
|
|||
result := make([]*OrderListResult, 0) |
|||
core.GetXormAuto().Table(new(models.OrderDrawActivity)).Alias("a"). |
|||
Select("a.id as order_draw_activity_id, r.id as order_draw_rule_id, a.order_draw_activity_name"). |
|||
Join("LEFT", new(models.OrderDrawRule).Alias("r"), |
|||
"a.id=r.order_draw_activity_id and r.is_delete=0"). |
|||
Where("a.is_delete=0 and a.activity_id=?", activityId).Find(&result) |
|||
|
|||
// 多地区的一个坑:分配给主会场的area_id不是主账号的area_id
|
|||
area := new(models.AreaStore) |
|||
if t.MustGetCustomerPid() == 0 { |
|||
exist, err = area.GetMainAreaById(activityId) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|||
|
|||
ruleIds := make([]int64, 0) |
|||
for _, v := range result { |
|||
ruleIds = append(ruleIds, v.OrderDrawRuleId) |
|||
} |
|||
|
|||
ladders := make([]*OrderLadderResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.OrderDrawRuleLadder)).Alias("l"). |
|||
Select("id as order_draw_ladder_id, status, prize_name, prize_img, prize_number, order_draw_rule_id"). |
|||
Where("is_delete=0").In("order_draw_rule_id", ruleIds).Find(&ladders) |
|||
t.CheckErr(err) |
|||
|
|||
ladderIds := make([]int64, 0) |
|||
for _, ladder := range ladders { |
|||
ladderIds = append(ladderIds, ladder.OrderDrawLadderId) |
|||
} |
|||
|
|||
records := make([]map[string]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Alias("r"). |
|||
Select("r.order_draw_rule_ladder_id as ladder_id, count(id) as num"). |
|||
Where("is_delete=0 and rehearsal_id=?", activity.RehearsalId). |
|||
In("r.order_draw_rule_ladder_id", ladderIds).GroupBy("ladder_id").Find(&records) |
|||
t.CheckErr(err) |
|||
|
|||
for i := range ladders { |
|||
for j := range records { |
|||
if ladders[i].OrderDrawLadderId == records[j]["ladder_id"] { |
|||
ladders[i].PrizeNumber = ladders[i].PrizeNumber - records[j]["num"] |
|||
} |
|||
} |
|||
} |
|||
|
|||
for i := range result { |
|||
for j := range ladders { |
|||
if result[i].OrderDrawRuleId == ladders[j].OrderDrawRuleId { |
|||
result[i].PrizeNumber += ladders[j].PrizeNumber |
|||
result[i].OrderDrawLadders = append(result[i].OrderDrawLadders, ladders[j]) |
|||
} |
|||
} |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
"status": order.Status, |
|||
}) |
|||
} |
|||
|
|||
//抽奖奖品
|
|||
func (t *OrderDrawCtl) Prize() { |
|||
ruleId := t.MustGetInt64("order_draw_rule_id") |
|||
|
|||
list := make([]*models.OrderDrawRuleLadder, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and order_draw_rule_id=?", ruleId).Find(&list) |
|||
t.CheckErr(err) |
|||
|
|||
for index := range list { |
|||
list[index].Des = "在该活动的所有订单用户中随机抽奖品数量的用户" |
|||
} |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(list), |
|||
"lise": list, |
|||
}) |
|||
} |
|||
|
|||
type OrderUsersResult struct { |
|||
UserId int64 `json:"user_id"` |
|||
Username string `json:"username"` |
|||
Avatar string `json:"avatar"` |
|||
} |
|||
|
|||
//统计人数和订单数量
|
|||
func (t *OrderDrawCtl) Users() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
ruleId := t.MustGetInt64("order_draw_rule_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
|
|||
result := make([]*OrderUsersResult, 0) |
|||
session := core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o"). |
|||
Select("o.buyer_id as user_id, u.nickname as username, u.avatar").Distinct("o.buyer_id"). |
|||
Join("LEFT", new(models.User).Alias("u"), "o.buyer_id=u.id and u.is_delete=0"). |
|||
Where("o.activity_id=? and o.is_delete=0 and o.rehearsal_id=?", |
|||
activityId, activity.RehearsalId) |
|||
|
|||
moduleService, exist, err := activity_service.GetModuleService(define.MODULE_ORDERLY, activity.Id) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "模块服务不存在") |
|||
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { |
|||
recordIds := make([]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Select("user_id"). |
|||
Where("order_draw_rule_id=? and rehearsal_id=? and is_delete=0", |
|||
ruleId, activity.RehearsalId).Find(&recordIds) |
|||
t.CheckErr(err) |
|||
session = session.NotIn("o.buyer_id", recordIds) |
|||
} |
|||
err = session.Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
// 订单抽奖动作
|
|||
func (t *OrderDrawCtl) Draw() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
ruleId := t.MustGetInt64("order_draw_rule_id") |
|||
ladderId := t.MustGetInt64("order_draw_rule_ladder_id") |
|||
number := t.MustGetInt("number") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
area := new(models.AreaStore) |
|||
if t.MustGetCustomerPid() == 0 { |
|||
exist, err = area.GetMainAreaById(activity.Id) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") |
|||
|
|||
rule := new(models.OrderDrawRule) |
|||
exist, err = models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在") |
|||
//t.CheckRunning(rule.OrderDrawStatus)
|
|||
|
|||
// 查询奖品
|
|||
ladder := new(models.OrderDrawRuleLadder) |
|||
exist, err = models.GetById(ladder, ladderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ORDER_LADDER_NOT_EXIST, "订单抽奖等级不存在") |
|||
t.CheckRunning(ladder.Status) |
|||
|
|||
count, err := core.GetXormAuto().Where("order_draw_rule_id=? and order_draw_rule_ladder_id=? "+ |
|||
"and rehearsal_id=? and is_delete=0", ruleId, ladderId, activity.RehearsalId).Count(new(models.OrderDrawRecord)) |
|||
t.CheckErr(err) |
|||
prizeNum := ladder.PrizeNumber - int(count) |
|||
if prizeNum <= 0 || prizeNum < number { |
|||
t.ERROR("奖品数量不足", code.MSG_LOTTERY_PRIZE_NOT_ENOUGH) |
|||
} |
|||
|
|||
moduleService, exist, err := activity_service.GetModuleService(define.MODULE_ORDERLY, activity.Id) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "模块服务不存在") |
|||
|
|||
orderUsers := make([]*lottery_service.LotteryUser, 0) |
|||
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { |
|||
//查询已经中奖的用户,剔除已经中奖的用户
|
|||
recordIds := make([]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Select("user_id"). |
|||
Where("order_draw_rule_id=? and rehearsal_id=? and is_delete=0", |
|||
ruleId, activity.RehearsalId).Find(&recordIds) |
|||
|
|||
err = core.GetXormAuto().Table(new(models.CustomerOrder)). |
|||
Select("buyer_id as user_id").Distinct("buyer_id"). |
|||
Where("activity_id=? and rehearsal_id=? and is_delete=0", |
|||
activity.Id, activity.RehearsalId).NotIn("buyer_id", recordIds). |
|||
Find(&orderUsers) |
|||
t.CheckErr(err) |
|||
if len(orderUsers) < 0 { |
|||
t.ERROR("剔除已经中奖的用户后,已经没有用户可以抽了", code.MSG_ERR) |
|||
} |
|||
} else { |
|||
// 不去除
|
|||
err = core.GetXormAuto().Table(new(models.CustomerOrder)).Select("buyer_id as user_id").Distinct("buyer_id"). |
|||
Where("activity_id=? and rehearsal_id=? and is_delete=0", |
|||
activity.Id, activity.RehearsalId).Find(&orderUsers) |
|||
t.CheckErr(err) |
|||
} |
|||
if len(orderUsers) < number { |
|||
t.ERROR("订单抽奖人数不足", code.MSG_LOTTERY_PEOPLE_NOT_ENOUGH) |
|||
} |
|||
|
|||
lottery_service.RandLotteryUser(orderUsers) |
|||
winners := orderUsers[:number] |
|||
userIds := make([]int64, 0) |
|||
for _, winner := range winners { |
|||
userIds = append(userIds, winner.UserId) |
|||
} |
|||
|
|||
users := make([]*models.User, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0").In("id", userIds).Find(&users) |
|||
t.CheckErr(err) |
|||
for i := range winners { |
|||
for j := range users { |
|||
if winners[i].UserId == users[j].Id { |
|||
winners[i].Username = users[j].Nickname |
|||
winners[i].Avatar = users[j].Avatar |
|||
winners[i].UserPhone = users[j].Phone |
|||
winners[i].LadderId = ladder.Id |
|||
winners[i].PrizeImg = ladder.PrizeImg |
|||
winners[i].PrizeName = ladder.PrizeName |
|||
break |
|||
} |
|||
} |
|||
// 订单抽奖 ==> 存入我的奖品
|
|||
userPrize := new(models.UserPrize) |
|||
userPrize.ActivityId = activityId |
|||
userPrize.RehearsalId = activity.RehearsalId |
|||
userPrize.ActivityName = activity.Name |
|||
userPrize.UserId = winners[i].UserId |
|||
userPrize.PrizeImg = ladder.PrizeImg |
|||
userPrize.PrizeName = ladder.PrizeName |
|||
userPrize.PrizeType = 2 |
|||
userPrize.IsDelete = false |
|||
userPrize.CreatedAt = time.Now() |
|||
userPrize.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().Insert(userPrize) |
|||
t.CheckErr(err) |
|||
|
|||
record := new(models.OrderDrawRecord) |
|||
record.UserPrizeId = userPrize.Id |
|||
record.ActivityId = activityId |
|||
record.RehearsalId = activity.RehearsalId |
|||
record.OrderDrawActivityId = rule.OrderDrawActivityId |
|||
record.OrderDrawRuleId = rule.Id |
|||
record.UserId = winners[i].UserId |
|||
record.OrderDrawRuleLadderId = ladder.Id |
|||
record.PrizeName = ladder.PrizeName |
|||
record.AreaId = area.Id |
|||
record.AreaName = area.Name |
|||
record.IsDelete = false |
|||
record.CreatedAt = time.Now() |
|||
record.UpdatedAt = time.Now() |
|||
_, err = core.GetXormAuto().InsertOne(record) |
|||
t.CheckErr(err) |
|||
} |
|||
t.RAW(winners) |
|||
} |
|||
|
|||
type WinnerResult struct { |
|||
UserId int64 `json:"user_id"` |
|||
Username string `json:"user_name"` |
|||
UserPhone string `json:"user_phone"` |
|||
Avatar string `json:"avatar"` |
|||
PrizeName string `json:"prize_name"` |
|||
} |
|||
|
|||
func (t *OrderDrawCtl) ListOfWinners() { |
|||
orderDrawRuleId := t.MustGetInt64("order_draw_rule_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
result := make([]*WinnerResult, 0) |
|||
err := core.GetXormAuto().Table(new(models.OrderDrawRecord)).Alias("r"). |
|||
Select("r.user_id, u.nickname as username, u.phone as user_phone, u.avatar, r.prize_name"). |
|||
Join("LEFT", new(models.User).Alias("u"), "u.id=r.user_id and u.is_delete=0"). |
|||
Where("r.is_delete=0 and r.order_draw_rule_id=? and r.rehearsal_id=?", |
|||
orderDrawRuleId, rehearsalId).Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
// 获取所有订单
|
|||
|
|||
type OrdersResult struct { |
|||
UserId int64 `json:"user_id"` |
|||
AreaName string `json:"area_name"` |
|||
GoodsName string `json:"goods_name"` |
|||
Nickname string `json:"nickname"` |
|||
ExtraData string `json:"-"` |
|||
Extra []map[string]interface{} `json:"extra"` |
|||
} |
|||
|
|||
func (t *OrderDrawCtl) Orders() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
orders := make([]*OrdersResult, 0) |
|||
err := core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o"). |
|||
Select("o.area_name, o.goods_name, o.buyer_id as user_id, u.nickname, l.extra_data as extra_data, o.created_at"). |
|||
Distinct("o.id").Join("LEFT", new(models.InvitationLetter).Alias("l"), |
|||
"o.buyer_id=l.user_id and o.activity_id=l.activity_id and l.is_delete=0"). |
|||
Join("LEFT", new(models.User).Alias("u"), "u.id=o.buyer_id and u.is_delete=0"). |
|||
Where("o.is_delete=0 and o.activity_id=? and o.rehearsal_id=?", activityId, rehearsalId). |
|||
Asc("o.created_at").Find(&orders) |
|||
t.CheckErr(err) |
|||
|
|||
items, err := invitation_service.GetOptionItem(activityId) |
|||
t.CheckErr(err) |
|||
for i := range orders { |
|||
data, err := invitation_service.GetOptionValue(items, orders[i].ExtraData) |
|||
t.CheckErr(err) |
|||
orders[i].Extra = data |
|||
} |
|||
|
|||
// 下订单人数
|
|||
buyerCount, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=?", |
|||
activityId, rehearsalId).Distinct("buyer_id").Count(new(models.CustomerOrder)) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"orders": orders, |
|||
"total": len(orders), |
|||
"buyer_count": buyerCount, |
|||
}) |
|||
} |
@ -0,0 +1,221 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/services/pay" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type RewardCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
type RewardResult struct { |
|||
models.RewardHistory `xorm:"extends"` |
|||
User *models.User `json:"user" xorm:"extends"` |
|||
} |
|||
|
|||
//获取最新的打赏记录
|
|||
func (t *RewardCtl) Latest() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
//获取打赏服务得id
|
|||
server := new(models.RewardServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
result := new(RewardResult) |
|||
exist, err = core.GetXormAuto().Table(new(models.RewardHistory)).Alias("h"). |
|||
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0"). |
|||
Where("h.is_delete=0 and h.status=2 and h.reward_server_id=? and h.rehearsal_id=?", server.Id, rehearsalId). |
|||
OrderBy("review_time desc").Get(result) |
|||
t.CheckErr(err) |
|||
if !exist { |
|||
t.RAW(result) |
|||
} |
|||
|
|||
result.User.Openid = "" |
|||
result.User.Unionid = "" |
|||
result.RewardHistory.RewardAmount = fmt.Sprintf("%.2f", result.RewardHistory.Amount) |
|||
t.CheckErr(models.Save(map[string]interface{}{ |
|||
"id=": result.RewardHistory.Id, |
|||
}, &models.RewardHistory{ |
|||
Status: 3, |
|||
UpdatedAt: time.Now(), |
|||
}, "status", "update_at")) |
|||
t.RAW(result) |
|||
} |
|||
|
|||
//获取待审核列表
|
|||
func (t *RewardCtl) WaitReview() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
//获取打赏服务得id
|
|||
server := new(models.RewardServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
t.CheckErr(pay_service.BatchQueryByActivityId(activityId)) |
|||
t.CheckErr(pay_service.BatchQueryRefundByActivityId(activityId)) |
|||
|
|||
result := make([]*RewardResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.RewardHistory)).Alias("h"). |
|||
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0"). |
|||
Where("h.is_delete=0 and h.status=0 and h.reward_server_id=? and h.rehearsal_id=?", |
|||
server.Id, rehearsalId).OrderBy("h.created_at desc").Find(&result) |
|||
t.CheckErr(err) |
|||
//根据打赏服务得id获取待审核得打赏列表
|
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//审核
|
|||
func (t *RewardCtl) Review() { |
|||
// todo: false 代表通过, true 代表不通过
|
|||
idList := t.MustGet("ids") |
|||
status := t.MustGetBool("status") |
|||
ids := strings.Split(idList, "|") |
|||
//rehearsalId := t.MustGetInt64("rehearsal_id")
|
|||
|
|||
result := make([]*models.RewardHistory, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0").In("id", ids).Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
//if rehearsalId != 0 { // 彩排不需要金额
|
|||
// t.RAW("审核成功")
|
|||
// return
|
|||
//}
|
|||
|
|||
// 审核
|
|||
for _, v := range result { |
|||
if v.Status != 0 { |
|||
t.ERROR("该打赏已处理", code.MSG_USER_DATA_ERROR) |
|||
} |
|||
if status { // false 通过 , true 不通过
|
|||
// 回退金额给用户
|
|||
// 应该微信退款
|
|||
|
|||
_, err := v.UpdateStatus(v.Id, 1) |
|||
t.CheckErr(err) |
|||
|
|||
//if rehearsalId != 0 { // 彩排不需要金额
|
|||
// continue
|
|||
//}
|
|||
|
|||
order := new(models.UserOrder) |
|||
exist, err := models.GetById(order, v.UserOrderId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_USER_ORDER_NOT_EXIST, "用户支付订单不存在") |
|||
|
|||
_, err = pay_service.Refund("欧轩互动-打赏拉黑", order.OutTradeNo, order.OpenId, order.GoodType, order.TotalFee, order.TotalFee, order.UserId, order.ActivityId) |
|||
t.CheckErr(err) |
|||
|
|||
} else { |
|||
//增加客户的金额
|
|||
_, err := v.UpdateStatus(v.Id, 2) |
|||
t.CheckErr(err) |
|||
|
|||
//if rehearsalId != 0 { // 彩排不需要金额
|
|||
// continue
|
|||
//}
|
|||
|
|||
uid := t.MustGetUID() |
|||
customer := new(models.Customer) |
|||
exist, err := models.GetById(customer, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
wallet := new(models.RewardWallet) |
|||
_, err = wallet.IncrBalance(uid, v.Amount) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = core.GetXormAuto().InsertOne(&models.RewardWalletHistory{ |
|||
CustomerId: uid, |
|||
Money: v.Amount, |
|||
Type: "打赏", |
|||
UserId: v.UserId, |
|||
RewardHistoryId: v.Id, |
|||
RewardAccount: v.RewardAmount, |
|||
Status: "交易成功", |
|||
Mark: "打赏金额", |
|||
CreatedAt: time.Now(), |
|||
UpdatedAt: time.Now(), |
|||
}) |
|||
t.CheckErr(err) |
|||
} |
|||
} |
|||
// 发送审核的信息
|
|||
t.RAW("审核成功") |
|||
} |
|||
|
|||
//获取打赏得总金额
|
|||
func (t *RewardCtl) Amount() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
//获取打赏服务得id
|
|||
server := new(models.RewardServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
totalAmount, err := core.GetXormAuto().Where("reward_server_id=? and status=3 and is_delete=0 "+ |
|||
" and rehearsal_id=?", server.Id, rehearsalId).Sum(new(models.RewardHistory), "amount") |
|||
t.CheckErr(err) |
|||
|
|||
t.DisplayByData(map[string]interface{}{ |
|||
"amount": utils.Float64CusDecimal(totalAmount, 2), |
|||
}) |
|||
} |
|||
|
|||
// 黑名单
|
|||
func (t *RewardCtl) Blacklist() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
// 获取打赏的服务id
|
|||
server := new(models.RewardServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
// 根据打赏服务id获取待审核的名单
|
|||
// status=true 代表审核不通过还是通过
|
|||
// 目前表示不通过,bully_screen也一样
|
|||
result := make([]*RewardResult, 0) |
|||
err = core.GetXormAuto().Table(new(models.RewardHistory)).Alias("h"). |
|||
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0"). |
|||
Where("h.is_delete=0 and h.status=1 and h.reward_server_id=? and h.rehearsal_id=?", |
|||
server.Id, rehearsalId).OrderBy("review_time desc").Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
// 开启打赏
|
|||
func (t *RewardCtl) Details() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
server := new(models.RewardServer) |
|||
exist, err := server.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"server": server, |
|||
}) |
|||
} |
@ -0,0 +1,213 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
red_envelope_service "hudongzhuanjia/services/red_envelope" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
) |
|||
|
|||
type ShakeRedEnvelopeCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
func (t *ShakeRedEnvelopeCtl) Ready() { |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
|
|||
rule := new(models.ShakeRedEnvelopeRule) |
|||
exist, err := models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包不存在") |
|||
if rule.ShakeRedEnvelopeStatus != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", rule.ShakeRedEnvelopeStatus), code.MSG_ERR) |
|||
} |
|||
envelope := new(models.ShakeRedEnvelopeActivity) |
|||
exist, err = models.GetById(envelope, rule.ShakeRedEnvelopeActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SHAKERB_NOT_EXIST, "摇红包不存在") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err = models.GetById(activity, envelope.ActivityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
// done: 把其他的准备中的状态改为未开始
|
|||
// 又一个坑, 红包的 轮次根据 activity_id
|
|||
sids := make([]int64, 0) |
|||
err = core.GetXormAuto().Table(new(models.ShakeRedEnvelopeActivity)).Select("id"). |
|||
Where("is_delete=0 and activity_id=?", activity.Id).Find(&sids) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = rule.UpdateToStatusBySids(sids, define.StatusReady, define.StatusNotBegin) |
|||
t.CheckErr(err) |
|||
|
|||
// 初始化红包
|
|||
err = red_envelope_service.GenRedEnvelope(activity.Id, activity.RehearsalId, rule) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = rule.UpdateStatus(ruleId, define.StatusReady) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("success") |
|||
} |
|||
|
|||
//开始摇红包
|
|||
func (t *ShakeRedEnvelopeCtl) Start() { |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
|
|||
//根据摇红包规则id查找该条记录并且更给状态
|
|||
rule := new(models.ShakeRedEnvelopeRule) |
|||
exist, err := models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包不存在") |
|||
|
|||
if rule.ShakeRedEnvelopeStatus != define.StatusReady { |
|||
t.ERROR(fmt.Sprintf("该活动%s", rule.ShakeRedEnvelopeStatus), code.MSG_ERR) |
|||
} |
|||
|
|||
_, err = rule.UpdateStatus(ruleId, define.StatusRunning) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("success") |
|||
} |
|||
|
|||
//停止摇红包
|
|||
func (t *ShakeRedEnvelopeCtl) Stop() { |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
|
|||
rule := new(models.ShakeRedEnvelopeRule) |
|||
exist, err := models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") |
|||
|
|||
rule.ShakeRedEnvelopeStatus = define.StatusEnding |
|||
_, err = rule.UpdateStatus(ruleId, rule.ShakeRedEnvelopeStatus) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("success") |
|||
} |
|||
|
|||
func (t *ShakeRedEnvelopeCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
activity := new(models.Activity) |
|||
exist, err := models.GetById(activity, activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|||
t.CheckRunning(activity.Status) |
|||
|
|||
list := make([]*models.ShakeRedEnvelopeActivity, 0) |
|||
total, err := core.GetXormAuto().Where("is_delete=0 and is_pay=1 and activity_id=?", activityId).FindAndCount(&list) |
|||
t.CheckErr(err) |
|||
aIds := make([]int64, 0) |
|||
for _, v := range list { |
|||
aIds = append(aIds, v.Id) |
|||
} |
|||
area := new(models.AreaStore) |
|||
if t.MustGetCustomerPid() == 0 { |
|||
exist, err = area.GetMainAreaById(activityId) |
|||
} else { |
|||
exist, err = area.GetAreaStoreById(t.MustGetAreaId()) |
|||
} |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") |
|||
|
|||
rules := make([]*models.ShakeRedEnvelopeRule, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and area_id=?", area.Id).In("shake_red_envelope_activity_id", aIds).Find(&rules) |
|||
t.CheckErr(err) |
|||
rIds := make([]int64, 0) |
|||
for _, v := range rules { |
|||
rIds = append(rIds, v.Id) |
|||
} |
|||
ladders := make([]*models.ShakeRedEnvelopeRuleLadder, 0) |
|||
core.GetXormAuto().Where("is_delete=0").In("shake_red_envelope_rule_id", rIds).Find(&ladders) |
|||
for index := range rules { |
|||
for i := range ladders { |
|||
if rules[index].Id == ladders[i].ShakeRedEnvelopeRuleId { |
|||
rules[index].ShakeRedEnvelopeRuleLadders = append(rules[index].ShakeRedEnvelopeRuleLadders, ladders[i]) |
|||
} |
|||
} |
|||
} |
|||
for index := range list { |
|||
for i := range rules { |
|||
if list[index].Id == rules[i].ShakeRedEnvelopeActivityId { |
|||
list[index].ShakeRedEnvelopeRule = rules[i] |
|||
break |
|||
} |
|||
} |
|||
} |
|||
|
|||
for index := range rules { |
|||
rules[index].Des = "根据对应得概率获得红包" |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": total, |
|||
"list": list, |
|||
}) |
|||
} |
|||
|
|||
//二维码
|
|||
func (t *ShakeRedEnvelopeCtl) Qrcode() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
customerId := t.MustGetUID() |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
|
|||
//将服务器得地址和activity_id,动态生成二维码
|
|||
qrcode, err := utils.GenH5Qrcode(define.H5ShakeRb, map[string]interface{}{ |
|||
"activity_id": activityId, |
|||
"customer_id": customerId, |
|||
"rule_id": ruleId, |
|||
}) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qrcode, |
|||
}) |
|||
} |
|||
|
|||
type ShakeRedEnvelopeRecordAndUser struct { |
|||
models.ShakeRedEnvelopeRecord `xorm:"extends"` |
|||
User *models.User `json:"user" xorm:"extends"` |
|||
} |
|||
|
|||
// 参数优化
|
|||
func (t *ShakeRedEnvelopeCtl) Winners() { |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
records := make([]*ShakeRedEnvelopeRecordAndUser, 0) |
|||
err := core.GetXormAuto().Table(new(models.ShakeRedEnvelopeRecord)).Alias("r"). |
|||
Join("LEFT", models.AliasTableName(new(models.User), "u"), "r.user_id=u.id and u.is_delete=0"). |
|||
Where("r.shake_red_envelope_rule_id=? and is_draw<>-1 and r.is_delete=0 and r.rehearsal_id=?", |
|||
ruleId, rehearsalId).OrderBy("r.created_at desc").Find(&records) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(records), |
|||
"winners": records, |
|||
}) |
|||
} |
|||
|
|||
// 统计摇红包参与人数和剩余红包数量
|
|||
func (t *ShakeRedEnvelopeCtl) Count() { |
|||
ruleId := t.MustGetInt64("shake_red_envelope_rule_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
rule := new(models.ShakeRedEnvelopeRule) |
|||
exist, err := models.GetById(rule, ruleId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包轮次不存在") |
|||
|
|||
numU, err := core.GetXormAuto().Where("is_delete=0 and shake_red_envelope_rule_id=? and rehearsal_id=?", |
|||
ruleId, rehearsalId).Count(new(models.ShakeRedEnvelopeUser)) |
|||
t.CheckErr(err) |
|||
|
|||
numR, err := core.GetXormAuto().Where("is_delete=0 and is_draw=-1 and shake_red_envelope_rule_id=? and rehearsal_id=?", |
|||
ruleId, rehearsalId).Count(new(models.ShakeRedEnvelopeRecord)) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"red_envelope_num": numR, |
|||
"red_envelope_user": numU, |
|||
}) |
|||
} |
@ -0,0 +1,87 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
//签到
|
|||
type SignCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//获取二维码
|
|||
func (t *SignCtl) Qrcode() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
uid := t.MustGetUID() |
|||
signUpId := t.MustGetInt64("sign_rule_id") |
|||
|
|||
//将服务器得地址和activity_id,动态生成二维码
|
|||
qrcode, err := utils.GenH5Qrcode(define.H5SignIn, map[string]interface{}{ |
|||
"activity_id": activityId, |
|||
"customer_id": uid, |
|||
"sign_rule_id": signUpId, |
|||
}) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qrcode, |
|||
"logo": "", |
|||
}) |
|||
|
|||
} |
|||
|
|||
//获取签到模式
|
|||
func (t *SignCtl) Mode() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
//通过activity_id查询ox_sign_rule的id
|
|||
signUp := new(models.SignUp) |
|||
exist, err := signUp.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到规则不存在") |
|||
|
|||
t.RAW(signUp.MaxModel) |
|||
} |
|||
|
|||
func (t *SignCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
signUps := make([]*models.SignUp, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).Asc("created_at").Find(&signUps) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(signUps), |
|||
"list": signUps, |
|||
}) |
|||
} |
|||
|
|||
type SignResult struct { |
|||
models.SignHistory `xorm:"extends"` |
|||
User *models.User `json:"user" xorm:"extends"` |
|||
} |
|||
|
|||
//处理签到信息
|
|||
func (t *SignCtl) SignInfo() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
result := make([]*SignResult, 0) |
|||
session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h"). |
|||
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0"). |
|||
Where("h.is_delete=0 and h.activity_id=? and rehearsal_id=?", activityId, rehearsalId) |
|||
if t.PageSize > 0 { // 增加分页
|
|||
session.Limit(t.PageSize, t.Page*t.PageSize) |
|||
} |
|||
count, err := session.FindAndCount(&result) |
|||
|
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"list": result, |
|||
"sign_up_total": count, |
|||
}) |
|||
} |
@ -0,0 +1,221 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type TugOfWarCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) Ready() { // 准备中
|
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") |
|||
if bahe.Status != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", bahe.Status), code.MSG_ERR) |
|||
} |
|||
// done: 把其他的准备中的状态改为未开始
|
|||
_, err = bahe.UpdateToStatusByAid(bahe.ActivityId, define.StatusReady, define.StatusNotBegin) |
|||
t.CheckErr(err) |
|||
|
|||
// 创建队伍 只容许创建一次
|
|||
redTeam := &models.BaheTeam{ |
|||
BaheTeamName: "red", |
|||
ActivityId: bahe.ActivityId, |
|||
BaheActivityId: bahe.Id, |
|||
IsDelete: false, |
|||
CreatedAt: time.Now(), |
|||
UpdatedAt: time.Now(), |
|||
} |
|||
err = models.Save(map[string]interface{}{ |
|||
"bahe_activity_id=": bahe.Id, |
|||
"is_delete=": 0, |
|||
"bahe_team_name=": define.TUGWAR_TEAM_RED, |
|||
}, redTeam) |
|||
t.CheckErr(err) |
|||
|
|||
blueTeam := &models.BaheTeam{ |
|||
BaheTeamName: "blue", |
|||
ActivityId: bahe.ActivityId, |
|||
BaheActivityId: bahe.Id, |
|||
IsDelete: false, |
|||
CreatedAt: time.Now(), |
|||
UpdatedAt: time.Now(), |
|||
} |
|||
err = models.Save(map[string]interface{}{ |
|||
"bahe_activity_id=": bahe.Id, |
|||
"is_delete=": 0, |
|||
"bahe_team_name=": define.TUGWAR_TEAM_BULE, |
|||
}, blueTeam) |
|||
t.CheckErr(err) |
|||
|
|||
_, err = bahe.UpdateStatusById(bahe.Id, define.StatusReady) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) Start() { |
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") |
|||
if bahe.Status != define.StatusReady { |
|||
t.ERROR(fmt.Sprintf("该活动%s", bahe.Status), code.MSG_ERR) |
|||
} |
|||
|
|||
_, err = bahe.UpdateStatusById(baheId, define.StatusRunning) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) Stop() { |
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") |
|||
if bahe.Status != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", bahe.Status), code.MSG_ERR) |
|||
} |
|||
|
|||
bahe.Status = define.StatusEnding |
|||
bahe.UpdatedAt = time.Now() |
|||
_, err = bahe.UpdateStatusById(bahe.Id, bahe.Status) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("操作成功") |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) Team() { |
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
customerId := t.MustGetUID() |
|||
|
|||
bahe := new(models.TugOfWar) |
|||
exist, err := models.GetById(bahe, baheId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_TUGWAR_NOT_EXIST, "拔河不存在") |
|||
|
|||
//获取队伍信息: 名字、二维码、颜色
|
|||
teams := make([]*models.BaheTeam, 0) |
|||
total, err := core.GetXormAuto().Where("is_delete=0 and bahe_activity_id=?", bahe.Id).FindAndCount(&teams) |
|||
t.CheckErr(err) |
|||
|
|||
// 队伍颜色
|
|||
qrcode := "" |
|||
// 二维码
|
|||
if bahe.Model != "随机分配模式" { |
|||
// 非随机模式,自选队伍
|
|||
for index := range teams { |
|||
qrcode, err = utils.GenH5Qrcode(define.H5TugOfWar, map[string]interface{}{ |
|||
"activity_id": bahe.ActivityId, |
|||
"customer_id": customerId, |
|||
"bahe_activity_id": bahe.Id, |
|||
"bahe_team_id": teams[index].Id, |
|||
"rehearsal_id": rehearsalId, |
|||
}) |
|||
t.CheckErr(err) |
|||
teams[index].Qrcode = qrcode |
|||
} |
|||
} else { |
|||
qrcode, err = utils.GenH5Qrcode(define.H5TugOfWar, map[string]interface{}{ |
|||
"activity_id": bahe.ActivityId, |
|||
"customer_id": customerId, |
|||
"bahe_activity_id": bahe.Id, |
|||
"bahe_team_id": 0, |
|||
"rehearsal_id": rehearsalId, |
|||
}) |
|||
t.CheckErr(err) |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": total, |
|||
"list": teams, |
|||
"qrcode": qrcode, |
|||
"model": bahe.Model, |
|||
}) |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) Member() { |
|||
baheId := t.MustGetInt64("bahe_activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
teams := make([]*models.BaheTeam, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and bahe_activity_id=?", baheId).Find(&teams) |
|||
t.CheckErr(err) |
|||
|
|||
var total int64 = 0 |
|||
for index := range teams { |
|||
members := make([]*models.BaheTeamMember, 0) |
|||
num, err := core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=?", |
|||
teams[index].Id, rehearsalId).Desc("score").Asc("sort_time").FindAndCount(&members) |
|||
t.CheckErr(err) |
|||
total += num |
|||
teams[index].Members = members |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": total, |
|||
"list": teams, |
|||
}) |
|||
} |
|||
|
|||
type BaheScoreResult struct { |
|||
TotalScore int64 `json:"total_score" description:"总分数"` |
|||
Id int64 `json:"id" description:"id"` |
|||
ActivityId int64 `json:"activity_id" description:"活动id"` |
|||
BaheActivityId int64 `json:"bahe_activity_id" description:"拔河活动id"` |
|||
BaheTeamName string `json:"bahe_team_name" description:"拔河队伍得名称"` |
|||
Members []*models.BaheTeamMember `json:"members"` |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) Score() { |
|||
baheActivityId := t.MustGetInt64("bahe_activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
teams := make([]*BaheScoreResult, 0) |
|||
err := core.GetXormAuto().Table(new(models.BaheTeam)).Alias("t"). |
|||
Select("sum(m.score) as total_score, t.id, t.activity_id, t.bahe_activity_id, t.bahe_team_name"). |
|||
Join("LEFT", new(models.BaheTeamMember).Alias("m"), |
|||
"t.id=m.team_id and m.is_delete=0 and m.rehearsal_id=?", rehearsalId). |
|||
Where("t.is_delete=0 and t.bahe_activity_id=?", baheActivityId). |
|||
GroupBy("t.id").Find(&teams) |
|||
t.CheckErr(err) |
|||
|
|||
for index := range teams { |
|||
members := make([]*models.BaheTeamMember, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=?", teams[index].Id, rehearsalId). |
|||
Desc("score").Asc("sort_time").Find(&members) |
|||
t.CheckErr(err) |
|||
teams[index].Members = members |
|||
} |
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(teams), |
|||
"list": teams, |
|||
}) |
|||
} |
|||
|
|||
func (t *TugOfWarCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
bahes := make([]*models.TugOfWar, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId). |
|||
Asc("created_at").Find(&bahes) |
|||
t.CheckErr(err) |
|||
t.JSON(map[string]interface{}{ |
|||
"bahe_activities": bahes, |
|||
}) |
|||
} |
@ -0,0 +1,181 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
ws_send_service "hudongzhuanjia/services/ws_send" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type UpperWallCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
type UpperWallResult struct { |
|||
models.UpperWall `xorm:"extends"` |
|||
User *models.User `json:"user" xorm:"extends"` |
|||
} |
|||
|
|||
//获取所有已审核的上墙消息
|
|||
func (t *UpperWallCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
result := make([]*UpperWallResult, 0) |
|||
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w"). |
|||
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0"). |
|||
Where("w.is_delete=0 and w.status=3 and w.activity_id=? and w.rehearsal_id=?", activityId, rehearsalId). |
|||
OrderBy("w.review_time desc").Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//获取待审核列表
|
|||
func (t *UpperWallCtl) WaitReview() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
//根据霸屏服务得id获取待审核得霸屏列表
|
|||
result := make([]*UpperWallResult, 0) |
|||
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w"). |
|||
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0"). |
|||
Where("w.is_delete=0 and w.status=0 and w.activity_id=? and w.rehearsal_id=?", activityId, rehearsalId). |
|||
OrderBy("w.review_time desc").Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//审核操作
|
|||
func (t *UpperWallCtl) Review() { |
|||
idList := t.MustGet("ids") |
|||
status := t.MustGetBool("status") |
|||
uid := t.MustGetUID() |
|||
|
|||
ids := strings.Split(idList, "|") |
|||
|
|||
customer := new(models.Customer) |
|||
exist, err := models.GetById(customer, uid) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
reviewStatus := 1 |
|||
if !status { |
|||
reviewStatus = 3 // 审核通过直接发送ws
|
|||
} |
|||
|
|||
t.CheckErr(models.Save(map[string]interface{}{ |
|||
"id in": ids, |
|||
}, &models.UpperWall{ |
|||
Status: reviewStatus, |
|||
ReviewTime: time.Now().Unix(), |
|||
}, "status", "review_time")) |
|||
|
|||
// false 通过
|
|||
if !status { |
|||
result := make([]*UpperWallResult, 0) |
|||
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w"). |
|||
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0"). |
|||
Where("w.is_delete=0").In("w.id", ids). |
|||
OrderBy("w.created_at asc").Find(&result) |
|||
t.CheckErr(err) |
|||
if len(result) == 0 { |
|||
t.ERROR("不存在上墙消息", code.MSG_DATA_NOT_EXIST) |
|||
return |
|||
} |
|||
|
|||
for index := range result { |
|||
bi, err := utils.Gif2Base64(result[index].Img) |
|||
t.CheckErr(err) |
|||
result[index].Img = bi |
|||
} |
|||
|
|||
go ws_send_service.SendUpperWall(fmt.Sprintf("%d", result[0].ActivityId), |
|||
define.TYPE_CUSTOMER, customer.Id, map[string]interface{}{ |
|||
"type": "upper_wall", |
|||
"customer_id": customer.Id, |
|||
"data": map[string]interface{}{ |
|||
"list": result, |
|||
"total": len(result)}, |
|||
}) |
|||
} |
|||
t.STRING("审核成功") |
|||
} |
|||
|
|||
//获取黑名单列表
|
|||
func (t *UpperWallCtl) Blacklist() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
result := make([]*UpperWallResult, 0) |
|||
|
|||
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w"). |
|||
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0"). |
|||
Where("w.is_delete=0 and w.status=1 and w.status=1 and w.rehearsal_id=? and w.activity_id=?", |
|||
rehearsalId, activityId).OrderBy("review_time desc").Find(&result) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": len(result), |
|||
"list": result, |
|||
}) |
|||
} |
|||
|
|||
//获取目前上墙得总条数
|
|||
func (t *UpperWallCtl) Total() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
|
|||
total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=3", |
|||
activityId, rehearsalId).Count(new(models.UpperWall)) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": total, |
|||
}) |
|||
} |
|||
|
|||
//二维码
|
|||
// 跳到主页
|
|||
func (t *UpperWallCtl) Qrcode() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
uid := t.MustGetUID() |
|||
|
|||
qrcode, err := utils.GenH5Qrcode(define.H5Index, map[string]interface{}{ |
|||
"activity_id": activityId, |
|||
"customer_id": uid, |
|||
"rehearsal_id": rehearsalId, |
|||
}) |
|||
t.CheckErr(err) |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qrcode, |
|||
}) |
|||
} |
|||
|
|||
func (t *UpperWallCtl) Details() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
msgWall := new(models.MsgWallServer) |
|||
exist, err := msgWall.GetByActivityId(activityId) |
|||
t.CheckErr(err) |
|||
if !exist { |
|||
t.ERROR("上墙服务模块不存在", code.MSG_ERR) |
|||
} |
|||
t.JSON(map[string]interface{}{ |
|||
"msg_wall": msgWall, |
|||
}) |
|||
} |
@ -0,0 +1,164 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
) |
|||
|
|||
type VoteCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
//二维码
|
|||
func (t *VoteCtl) Qrcode() { |
|||
qrcode, err := utils.GenH5Qrcode(define.H5Vote, map[string]interface{}{ |
|||
"activity_id": t.MustGetInt64("activity_id"), |
|||
"customer_id": t.MustGetUID(), |
|||
"vote_activity_id": t.MustGetInt64("vote_activity_id"), |
|||
}) |
|||
t.CheckErr(err) |
|||
|
|||
//直接输出二维码
|
|||
t.JSON(map[string]interface{}{ |
|||
"qrcode": qrcode, |
|||
}) |
|||
} |
|||
|
|||
// 装备数据
|
|||
func (t *VoteCtl) ReadyVote() { |
|||
voteId := t.MustGetInt64("vote_activity_id") |
|||
vote := new(models.NewVoteActivity) |
|||
exist, err := models.GetById(vote, voteId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") |
|||
if vote.VoteStatus != define.StatusNotBegin { |
|||
t.ERROR(fmt.Sprintf("该活动%s", vote.VoteStatus), code.MSG_ERR) |
|||
} |
|||
_, err = vote.UpdateToStatusByAid(vote.ActivityId, define.StatusReady, define.StatusNotBegin) |
|||
t.CheckErr(err) |
|||
|
|||
// 初始化某些数据, 例如投票的初始票数
|
|||
// 彩排结束恢复某些数据
|
|||
ladders := make([]*models.NewVoteActivityLadder, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0 and vote_activity_id=?", vote.Id).Find(&ladders) |
|||
t.CheckErr(err) |
|||
for _, ladder := range ladders { |
|||
ladder.TotalNumber = ladder.VoteNumber |
|||
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", ladder.Id). |
|||
Cols("total_number").Update(ladder) |
|||
t.CheckErr(err) |
|||
} |
|||
|
|||
_, err = vote.UpdateStatusById(vote.Id, define.StatusReady) |
|||
t.CheckErr(err) |
|||
t.SUCCESS("success") |
|||
} |
|||
|
|||
//开始投票
|
|||
func (t *VoteCtl) StartVote() { |
|||
voteId := t.MustGetInt64("vote_activity_id") |
|||
vote := new(models.NewVoteActivity) |
|||
exist, err := models.GetById(vote, voteId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") |
|||
|
|||
if vote.VoteStatus != define.StatusReady { |
|||
t.ERROR(fmt.Sprintf("该活动%s", vote.VoteStatus), code.MSG_ERR) |
|||
} |
|||
vote.VoteStatus = define.StatusRunning |
|||
vote.UpdatedAt = time.Now() |
|||
if vote.VoteLastTime == "" { |
|||
vote.VoteLastTime = "0" |
|||
} |
|||
duration, _ := strconv.ParseInt(vote.VoteLastTime, 10, 64) |
|||
vote.VoteEndTime = time.Now().Unix() + duration |
|||
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", voteId). |
|||
Cols("vote_status", "vote_end_time", "updated_at").Update(vote) |
|||
t.CheckErr(err) |
|||
t.STRING("操作成功") |
|||
} |
|||
|
|||
//停止投票
|
|||
func (t *VoteCtl) StopVote() { |
|||
voteId := t.MustGetInt64("vote_activity_id") |
|||
|
|||
vote := new(models.NewVoteActivity) |
|||
exist, err := models.GetById(vote, voteId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") |
|||
|
|||
if vote.VoteStatus != define.StatusRunning { |
|||
t.ERROR(fmt.Sprintf("该活动%s", vote.VoteStatus), code.MSG_ERR) |
|||
} |
|||
|
|||
vote.VoteStatus = define.StatusEnding |
|||
vote.UpdatedAt = time.Now() |
|||
vote.VoteEndTime = 0 |
|||
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", voteId). |
|||
Cols("vote_status", "updated_at", "vote_end_time").Update(vote) |
|||
t.CheckErr(err) |
|||
|
|||
t.STRING("操作成功") |
|||
} |
|||
|
|||
//获取参与人数
|
|||
func (t *VoteCtl) JoinTotal() { |
|||
voteActivityId := t.MustGetInt64("vote_activity_id") |
|||
rehearsalId := t.MustGetInt64("rehearsal_id") |
|||
total, err := core.GetXormAuto().Distinct("user_id").Where("vote_activity_id=? and rehearsal_id=? and is_delete=0", |
|||
voteActivityId, rehearsalId).Count(new(models.NewVoteActivityHistory)) |
|||
t.CheckErr(err) |
|||
t.RAW(total) |
|||
} |
|||
|
|||
//获取所有的投票活动
|
|||
func (t *VoteCtl) List() { |
|||
activityId := t.MustGetInt64("activity_id") |
|||
|
|||
list := make([]*models.NewVoteActivity, 0) |
|||
total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId). |
|||
Asc("created_at").FindAndCount(&list) |
|||
t.CheckErr(err) |
|||
|
|||
ids := make([]int64, 0) |
|||
for _, v := range list { |
|||
ids = append(ids, v.Id) |
|||
} |
|||
ladders := make([]*models.NewVoteActivityLadder, 0) |
|||
err = core.GetXormAuto().Where("is_delete=0").In("vote_activity_id", ids).Find(&ladders) |
|||
t.CheckErr(err) |
|||
|
|||
for index := range list { |
|||
for i := range ladders { |
|||
if list[index].Id == ladders[i].VoteActivityId { |
|||
list[index].VoteActivityLadders = append(list[index].VoteActivityLadders, ladders[i]) |
|||
} |
|||
} |
|||
} |
|||
|
|||
t.JSON(map[string]interface{}{ |
|||
"total": total, |
|||
"list": list, |
|||
}) |
|||
} |
|||
|
|||
//获取投票的前几(头像、姓名、票数)
|
|||
func (t *VoteCtl) History() { |
|||
voteActivityId := t.MustGetInt64("vote_activity_id") |
|||
//rehearsalId := t.MustGetInt64("rehearsal_id")
|
|||
total := t.MustGetInt("total") |
|||
|
|||
ladders := make([]*models.NewVoteActivityLadder, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and vote_activity_id=?", voteActivityId). |
|||
Desc("total_number").Asc("updated_at").Limit(total).Find(&ladders) |
|||
t.CheckErr(err) |
|||
t.RAW(ladders) |
|||
} |
@ -0,0 +1,83 @@ |
|||
package pc |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"hudongzhuanjia/controllers" |
|||
"hudongzhuanjia/logger" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils/code" |
|||
"time" |
|||
) |
|||
|
|||
type WsCtl struct { |
|||
controllers.AuthorCtl |
|||
} |
|||
|
|||
// ws doc
|
|||
// @Summary ws
|
|||
// @Description get current operation
|
|||
// @Tags ws
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param activity_id query int true "Activity ID"
|
|||
// @Success 0 {array} models.CustomerOperation
|
|||
// @Failure 503 {string} string "参数不存在"
|
|||
// @Failure 504 {object} string "用户不存在"
|
|||
// @Router /Pc/WsCtl/ops [get]
|
|||
func (t *WsCtl) Ops() { |
|||
customerId := t.MustGetUID() |
|||
activityId, _ := t.GetInt64("activity_id") |
|||
customer := new(models.Customer) |
|||
exist, err := models.GetById(customer, customerId) |
|||
t.CheckErr(err) |
|||
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|||
|
|||
op := new(models.CustomerOperation) |
|||
if customer.Pid == 0 { |
|||
exist, err = op.GetOpByActivityId(activityId) |
|||
} else { |
|||
exist, err = op.GetOpByCustomerId(customer.Pid) |
|||
} |
|||
t.CheckErr(err) |
|||
if !exist { |
|||
t.JSON(map[string]interface{}{ |
|||
"operations": []*models.CustomerOperation{}, |
|||
}) |
|||
} |
|||
|
|||
var m = make(map[string]interface{}) |
|||
err = json.Unmarshal([]byte(op.ExtraData), &m) |
|||
t.CheckErr(err) |
|||
|
|||
op.OtherData = m |
|||
t.JSON(map[string]interface{}{ |
|||
"operations": []*models.CustomerOperation{op}, |
|||
}) |
|||
} |
|||
|
|||
// ws doc
|
|||
// @Summary ws
|
|||
// @Description save operation
|
|||
// @Tags ws
|
|||
// @Accept json
|
|||
// @Produce json
|
|||
// @Param operation query string true "操作内容"
|
|||
// @Success 0 {string} string "success"
|
|||
// @Failure 503 {string} string "参数不存在"
|
|||
// @Failure 504 {object} string "用户不存在"
|
|||
// @Router /Pc/WsCtl/saveOp [post]
|
|||
func (t *WsCtl) SaveOp() { |
|||
customerId := t.MustGetInt64("customer_id") |
|||
extraData := t.Default("extra_data", "") |
|||
op := &models.CustomerOperation{ |
|||
CustomerId: customerId, |
|||
ExtraData: extraData, |
|||
UpdatedAt: time.Now(), |
|||
CreatedAt: time.Now(), |
|||
} |
|||
if row := op.SaveCustomerOperation(); row != 1 { |
|||
logger.Sugar.Debugf("save customer_operation出现错误") |
|||
t.ERROR("customer operation格式错误", code.MSG_ERR) |
|||
} |
|||
t.STRING("success") |
|||
} |
@ -0,0 +1,596 @@ |
|||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
|||
// This file was generated by swaggo/swag at
|
|||
// 2019-11-07 14:33:12.2505817 +0800 CST m=+0.073000101
|
|||
|
|||
package docs |
|||
|
|||
import ( |
|||
"bytes" |
|||
"encoding/json" |
|||
|
|||
"github.com/alecthomas/template" |
|||
"github.com/swaggo/swag" |
|||
) |
|||
|
|||
var doc = `{ |
|||
"schemes": {{ marshal .Schemes }}, |
|||
"swagger": "2.0", |
|||
"info": { |
|||
"description": "This is a sample server Petstore server.", |
|||
"title": "hudongzhuangjia api", |
|||
"termsOfService": "http://swagger.io/terms/", |
|||
"contact": { |
|||
"name": "API Support", |
|||
"url": "http://www.swagger.io/support", |
|||
"email": "support@swagger.io" |
|||
}, |
|||
"license": { |
|||
"name": "Apache 2.0", |
|||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" |
|||
}, |
|||
"version": "1.0" |
|||
}, |
|||
"host": "172.0.0.1:20181", |
|||
"basePath": "/PcClient", |
|||
"paths": { |
|||
"/Client/InviteEnvelopeCtl/invite": { |
|||
"post": { |
|||
"description": "填写要求信息", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"invite envelope" |
|||
], |
|||
"summary": "InviteEnvelope", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "邀请函内容", |
|||
"name": "activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"404": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"405": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Client/InviteEnvelopeCtl/setting": { |
|||
"get": { |
|||
"description": "get invite envelope setting", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"invite envelope" |
|||
], |
|||
"summary": "InviteEnvelope", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Activity ID", |
|||
"name": "activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/models.Invitation" |
|||
} |
|||
}, |
|||
"404": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"405": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Client/TugOfWarCtl/shake": { |
|||
"get": { |
|||
"description": "shake bahe activity", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"tug war" |
|||
], |
|||
"summary": "tug war", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Bahe Activity ID", |
|||
"name": "bahe_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/models.BaheTeam" |
|||
} |
|||
}, |
|||
"404": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"405": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Client/TugOfWarCtl/status": { |
|||
"get": { |
|||
"description": "get current status", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"client tug war" |
|||
], |
|||
"summary": "client tug war", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Bahe Activity ID", |
|||
"name": "bahe_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/models.TugOfWar" |
|||
} |
|||
}, |
|||
"503": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"504": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/ActivityCtl/list": { |
|||
"get": { |
|||
"description": "get all area store", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"pc" |
|||
], |
|||
"summary": "activity", |
|||
"responses": { |
|||
"200": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/AuctionCtl/startAuction": { |
|||
"get": { |
|||
"description": "开始竞拍", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"pc" |
|||
], |
|||
"summary": "auction", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "竞拍id", |
|||
"name": "auction_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"200": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/AuctionCtl/stopAuction": { |
|||
"get": { |
|||
"description": "结束竞拍", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"pc" |
|||
], |
|||
"summary": "auction", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "竞拍id", |
|||
"name": "auction_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"200": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/WsCtl/ops": { |
|||
"get": { |
|||
"description": "get current operation", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"ws" |
|||
], |
|||
"summary": "ws", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Activity ID", |
|||
"name": "activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "array", |
|||
"items": { |
|||
"$ref": "#/definitions/models.CustomerOperation" |
|||
} |
|||
} |
|||
}, |
|||
"503": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"504": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/WsCtl/saveOp": { |
|||
"post": { |
|||
"description": "save operation", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"ws" |
|||
], |
|||
"summary": "ws", |
|||
"parameters": [ |
|||
{ |
|||
"type": "string", |
|||
"description": "操作内容", |
|||
"name": "operation", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"503": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"504": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"definitions": { |
|||
"models.BaheTeam": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"bahe_activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"bahe_team_name": { |
|||
"type": "string" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"is_delete": { |
|||
"type": "boolean" |
|||
}, |
|||
"members": { |
|||
"type": "array", |
|||
"items": { |
|||
"$ref": "#/definitions/models.BaheTeamMember" |
|||
} |
|||
}, |
|||
"qrcode": { |
|||
"type": "string" |
|||
}, |
|||
"rank": { |
|||
"type": "integer" |
|||
}, |
|||
"total_score": { |
|||
"type": "integer" |
|||
} |
|||
} |
|||
}, |
|||
"models.BaheTeamMember": { |
|||
"type": "object", |
|||
"properties": { |
|||
"avatar": { |
|||
"type": "string" |
|||
}, |
|||
"bahe_activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"member_id": { |
|||
"type": "integer" |
|||
}, |
|||
"nick_name": { |
|||
"type": "string" |
|||
}, |
|||
"rehearsal_id": { |
|||
"type": "integer" |
|||
}, |
|||
"score": { |
|||
"type": "integer" |
|||
}, |
|||
"team_id": { |
|||
"type": "integer" |
|||
}, |
|||
"team_name": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
}, |
|||
"models.CustomerOperation": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"area_id": { |
|||
"type": "integer" |
|||
}, |
|||
"created_at": { |
|||
"type": "string" |
|||
}, |
|||
"customer_id": { |
|||
"type": "integer" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"is_delete": { |
|||
"type": "boolean" |
|||
}, |
|||
"module_activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"module_activity_type": { |
|||
"type": "string" |
|||
}, |
|||
"operation": { |
|||
"type": "string" |
|||
}, |
|||
"other_data": { |
|||
"type": "object" |
|||
}, |
|||
"updated_at": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
}, |
|||
"models.Invitation": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"qr_dest_url": { |
|||
"type": "string" |
|||
}, |
|||
"qr_image_url": { |
|||
"type": "string" |
|||
}, |
|||
"self_box": { |
|||
"type": "string" |
|||
}, |
|||
"setting_box": { |
|||
"type": "string" |
|||
}, |
|||
"submit_time_limit": { |
|||
"type": "string" |
|||
}, |
|||
"time_limit_end": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
}, |
|||
"models.TugOfWar": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"created_at": { |
|||
"type": "string" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"is_delete": { |
|||
"type": "boolean" |
|||
}, |
|||
"model": { |
|||
"type": "string" |
|||
}, |
|||
"number": { |
|||
"type": "integer" |
|||
}, |
|||
"status": { |
|||
"type": "string" |
|||
}, |
|||
"updated_at": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}` |
|||
|
|||
type swaggerInfo struct { |
|||
Version string |
|||
Host string |
|||
BasePath string |
|||
Schemes []string |
|||
Title string |
|||
Description string |
|||
} |
|||
|
|||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
|||
var SwaggerInfo = swaggerInfo{ Schemes: []string{}} |
|||
|
|||
type s struct{} |
|||
|
|||
func (s *s) ReadDoc() string { |
|||
t, err := template.New("swagger_info").Funcs(template.FuncMap{ |
|||
"marshal": func(v interface {}) string { |
|||
a, _ := json.Marshal(v) |
|||
return string(a) |
|||
}, |
|||
}).Parse(doc) |
|||
if err != nil { |
|||
return doc |
|||
} |
|||
|
|||
var tpl bytes.Buffer |
|||
if err := t.Execute(&tpl, SwaggerInfo); err != nil { |
|||
return doc |
|||
} |
|||
|
|||
return tpl.String() |
|||
} |
|||
|
|||
func init() { |
|||
swag.Register(swag.Name, &s{}) |
|||
} |
@ -0,0 +1,544 @@ |
|||
{ |
|||
"swagger": "2.0", |
|||
"info": { |
|||
"description": "This is a sample server Petstore server.", |
|||
"title": "hudongzhuangjia api", |
|||
"termsOfService": "http://swagger.io/terms/", |
|||
"contact": { |
|||
"name": "API Support", |
|||
"url": "http://www.swagger.io/support", |
|||
"email": "support@swagger.io" |
|||
}, |
|||
"license": { |
|||
"name": "Apache 2.0", |
|||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" |
|||
}, |
|||
"version": "1.0" |
|||
}, |
|||
"host": "172.0.0.1:20181", |
|||
"basePath": "/PcClient", |
|||
"paths": { |
|||
"/Client/InviteEnvelopeCtl/invite": { |
|||
"post": { |
|||
"description": "填写要求信息", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"invite envelope" |
|||
], |
|||
"summary": "InviteEnvelope", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "邀请函内容", |
|||
"name": "activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"404": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"405": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Client/InviteEnvelopeCtl/setting": { |
|||
"get": { |
|||
"description": "get invite envelope setting", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"invite envelope" |
|||
], |
|||
"summary": "InviteEnvelope", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Activity ID", |
|||
"name": "activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/models.Invitation" |
|||
} |
|||
}, |
|||
"404": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"405": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Client/TugOfWarCtl/shake": { |
|||
"get": { |
|||
"description": "shake bahe activity", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"tug war" |
|||
], |
|||
"summary": "tug war", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Bahe Activity ID", |
|||
"name": "bahe_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/models.BaheTeam" |
|||
} |
|||
}, |
|||
"404": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"405": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Client/TugOfWarCtl/status": { |
|||
"get": { |
|||
"description": "get current status", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"client tug war" |
|||
], |
|||
"summary": "client tug war", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Bahe Activity ID", |
|||
"name": "bahe_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/models.TugOfWar" |
|||
} |
|||
}, |
|||
"503": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"504": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/ActivityCtl/list": { |
|||
"get": { |
|||
"description": "get all area store", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"pc" |
|||
], |
|||
"summary": "activity", |
|||
"responses": { |
|||
"200": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/AuctionCtl/startAuction": { |
|||
"get": { |
|||
"description": "开始竞拍", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"pc" |
|||
], |
|||
"summary": "auction", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "竞拍id", |
|||
"name": "auction_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"200": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/AuctionCtl/stopAuction": { |
|||
"get": { |
|||
"description": "结束竞拍", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"pc" |
|||
], |
|||
"summary": "auction", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "竞拍id", |
|||
"name": "auction_activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"200": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/WsCtl/ops": { |
|||
"get": { |
|||
"description": "get current operation", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"ws" |
|||
], |
|||
"summary": "ws", |
|||
"parameters": [ |
|||
{ |
|||
"type": "integer", |
|||
"description": "Activity ID", |
|||
"name": "activity_id", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"schema": { |
|||
"type": "array", |
|||
"items": { |
|||
"$ref": "#/definitions/models.CustomerOperation" |
|||
} |
|||
} |
|||
}, |
|||
"503": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"504": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"/Pc/WsCtl/saveOp": { |
|||
"post": { |
|||
"description": "save operation", |
|||
"consumes": [ |
|||
"application/json" |
|||
], |
|||
"produces": [ |
|||
"application/json" |
|||
], |
|||
"tags": [ |
|||
"ws" |
|||
], |
|||
"summary": "ws", |
|||
"parameters": [ |
|||
{ |
|||
"type": "string", |
|||
"description": "操作内容", |
|||
"name": "operation", |
|||
"in": "query", |
|||
"required": true |
|||
} |
|||
], |
|||
"responses": { |
|||
"0": { |
|||
"description": "success", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"503": { |
|||
"description": "参数不存在", |
|||
"schema": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"504": { |
|||
"description": "用户不存在", |
|||
"schema": { |
|||
"type": "object", |
|||
"$ref": "#/definitions/string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"definitions": { |
|||
"models.BaheTeam": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"bahe_activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"bahe_team_name": { |
|||
"type": "string" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"is_delete": { |
|||
"type": "boolean" |
|||
}, |
|||
"members": { |
|||
"type": "array", |
|||
"items": { |
|||
"$ref": "#/definitions/models.BaheTeamMember" |
|||
} |
|||
}, |
|||
"qrcode": { |
|||
"type": "string" |
|||
}, |
|||
"rank": { |
|||
"type": "integer" |
|||
}, |
|||
"total_score": { |
|||
"type": "integer" |
|||
} |
|||
} |
|||
}, |
|||
"models.BaheTeamMember": { |
|||
"type": "object", |
|||
"properties": { |
|||
"avatar": { |
|||
"type": "string" |
|||
}, |
|||
"bahe_activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"member_id": { |
|||
"type": "integer" |
|||
}, |
|||
"nick_name": { |
|||
"type": "string" |
|||
}, |
|||
"rehearsal_id": { |
|||
"type": "integer" |
|||
}, |
|||
"score": { |
|||
"type": "integer" |
|||
}, |
|||
"team_id": { |
|||
"type": "integer" |
|||
}, |
|||
"team_name": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
}, |
|||
"models.CustomerOperation": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"area_id": { |
|||
"type": "integer" |
|||
}, |
|||
"created_at": { |
|||
"type": "string" |
|||
}, |
|||
"customer_id": { |
|||
"type": "integer" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"is_delete": { |
|||
"type": "boolean" |
|||
}, |
|||
"module_activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"module_activity_type": { |
|||
"type": "string" |
|||
}, |
|||
"operation": { |
|||
"type": "string" |
|||
}, |
|||
"other_data": { |
|||
"type": "object" |
|||
}, |
|||
"updated_at": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
}, |
|||
"models.Invitation": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"qr_dest_url": { |
|||
"type": "string" |
|||
}, |
|||
"qr_image_url": { |
|||
"type": "string" |
|||
}, |
|||
"self_box": { |
|||
"type": "string" |
|||
}, |
|||
"setting_box": { |
|||
"type": "string" |
|||
}, |
|||
"submit_time_limit": { |
|||
"type": "string" |
|||
}, |
|||
"time_limit_end": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
}, |
|||
"models.TugOfWar": { |
|||
"type": "object", |
|||
"properties": { |
|||
"activity_id": { |
|||
"type": "integer" |
|||
}, |
|||
"created_at": { |
|||
"type": "string" |
|||
}, |
|||
"id": { |
|||
"type": "integer" |
|||
}, |
|||
"is_delete": { |
|||
"type": "boolean" |
|||
}, |
|||
"model": { |
|||
"type": "string" |
|||
}, |
|||
"number": { |
|||
"type": "integer" |
|||
}, |
|||
"status": { |
|||
"type": "string" |
|||
}, |
|||
"updated_at": { |
|||
"type": "string" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,360 @@ |
|||
basePath: /PcClient |
|||
definitions: |
|||
models.BaheTeam: |
|||
properties: |
|||
activity_id: |
|||
type: integer |
|||
bahe_activity_id: |
|||
type: integer |
|||
bahe_team_name: |
|||
type: string |
|||
id: |
|||
type: integer |
|||
is_delete: |
|||
type: boolean |
|||
members: |
|||
items: |
|||
$ref: '#/definitions/models.BaheTeamMember' |
|||
type: array |
|||
qrcode: |
|||
type: string |
|||
rank: |
|||
type: integer |
|||
total_score: |
|||
type: integer |
|||
type: object |
|||
models.BaheTeamMember: |
|||
properties: |
|||
avatar: |
|||
type: string |
|||
bahe_activity_id: |
|||
type: integer |
|||
id: |
|||
type: integer |
|||
member_id: |
|||
type: integer |
|||
nick_name: |
|||
type: string |
|||
rehearsal_id: |
|||
type: integer |
|||
score: |
|||
type: integer |
|||
team_id: |
|||
type: integer |
|||
team_name: |
|||
type: string |
|||
type: object |
|||
models.CustomerOperation: |
|||
properties: |
|||
activity_id: |
|||
type: integer |
|||
area_id: |
|||
type: integer |
|||
created_at: |
|||
type: string |
|||
customer_id: |
|||
type: integer |
|||
id: |
|||
type: integer |
|||
is_delete: |
|||
type: boolean |
|||
module_activity_id: |
|||
type: integer |
|||
module_activity_type: |
|||
type: string |
|||
operation: |
|||
type: string |
|||
other_data: |
|||
type: object |
|||
updated_at: |
|||
type: string |
|||
type: object |
|||
models.Invitation: |
|||
properties: |
|||
activity_id: |
|||
type: integer |
|||
id: |
|||
type: integer |
|||
qr_dest_url: |
|||
type: string |
|||
qr_image_url: |
|||
type: string |
|||
self_box: |
|||
type: string |
|||
setting_box: |
|||
type: string |
|||
submit_time_limit: |
|||
type: string |
|||
time_limit_end: |
|||
type: string |
|||
type: object |
|||
models.TugOfWar: |
|||
properties: |
|||
activity_id: |
|||
type: integer |
|||
created_at: |
|||
type: string |
|||
id: |
|||
type: integer |
|||
is_delete: |
|||
type: boolean |
|||
model: |
|||
type: string |
|||
number: |
|||
type: integer |
|||
status: |
|||
type: string |
|||
updated_at: |
|||
type: string |
|||
type: object |
|||
host: 172.0.0.1:20181 |
|||
info: |
|||
contact: |
|||
email: support@swagger.io |
|||
name: API Support |
|||
url: http://www.swagger.io/support |
|||
description: This is a sample server Petstore server. |
|||
license: |
|||
name: Apache 2.0 |
|||
url: http://www.apache.org/licenses/LICENSE-2.0.html |
|||
termsOfService: http://swagger.io/terms/ |
|||
title: hudongzhuangjia api |
|||
version: "1.0" |
|||
paths: |
|||
/Client/InviteEnvelopeCtl/invite: |
|||
post: |
|||
consumes: |
|||
- application/json |
|||
description: 填写要求信息 |
|||
parameters: |
|||
- description: 邀请函内容 |
|||
in: query |
|||
name: activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"0": |
|||
description: success |
|||
schema: |
|||
type: string |
|||
"404": |
|||
description: 参数不存在 |
|||
schema: |
|||
type: string |
|||
"405": |
|||
description: 用户不存在 |
|||
schema: |
|||
type: string |
|||
summary: InviteEnvelope |
|||
tags: |
|||
- invite envelope |
|||
/Client/InviteEnvelopeCtl/setting: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: get invite envelope setting |
|||
parameters: |
|||
- description: Activity ID |
|||
in: query |
|||
name: activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"0": |
|||
schema: |
|||
$ref: '#/definitions/models.Invitation' |
|||
type: object |
|||
"404": |
|||
description: 参数不存在 |
|||
schema: |
|||
type: string |
|||
"405": |
|||
description: 用户不存在 |
|||
schema: |
|||
type: string |
|||
summary: InviteEnvelope |
|||
tags: |
|||
- invite envelope |
|||
/Client/TugOfWarCtl/shake: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: shake bahe activity |
|||
parameters: |
|||
- description: Bahe Activity ID |
|||
in: query |
|||
name: bahe_activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"0": |
|||
schema: |
|||
$ref: '#/definitions/models.BaheTeam' |
|||
type: object |
|||
"404": |
|||
description: 参数不存在 |
|||
schema: |
|||
type: string |
|||
"405": |
|||
description: 用户不存在 |
|||
schema: |
|||
$ref: '#/definitions/string' |
|||
type: object |
|||
summary: tug war |
|||
tags: |
|||
- tug war |
|||
/Client/TugOfWarCtl/status: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: get current status |
|||
parameters: |
|||
- description: Bahe Activity ID |
|||
in: query |
|||
name: bahe_activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"0": |
|||
schema: |
|||
$ref: '#/definitions/models.TugOfWar' |
|||
type: object |
|||
"503": |
|||
description: 参数不存在 |
|||
schema: |
|||
type: string |
|||
"504": |
|||
description: 用户不存在 |
|||
schema: |
|||
$ref: '#/definitions/string' |
|||
type: object |
|||
summary: client tug war |
|||
tags: |
|||
- client tug war |
|||
/Pc/ActivityCtl/list: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: get all area store |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"200": |
|||
description: success |
|||
schema: |
|||
type: string |
|||
summary: activity |
|||
tags: |
|||
- pc |
|||
/Pc/AuctionCtl/startAuction: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: 开始竞拍 |
|||
parameters: |
|||
- description: 竞拍id |
|||
in: query |
|||
name: auction_activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"200": |
|||
description: success |
|||
schema: |
|||
type: string |
|||
summary: auction |
|||
tags: |
|||
- pc |
|||
/Pc/AuctionCtl/stopAuction: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: 结束竞拍 |
|||
parameters: |
|||
- description: 竞拍id |
|||
in: query |
|||
name: auction_activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"200": |
|||
description: success |
|||
schema: |
|||
type: string |
|||
summary: auction |
|||
tags: |
|||
- pc |
|||
/Pc/WsCtl/ops: |
|||
get: |
|||
consumes: |
|||
- application/json |
|||
description: get current operation |
|||
parameters: |
|||
- description: Activity ID |
|||
in: query |
|||
name: activity_id |
|||
required: true |
|||
type: integer |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"0": |
|||
schema: |
|||
items: |
|||
$ref: '#/definitions/models.CustomerOperation' |
|||
type: array |
|||
"503": |
|||
description: 参数不存在 |
|||
schema: |
|||
type: string |
|||
"504": |
|||
description: 用户不存在 |
|||
schema: |
|||
$ref: '#/definitions/string' |
|||
type: object |
|||
summary: ws |
|||
tags: |
|||
- ws |
|||
/Pc/WsCtl/saveOp: |
|||
post: |
|||
consumes: |
|||
- application/json |
|||
description: save operation |
|||
parameters: |
|||
- description: 操作内容 |
|||
in: query |
|||
name: operation |
|||
required: true |
|||
type: string |
|||
produces: |
|||
- application/json |
|||
responses: |
|||
"0": |
|||
description: success |
|||
schema: |
|||
type: string |
|||
"503": |
|||
description: 参数不存在 |
|||
schema: |
|||
type: string |
|||
"504": |
|||
description: 用户不存在 |
|||
schema: |
|||
$ref: '#/definitions/string' |
|||
type: object |
|||
summary: ws |
|||
tags: |
|||
- ws |
|||
swagger: "2.0" |
@ -0,0 +1,34 @@ |
|||
module hudongzhuanjia |
|||
|
|||
go 1.12 |
|||
|
|||
require ( |
|||
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1 |
|||
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee |
|||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 |
|||
github.com/dgrijalva/jwt-go v3.2.0+incompatible |
|||
github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect |
|||
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect |
|||
github.com/gorilla/websocket v1.4.0 |
|||
github.com/iGoogle-ink/gopay v1.5.1 // indirect |
|||
github.com/iGoogle-ink/gopay/v2 v2.0.5 |
|||
github.com/kirinlabs/HttpRequest v0.1.5 |
|||
github.com/ouxuanserver/osmanthuswine v0.0.0-20190916032555-480efadf4941 |
|||
github.com/panjf2000/ants v4.0.2+incompatible |
|||
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 |
|||
github.com/smartystreets/goconvey v1.6.4 |
|||
github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e |
|||
github.com/swaggo/swag v1.6.3 |
|||
github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190926121715-a33db3b0dede |
|||
github.com/xormplus/xorm v0.0.0-20190419084314-284871d688a4 |
|||
go.uber.org/atomic v1.4.0 // indirect |
|||
go.uber.org/multierr v1.2.0 // indirect |
|||
go.uber.org/zap v1.10.0 |
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect |
|||
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a // indirect |
|||
golang.org/x/net v0.0.0-20191021144547-ec77196f6094 // indirect |
|||
golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae // indirect |
|||
golang.org/x/tools v0.0.0-20191025023517-2077df36852e // indirect |
|||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 |
|||
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 |
|||
) |
@ -0,0 +1,412 @@ |
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= |
|||
cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= |
|||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= |
|||
cloud.google.com/go v0.37.2/go.mod h1:H8IAquKe2L30IxoupDgqTaQvKSwF/c8prYHynGIWQbA= |
|||
cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= |
|||
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= |
|||
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= |
|||
git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= |
|||
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1 h1:gnknz1/4RnpL2fZsJzsqsGHgjWDT7k11tGPsFiDQeDk= |
|||
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1/go.mod h1:fkN+AZg31J/y9B4AtylxjzzNYetIxi6cElYu/WBUb7g= |
|||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= |
|||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= |
|||
github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 h1:Etfj2lhXyrYemgmWzEtEQQb1kezeEXc8jVjkQUyJnWI= |
|||
github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6/go.mod h1:YzuYAe2hrrwKXkM9kqjbkTLlkbA+/xw2MA46f1+ENxc= |
|||
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a h1:3SgJcK9l5uPdBC/X17wanyJAMxM33+4ZhEIV96MIH8U= |
|||
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= |
|||
github.com/CloudyKit/jet v2.1.2+incompatible h1:ybZoYzMBdoijK6I+Ke3vg9GZsmlKo/ZhKdNMWz0P26c= |
|||
github.com/CloudyKit/jet v2.1.2+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= |
|||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= |
|||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= |
|||
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= |
|||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= |
|||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= |
|||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= |
|||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= |
|||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= |
|||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= |
|||
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee h1:0RklYSvekYaIFI9JUx7TFPQvo++TdILmZiV17QI4nXk= |
|||
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee/go.mod h1:M9nmO4lBRWR/bBv7UCOmDJ1MB2DVoqz19B4JchDA+K0= |
|||
github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 h1:XBNSe5eibe5Fh131ah+xnO6s4A97U1T3tKZKLQQvqu0= |
|||
github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4/go.mod h1:n7qJAqL9BKqGqiJyjPbWtxpdswTL5wX0IVP2Uw4vVhQ= |
|||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= |
|||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= |
|||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= |
|||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= |
|||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= |
|||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= |
|||
github.com/aws/aws-sdk-go v1.19.14 h1:wUq6zI7Y5RfzFIkworUhK71bd/Vld9Otc6bgM/0ws1A= |
|||
github.com/aws/aws-sdk-go v1.19.14/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= |
|||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= |
|||
github.com/bndr/gotabulate v1.1.2 h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c= |
|||
github.com/bndr/gotabulate v1.1.2/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= |
|||
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= |
|||
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= |
|||
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= |
|||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= |
|||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= |
|||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= |
|||
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= |
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
|||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
|||
github.com/denisenkom/go-mssqldb v0.0.0-20190401154936-ce35bd87d4b3/go.mod h1:EcO5fNtMZHCMjAvj8LE6T+5bphSdR6LQ75n+m1TtsFI= |
|||
github.com/denisenkom/go-mssqldb v0.0.0-20190418034912-35416408c946 h1:xn+jBHAqNYs6CnHhJwfWZQspPHMEL+LzUk0vpqWj6eo= |
|||
github.com/denisenkom/go-mssqldb v0.0.0-20190418034912-35416408c946/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= |
|||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= |
|||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= |
|||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= |
|||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= |
|||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= |
|||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= |
|||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= |
|||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= |
|||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= |
|||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= |
|||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= |
|||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= |
|||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= |
|||
github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= |
|||
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= |
|||
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= |
|||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= |
|||
github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= |
|||
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= |
|||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= |
|||
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= |
|||
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= |
|||
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs= |
|||
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= |
|||
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= |
|||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= |
|||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= |
|||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= |
|||
github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= |
|||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= |
|||
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= |
|||
github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= |
|||
github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= |
|||
github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= |
|||
github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= |
|||
github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= |
|||
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= |
|||
github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4= |
|||
github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= |
|||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= |
|||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= |
|||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
|||
github.com/go-xorm/core v0.6.2 h1:EJLcSxf336POJr670wKB55Mah9f93xzvGYzNRgnT8/Y= |
|||
github.com/go-xorm/core v0.6.2/go.mod h1:bwPIfLdm/FzWgVUH8WPVlr+uJhscvNGFcaZKXsI3n2c= |
|||
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y= |
|||
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= |
|||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= |
|||
github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= |
|||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= |
|||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= |
|||
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= |
|||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= |
|||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= |
|||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= |
|||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= |
|||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= |
|||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= |
|||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= |
|||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= |
|||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= |
|||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= |
|||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= |
|||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= |
|||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= |
|||
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= |
|||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= |
|||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= |
|||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= |
|||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= |
|||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= |
|||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= |
|||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= |
|||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= |
|||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= |
|||
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= |
|||
github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= |
|||
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= |
|||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= |
|||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= |
|||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
|||
github.com/iGoogle-ink/gopay v1.4.8 h1:c98uztaUODTJuV8vsJQUswN6G+TxVqn6cl/DYv5kHxg= |
|||
github.com/iGoogle-ink/gopay v1.5.1 h1:uAKvQows+O7P8tPsdxXMwe/YqqeEIEswrdVDwF8bFOU= |
|||
github.com/iGoogle-ink/gopay v1.5.1/go.mod h1:/A7M5Ts6OUEaQD+88stwhPtFV1AxOCL+CAtjreZlGGQ= |
|||
github.com/iGoogle-ink/gopay/v2 v2.0.5 h1:jjiHTzkbXEOLC87hs3cAfAGC6+CqWzz/hQ/2x3w1lIU= |
|||
github.com/iGoogle-ink/gopay/v2 v2.0.5/go.mod h1:plZK1Q8XAw19RkO4MLMYEWWmIhshVK9FtLOrS1ooNwg= |
|||
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc= |
|||
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= |
|||
github.com/jackc/pgx v3.3.0+incompatible h1:Wa90/+qsITBAPkAZjiByeIGHFcj3Ztu+VzrrIpHjL90= |
|||
github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= |
|||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= |
|||
github.com/jinzhu/gorm v1.9.4 h1:3KDoUjMEfH58nweXdD5Dng222YiwOVUNFShENhehJyQ= |
|||
github.com/jinzhu/gorm v1.9.4/go.mod h1:7ZYqlk/T0SqZip7ZOIL1aC/sjDj+dJo6sN98WljHFXY= |
|||
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a h1:eeaG9XMUvRBYXJi4pg1ZKM7nxc5AfXfojeLLW7O5J3k= |
|||
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= |
|||
github.com/jinzhu/now v1.0.0 h1:6WV8LvwPpDhKjo5U9O6b4+xdG/jTXNPwlDme/MTo8Ns= |
|||
github.com/jinzhu/now v1.0.0/go.mod h1:oHTiXerJ20+SfYcrdlBO7rzZRJWGwSTQ0iUY2jI6Gfc= |
|||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= |
|||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= |
|||
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= |
|||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= |
|||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= |
|||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= |
|||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= |
|||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= |
|||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= |
|||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= |
|||
github.com/kirinlabs/HttpRequest v0.1.5 h1:BzOb6AmBii232R93birBsf663kt8N9y8N0TCQKoEzhA= |
|||
github.com/kirinlabs/HttpRequest v0.1.5/go.mod h1:XV38fA4rXZox83tlEV9KIQ7Cdsut319x6NGzVLuRlB8= |
|||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= |
|||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= |
|||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= |
|||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= |
|||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= |
|||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= |
|||
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= |
|||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= |
|||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= |
|||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= |
|||
github.com/lib/pq v1.1.0 h1:/5u4a+KGJptBRqGzPvYQL9p0d/tPR4S31+Tnzj9lEO4= |
|||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= |
|||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= |
|||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= |
|||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= |
|||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= |
|||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= |
|||
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= |
|||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= |
|||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= |
|||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
|||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= |
|||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= |
|||
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= |
|||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= |
|||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= |
|||
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
|||
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= |
|||
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
|||
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= |
|||
github.com/openzipkin/zipkin-go v0.1.3/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= |
|||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= |
|||
github.com/ouxuanserver/osmanthuswine v0.0.0-20190916032555-480efadf4941 h1:MpkZbGXvxwbsYNTtDphTCsGMi//M2ija6LJr3N6/DpI= |
|||
github.com/ouxuanserver/osmanthuswine v0.0.0-20190916032555-480efadf4941/go.mod h1:lIF2zcUhvVpFuLKpEYh3ArHRoZsGNo3PZS7FYqmQBXI= |
|||
github.com/panjf2000/ants v4.0.2+incompatible h1:6K9b4YyUmbTvfxGm2YZgmDgIiCEyP1x+gewN+tBr/8U= |
|||
github.com/panjf2000/ants v4.0.2+incompatible/go.mod h1:AaACblRPzq35m1g3enqYcxspbbiOJJYaxU2wMpm1cXY= |
|||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= |
|||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
|||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= |
|||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
|||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
|||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
|||
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= |
|||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= |
|||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= |
|||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= |
|||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= |
|||
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= |
|||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= |
|||
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
|||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
|||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
|||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= |
|||
github.com/satori/go.uuid v0.0.0-20190313024323-b2ce2384e17b h1:PB8A682UQ6pwoFhkszETBsYw3B9Ze9FEA4cf9H9O3f8= |
|||
github.com/satori/go.uuid v0.0.0-20190313024323-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= |
|||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE= |
|||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= |
|||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= |
|||
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= |
|||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= |
|||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= |
|||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= |
|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
|||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
|||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
|||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= |
|||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
|||
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM= |
|||
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= |
|||
github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= |
|||
github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e h1:m5sYJ43teIUlESuKRFQRRm7kqi6ExiYwVKfoXNuRgHU= |
|||
github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e/go.mod h1:eycbshptIv+tqTMlLEaGC2noPNcetbrcYEelLafrIDI= |
|||
github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= |
|||
github.com/swaggo/swag v1.6.3 h1:N+uVPGP4H2hXoss2pt5dctoSUPKKRInr6qcTMOm0usI= |
|||
github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio= |
|||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= |
|||
github.com/tealeg/xlsx v1.0.3 h1:BXsDIQYBPq2HgbwUxrsVXIrnO0BDxmsdUfHSfvwfBuQ= |
|||
github.com/tealeg/xlsx v1.0.3/go.mod h1:uxu5UY2ovkuRPWKQ8Q7JG0JbSivrISjdPzZQKeo74mA= |
|||
github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190926121715-a33db3b0dede h1:4FiecrX2TsfWVkXozpV2JOOI09KvC4jD1JotxY2bSnQ= |
|||
github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190926121715-a33db3b0dede/go.mod h1:wk2XFUg6egk4tSDNZtXeKfe2G6690UVyt163PuUxBZk= |
|||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= |
|||
github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0= |
|||
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= |
|||
github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI= |
|||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= |
|||
github.com/wailovet/db2struct v0.0.0-20190220022639-a297dc96489a h1:RndWCoBQ9Ltyj1m46BmGexEv3ZU8hPjV3fGo1xxh07A= |
|||
github.com/wailovet/db2struct v0.0.0-20190220022639-a297dc96489a/go.mod h1:Dqil0kg+pAM/6QVGUG6LY9EVUtT/SJqpXsaklNalmz0= |
|||
github.com/wailovet/overseer v0.0.0-20190412102736-c280479fa09f h1:N69pQZKxZw3tUsnCWJSw4dG+t4lbb4mCLbiHz1sHfMk= |
|||
github.com/wailovet/overseer v0.0.0-20190412102736-c280479fa09f/go.mod h1:IE0ZeKrlRAFsChkP21Tg3CKgybYJ7qiHHJAcH/xB4Sg= |
|||
github.com/xormplus/builder v0.0.0-20181220055446-b12ceebee76f h1:1kd2rgJuSRqTCUSqFkKuaUNsNogLzjPhC9Pr8qnhZDs= |
|||
github.com/xormplus/builder v0.0.0-20181220055446-b12ceebee76f/go.mod h1:Sz1j9HNsNKOUBDcBcezcwVpydQ/UkFrDo1M2XmuU3mc= |
|||
github.com/xormplus/core v0.0.0-20190120064039-da7907271e2f h1:RTzjDWlXKTcurd/cWTOuaxTACdWw+gs7HaNCLaK1PJQ= |
|||
github.com/xormplus/core v0.0.0-20190120064039-da7907271e2f/go.mod h1:V3p6iAR/MaICgU6GJqxGQxspfljTyfOTv4Czz0B5atU= |
|||
github.com/xormplus/xorm v0.0.0-20190419084314-284871d688a4 h1:7cw+J6ScPpTq9QgHSS4wrGUkrbCE2oVL/dct7YP4d+M= |
|||
github.com/xormplus/xorm v0.0.0-20190419084314-284871d688a4/go.mod h1:+v6b10b4x5IcQmp1/Cbo9IqaknxVeuhQng+fhya6bdI= |
|||
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= |
|||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= |
|||
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= |
|||
go.opencensus.io v0.19.1/go.mod h1:gug0GbSHa8Pafr0d2urOSgoXHZ6x/RUlaiT0d9pqb4A= |
|||
go.opencensus.io v0.19.2/go.mod h1:NO/8qkisMZLZ1FCsKNqtJPwc8/TaclWyY0B6wcYNg9M= |
|||
go.opencensus.io v0.20.1 h1:pMEjRZ1M4ebWGikflH7nQpV6+Zr88KBMA2XJD3sbijw= |
|||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= |
|||
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= |
|||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= |
|||
go.uber.org/multierr v1.2.0 h1:6I+W7f5VwC5SV9dNrZ3qXrDB9mD0dyGOi/ZJmYw03T4= |
|||
go.uber.org/multierr v1.2.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= |
|||
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= |
|||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= |
|||
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= |
|||
golang.org/x/build v0.0.0-20190314133821-5284462c4bec/go.mod h1:atTaCNAy0f16Ah5aV1gMSwgiKVHwu/JncqDpuRr7lS4= |
|||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= |
|||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= |
|||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|||
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk= |
|||
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= |
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= |
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= |
|||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= |
|||
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0= |
|||
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= |
|||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= |
|||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f h1:hX65Cu3JDlGH3uEdK7I99Ii+9kjD6mvnnpfLdEAH0x4= |
|||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba h1:h0zCzEL5UW1mERvwTN6AXcc75PpLkY6OcReia6Dq1BM= |
|||
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a h1:+KkCgOMgnKSgenxTBoiwkMqTiouMIy/3o8RLdmSbGoY= |
|||
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
|||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
|||
golang.org/x/net v0.0.0-20191021144547-ec77196f6094 h1:5O4U9trLjNpuhpynaDsqwCk+Tw6seqJz1EbqbnzHrc8= |
|||
golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
|||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
|||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
|||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
|||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI= |
|||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= |
|||
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= |
|||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181218192612-074acd46bca6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be h1:mI+jhqkn68ybP0ORJqunXn+fq+Eeb4hHKqLQcFICjAc= |
|||
golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae h1:xiXzMMEQdQcric9hXtr1QU98MHunKK7OTtsoU6bYWs4= |
|||
golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae h1:QoJmnb9uyPCrH8GIg9uRLn4Ta45yhcQtpymCd0AavO8= |
|||
golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
|||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
|||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= |
|||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
|||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
|||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
|||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20181219222714-6e267b5cc78e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= |
|||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= |
|||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= |
|||
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= |
|||
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0= |
|||
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= |
|||
golang.org/x/tools v0.0.0-20191025023517-2077df36852e h1:ejUPpxsbZzyShOEURCSvFIT0ltnmBW92Vsc3i8QRcw8= |
|||
golang.org/x/tools v0.0.0-20191025023517-2077df36852e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |
|||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
|||
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= |
|||
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= |
|||
google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= |
|||
google.golang.org/api v0.2.0/go.mod h1:IfRCZScioGtypHNTlz3gFk67J8uePVW7uDTBzXuIkhU= |
|||
google.golang.org/api v0.3.0/go.mod h1:IuvZyQh8jgscv8qWfQ4ABd8m7hEudgBFM/EdhA3BnXw= |
|||
google.golang.org/api v0.3.1 h1:oJra/lMfmtm13/rgY/8i3MzjFWYXvQIAKjQ3HqofMk8= |
|||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= |
|||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= |
|||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= |
|||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= |
|||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= |
|||
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= |
|||
google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= |
|||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= |
|||
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 h1:xtNn7qFlagY2mQNFHMSRPjT2RkOV4OXM7P5TVy9xATo= |
|||
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= |
|||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= |
|||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= |
|||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= |
|||
google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= |
|||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= |
|||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= |
|||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
|||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= |
|||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
|||
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 h1:eyQQg/uGuZ3ndaBhqteakHpVW+dSOPalilfC9RpM2TA= |
|||
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4/go.mod h1:bJkYqV5pg6+Z7MsSu/hSb1zsPT955hBW2QHLE1jm4wA= |
|||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= |
|||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= |
|||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= |
|||
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= |
|||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= |
|||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= |
|||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= |
|||
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 h1:sY2a+y0j4iDrajJcorb+a0hJIQ6uakU5gybjfLWHlXo= |
|||
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376/go.mod h1:BHKOc1m5wm8WwQkMqYBoo4vNxhmF7xg8+xhG8L+Cy3M= |
|||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= |
|||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= |
|||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
|||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= |
|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
|||
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= |
|||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
|||
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
|||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
|||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
@ -0,0 +1,3 @@ |
|||
lang=go |
|||
genJson=1 |
|||
prefix=ox_ |
@ -0,0 +1,20 @@ |
|||
|
|||
package {{.Models}} |
|||
|
|||
{{$ilen := len .Imports}} |
|||
{{if gt $ilen 0}} |
|||
import ( |
|||
{{range .Imports}}"{{.}}"{{end}} |
|||
) |
|||
{{end}} |
|||
|
|||
{{range .Tables}} |
|||
type {{Mapper .Name}} struct { |
|||
{{$table := .}} |
|||
{{range .ColumnsSeq}}{{$col := $table.GetColumn .}} {{Mapper $col.Name}} {{Type $col}} {{Tag $table $col}} |
|||
{{end}} |
|||
} |
|||
|
|||
var {{Mapper .Name}}Entity {{Mapper .Name}} |
|||
|
|||
{{end}} |
@ -0,0 +1,67 @@ |
|||
package jwt |
|||
|
|||
import ( |
|||
"errors" |
|||
"fmt" |
|||
"time" |
|||
|
|||
"github.com/dgrijalva/jwt-go" |
|||
"github.com/ouxuanserver/osmanthuswine/src/helper" |
|||
) |
|||
|
|||
type JwtClaims struct { |
|||
AccountType string |
|||
AccountId int64 |
|||
CustomerId int64 |
|||
CustomerPid int64 |
|||
Username string |
|||
ActivityId int64 |
|||
AreaId int64 |
|||
jwt.StandardClaims |
|||
} |
|||
|
|||
func GenJwtToken(accountType string, accountId, customerId, customerPid, areaId, activityId int64, username string) (string, error) { |
|||
claims := JwtClaims{ |
|||
accountType, |
|||
accountId, |
|||
customerId, |
|||
customerPid, |
|||
username, |
|||
activityId, |
|||
areaId, |
|||
jwt.StandardClaims{ |
|||
ExpiresAt: time.Now().Add(time.Duration(24000) * time.Hour).Unix(), |
|||
Id: helper.CreateUUID(), |
|||
Issuer: Issuer, |
|||
Subject: Subject, |
|||
Audience: Audience, |
|||
}, |
|||
} |
|||
|
|||
t := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) |
|||
return t.SignedString([]byte(Secret)) |
|||
} |
|||
|
|||
const Secret = "osmanthuswine-very-secret" |
|||
const Issuer = "osmanthuswine-issuer-ox" |
|||
const Subject = "osmanthuswine-subject-ox" |
|||
const Audience = "osmanthuswine-audience-ox" |
|||
|
|||
func ParseAccessToken(accessToken string) (*JwtClaims, error) { |
|||
var claims = &JwtClaims{} |
|||
token, err := jwt.ParseWithClaims(accessToken, claims, func(token *jwt.Token) (i interface{}, e error) { |
|||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { |
|||
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) |
|||
} |
|||
return []byte(Secret), nil |
|||
}) |
|||
|
|||
if token == nil { |
|||
return claims, errors.New("token invalid") |
|||
} |
|||
|
|||
if !claims.VerifyExpiresAt(time.Now().Unix(), true) { |
|||
return nil, errors.New("token expired") |
|||
} |
|||
return claims, err |
|||
} |
@ -0,0 +1,8 @@ |
|||
package jwt |
|||
|
|||
import ( |
|||
"testing" |
|||
) |
|||
|
|||
func TestJwt(t *testing.T) { |
|||
} |
@ -0,0 +1,139 @@ |
|||
package qq |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"fmt" |
|||
"github.com/ouxuanserver/osmanthuswine/src/helper" |
|||
"io/ioutil" |
|||
"net/http" |
|||
"net/url" |
|||
) |
|||
|
|||
var ( |
|||
Appid = "" |
|||
AppKey = "" |
|||
RedirectUri = "" |
|||
DefaultScope = "get_user_info" |
|||
CodeUrl = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%s&redirect_uri=%s&state=%s&scope=%s" |
|||
TokenUrl = "https://graph.qq.com/oauth2.0/authorize?grant_type=authorization_code&client_id=%s&client_serect=%s&code=%s&redirect_uri=%s" |
|||
RefreshUrl = "https://graph.qq.com/oauth2.0/token?grant_type=refresh_token&client_id=%s&client_serect=%s&refresh_token=%s" |
|||
PcOpenidUrl = "https://graph.qq.com/oauth2.0/me?access_token=%s" |
|||
WapOpenidUrl = "https://graph.z.qq.com/moc2/me?access_token=%s" |
|||
UserInfoUrl = "https://graph.qq.com/user/get_user_info?access_token=%s&oauth_consumer_key=%s&openid=%s&format=json" |
|||
) |
|||
|
|||
func GetCodeUrl() string { |
|||
uid := helper.CreateUUID() |
|||
return fmt.Sprintf(CodeUrl, Appid, url.PathEscape(RedirectUri), uid, DefaultScope) |
|||
} |
|||
|
|||
func GetTokenUrl(code string) string { |
|||
return fmt.Sprintf(TokenUrl, Appid, AppKey, code, RedirectUri) |
|||
} |
|||
|
|||
func GetRefreshUrl(refreshToken string) string { |
|||
return fmt.Sprintf(RefreshUrl, Appid, AppKey, refreshToken) |
|||
} |
|||
|
|||
func GetPcOpenidUrl(accessToken string) string { |
|||
return fmt.Sprintf(PcOpenidUrl, accessToken) |
|||
} |
|||
|
|||
func GetWapOpenidUrl(accessToken string) string { |
|||
return fmt.Sprintf(WapOpenidUrl, accessToken) |
|||
} |
|||
|
|||
func GetUserInfoUrl(accessToken, openid string) string { |
|||
return fmt.Sprintf(UserInfoUrl, accessToken, Appid, openid) |
|||
} |
|||
|
|||
type Token struct { |
|||
AccessToken string `json:"access_token"` |
|||
ExpiresIn int64 `json:"expires_in"` |
|||
RefreshToken string `json:"refresh_token"` |
|||
} |
|||
|
|||
func GetToken(code string) (*Token, error) { |
|||
tokenUrl := GetTokenUrl(code) |
|||
resp, err := http.Get(tokenUrl) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
body, err := ioutil.ReadAll(resp.Body) |
|||
defer resp.Body.Close() |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
token := new(Token) |
|||
err = json.Unmarshal(body, token) |
|||
return token, err |
|||
} |
|||
|
|||
func RefreshToken(refreshToken string) (*Token, error) { |
|||
refreshUrl := GetRefreshUrl(refreshToken) |
|||
resp, err := http.Get(refreshUrl) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
body, err := ioutil.ReadAll(resp.Body) |
|||
defer resp.Body.Close() |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
token := new(Token) |
|||
err = json.Unmarshal(body, token) |
|||
return token, err |
|||
} |
|||
|
|||
type Open struct { |
|||
Openid string `json:"openid"` |
|||
ClientId string `json:"client_id"` |
|||
} |
|||
|
|||
func GetPcOpenid(accessToken string) (*Open, error) { |
|||
pcOpenidUrl := GetPcOpenidUrl(accessToken) |
|||
resp, err := http.Get(pcOpenidUrl) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
body, err := ioutil.ReadAll(resp.Body) |
|||
defer resp.Body.Close() |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
open := new(Open) |
|||
err = json.Unmarshal(body, open) |
|||
return open, err |
|||
} |
|||
|
|||
type UserInfo struct { |
|||
Ret int `json:"ret"` |
|||
Msg string `json:"msg"` |
|||
Nickname string `json:"nickname"` |
|||
Figureurl string `json:"figureurl"` |
|||
Figureurl1 string `json:"figureurl_1"` |
|||
Figureurl2 string `json:"figureurl_2"` |
|||
FigureurlQq1 string `json:"figureurl_qq_1"` |
|||
FigureurlQq2 string `json:"figureurl_qq_2"` |
|||
Gender string `json:"gender"` |
|||
IsYellowVip string `json:"is_yellow_vip"` |
|||
Vip string `json:"vip"` |
|||
YellowVipLevel string `json:"yellow_vip_level"` |
|||
Level string `json:"level"` |
|||
IsYellowYearVip string `json:"is_yellow_year_vip"` |
|||
} |
|||
|
|||
func GetUserInfo(accessToken, openid string) (*UserInfo, error) { |
|||
userInfoUrl := GetUserInfoUrl(accessToken, openid) |
|||
resp, err := http.Get(userInfoUrl) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
body, err := ioutil.ReadAll(resp.Body) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
userInfo := new(UserInfo) |
|||
err = json.Unmarshal(body, userInfo) |
|||
return userInfo, err |
|||
} |
@ -0,0 +1,32 @@ |
|||
package wx |
|||
|
|||
const CODE_SUCCESS = "SUCCESS" // 成功
|
|||
const CODE_FAIL = "FAIL" // 失败
|
|||
const CODE_NOTPAY = "NOTPAY" // 未支付
|
|||
const CODE_CHANGE = "CHANGE" // 退款异常
|
|||
const CODE_REFUNDCLOSE = "REFUNDCLOSE" // 退款关闭
|
|||
const CODE_ERROR = "ERROR" // 业务错误
|
|||
const CODE_INVALID_REQUEST = "INVALID_REQUEST" // 无效请求
|
|||
const CODE_NOAUTH = "NOAUTH" // 异常IP请求不予受理
|
|||
const CODE_NOTENOUGH = "NOTENOUGH" // 余额不足
|
|||
const CODE_ORDERPAID = "ORDERPAID" // 订单已支付
|
|||
const CODE_ORDERCLOSED = "ORDERCLOSED" // 订单已关闭
|
|||
const CODE_SYSTEMERROR = "SYSTEMERROR" // 系统错误
|
|||
const CODE_APPID_NOT_EXIST = "APPID_NOT_EXIST" // APPID不存在
|
|||
const CODE_MCHID_NOT_EXIST = "MCHID_NOT_EXIST" // MCHID不存在
|
|||
const CODE_APPID_MCHID_NOT_MATCH = "APPID_MCHID_NOT_MATCH" // APPID MCHID 不匹配
|
|||
const CODE_LACK_PARAMS = "LACK_PARAMS" // 缺少参数
|
|||
const CODE_OUT_TRADE_NO_USED = "OUT_TRADE_NO_USED" // 商户订单号重复
|
|||
const CODE_SIGNERROR = "SIGNERROR" // 签名错误
|
|||
const CODE_XML_FORMAT_ERROR = "XML_FORMAT_ERROR" // xml格式错误
|
|||
const CODE_REQUIRE_POST_METHOD = "REQUIRE_POST_METHOD" // 请使用post请求方法
|
|||
const CODE_POST_DATA_EMPTY = "POST_DATA_EMPTY" // post数据为空
|
|||
const CODE_NOT_UTF8 = "NOT_UTF8" // 编码错误
|
|||
const CODE_ORDERNOTEXIST = "ORDERNOTEXIST" // 交易订单号不存在
|
|||
const CODE_BIZERR_NEED_RETRY = "BIZERR_NEED_RETRY" // 退款业务流程错误,需要商户触发重试来解决
|
|||
const CODE_TRADE_OVERDUE = "TRADE_OVERDUE" // 订单已经超过退款期限
|
|||
const CODE_USER_ACCOUNT_ABNORMAL = "USER_ACCOUNT_ABNORMAL" // 退款请求失败用户帐号注销
|
|||
const CODE_INVALID_REQ_TOO_MUCH = "INVALID_REQ_TOO_MUCH" // 无效请求过多
|
|||
const CODE_INVALID_TRANSACTIONID = "INVALID_TRANSACTIONID" // 无效transaction_id
|
|||
const CODE_PARAM_ERROR = "PARAM_ERROR" // 参数错误
|
|||
const CODE_FREQUENCY_LIMITED = "FREQUENCY_LIMITED" // 请求频率限制
|
@ -0,0 +1,135 @@ |
|||
package wx |
|||
|
|||
// import (
|
|||
// "bytes"
|
|||
// "crypto/tls"
|
|||
// "crypto/x509"
|
|||
// "encoding/xml"
|
|||
// "io/ioutil"
|
|||
// "net/http"
|
|||
// "net/url"
|
|||
// "strconv"
|
|||
|
|||
// "github.com/ouxuanserver/osmanthuswine/src/helper"
|
|||
// )
|
|||
|
|||
// const KEY = "wechat_key"
|
|||
|
|||
// var transfers = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"
|
|||
|
|||
// type Order struct {
|
|||
// XMLName xml.Name `xml:"xml"`
|
|||
// MchAppid string `xml:"mch_appid"`
|
|||
// Mchid string `xml:"mchid"`
|
|||
// DeviceInfo string `xml:"device_info"`
|
|||
// NonceStr string `xml:"nonce_str"`
|
|||
// Sign string `xml:"sign"`
|
|||
// PartnerTradeNo string `xml:"partner_trade_no"`
|
|||
// Openid string `xml:"openid"`
|
|||
// CheckName string `xml:"check_name"`
|
|||
// ReUserName string `xml:"re_user_name"`
|
|||
// Amount int `xml:"amount"`
|
|||
// Desc string `xml:"desc"`
|
|||
// SpbillCreateIp string `xml:"spbill_create_ip"`
|
|||
// }
|
|||
|
|||
// type OrderResult struct {
|
|||
// ReturnCode string `xml:"return_code"`
|
|||
// ReturnMsg string `xml:"return_msg"`
|
|||
// ResultCode string `xml:"result_code"`
|
|||
// ErrCode string `xml:"err_code"`
|
|||
// ErrCodeDes string `xml:"err_code_des"`
|
|||
// MchAppid string `xml:"mch_appid"`
|
|||
// Mchid string `json:"mchid"`
|
|||
// DeviceInfo string `json:"device_info"`
|
|||
// NonceStr string `json:"nonce_str"`
|
|||
// PartnerTradeNo string `xml:"partner_trade_no"`
|
|||
// PaymentNo string `xml:"payment_no"`
|
|||
// PaymentTime string `xml:"payment_time"`
|
|||
// }
|
|||
|
|||
// //付款,成功返回自定义订单号,微信订单号,true,失败返回错误信息,false
|
|||
// func Withdraw(appid, mchid, openid, amount, partnerTradeNo, desc, clientIp string) (*OrderResult, error) {
|
|||
// order := Order{}
|
|||
// order.MchAppid = appid
|
|||
// order.Mchid = mchid
|
|||
// order.Openid = openid
|
|||
// order.Amount, _ = strconv.Atoi(amount)
|
|||
// order.Desc = desc
|
|||
// order.PartnerTradeNo = partnerTradeNo
|
|||
// order.DeviceInfo = "WEB"
|
|||
// order.CheckName = "NO_CHECK" //NO_CHECK:不校验真实姓名 FORCE_CHECK:强校验真实姓名
|
|||
// order.SpbillCreateIp = clientIp
|
|||
// order.NonceStr = helper.CreateUUID()
|
|||
// order.Sign = md5WithdrawOrder(order)
|
|||
// xmlBody, _ := xml.MarshalIndent(order, " ", " ")
|
|||
// resp, err := SecurePost(transfers, xmlBody)
|
|||
// if err != nil {
|
|||
// return nil, err
|
|||
// }
|
|||
// defer resp.Body.Close()
|
|||
// bodyByte, _ := ioutil.ReadAll(resp.Body)
|
|||
// res := new(OrderResult)
|
|||
// err = xml.Unmarshal(bodyByte, res)
|
|||
// return res, err
|
|||
// }
|
|||
// func md5WithdrawOrder(order Order) string {
|
|||
// o := url.Values{}
|
|||
// o.Add("mch_appid", order.MchAppid)
|
|||
// o.Add("mchid", order.Mchid)
|
|||
// o.Add("device_info", order.DeviceInfo)
|
|||
// o.Add("partner_trade_no", order.PartnerTradeNo)
|
|||
// o.Add("check_name", order.CheckName)
|
|||
// o.Add("amount", strconv.Itoa(order.Amount))
|
|||
// o.Add("spbill_create_ip", order.SpbillCreateIp)
|
|||
// o.Add("desc", order.Desc)
|
|||
// o.Add("nonce_str", order.NonceStr)
|
|||
// o.Add("openid", order.Openid)
|
|||
// r, _ := url.QueryUnescape(o.Encode())
|
|||
// return helper.Md5(r + "&key=" + KEY)
|
|||
// }
|
|||
|
|||
// var (
|
|||
// wechatCertPath = `./cert/cert.pem`
|
|||
// wechatKeyPath = `./cert/key.pem`
|
|||
// wechatCAPath = `./cert/rootca.pem`
|
|||
// )
|
|||
|
|||
|
|||
//采用单例模式初始化ca
|
|||
// func getTLSConfig() (*tls.Config, error) {
|
|||
// if _tlsConfig != nil {
|
|||
// return _tlsConfig, nil
|
|||
// }
|
|||
// // load cert
|
|||
// cert, err := tls.LoadX509KeyPair(wechatCertPath, wechatKeyPath)
|
|||
// if err != nil {
|
|||
// return nil, err
|
|||
// }
|
|||
// // load root ca
|
|||
// caData, err := ioutil.ReadFile(wechatCAPath)
|
|||
// if err != nil {
|
|||
// return nil, err
|
|||
// }
|
|||
// pool := x509.NewCertPool()
|
|||
// pool.AppendCertsFromPEM(caData)
|
|||
// _tlsConfig = &tls.Config{
|
|||
// Certificates: []tls.Certificate{cert},
|
|||
// RootCAs: pool,
|
|||
// }
|
|||
// return _tlsConfig, nil
|
|||
// }
|
|||
|
|||
// //携带ca证书的安全请求
|
|||
// func SecurePost(url string, xmlContent []byte) (*http.Response, error) {
|
|||
// tlsConfig, err := getTLSConfig()
|
|||
// if err != nil {
|
|||
// return nil, err
|
|||
// }
|
|||
// tr := &http.Transport{TLSClientConfig: tlsConfig}
|
|||
// client := &http.Client{Transport: tr}
|
|||
// return client.Post(
|
|||
// url,
|
|||
// "application/xml",
|
|||
// bytes.NewBuffer(xmlContent))
|
|||
// }
|
@ -0,0 +1,287 @@ |
|||
package wx |
|||
|
|||
import ( |
|||
"encoding/xml" |
|||
"fmt" |
|||
"hudongzhuanjia/utils/define" |
|||
) |
|||
|
|||
var ( |
|||
WxCertPath = `./cacert/apiclient_cert.pem` |
|||
WxKeyPath = `./cacert/apiclient_key.pem` |
|||
WxCaPath = `./cacert/rootca.pem` |
|||
Appid = "wx7b0bcf476552c5e9" |
|||
Secret = "f6aabdd40ea25272f4442603a7dc8028" |
|||
Mchid = `1394404502` |
|||
ApiKey = `2c82c64ceec6ba89ffc9f593c671a12f` |
|||
mainHost = `https://api.mch.weixin.qq.com` |
|||
backHost = `https://api2.mch.weixin.qq.com` |
|||
) |
|||
|
|||
var ( |
|||
RedirectUri = "http://api.hudongzhuanjia.com/" |
|||
CodeUrl = "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_login&state=%s#wechat_redirect" |
|||
AccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code " |
|||
RefreshTokenUrl = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s" |
|||
AuthUrl = "https://api.weixin.qq.com/sns/auth?access_token=%s&openid=%s" |
|||
UserInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s" |
|||
TicketTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s" |
|||
TicketUrl = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi" |
|||
Expired = 7200 |
|||
) |
|||
|
|||
var ( |
|||
NotifyURL = fmt.Sprintf("%s/wechat/callback", define.HOST) // 微信回调通知
|
|||
UnifiedOrderURL = fmt.Sprintf("%s/pay/unifiedorder", mainHost) // 统一下单url
|
|||
QueryOrderURL = fmt.Sprintf("%s/pay/orderquery", mainHost) // 微信查询订单
|
|||
CloseOrderURL = fmt.Sprintf("%s/pay/closeorder", mainHost) // 微信关闭订单
|
|||
RefundURL = fmt.Sprintf("%s/secapi/pay/refund", mainHost) // 微信退款
|
|||
RefundQueryURL = fmt.Sprintf("%s/pay/refundquery", mainHost) // 微信查询退款
|
|||
DownloadBillURL = fmt.Sprintf("%s/pay/downloadbill", mainHost) // 微信下载账单
|
|||
DownloadFundFlowURL = fmt.Sprintf("%s/pay/downloadfundflow", mainHost) |
|||
TransfersURL = fmt.Sprintf("%s/mmpaymkttransfers/promotion/transfers", mainHost) |
|||
SendRedPackURL = fmt.Sprintf("%s/mmpaymkttransfers/sendredpack", mainHost) |
|||
QueryRedPackURL = fmt.Sprintf("%s/mmpaymkttransfers/gethbinfo", mainHost) |
|||
) |
|||
|
|||
type CommonReturn struct { |
|||
ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` |
|||
ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` |
|||
} |
|||
|
|||
type CommonResult struct { |
|||
ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` |
|||
ResultMsg string `xml:"result_msg,omitempty" json:"result_msg,omitempty"` |
|||
ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` |
|||
ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` |
|||
} |
|||
|
|||
type CommonParam struct { |
|||
Appid string `xml:"appid,omitempty" json:"appid,omitempty"` |
|||
MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` |
|||
NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` |
|||
Sign string `xml:"sign,omitempty" json:"sign,omitempty"` |
|||
SignType string `xml:"sign_type,omitempty" json:"sign_type,omitempty"` |
|||
} |
|||
|
|||
// ========================================== 基础配置
|
|||
|
|||
type UnifiedOrderParam struct { |
|||
CommonParam |
|||
XMLName xml.Name `xml:"xml" json:"xml_name,omitempty"` |
|||
DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` |
|||
Body cdata `xml:"body,omitempty" json:"body,omitempty"` |
|||
Detail cdata `xml:"detail,omitempty" json:"detail,omitempty"` |
|||
Attach string `xml:"attach,omitempty" json:"attach,omitempty"` |
|||
OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` |
|||
FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` |
|||
TotalFee string |