// Package service /** * @ File: shop * @ Date: 2021/4/13 10:41 * @ Author: JYQ * @ Description: */ package service import ( pb "sportfitness/base/api/grpc/base" "sportfitness/base/assembly/base/repository/postgre" "sportfitness/base/errors" "sportfitness/base/repository/grpc/bsw/im" "strconv" ) type Shop struct { base } func (s Shop) ShopGroupQuery(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopGroupQuery(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } func (s Shop) ManageableShopList(token string, r *pb.ShopListRequest) *pb.ShopListReply { // 获取商家可用商家列表shopId传入0,因为是通用接口 _ = s.checkPermission(token, 0) status := s.WebStatusToManageStatus(r.Status) rst := im.ShopListRequest(r.Name, status, r.SId) //println(rst) var info []*pb.ShopInfo if len(rst.List) > 0 { for _, v := range rst.List { l := &pb.ShopInfo{} l.ShopId = v.ShopId l.Name = v.Name l.SId = v.SId l.Addr = v.Addr l.Phone = v.Phone l.Contacts = v.Contacts l.CreatedAt = strconv.FormatInt(v.CreatedAt, 10) l.UpdatedAt = strconv.FormatInt(v.UpdatedAt, 10) l.ShopUUID = strconv.FormatInt(v.ShopId, 10) l.Status = s.ManageStatusToWebStatus(v.Status) //println(l.ShopUUID) info = append(info, l) } } return &pb.ShopListReply{List: info} } func (s Shop) ManageableGetShopInfo(token string, r *pb.ShopDetailRequest) *pb.ShopInfo { optId := s.checkPermission(token, r.GetShopId()) rst := im.ShopDetail(r.ShopId) navi := im.GetShopNavi(int64(optId), r.GetShopId(), 0) var isHr, isScore int64 = 0, 0 if len(navi.List) > 0 { for _, v := range navi.List { if v.Name == "心率管理" { isHr = 1 } if v.Name == "运动评估" { isScore = 1 } } } info := &pb.ShopInfo{ ShopId: rst.ShopId, Name: rst.Name, SId: rst.SId, Addr: rst.Addr, Phone: rst.Phone, Contacts: rst.Contacts, Status: s.ManageStatusToWebStatus(rst.Status), CreatedAt: strconv.FormatInt(rst.CreatedAt, 10), CreatedUser: rst.CreatedUser, UpdatedAt: strconv.FormatInt(rst.UpdatedAt, 10), UpdatedUser: rst.UpdatedUser, IsHr: isHr, IsScore: isScore, } return info } func (s Shop) LicenseTypeMap(token string, r *pb.IdList) *pb.LicenseTypeMapReply { _ = s.checkPermission(token, 0) rst := im.LicenseTypeMap(r.IdList) println(rst) //var info map[int64]pb.LicenseType //if rst != nil { // for _, v := range rst.List { // l := &pb.ShopInfo{} // l.ShopId = v.ShopId // l.Name = v.Name // l.SId = v.SId // l.Addr = v.Addr // l.Phone = v.Phone // l.Contacts = v.Contacts // l.CreatedAt = v.CreatedAt // l.UpdatedAt = v.UpdatedAt // l.Status = s.ManageStatusToWebStatus(v.Status) // info = append(info, l) // } //} return nil } // GetShopNavi 获取商家导航 func (s Shop) GetShopNavi(token string, r *pb.GetShopNaviRequest) *pb.GetShopNaviReply { optId := s.checkPermission(token, r.GetShopId()) rst := im.GetShopNavi(int64(optId), r.GetShopId(), r.GetParentId()) var info []*pb.Column if len(rst.List) > 0 { for _, v := range rst.List { l := &pb.Column{} l.Name = v.Name l.Url = v.Url l.Code = v.Code l.Sn = v.Sn l.NavShow = v.NavShow l.Id = strconv.FormatInt(v.Id, 10) l.Status = s.ManageStatusToWebStatus(v.Status) info = append(info, l) } } return &pb.GetShopNaviReply{List: info} } // ShopLicenseList 获取商家许可证 func (s Shop) ShopLicenseList(token string, r *pb.ShopDetailRequest) *pb.LicenseList { _ = s.checkPermission(token, r.GetShopId()) rst := im.ShopLicenseList(r.ShopId) var info []*pb.License if len(rst.List) > 0 { for _, v := range rst.List { l := &pb.License{} l.Id = v.Id l.LcsTypeId = v.LcsTypeId l.Name = v.Name l.ValidPeriod = v.ValidPeriod l.LcsPrice = v.LcsPrice l.LcsBeginTime = v.LcsBeginTime l.LcsEndTime = v.LcsEndTime l.FeeId = v.FeeId l.Status = s.ManageStatusToWebStatus(v.Status) l.Memo = v.Memo l.CreatedAt = v.CreatedUser l.UpdatedAt = v.UpdatedAt info = append(info, l) } } return &pb.LicenseList{List: info} } func (s Shop) ShopGroupAdd(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopGroupAdd(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } func (s Shop) ShopGroupEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopGroupEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } func (s Shop) ShopGroupStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopGroupStatusEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } func (s Shop) ShopGroupDetailsQuery(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopGroupDetailsQuery(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } func (s Shop) ShopVenueQuery(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueQuery(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueAdd 商家区域添加 @token:token func (s Shop) ShopVenueAdd(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueAdd(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueEdit 商家区域编辑 func (s Shop) ShopVenueEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueStatusEdit 商家区域状态修改 func (s Shop) ShopVenueStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueStatusEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueEquipQuery 商家设备查询 func (s Shop) ShopVenueEquipQuery(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueEquipAdd 商家设备添加 func (s Shop) ShopVenueEquipAdd(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueEquipEdit 商家设备编辑 func (s Shop) ShopVenueEquipEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueEquipEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueEquipStatusEdit 商家设备状态修改 func (s Shop) ShopVenueEquipStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueEquipStatusEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopVenueEquipStatusDel 商家设备删除 func (s Shop) ShopVenueEquipStatusDel(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopVenueEquipStatusDel(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopConfigQuery 商家配置查询 func (s Shop) ShopConfigQuery(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopConfigQuery(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst } // ShopConfigEdit 商家设备删除 func (s Shop) ShopConfigEdit(token string, objectShopId int64, jsonStr string, sign string) string { optId := s.checkPermission(token, objectShopId) rst, err := postgre.PGShop{}.ShopConfigEdit(optId, objectShopId, jsonStr, sign) if err != nil { panic(errors.PGError) } return rst }