shop.go 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. println(l.ShopId)
  46. info = append(info, l)
  47. }
  48. }
  49. return &pb.ShopListReply{List: info}
  50. }
  51. func (s Shop) ManageableGetShopInfo(token string, r *pb.ShopDetailRequest) *pb.ShopInfo {
  52. optId := s.checkPermission(token, r.GetShopId())
  53. rst := im.ShopDetail(r.ShopId)
  54. navi := im.GetShopNavi(int64(optId), r.GetShopId(), 0)
  55. var isHr, isScore int64 = 0, 0
  56. if len(navi.List) > 0 {
  57. for _, v := range navi.List {
  58. if v.Name == "心率管理" {
  59. isHr = 1
  60. }
  61. if v.Name == "运动评估" {
  62. isScore = 1
  63. }
  64. }
  65. }
  66. info := &pb.ShopInfo{
  67. ShopId: rst.ShopId,
  68. Name: rst.Name,
  69. SId: rst.SId,
  70. Addr: rst.Addr,
  71. Phone: rst.Phone,
  72. Contacts: rst.Contacts,
  73. Status: s.ManageStatusToWebStatus(rst.Status),
  74. CreatedAt: rst.CreatedAt,
  75. CreatedUser: rst.CreatedUser,
  76. UpdatedAt: rst.UpdatedAt,
  77. UpdatedUser: rst.UpdatedUser,
  78. IsHr: isHr,
  79. IsScore: isScore,
  80. }
  81. return info
  82. }
  83. func (s Shop) LicenseTypeMap(token string, r *pb.IdList) *pb.LicenseTypeMapReply {
  84. _ = s.checkPermission(token, 0)
  85. rst := im.LicenseTypeMap(r.IdList)
  86. println(rst)
  87. //var info map[int64]pb.LicenseType
  88. //if rst != nil {
  89. // l := &pb.ShopInfo{}
  90. // for _, v := range rst.List {
  91. // l.ShopId = v.ShopId
  92. // l.Name = v.Name
  93. // l.SId = v.SId
  94. // l.Addr = v.Addr
  95. // l.Phone = v.Phone
  96. // l.Contacts = v.Contacts
  97. // l.CreatedAt = v.CreatedAt
  98. // l.UpdatedAt = v.UpdatedAt
  99. // l.Status = s.ManageStatusToWebStatus(v.Status)
  100. // info = append(info, l)
  101. // }
  102. //}
  103. return nil
  104. }
  105. // GetShopNavi 获取商家导航
  106. func (s Shop) GetShopNavi(token string, r *pb.GetShopNaviRequest) *pb.GetShopNaviReply {
  107. optId := s.checkPermission(token, r.GetShopId())
  108. rst := im.GetShopNavi(int64(optId), r.GetShopId(), r.GetParentId())
  109. var info []*pb.Column
  110. if len(rst.List) > 0 {
  111. l := &pb.Column{}
  112. for _, v := range rst.List {
  113. l.Name = v.Name
  114. l.Url = v.Url
  115. l.Code = v.Code
  116. l.Sn = v.Sn
  117. l.NavShow = v.NavShow
  118. l.Id = v.Id
  119. l.Status = s.ManageStatusToWebStatus(v.Status)
  120. info = append(info, l)
  121. }
  122. }
  123. return &pb.GetShopNaviReply{List: info}
  124. }
  125. // ShopLicenseList 获取商家许可证
  126. func (s Shop) ShopLicenseList(token string, r *pb.ShopDetailRequest) *pb.LicenseList {
  127. _ = s.checkPermission(token, r.GetShopId())
  128. rst := im.ShopLicenseList(r.ShopId)
  129. var info []*pb.License
  130. if len(rst.List) > 0 {
  131. l := &pb.License{}
  132. for _, v := range rst.List {
  133. l.Id = v.Id
  134. l.LcsTypeId = v.LcsTypeId
  135. l.Name = v.Name
  136. l.ValidPeriod = v.ValidPeriod
  137. l.LcsPrice = v.LcsPrice
  138. l.LcsBeginTime = v.LcsBeginTime
  139. l.LcsEndTime = v.LcsEndTime
  140. l.FeeId = v.FeeId
  141. l.Status = s.ManageStatusToWebStatus(v.Status)
  142. l.Memo = v.Memo
  143. l.CreatedAt = v.CreatedUser
  144. l.UpdatedAt = v.UpdatedAt
  145. info = append(info, l)
  146. }
  147. }
  148. return &pb.LicenseList{List: info}
  149. }
  150. func (s Shop) ShopGroupAdd(token string, objectShopId int64, jsonStr string, sign string) string {
  151. optId := s.checkPermission(token, objectShopId)
  152. rst, err := postgre.PGShop{}.ShopGroupAdd(optId, objectShopId, jsonStr, sign)
  153. if err != nil {
  154. panic(errors.PGError)
  155. }
  156. return rst
  157. }
  158. func (s Shop) ShopGroupEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  159. optId := s.checkPermission(token, objectShopId)
  160. rst, err := postgre.PGShop{}.ShopGroupEdit(optId, objectShopId, jsonStr, sign)
  161. if err != nil {
  162. panic(errors.PGError)
  163. }
  164. return rst
  165. }
  166. func (s Shop) ShopGroupStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  167. optId := s.checkPermission(token, objectShopId)
  168. rst, err := postgre.PGShop{}.ShopGroupStatusEdit(optId, objectShopId, jsonStr, sign)
  169. if err != nil {
  170. panic(errors.PGError)
  171. }
  172. return rst
  173. }
  174. func (s Shop) ShopGroupDetailsQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  175. optId := s.checkPermission(token, objectShopId)
  176. rst, err := postgre.PGShop{}.ShopGroupDetailsQuery(optId, objectShopId, jsonStr, sign)
  177. if err != nil {
  178. panic(errors.PGError)
  179. }
  180. return rst
  181. }
  182. func (s Shop) ShopVenueQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  183. optId := s.checkPermission(token, objectShopId)
  184. rst, err := postgre.PGShop{}.ShopVenueQuery(optId, objectShopId, jsonStr, sign)
  185. if err != nil {
  186. panic(errors.PGError)
  187. }
  188. return rst
  189. }
  190. // ShopVenueAdd 商家区域添加 @token:token
  191. func (s Shop) ShopVenueAdd(token string, objectShopId int64, jsonStr string, sign string) string {
  192. optId := s.checkPermission(token, objectShopId)
  193. rst, err := postgre.PGShop{}.ShopVenueAdd(optId, objectShopId, jsonStr, sign)
  194. if err != nil {
  195. panic(errors.PGError)
  196. }
  197. return rst
  198. }
  199. // ShopVenueEdit 商家区域编辑
  200. func (s Shop) ShopVenueEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  201. optId := s.checkPermission(token, objectShopId)
  202. rst, err := postgre.PGShop{}.ShopVenueEdit(optId, objectShopId, jsonStr, sign)
  203. if err != nil {
  204. panic(errors.PGError)
  205. }
  206. return rst
  207. }
  208. // ShopVenueStatusEdit 商家区域状态修改
  209. func (s Shop) ShopVenueStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  210. optId := s.checkPermission(token, objectShopId)
  211. rst, err := postgre.PGShop{}.ShopVenueStatusEdit(optId, objectShopId, jsonStr, sign)
  212. if err != nil {
  213. panic(errors.PGError)
  214. }
  215. return rst
  216. }
  217. // ShopVenueEquipQuery 商家设备查询
  218. func (s Shop) ShopVenueEquipQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  219. optId := s.checkPermission(token, objectShopId)
  220. rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign)
  221. if err != nil {
  222. panic(errors.PGError)
  223. }
  224. return rst
  225. }
  226. // ShopVenueEquipAdd 商家设备添加
  227. func (s Shop) ShopVenueEquipAdd(token string, objectShopId int64, jsonStr string, sign string) string {
  228. optId := s.checkPermission(token, objectShopId)
  229. rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign)
  230. if err != nil {
  231. panic(errors.PGError)
  232. }
  233. return rst
  234. }
  235. // ShopVenueEquipEdit 商家设备编辑
  236. func (s Shop) ShopVenueEquipEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  237. optId := s.checkPermission(token, objectShopId)
  238. rst, err := postgre.PGShop{}.ShopVenueEquipEdit(optId, objectShopId, jsonStr, sign)
  239. if err != nil {
  240. panic(errors.PGError)
  241. }
  242. return rst
  243. }
  244. // ShopVenueEquipStatusEdit 商家设备状态修改
  245. func (s Shop) ShopVenueEquipStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  246. optId := s.checkPermission(token, objectShopId)
  247. rst, err := postgre.PGShop{}.ShopVenueEquipStatusEdit(optId, objectShopId, jsonStr, sign)
  248. if err != nil {
  249. panic(errors.PGError)
  250. }
  251. return rst
  252. }
  253. // ShopVenueEquipStatusDel 商家设备删除
  254. func (s Shop) ShopVenueEquipStatusDel(token string, objectShopId int64, jsonStr string, sign string) string {
  255. optId := s.checkPermission(token, objectShopId)
  256. rst, err := postgre.PGShop{}.ShopVenueEquipStatusDel(optId, objectShopId, jsonStr, sign)
  257. if err != nil {
  258. panic(errors.PGError)
  259. }
  260. return rst
  261. }
  262. // ShopConfigQuery 商家配置查询
  263. func (s Shop) ShopConfigQuery(token string, objectShopId int64, jsonStr string, sign string) string {
  264. optId := s.checkPermission(token, objectShopId)
  265. rst, err := postgre.PGShop{}.ShopConfigQuery(optId, objectShopId, jsonStr, sign)
  266. if err != nil {
  267. panic(errors.PGError)
  268. }
  269. return rst
  270. }
  271. // ShopConfigEdit 商家设备删除
  272. func (s Shop) ShopConfigEdit(token string, objectShopId int64, jsonStr string, sign string) string {
  273. optId := s.checkPermission(token, objectShopId)
  274. rst, err := postgre.PGShop{}.ShopConfigEdit(optId, objectShopId, jsonStr, sign)
  275. if err != nil {
  276. panic(errors.PGError)
  277. }
  278. return rst
  279. }