| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469 |
- // Package service
- /**
- * @ File: shop
- * @ Date: 2021/4/13 10:41
- * @ Author: JYQ
- * @ Description:
- */
- package service
- import (
- "encoding/json"
- pb "sportfitness/base/api/grpc/base"
- "sportfitness/base/assembly/base/repository/postgre"
- "sportfitness/base/errors"
- "sportfitness/base/repository/grpc/bsw/im"
- im2 "sportfitness/base/repository/grpc/bsw/im/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}
- }
- type ManageableSimpleList struct {
- Id string
- UserCode string
- Name string
- Email string
- Phone string
- Qq string
- Memo string
- Status pb.WebStatus
- //RoleId int64 // 考虑要带出来用户权限,后废弃,不需要传出权限
- //RoleName string
- }
- func (s Shop) ManageableSimpleQuery(token string, shopId int64) *pb.ManageableSimpleQueryReply {
- // 获取商家可用商家列表shopId传入0,因为是通用接口
- _ = s.checkPermission(token, 0)
- rst := im.ManageableSimpleQuery(shopId, im2.Status_On)
- //println(rst)
- var info []*ManageableSimpleList
- if len(rst.List) > 0 {
- for _, v := range rst.List {
- l := &ManageableSimpleList{}
- l.Id = strconv.FormatInt(v.Id, 10)
- l.UserCode = v.UserCode
- l.Name = v.Name
- l.Email = v.Email
- l.Qq = v.Qq
- l.Phone = v.Phone
- l.Memo = v.Memo
- l.Status = s.ManageStatusToWebStatus(v.Status)
- // 考虑要带出来用户权限,后废弃,不需要传出权限
- //roleRs := im.RoleList(l.Id, int64(global.SysID))
- //for _, vr := range roleRs.List {
- // l.RoleId = vr.Id
- // l.RoleName = vr.Name
- //}
- info = append(info, l)
- }
- }
- str, err := json.Marshal(info)
- if err != nil {
- println(err)
- }
- println(string(str))
- return &pb.ManageableSimpleQueryReply{JsonList: string(str)}
- }
- 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, s.WebStatusToManageStatus(pb.WebStatus_On))
- 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(optId, r.GetShopId(), r.GetParentId(), s.WebStatusToManageStatus(pb.WebStatus_On))
- 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.Icon = v.Icon
- l.Id = strconv.FormatInt(v.Id, 10)
- l.Status = s.ManageStatusToWebStatus(v.Status)
- info = append(info, l)
- }
- }
- column, err := json.Marshal(info)
- if err != nil {
- println(err)
- }
- println(string(column))
- return &pb.GetShopNaviReply{List: info}
- }
- type ShopColumn struct {
- Navi
- Second []Navi
- }
- type Navi struct {
- Name string
- Url string
- Code string
- Sn int32
- Status pb.WebStatus
- NavShow bool
- Id string
- Icon string
- }
- // GetShopNaviAll 获取全部商家导航
- func (s Shop) GetShopNaviAll(token string, r *pb.GetShopNaviAllRequest) *pb.GetShopNaviAllReply {
- optId := s.checkPermission(token, r.GetShopId())
- rst := im.GetShopNavi(optId, r.GetShopId(), 0, s.WebStatusToManageStatus(pb.WebStatus_On))
- var info []*ShopColumn
- if len(rst.List) > 0 {
- for _, v := range rst.List {
- l := &ShopColumn{}
- 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)
- l.Icon = v.Icon
- secRs := im.GetShopNavi(optId, r.GetShopId(), v.Id, s.WebStatusToManageStatus(pb.WebStatus_On))
- if secRs.List != nil {
- for _, v := range secRs.List {
- n := Navi{}
- n.Name = v.Name
- n.Url = v.Url
- n.Code = v.Code
- n.Sn = v.Sn
- n.NavShow = v.NavShow
- n.Id = strconv.FormatInt(v.Id, 10)
- n.Status = s.ManageStatusToWebStatus(v.Status)
- n.Icon = v.Icon
- l.Second = append(l.Second, n)
- }
- } else {
- l.Second = make([]Navi, 0)
- }
- info = append(info, l)
- }
- }
- column, err := json.Marshal(info)
- if err != nil {
- println(err)
- }
- return &pb.GetShopNaviAllReply{ColumnRs: string(column)}
- }
- // 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{}.ShopVenueEquipAdd(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
- }
- // GroupSimpleQueryByShopID 商家分组简单查询-通过商家自己ID查询
- func (s Shop) GroupSimpleQueryByShopID(token string, objectShopId int64, jsonStr string, sign string) string {
- optId := s.checkPermission(token, objectShopId)
- rst, err := postgre.PGShop{}.GroupSimpleQuery(optId, objectShopId, jsonStr, sign)
- if err != nil {
- panic(errors.PGError)
- }
- return rst
- }
- // EqSimpleQuery 显示设备简单查询
- func (s Shop) EqSimpleQuery(token string, objectShopId int64, jsonStr string, sign string) string {
- optId := s.checkPermission(token, objectShopId)
- rst, err := postgre.PGShop{}.EqSimpleQuery(optId, objectShopId, jsonStr, sign)
- if err != nil {
- panic(errors.PGError)
- }
- return rst
- }
|