调整接口
This commit is contained in:
@ -263,3 +263,16 @@ func (s *sStore) DeleteIP(ctx context.Context, in *model.IPDeleteIn) (*model.IPD
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
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()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询门店出现异常")
|
||||
}
|
||||
if one.IsEmpty() {
|
||||
return nil, ecode.Params.Sub("门店不存在")
|
||||
}
|
||||
return &model.StoreDetailOut{
|
||||
Id: one[dao.Stores.Columns().Id].Int64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -13,10 +13,17 @@ import (
|
||||
)
|
||||
|
||||
type sStoreDesktopSetting struct {
|
||||
mqttCLient mqtt.MqttClient
|
||||
}
|
||||
|
||||
func New() service.IStoreDesktopSetting {
|
||||
return &sStoreDesktopSetting{}
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil
|
||||
}
|
||||
return &sStoreDesktopSetting{
|
||||
mqttCLient: client,
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterStoreDesktopSetting(New())
|
||||
@ -63,15 +70,11 @@ func (s *sStoreDesktopSetting) Save(ctx context.Context, in model.SaveDesktopSet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil, gerror.New("获取MQTT客户端失败")
|
||||
}
|
||||
marshal, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = client.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
err = s.mqttCLient.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -76,6 +76,17 @@ func (s *sTask) UserTaskRankingList(ctx context.Context, in *model.UserTaskRanki
|
||||
|
||||
if in.StoreId > 0 {
|
||||
m = m.Where(dao.UserTasks.Columns().StoreId, in.StoreId)
|
||||
} else if in.NetBarAccount != "" && in.StoreId <= 0 {
|
||||
value, err := dao.Stores.Ctx(ctx).Where(dao.Stores.Columns().NetbarAccount, in.NetBarAccount).Fields(dao.Stores.Columns().Id).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询门店ID失败")
|
||||
}
|
||||
if value.IsEmpty() {
|
||||
return nil, ecode.Fail.Sub("门店不存在")
|
||||
}
|
||||
|
||||
m = m.Where(dao.UserTasks.Columns().StoreId, value.Int())
|
||||
|
||||
}
|
||||
|
||||
list := make([]model.UserTaskRankingArgs, 0)
|
||||
@ -302,9 +313,22 @@ func (s *sTask) GetSelectorList(ctx context.Context, in *model.SelectorIn) (out
|
||||
|
||||
// GetTask 完成任务
|
||||
func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error) {
|
||||
|
||||
var storeId int
|
||||
if in.StoreId > 0 {
|
||||
storeId = in.StoreId
|
||||
} else if in.NetBarAccount != "" && in.StoreId <= 0 {
|
||||
value, err := dao.Stores.Ctx(ctx).Where(do.Stores{NetbarAccount: in.NetBarAccount}).Fields(dao.Stores.Columns().Id).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取门店ID异常")
|
||||
}
|
||||
if value.IsEmpty() {
|
||||
return nil, ecode.Fail.Sub("获取门店ID异常")
|
||||
}
|
||||
storeId = value.Int()
|
||||
}
|
||||
var userTask []*model.UserTask
|
||||
err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: in.StoreId, GameId: in.GameId}).WhereNot("status", 3).Scan(&userTask)
|
||||
|
||||
err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, GameId: in.GameId}).WhereNot("status", 3).Scan(&userTask)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询用户该任务记录失败")
|
||||
}
|
||||
@ -323,7 +347,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge
|
||||
_, err = dao.UserTasks.Ctx(ctx).Insert(do.UserTasks{
|
||||
UserId: in.UserId,
|
||||
TaskId: in.TaskId,
|
||||
StoreId: in.StoreId,
|
||||
StoreId: storeId,
|
||||
Status: 1,
|
||||
SerialNumber: serialNumber,
|
||||
TaskName: in.TaskName,
|
||||
|
||||
Reference in New Issue
Block a user