shop.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. // Package service
  2. /**
  3. * @ File: shop
  4. * @ Date: 2021/4/13 10:41
  5. * @ Author: JYQ
  6. * @ Description:
  7. */
  8. package service
  9. import (
  10. pb "sportfitness/base/api/grpc/base"
  11. "sportfitness/base/assembly/base/repository/postgre"
  12. "sportfitness/base/errors"
  13. "sportfitness/base/repository/grpc/bsw/im"
  14. )
  15. type Shop struct {
  16. base
  17. }
  18. func (s Shop) ShopGroupQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  19. optId := s.checkPermission(token, objectShopId)
  20. rst, err := postgre.PGShop{}.ShopGroupQuery(optId, objectShopId, jsonStr, sign)
  21. if err != nil {
  22. panic(errors.PGError)
  23. }
  24. return rst
  25. }
  26. func (s Shop) ManageableShopList(token string, r *pb.ShopListRequest) *pb.ShopListReply {
  27. // 获取商家可用商家列表shopId传入0,因为是通用接口
  28. _ = s.checkPermission(token, 0)
  29. status := s.WebStatusToManageStatus(r.Status)
  30. rst := im.ShopListRequest(r.Name, status, r.SId)
  31. println(rst)
  32. var info []*pb.ShopInfo
  33. if len(rst.List) > 0 {
  34. l := &pb.ShopInfo{}
  35. for _, v := range rst.List {
  36. l.ShopId = v.ShopId
  37. l.Name = v.Name
  38. l.SId = v.SId
  39. l.Addr = v.Addr
  40. l.Phone = v.Phone
  41. l.Contacts = v.Contacts
  42. l.CreatedAt = v.CreatedAt
  43. l.UpdatedAt = v.UpdatedAt
  44. l.Status = s.ManageStatusToWebStatus(v.Status)
  45. info = append(info, l)
  46. }
  47. }
  48. return &pb.ShopListReply{List: info}
  49. }
  50. // GetShopNavi 获取商家导航
  51. func (s Shop) GetShopNavi(token string, r *pb.GetShopNaviRequest) *pb.GetShopNaviReply {
  52. optId := s.checkPermission(token, r.GetShopId())
  53. rst := im.GetShopNavi(int64(optId), r.GetShopId(), r.GetParentId())
  54. var info []*pb.Column
  55. if len(rst.List) > 0 {
  56. l := &pb.Column{}
  57. for _, v := range rst.List {
  58. l.Name = v.Name
  59. l.Url = v.Url
  60. l.Code = v.Code
  61. l.Sn = v.Sn
  62. l.NavShow = v.NavShow
  63. l.Id = v.Id
  64. l.Status = s.ManageStatusToWebStatus(v.Status)
  65. info = append(info, l)
  66. }
  67. }
  68. return &pb.GetShopNaviReply{List: info}
  69. }
  70. func (s Shop) ShopGroupAdd(token string, objectShopId int64, jsonStr string, sign string) string {
  71. optId := s.checkPermission(token, objectShopId)
  72. rst, err := postgre.PGShop{}.ShopGroupAdd(optId, objectShopId, jsonStr, sign)
  73. if err != nil {
  74. panic(errors.PGError)
  75. }
  76. return rst
  77. }
  78. func (s Shop) ShopGroupEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  79. optId := s.checkPermission(token, objectShopId)
  80. rst, err := postgre.PGShop{}.ShopGroupEdit(optId, objectShopId, jsonStr, sign)
  81. if err != nil {
  82. panic(errors.PGError)
  83. }
  84. return rst
  85. }
  86. func (s Shop) ShopGroupStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  87. optId := s.checkPermission(token, objectShopId)
  88. rst, err := postgre.PGShop{}.ShopGroupStatusEdit(optId, objectShopId, jsonStr, sign)
  89. if err != nil {
  90. panic(errors.PGError)
  91. }
  92. return rst
  93. }
  94. func (s Shop) ShopGroupDetailsQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  95. optId := s.checkPermission(token, objectShopId)
  96. rst, err := postgre.PGShop{}.ShopGroupDetailsQuery(optId, objectShopId, jsonStr, sign)
  97. if err != nil {
  98. panic(errors.PGError)
  99. }
  100. return rst
  101. }
  102. func (s Shop) ShopVenueQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  103. optId := s.checkPermission(token, objectShopId)
  104. rst, err := postgre.PGShop{}.ShopVenueQuery(optId, objectShopId, jsonStr, sign)
  105. if err != nil {
  106. panic(errors.PGError)
  107. }
  108. return rst
  109. }
  110. // ShopVenueAdd 商家区域添加 @token:token
  111. func (s Shop) ShopVenueAdd(token string, objectShopId int64, jsonStr string, sign string) string {
  112. optId := s.checkPermission(token, objectShopId)
  113. rst, err := postgre.PGShop{}.ShopVenueAdd(optId, objectShopId, jsonStr, sign)
  114. if err != nil {
  115. panic(errors.PGError)
  116. }
  117. return rst
  118. }
  119. // ShopVenueEdit 商家区域编辑
  120. func (s Shop) ShopVenueEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  121. optId := s.checkPermission(token, objectShopId)
  122. rst, err := postgre.PGShop{}.ShopVenueEdit(optId, objectShopId, jsonStr, sign)
  123. if err != nil {
  124. panic(errors.PGError)
  125. }
  126. return rst
  127. }
  128. // ShopVenueStatusEdit 商家区域状态修改
  129. func (s Shop) ShopVenueStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  130. optId := s.checkPermission(token, objectShopId)
  131. rst, err := postgre.PGShop{}.ShopVenueStatusEdit(optId, objectShopId, jsonStr, sign)
  132. if err != nil {
  133. panic(errors.PGError)
  134. }
  135. return rst
  136. }
  137. // ShopVenueEquipQuery 商家设备查询
  138. func (s Shop) ShopVenueEquipQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  139. optId := s.checkPermission(token, objectShopId)
  140. rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign)
  141. if err != nil {
  142. panic(errors.PGError)
  143. }
  144. return rst
  145. }
  146. // ShopVenueEquipAdd 商家设备添加
  147. func (s Shop) ShopVenueEquipAdd(token string, objectShopId int64, jsonStr string, sign string) string {
  148. optId := s.checkPermission(token, objectShopId)
  149. rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign)
  150. if err != nil {
  151. panic(errors.PGError)
  152. }
  153. return rst
  154. }
  155. // ShopVenueEquipEdit 商家设备编辑
  156. func (s Shop) ShopVenueEquipEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  157. optId := s.checkPermission(token, objectShopId)
  158. rst, err := postgre.PGShop{}.ShopVenueEquipEdit(optId, objectShopId, jsonStr, sign)
  159. if err != nil {
  160. panic(errors.PGError)
  161. }
  162. return rst
  163. }
  164. // ShopVenueEquipStatusEdit 商家设备状态修改
  165. func (s Shop) ShopVenueEquipStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  166. optId := s.checkPermission(token, objectShopId)
  167. rst, err := postgre.PGShop{}.ShopVenueEquipStatusEdit(optId, objectShopId, jsonStr, sign)
  168. if err != nil {
  169. panic(errors.PGError)
  170. }
  171. return rst
  172. }
  173. // ShopVenueEquipStatusDel 商家设备删除
  174. func (s Shop) ShopVenueEquipStatusDel(token string, objectShopId int64, jsonStr string, sign string) string {
  175. optId := s.checkPermission(token, objectShopId)
  176. rst, err := postgre.PGShop{}.ShopVenueEquipStatusDel(optId, objectShopId, jsonStr, sign)
  177. if err != nil {
  178. panic(errors.PGError)
  179. }
  180. return rst
  181. }
  182. // ShopConfigQuery 商家配置查询
  183. func (s Shop) ShopConfigQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  184. optId := s.checkPermission(token, objectShopId)
  185. rst, err := postgre.PGShop{}.ShopConfigQuery(optId, objectShopId, jsonStr, sign)
  186. if err != nil {
  187. panic(errors.PGError)
  188. }
  189. return rst
  190. }
  191. // ShopConfigEdit 商家设备删除
  192. func (s Shop) ShopConfigEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  193. optId := s.checkPermission(token, objectShopId)
  194. rst, err := postgre.PGShop{}.ShopConfigEdit(optId, objectShopId, jsonStr, sign)
  195. if err != nil {
  196. panic(errors.PGError)
  197. }
  198. return rst
  199. }