Compare commits
6 Commits
d1025e0d77
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f35548fe2 | |||
| 6aa28533bd | |||
| 7e93ce31a3 | |||
| 1462018682 | |||
| 9113dab102 | |||
| 1fd809ebfe |
@ -88,10 +88,11 @@ type GetIpListRes struct {
|
||||
}
|
||||
type DetailReq struct {
|
||||
g.Meta `path:"/store/detail" method:"get" tags:"Backend/Store" summary:"(系统、商户门店后台)门店详情"`
|
||||
NetbarAccount string `json:"netbarAccount" v:"required" dc:"门店账号"`
|
||||
StoreId int64 `json:"storeId" v:"required" dc:"门店ID"`
|
||||
}
|
||||
type DetailRes struct {
|
||||
Id int64 `json:"id" dc:"门店ID"`
|
||||
NetbarAccount string `json:"netbarAccount" dc:"门店账号"`
|
||||
}
|
||||
|
||||
type StoreMemberLevelReq struct {
|
||||
|
||||
@ -8,7 +8,10 @@ type InfoReq struct {
|
||||
|
||||
type InfoRes struct {
|
||||
Id int64 `json:"id"`
|
||||
StoreId int64 `json:"storeId"`
|
||||
Username string `json:"username"`
|
||||
Realname string `json:"realname"`
|
||||
IsPrimary bool `json:"isPrimary"`
|
||||
}
|
||||
type ListReq struct {
|
||||
g.Meta `path:"/store/admin" method:"get" tags:"Backend/StoreAdmin" summary:"(系统、商户门店后台)门店管理员列表"`
|
||||
|
||||
@ -54,6 +54,8 @@ func (c *ControllerV1) Callback(ctx context.Context, req *v1.CallbackReq) (res *
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
glog.Infof(ctx, "回调响应:%s", marshal)
|
||||
|
||||
g.RequestFromCtx(ctx).Response.Write(marshal)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error) {
|
||||
out, err := service.Store().Detail(ctx, &model.StoreDetailIn{NetbarAccount: req.NetbarAccount})
|
||||
out, err := service.Store().Detail(ctx, &model.StoreDetailIn{StoreId: req.StoreId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.DetailRes{Id: out.Id}, nil
|
||||
return &v1.DetailRes{Id: out.Id, NetbarAccount: out.NetbarAccount}, nil
|
||||
}
|
||||
|
||||
@ -3,14 +3,17 @@ package storeAdmin
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/storeAdmin/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
|
||||
g.RequestFromCtx(ctx)
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
storeAdminId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||
out, err := service.StoreAdmin().Info(ctx, &model.StoreAdminInfoIn{StoreAdminId: storeAdminId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.InfoRes{Id: out.Id, StoreId: out.StoreId, Username: out.Username, Realname: out.RealName, IsPrimary: out.IsPrimary}, nil
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ func (c *ControllerV1) GetTaskList(ctx context.Context, req *v1.GetTaskListReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
glog.Infof(ctx, "The return task length of Game %d: %d", req.Gid, len(list.Data))
|
||||
glog.Info(ctx, list)
|
||||
return &v1.GetTaskListRes{
|
||||
List: list,
|
||||
|
||||
@ -608,30 +608,30 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode
|
||||
//if err2 != nil {
|
||||
if err2 != nil && err2.Error() == "奖励领取超出限制,-1" {
|
||||
// 修改奖励领取状态为5
|
||||
_, err2 = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{Id: in.Id}).Data(do.UserTaskRewards{
|
||||
Status: consts.RewardFailedStatus,
|
||||
}).Update()
|
||||
|
||||
if err2 != nil {
|
||||
return nil, ecode.Fail.Sub("修改用奖励领取状态失败")
|
||||
}
|
||||
|
||||
// 判断奖励是否领完,修改用户任务记录为 2
|
||||
exist, err2 := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3}).Exist()
|
||||
if err2 != nil {
|
||||
return nil, ecode.Fail.Sub("查询用户任务奖励失败")
|
||||
}
|
||||
|
||||
if !exist {
|
||||
// 修改用户任务记录为 2
|
||||
_, err2 = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
|
||||
Status: 2,
|
||||
}).Update()
|
||||
|
||||
if err2 != nil {
|
||||
return nil, ecode.Fail.Sub("修改用户任务状态失败")
|
||||
}
|
||||
}
|
||||
//_, err2 = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{Id: in.Id}).Data(do.UserTaskRewards{
|
||||
// Status: consts.RewardFailedStatus,
|
||||
//}).Update()
|
||||
//
|
||||
//if err2 != nil {
|
||||
// return nil, ecode.Fail.Sub("修改用奖励领取状态失败")
|
||||
//}
|
||||
//
|
||||
//// 判断奖励是否领完,修改用户任务记录为 2
|
||||
//exist, err2 := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3}).Exist()
|
||||
//if err2 != nil {
|
||||
// return nil, ecode.Fail.Sub("查询用户任务奖励失败")
|
||||
//}
|
||||
//
|
||||
//if !exist {
|
||||
// // 修改用户任务记录为 2
|
||||
// _, err2 = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
|
||||
// Status: 2,
|
||||
// }).Update()
|
||||
//
|
||||
// if err2 != nil {
|
||||
// return nil, ecode.Fail.Sub("修改用户任务状态失败")
|
||||
// }
|
||||
//}
|
||||
|
||||
return nil, ecode.RewardExceedLimited
|
||||
} else if err2 != nil {
|
||||
|
||||
@ -266,7 +266,7 @@ func (s *sStore) DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPD
|
||||
}
|
||||
|
||||
func (s *sStore) Detail(ctx context.Context, in *model.StoreDetailIn) (out *model.StoreDetailOut, err error) {
|
||||
one, err := dao.Stores.Ctx(ctx).Where(do.Stores{NetbarAccount: in.NetbarAccount}).One()
|
||||
one, err := dao.Stores.Ctx(ctx).Where(do.Stores{Id: in.StoreId}).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询门店出现异常")
|
||||
}
|
||||
@ -275,6 +275,7 @@ func (s *sStore) Detail(ctx context.Context, in *model.StoreDetailIn) (out *mode
|
||||
}
|
||||
return &model.StoreDetailOut{
|
||||
Id: one[dao.Stores.Columns().Id].Int64(),
|
||||
NetbarAccount: one[dao.Stores.Columns().NetbarAccount].String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@ -97,7 +97,11 @@ func (s *sStoreAdmin) Info(ctx context.Context, in *model.StoreAdminInfoIn) (out
|
||||
return nil, ecode.Fail.Sub("查询门店管理员失败")
|
||||
}
|
||||
out = &model.StoreAdminInfoOut{
|
||||
Id: storeAdmin.Id,
|
||||
StoreId: storeAdmin.StoreId,
|
||||
Username: storeAdmin.Username,
|
||||
RealName: storeAdmin.RealName,
|
||||
IsPrimary: storeAdmin.IsPrimary,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -500,6 +500,7 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
|
||||
if !ok {
|
||||
return nil, ecode.Fail.Sub("数据类型转换失败")
|
||||
}
|
||||
glog.Infof(ctx, "The tencent task length of Game %d: %d", in.Gid, len(result.TaskList))
|
||||
for i, v := range result.TaskList {
|
||||
// 获取任务奖励列表
|
||||
err := dao.TaskRewards.Ctx(ctx).Where(do.TaskRewards{TaskId: v.TaskID}).WhereOr(do.TaskRewards{TaskId: v.TaskID, NetbarAccount: in.NetBarAccount}).
|
||||
@ -523,10 +524,11 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
|
||||
result.TaskList[i].Status = 1
|
||||
} else {
|
||||
// 存在用户记录,自行判断用户是否完成任务
|
||||
userTaskStatus := one["status"].Int64()
|
||||
|
||||
if userTaskStatus == 1 {
|
||||
if v.UserTimes-one["user_times"].Int64() >= v.TargetTimes {
|
||||
completeTime := gtime.Now()
|
||||
userTaskStatus := one["status"].Int64()
|
||||
if userTaskStatus == 1 {
|
||||
if err := dao.UserTasks.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
// 用户任务完成修改任务记录完成时间
|
||||
_, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: v.TaskID}).Data(do.UserTasks{CompletedAt: completeTime}).Update()
|
||||
@ -560,7 +562,7 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
|
||||
updateData.IssueQuantity = quantity
|
||||
}
|
||||
}
|
||||
if _, err := dao.UserTaskRewards.Ctx(ctx).Data(updateData).Update(); err != nil {
|
||||
if _, err := dao.UserTaskRewards.Ctx(ctx).Data(updateData).Where(do.UserTaskRewards{Id: record["id"].Int64()}).Update(); err != nil {
|
||||
return ecode.Fail.Sub("修改用户任务奖励失败")
|
||||
}
|
||||
}
|
||||
@ -569,16 +571,17 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out
|
||||
return nil, err
|
||||
}
|
||||
result.TaskList[i].Status = 2
|
||||
} else {
|
||||
result.TaskList[i].UserTimes -= one["user_times"].Int64()
|
||||
result.TaskList[i].Status = 1
|
||||
}
|
||||
} else if userTaskStatus == 3 {
|
||||
result.TaskList[i].Status = 2
|
||||
} else {
|
||||
result.TaskList[i].Status = 3
|
||||
}
|
||||
} else {
|
||||
result.TaskList[i].UserTimes -= one["user_times"].Int64()
|
||||
result.TaskList[i].Status = 1
|
||||
}
|
||||
result.TaskList[i].UserTaskId = one["id"].Int64()
|
||||
|
||||
}
|
||||
}
|
||||
out.PageIdx = result.PageIdx
|
||||
|
||||
@ -112,9 +112,11 @@ type IPCreateOut struct {
|
||||
}
|
||||
type StoreDetailIn struct {
|
||||
NetbarAccount string
|
||||
StoreId int64
|
||||
}
|
||||
type StoreDetailOut struct {
|
||||
Id int64 `json:"id"`
|
||||
NetbarAccount string `json:"netbarAccount"`
|
||||
}
|
||||
|
||||
type StoreByNetbarAccountIn struct {
|
||||
|
||||
@ -5,7 +5,11 @@ type StoreAdminInfoIn struct {
|
||||
}
|
||||
|
||||
type StoreAdminInfoOut struct {
|
||||
Id int64
|
||||
StoreId int64
|
||||
Username string
|
||||
RealName string
|
||||
IsPrimary bool
|
||||
}
|
||||
|
||||
type StoreAdminLoginIn struct {
|
||||
|
||||
@ -103,6 +103,7 @@ func init() {
|
||||
enforcer.AddPolicy("store", "/x/store/netfeeSetting", "POST", "修改门店网费设置")
|
||||
// 门店:修改
|
||||
enforcer.AddPolicy("store", "/x/task/sync", "POST", "同步任务")
|
||||
enforcer.AddPolicy("store", "/x/store/detail", "GET", "获取门店详情")
|
||||
// 奖励类型
|
||||
enforcer.AddPolicy("store", "/x/rewardType", "GET", "获取奖励类型列表")
|
||||
enforcer.AddPolicy("store", "/x/rewardType", "POST", "添加奖励类型")
|
||||
|
||||
Reference in New Issue
Block a user