base.go 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. package grpc
  2. import (
  3. "context"
  4. "encoding/json"
  5. pb "sportfitness/base/api/grpc/base"
  6. "sportfitness/base/assembly/base/service"
  7. "sportfitness/base/errors"
  8. "sportfitness/base/global"
  9. "strings"
  10. "time"
  11. "google.golang.org/grpc/metadata"
  12. )
  13. type Api struct {
  14. pb.UnimplementedApiServer
  15. }
  16. func (Api) getRemoteIp(ctx context.Context) string {
  17. if md, ok := metadata.FromIncomingContext(ctx); ok {
  18. ip := md.Get("x-forwarded-for")
  19. if len(ip) > 0 {
  20. return ip[0]
  21. }
  22. }
  23. return ""
  24. }
  25. func (Api) getUserAgent(ctx context.Context) string {
  26. if md, ok := metadata.FromIncomingContext(ctx); ok {
  27. agents := md.Get("user-agent")
  28. return strings.Join(agents, "\n")
  29. }
  30. return ""
  31. }
  32. func (Api) getToken(ctx context.Context) (token string) {
  33. if md, ok := metadata.FromIncomingContext(ctx); ok {
  34. sl := md.Get("Token")
  35. if len(sl) >= 1 {
  36. token = sl[0]
  37. }
  38. }
  39. return
  40. }
  41. func (Api) checkRs(rs string) bool {
  42. b := false
  43. rsMap := make(map[string]interface{})
  44. err := json.Unmarshal([]byte(rs), &rsMap)
  45. if err != nil {
  46. panic(errors.J2MError)
  47. }
  48. code := int(rsMap["code"].(float64))
  49. if code == 0 {
  50. b = true
  51. } else {
  52. b = false
  53. }
  54. return b
  55. }
  56. // webToGoVerify 前端入Go验证签名函数,只允许StandardRequest进行验证
  57. func (a Api) webToGoVerify(ctx context.Context, q *pb.StandardRequest) (string, *pb.StandardRequest, string) {
  58. token := a.getToken(ctx)
  59. //wtgStr = q.JsonStr
  60. wtgSign := q.Sign // 生成新签名
  61. return token, q, wtgSign
  62. }
  63. // courseToGoVerify 前端入Go验证签名函数,只允许StandardRequest进行验证
  64. func (a Api) courseToGoVerify(ctx context.Context, q *pb.CourseStandardRequest) (string, *pb.CourseStandardRequest, string) {
  65. token := a.getToken(ctx)
  66. //wtgStr = q.JsonStr
  67. wtgSign := q.Sign // 生成新签名
  68. return token, q, wtgSign
  69. }
  70. func (Api) goToWebSigner(content string) (gtwStr, gtwSign string) {
  71. gtwStr = content
  72. gtwSign = ""
  73. return
  74. }
  75. func (a Api) toWebFunc(content string) *pb.StandardReply {
  76. gtwStr, gtwSign := a.goToWebSigner(content) // 空函数,go透传给前台数据时生成签名
  77. return &pb.StandardReply{
  78. JsonRst: gtwStr,
  79. Sign: gtwSign,
  80. }
  81. }
  82. func (a Api) SignIn(ctx context.Context, q *pb.SignInRequest) (*pb.SignInReply, error) {
  83. token := service.User{}.SignInUserCodePassword(
  84. q.Name, q.Password, a.getRemoteIp(ctx), a.getUserAgent(ctx), q.CodeId, q.VerifyCode)
  85. return &pb.SignInReply{Token: token}, nil
  86. }
  87. func (a Api) GenVerifyImage(ctx context.Context, q *pb.GenVerifyImageRequest) (*pb.GenVerifyImageReply, error) {
  88. codeId, imageBase64 := service.User{}.GenVerifyImage(q.Height, q.Width)
  89. return &pb.GenVerifyImageReply{ImageBase64: imageBase64, CodeId: codeId}, nil
  90. }
  91. func (a Api) SignOut(ctx context.Context, q *pb.DefaultRequest) (*pb.DefaultReply, error) {
  92. token := a.getToken(ctx)
  93. service.User{}.SignOut(token)
  94. return &pb.DefaultReply{}, nil
  95. }
  96. //func (a Api) SignUpInWithPhone() {
  97. //
  98. //}
  99. // ----------------------- 商家信息管理 ---------------------------------------------
  100. // AcrossUserSimpleQuery 可跨店会员简单查询
  101. func (a Api) AcrossUserSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  102. // 获取token,并验证签名函数
  103. token, q, sign := a.webToGoVerify(ctx, r)
  104. rs := service.User{}.AcrossUserSimpleQuery(token, q.ShopID, q.JsonStr, sign)
  105. rst := a.toWebFunc(rs)
  106. return rst, nil
  107. }
  108. // VipUserSimpleQuery 会员简单查询
  109. func (a Api) VipUserSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  110. // 获取token,并验证签名函数
  111. token, q, sign := a.webToGoVerify(ctx, r)
  112. rs := service.User{}.VipUserSimpleQuery(token, q.ShopID, q.JsonStr, sign)
  113. rst := a.toWebFunc(rs)
  114. return rst, nil
  115. }
  116. // TempVipUserSimpleQuery 临时会员简单查询
  117. func (a Api) TempVipUserSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  118. // 获取token,并验证签名函数
  119. token, q, sign := a.webToGoVerify(ctx, r)
  120. rs := service.User{}.TempVipUserSimpleQuery(token, q.ShopID, q.JsonStr, sign)
  121. rst := a.toWebFunc(rs)
  122. return rst, nil
  123. }
  124. // ClassSimpleQuery 课目简单查询
  125. func (a Api) ClassSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  126. // 获取token,并验证签名函数
  127. token, q, sign := a.webToGoVerify(ctx, r)
  128. rs := service.Class{}.ClassSimpleQuery(token, q.ShopID, q.JsonStr, sign)
  129. rst := a.toWebFunc(rs)
  130. return rst, nil
  131. }
  132. // SelectHrSensors 心率带简单查询
  133. func (a Api) SelectHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  134. // 获取token,并验证签名函数
  135. token, q, sign := a.webToGoVerify(ctx, r)
  136. rs := service.Hr{}.SelectHrSensors(token, q.ShopID, q.JsonStr, sign)
  137. rst := a.toWebFunc(rs)
  138. return rst, nil
  139. }
  140. // GroupSimpleQueryByShopID 商家分组简单查询-通过商家自己ID查询
  141. func (a Api) GroupSimpleQueryByShopID(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  142. // 获取token,并验证签名函数
  143. token, q, sign := a.webToGoVerify(ctx, r)
  144. rs := service.Shop{}.GroupSimpleQueryByShopID(token, q.ShopID, q.JsonStr, sign)
  145. rst := a.toWebFunc(rs)
  146. return rst, nil
  147. }
  148. // EqSimpleQuery 商家分组简单查询-通过商家自己ID查询
  149. func (a Api) EqSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  150. // 获取token,并验证签名函数
  151. token, q, sign := a.webToGoVerify(ctx, r)
  152. rs := service.Shop{}.EqSimpleQuery(token, q.ShopID, q.JsonStr, sign)
  153. rst := a.toWebFunc(rs)
  154. return rst, nil
  155. }
  156. // ManageableSimpleQuery 商家管理员简单查询-通过商家自己ID查询
  157. func (a Api) ManageableSimpleQuery(ctx context.Context, r *pb.ManageableSimpleQueryRequest) (*pb.ManageableSimpleQueryReply, error) {
  158. token := a.getToken(ctx)
  159. rs := service.Shop{}.ManageableSimpleQuery(token, r.GetShopId())
  160. return rs, nil
  161. }
  162. // ----------------------- 商家信息管理 ---------------------------------------------
  163. func (a Api) ManageableShopList(ctx context.Context, r *pb.ShopListRequest) (*pb.ShopListReply, error) {
  164. token := a.getToken(ctx)
  165. rs := service.Shop{}.ManageableShopList(token, r)
  166. return rs, nil
  167. }
  168. func (a Api) ManageableGetShopInfo(ctx context.Context, r *pb.ShopDetailRequest) (*pb.ShopInfo, error) {
  169. token := a.getToken(ctx)
  170. rs := service.Shop{}.ManageableGetShopInfo(token, r)
  171. return rs, nil
  172. }
  173. func (a Api) ShopLicenseList(ctx context.Context, r *pb.ShopDetailRequest) (*pb.LicenseList, error) {
  174. token := a.getToken(ctx)
  175. rs := service.Shop{}.ShopLicenseList(token, r)
  176. return rs, nil
  177. }
  178. //func (a Api) ShopLicenseTypeMap(ctx context.Context, r *pb.IdList) (*pb.LicenseTypeMapReply, error) {
  179. // token := a.getToken(ctx)
  180. //
  181. // _ = service.Shop{}.LicenseTypeMap(token, r)
  182. //
  183. // return nil, nil
  184. //}
  185. // ShopGroupQuery 商家跨店分组查询
  186. func (a Api) ShopGroupQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  187. // 获取token,并验证签名函数
  188. token, q, sign := a.webToGoVerify(ctx, r)
  189. rs := service.Shop{}.ShopGroupQuery(token, q.ShopID, q.JsonStr, sign)
  190. rst := a.toWebFunc(rs)
  191. return rst, nil
  192. }
  193. // GetShopNavi 查询商家栏目:分级查询,查询一级菜单parentId传入0
  194. func (a Api) GetShopNavi(ctx context.Context, r *pb.GetShopNaviRequest) (*pb.GetShopNaviReply, error) {
  195. token := a.getToken(ctx)
  196. rs := service.Shop{}.GetShopNavi(token, r)
  197. return rs, nil
  198. }
  199. // GetShopNaviAll 查询商家全部栏目
  200. func (a Api) GetShopNaviAll(ctx context.Context, r *pb.GetShopNaviAllRequest) (*pb.GetShopNaviAllReply, error) {
  201. token := a.getToken(ctx)
  202. rs := service.Shop{}.GetShopNaviAll(token, r)
  203. return rs, nil
  204. }
  205. // ShopGroupAdd 商家跨店分组添加
  206. func (a Api) ShopGroupAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  207. // 获取token,并验证签名函数
  208. token, q, sign := a.webToGoVerify(ctx, r)
  209. rs := service.Shop{}.ShopGroupAdd(token, q.ShopID, q.JsonStr, sign)
  210. rst := a.toWebFunc(rs)
  211. return rst, nil
  212. }
  213. // ShopGroupEdit 商家跨店分组编辑
  214. func (a Api) ShopGroupEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  215. // 获取token,并验证签名函数
  216. token, q, sign := a.webToGoVerify(ctx, r)
  217. rs := service.Shop{}.ShopGroupEdit(token, q.ShopID, q.JsonStr, sign)
  218. rst := a.toWebFunc(rs)
  219. return rst, nil
  220. }
  221. // ShopGroupStatusEdit 商家跨店分组状态修改
  222. func (a Api) ShopGroupStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  223. // 获取token,并验证签名函数
  224. token, q, sign := a.webToGoVerify(ctx, r)
  225. rs := service.Shop{}.ShopGroupStatusEdit(token, q.ShopID, q.JsonStr, sign)
  226. rst := a.toWebFunc(rs)
  227. return rst, nil
  228. }
  229. // ShopGroupDetailsQuery 跨店分组详情查询
  230. func (a Api) ShopGroupDetailsQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  231. // 获取token,并验证签名函数
  232. token, q, sign := a.webToGoVerify(ctx, r)
  233. rs := service.Shop{}.ShopGroupDetailsQuery(token, q.ShopID, q.JsonStr, sign)
  234. rst := a.toWebFunc(rs)
  235. return rst, nil
  236. }
  237. // ShopVenueQuery 商家区域查询
  238. func (a Api) ShopVenueQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  239. // 获取token,并验证签名函数
  240. token, q, sign := a.webToGoVerify(ctx, r)
  241. rs := service.Shop{}.ShopVenueQuery(token, q.ShopID, q.JsonStr, sign)
  242. rst := a.toWebFunc(rs)
  243. return rst, nil
  244. }
  245. // ShopVenueAdd 商家区域添加
  246. func (a Api) ShopVenueAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  247. // 获取token,并验证签名函数
  248. token, q, sign := a.webToGoVerify(ctx, r)
  249. rs := service.Shop{}.ShopVenueAdd(token, q.ShopID, q.JsonStr, sign)
  250. rst := a.toWebFunc(rs)
  251. return rst, nil
  252. }
  253. // ShopVenueEdit 商家区域编辑
  254. func (a Api) ShopVenueEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  255. // 获取token,并验证签名函数
  256. token, q, sign := a.webToGoVerify(ctx, r)
  257. rs := service.Shop{}.ShopVenueEdit(token, q.ShopID, q.JsonStr, sign)
  258. rst := a.toWebFunc(rs)
  259. return rst, nil
  260. }
  261. // ShopVenueStatusEdit 商家区域状态修改
  262. func (a Api) ShopVenueStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  263. // 获取token,并验证签名函数
  264. token, q, sign := a.webToGoVerify(ctx, r)
  265. rs := service.Shop{}.ShopVenueStatusEdit(token, q.ShopID, q.JsonStr, sign)
  266. rst := a.toWebFunc(rs)
  267. return rst, nil
  268. }
  269. // ShopVenueEquipQuery 商家设备查询
  270. func (a Api) ShopVenueEquipQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  271. // 获取token,并验证签名函数
  272. token, q, sign := a.webToGoVerify(ctx, r)
  273. rs := service.Shop{}.ShopVenueEquipQuery(token, q.ShopID, q.JsonStr, sign)
  274. rst := a.toWebFunc(rs)
  275. return rst, nil
  276. }
  277. // ShopVenueEquipAdd 商家设备添加
  278. func (a Api) ShopVenueEquipAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  279. // 获取token,并验证签名函数
  280. token, q, sign := a.webToGoVerify(ctx, r)
  281. rs := service.Shop{}.ShopVenueEquipAdd(token, q.ShopID, q.JsonStr, sign)
  282. rst := a.toWebFunc(rs)
  283. return rst, nil
  284. }
  285. // ShopVenueEquipEdit 商家设备编辑
  286. func (a Api) ShopVenueEquipEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  287. // 获取token,并验证签名函数
  288. token, q, sign := a.webToGoVerify(ctx, r)
  289. rs := service.Shop{}.ShopVenueEquipEdit(token, q.ShopID, q.JsonStr, sign)
  290. rst := a.toWebFunc(rs)
  291. return rst, nil
  292. }
  293. // ShopVenueEquipStatusEdit 商家设备状态修改
  294. func (a Api) ShopVenueEquipStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  295. // 获取token,并验证签名函数
  296. token, q, sign := a.webToGoVerify(ctx, r)
  297. rs := service.Shop{}.ShopVenueEquipStatusEdit(token, q.ShopID, q.JsonStr, sign)
  298. rst := a.toWebFunc(rs)
  299. return rst, nil
  300. }
  301. // ShopVenueEquipStatusDel 商家设备删除
  302. func (a Api) ShopVenueEquipStatusDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  303. // 获取token,并验证签名函数
  304. token, q, sign := a.webToGoVerify(ctx, r)
  305. rs := service.Shop{}.ShopVenueEquipStatusEdit(token, q.ShopID, q.JsonStr, sign)
  306. rst := a.toWebFunc(rs)
  307. return rst, nil
  308. }
  309. // ShopConfigQuery 商家配置查询
  310. func (a Api) ShopConfigQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  311. // 获取token,并验证签名函数
  312. token, q, sign := a.webToGoVerify(ctx, r)
  313. rs := service.Shop{}.ShopConfigQuery(token, q.ShopID, q.JsonStr, sign)
  314. rst := a.toWebFunc(rs)
  315. return rst, nil
  316. }
  317. // ShopConfigEdit 商家配置编辑
  318. func (a Api) ShopConfigEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  319. // 获取token,并验证签名函数
  320. token, q, sign := a.webToGoVerify(ctx, r)
  321. rs := service.Shop{}.ShopConfigEdit(token, q.ShopID, q.JsonStr, sign)
  322. rst := a.toWebFunc(rs)
  323. return rst, nil
  324. }
  325. // --------------------------商家会员管理----------------------------------------------------
  326. // ShopVipUserQuery 商家会员查询
  327. func (a Api) ShopVipUserQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  328. // 获取token,并验证签名函数
  329. token, q, sign := a.webToGoVerify(ctx, r)
  330. rs := service.User{}.ShopVipUserQuery(token, q.ShopID, q.JsonStr, sign)
  331. rst := a.toWebFunc(rs)
  332. return rst, nil
  333. }
  334. // ShopVipUserAdd 商家会员添加
  335. func (a Api) ShopVipUserAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  336. // 获取token,并验证签名函数
  337. token, q, sign := a.webToGoVerify(ctx, r)
  338. rs := service.User{}.ShopVipUserAdd(token, q.ShopID, q.JsonStr, sign)
  339. rst := a.toWebFunc(rs)
  340. return rst, nil
  341. }
  342. // ShopVipUserEdit 商家会员编辑
  343. func (a Api) ShopVipUserEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  344. // 获取token,并验证签名函数
  345. token, q, sign := a.webToGoVerify(ctx, r)
  346. rs := service.User{}.ShopVipUserEdit(token, q.ShopID, q.JsonStr, sign)
  347. rst := a.toWebFunc(rs)
  348. return rst, nil
  349. }
  350. // ShopVipUserStatusEdit 商家会员状态编辑
  351. func (a Api) ShopVipUserStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  352. // 获取token,并验证签名函数
  353. token, q, sign := a.webToGoVerify(ctx, r)
  354. rs := service.User{}.ShopVipUserStatusEdit(token, q.ShopID, q.JsonStr, sign)
  355. rst := a.toWebFunc(rs)
  356. return rst, nil
  357. }
  358. // AcrossVipUserQuery 跨店会员查询
  359. func (a Api) AcrossVipUserQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  360. // 获取token,并验证签名函数
  361. token, q, sign := a.webToGoVerify(ctx, r)
  362. rs := service.User{}.AcrossVipUserQuery(token, q.ShopID, q.JsonStr, sign)
  363. rst := a.toWebFunc(rs)
  364. return rst, nil
  365. }
  366. // AcrossVipUserAdd 跨店会员添加
  367. func (a Api) AcrossVipUserAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  368. // 获取token,并验证签名函数
  369. token, q, sign := a.webToGoVerify(ctx, r)
  370. rs := service.User{}.AcrossVipUserQuery(token, q.ShopID, q.JsonStr, sign)
  371. rst := a.toWebFunc(rs)
  372. return rst, nil
  373. }
  374. // AcrossVipUserDel 跨店会员删除
  375. func (a Api) AcrossVipUserDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  376. // 获取token,并验证签名函数
  377. token, q, sign := a.webToGoVerify(ctx, r)
  378. rs := service.User{}.AcrossVipUserDel(token, q.ShopID, q.JsonStr, sign)
  379. rst := a.toWebFunc(rs)
  380. return rst, nil
  381. }
  382. // VipPhoneQuery 商家会员手机号查询
  383. func (a Api) VipPhoneQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  384. // 获取token,并验证签名函数
  385. token, q, sign := a.webToGoVerify(ctx, r)
  386. rs := service.User{}.VipPhoneQuery(token, q.ShopID, q.JsonStr, sign)
  387. rst := a.toWebFunc(rs)
  388. return rst, nil
  389. }
  390. // VipMainPhoneCheck 商家会员主手机号校验
  391. func (a Api) VipMainPhoneCheck(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  392. // 获取token,并验证签名函数
  393. token, q, sign := a.webToGoVerify(ctx, r)
  394. rs := service.User{}.VipMainPhoneCheck(token, q.ShopID, q.JsonStr, sign)
  395. rst := a.toWebFunc(rs)
  396. return rst, nil
  397. }
  398. // VipOtherPhoneAdd 商家会员其他手机号添加
  399. func (a Api) VipOtherPhoneAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  400. // 获取token,并验证签名函数
  401. token, q, sign := a.webToGoVerify(ctx, r)
  402. rs := service.User{}.VipOtherPhoneAdd(token, q.ShopID, q.JsonStr, sign)
  403. rst := a.toWebFunc(rs)
  404. return rst, nil
  405. }
  406. // VipOtherPhoneEdit 商家会员其他手机号编辑
  407. func (a Api) VipOtherPhoneEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  408. // 获取token,并验证签名函数
  409. token, q, sign := a.webToGoVerify(ctx, r)
  410. rs := service.User{}.VipOtherPhoneEdit(token, q.ShopID, q.JsonStr, sign)
  411. rst := a.toWebFunc(rs)
  412. return rst, nil
  413. }
  414. // VipOtherPhoneStatusEdit 商家会员其他手机号状态修改
  415. func (a Api) VipOtherPhoneStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  416. // 获取token,并验证签名函数
  417. token, q, sign := a.webToGoVerify(ctx, r)
  418. rs := service.User{}.VipOtherPhoneStatusEdit(token, q.ShopID, q.JsonStr, sign)
  419. rst := a.toWebFunc(rs)
  420. return rst, nil
  421. }
  422. // TempVipUserQuery 商家临时会员查询
  423. func (a Api) TempVipUserQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  424. // 获取token,并验证签名函数
  425. token, q, sign := a.webToGoVerify(ctx, r)
  426. rs := service.User{}.TempVipUserQuery(token, q.ShopID, q.JsonStr, sign)
  427. rst := a.toWebFunc(rs)
  428. return rst, nil
  429. }
  430. // TempVipUserAdd 商家临时会员添加
  431. func (a Api) TempVipUserAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  432. // 获取token,并验证签名函数
  433. token, q, sign := a.webToGoVerify(ctx, r)
  434. rs := service.User{}.TempVipUserAdd(token, q.ShopID, q.JsonStr, sign)
  435. rst := a.toWebFunc(rs)
  436. return rst, nil
  437. }
  438. // TempVipUserEdit 商家临时会员编辑
  439. func (a Api) TempVipUserEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  440. // 获取token,并验证签名函数
  441. token, q, sign := a.webToGoVerify(ctx, r)
  442. rs := service.User{}.TempVipUserEdit(token, q.ShopID, q.JsonStr, sign)
  443. rst := a.toWebFunc(rs)
  444. return rst, nil
  445. }
  446. // TempVipUserStatusEdit 商家临时会员状态修改
  447. func (a Api) TempVipUserStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  448. // 获取token,并验证签名函数
  449. token, q, sign := a.webToGoVerify(ctx, r)
  450. rs := service.User{}.TempVipUserStatusEdit(token, q.ShopID, q.JsonStr, sign)
  451. rst := a.toWebFunc(rs)
  452. return rst, nil
  453. }
  454. // VipHourEdit 商家会员课时编辑
  455. func (a Api) VipHourEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  456. // 获取token,并验证签名函数
  457. token, q, sign := a.webToGoVerify(ctx, r)
  458. rs := service.User{}.VipHourEdit(token, q.ShopID, q.JsonStr, sign)
  459. rst := a.toWebFunc(rs)
  460. return rst, nil
  461. }
  462. // VipConsumeListQuery 商家会员消费课时查询
  463. func (a Api) VipConsumeListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  464. // 获取token,并验证签名函数
  465. token, q, sign := a.webToGoVerify(ctx, r)
  466. rs := service.User{}.VipConsumeListQuery(token, q.ShopID, q.JsonStr, sign)
  467. rst := a.toWebFunc(rs)
  468. return rst, nil
  469. }
  470. // VipConsumeDetailQuery 商家会员消费课时详情查询
  471. func (a Api) VipConsumeDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  472. // 获取token,并验证签名函数
  473. token, q, sign := a.webToGoVerify(ctx, r)
  474. rs := service.User{}.VipConsumeDetailQuery(token, q.ShopID, q.JsonStr, sign)
  475. rst := a.toWebFunc(rs)
  476. return rst, nil
  477. }
  478. // VipClassRelationEdit 商家会员对应课程增删
  479. func (a Api) VipClassRelationEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  480. // 获取token,并验证签名函数
  481. token, q, sign := a.webToGoVerify(ctx, r)
  482. rs := service.User{}.VipClassRelationEdit(token, q.ShopID, q.JsonStr, sign)
  483. rst := a.toWebFunc(rs)
  484. return rst, nil
  485. }
  486. // VipHourChgQuery 商家会员消费课时详情查询
  487. func (a Api) VipHourChgQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  488. // 获取token,并验证签名函数
  489. token, q, sign := a.webToGoVerify(ctx, r)
  490. rs := service.User{}.VipHourChgQuery(token, q.ShopID, q.JsonStr, sign)
  491. rst := a.toWebFunc(rs)
  492. return rst, nil
  493. }
  494. // VipUserClassQuery 商家会员课程查询
  495. func (a Api) VipUserClassQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  496. // 获取token,并验证签名函数
  497. token, q, sign := a.webToGoVerify(ctx, r)
  498. rs := service.User{}.VipUserClassQuery(token, q.ShopID, q.JsonStr, sign)
  499. rst := a.toWebFunc(rs)
  500. return rst, nil
  501. }
  502. // GetSimpleQiNiuToken 获取七牛简单Token
  503. func (a Api) GetSimpleQiNiuToken(ctx context.Context, r *pb.DefaultRequest) (*pb.QiNiuTokenReply, error) {
  504. token := a.getToken(ctx)
  505. rs := service.User{}.GetSimpleQiNiuToken(token)
  506. return rs, nil
  507. }
  508. // GetOverlayImgQiNiuToken 获取七牛可覆盖文件Token
  509. func (a Api) GetOverlayImgQiNiuToken(ctx context.Context, r *pb.GetOverlayImgRequest) (*pb.QiNiuTokenReply, error) {
  510. token := a.getToken(ctx)
  511. rs := service.User{}.GetOverlayImgQiNiuToken(token, r.FileName)
  512. return rs, nil
  513. }
  514. // ClassQuery 商家基础课程查询
  515. func (a Api) ClassQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  516. // 获取token,并验证签名函数
  517. token, q, sign := a.webToGoVerify(ctx, r)
  518. rs := service.Class{}.ClassQuery(token, q.ShopID, q.JsonStr, sign)
  519. rst := a.toWebFunc(rs)
  520. return rst, nil
  521. }
  522. // ClassAdd 商家基础课程添加
  523. func (a Api) ClassAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  524. // 获取token,并验证签名函数
  525. token, q, sign := a.webToGoVerify(ctx, r)
  526. rs := service.Class{}.ClassAdd(token, q.ShopID, q.JsonStr, sign)
  527. rst := a.toWebFunc(rs)
  528. return rst, nil
  529. }
  530. // ClassEdit 商家基础课程编辑
  531. func (a Api) ClassEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  532. // 获取token,并验证签名函数
  533. token, q, sign := a.webToGoVerify(ctx, r)
  534. rs := service.Class{}.ClassEdit(token, q.ShopID, q.JsonStr, sign)
  535. rst := a.toWebFunc(rs)
  536. return rst, nil
  537. }
  538. // ClassStatusEdit 商家基础课程状态编辑
  539. func (a Api) ClassStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  540. // 获取token,并验证签名函数
  541. token, q, sign := a.webToGoVerify(ctx, r)
  542. rs := service.Class{}.ClassStatusEdit(token, q.ShopID, q.JsonStr, sign)
  543. rst := a.toWebFunc(rs)
  544. return rst, nil
  545. }
  546. // ClassColorEdit 商家基础课程颜色修改
  547. func (a Api) ClassColorEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  548. // 获取token,并验证签名函数
  549. token, q, sign := a.webToGoVerify(ctx, r)
  550. rs := service.Class{}.ClassColorEdit(token, q.ShopID, q.JsonStr, sign)
  551. rst := a.toWebFunc(rs)
  552. return rst, nil
  553. }
  554. // ClassWxVisibleEdit 商家基础课程微信显示状态修改
  555. func (a Api) ClassWxVisibleEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  556. // 获取token,并验证签名函数
  557. token, q, sign := a.webToGoVerify(ctx, r)
  558. rs := service.Class{}.ClassWxVisibleEdit(token, q.ShopID, q.JsonStr, sign)
  559. rst := a.toWebFunc(rs)
  560. return rst, nil
  561. }
  562. // ClassVipEdit 商家课程会员增删
  563. func (a Api) ClassVipEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  564. // 获取token,并验证签名函数
  565. token, q, sign := a.webToGoVerify(ctx, r)
  566. rs := service.Class{}.ClassVipEdit(token, q.ShopID, q.JsonStr, sign)
  567. rst := a.toWebFunc(rs)
  568. return rst, nil
  569. }
  570. // SttPlanBasicQuery 商家课程表模板总览查询
  571. func (a Api) SttPlanBasicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  572. // 获取token,并验证签名函数
  573. token, q, sign := a.webToGoVerify(ctx, r)
  574. rs := service.Class{}.SttPlanBasicQuery(token, q.ShopID, q.JsonStr, sign)
  575. rst := a.toWebFunc(rs)
  576. return rst, nil
  577. }
  578. // SttPlanBasicAdd 商家课程表模板总览添加
  579. func (a Api) SttPlanBasicAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  580. // 获取token,并验证签名函数
  581. token, q, sign := a.webToGoVerify(ctx, r)
  582. rs := service.Class{}.SttPlanBasicAdd(token, q.ShopID, q.JsonStr, sign)
  583. rst := a.toWebFunc(rs)
  584. return rst, nil
  585. }
  586. // SttPlanBasicEdit 商家课程表模板总览编辑
  587. func (a Api) SttPlanBasicEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  588. // 获取token,并验证签名函数
  589. token, q, sign := a.webToGoVerify(ctx, r)
  590. rs := service.Class{}.SttPlanBasicEdit(token, q.ShopID, q.JsonStr, sign)
  591. rst := a.toWebFunc(rs)
  592. return rst, nil
  593. }
  594. // SttPlanBasicShopEdit 商家课程表模板总览所属商家修改
  595. func (a Api) SttPlanBasicShopEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  596. // 获取token,并验证签名函数
  597. token, q, sign := a.webToGoVerify(ctx, r)
  598. rs := service.Class{}.SttPlanBasicShopEdit(token, q.ShopID, q.JsonStr, sign)
  599. rst := a.toWebFunc(rs)
  600. return rst, nil
  601. }
  602. // SttPlanBasicStatusEdit 商家课程表模板状态
  603. func (a Api) SttPlanBasicStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  604. // 获取token,并验证签名函数
  605. token, q, sign := a.webToGoVerify(ctx, r)
  606. rs := service.Class{}.SttPlanBasicStatusEdit(token, q.ShopID, q.JsonStr, sign)
  607. rst := a.toWebFunc(rs)
  608. return rst, nil
  609. }
  610. // SttPlanBasicPublish 商家课程表模板发布
  611. func (a Api) SttPlanBasicPublish(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  612. // 获取token,并验证签名函数
  613. token, q, sign := a.webToGoVerify(ctx, r)
  614. rs := service.Class{}.SttPlanBasicPublish(token, q.ShopID, q.JsonStr, sign)
  615. rst := a.toWebFunc(rs)
  616. return rst, nil
  617. }
  618. // SttPlanPreview 商家课程表模板详情预览
  619. func (a Api) SttPlanPreview(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  620. // 获取token,并验证签名函数
  621. token, q, sign := a.webToGoVerify(ctx, r)
  622. rs := service.Class{}.SttPlanPreview(token, q.ShopID, q.JsonStr, sign)
  623. rst := a.toWebFunc(rs)
  624. return rst, nil
  625. }
  626. // SttPlanCopy 商家课程表模板复制
  627. func (a Api) SttPlanCopy(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  628. // 获取token,并验证签名函数
  629. token, q, sign := a.webToGoVerify(ctx, r)
  630. rs := service.Class{}.SttPlanCopy(token, q.ShopID, q.JsonStr, sign)
  631. rst := a.toWebFunc(rs)
  632. return rst, nil
  633. }
  634. // SttPlanDetailQuery 商家课程表模板详情查询
  635. func (a Api) SttPlanDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  636. // 获取token,并验证签名函数
  637. token, q, sign := a.webToGoVerify(ctx, r)
  638. rs := service.Class{}.SttPlanDetailQuery(token, q.ShopID, q.JsonStr, sign)
  639. rst := a.toWebFunc(rs)
  640. return rst, nil
  641. }
  642. // SttPlanDetailBatchSave 商家课程表模板详情批量保存
  643. func (a Api) SttPlanDetailBatchSave(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  644. // 获取token,并验证签名函数
  645. token, q, sign := a.webToGoVerify(ctx, r)
  646. rs := service.Class{}.SttPlanDetailBatchSave(token, q.ShopID, q.JsonStr, sign)
  647. rst := a.toWebFunc(rs)
  648. return rst, nil
  649. }
  650. // STTBasicQuery 商家课程表总览查询
  651. func (a Api) STTBasicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  652. // 获取token,并验证签名函数
  653. token, q, sign := a.webToGoVerify(ctx, r)
  654. rs := service.Class{}.STTBasicQuery(token, q.ShopID, q.JsonStr, sign)
  655. rst := a.toWebFunc(rs)
  656. return rst, nil
  657. }
  658. // STTBasicAdd 商家课程表总览添加
  659. func (a Api) STTBasicAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  660. // 获取token,并验证签名函数
  661. token, q, sign := a.webToGoVerify(ctx, r)
  662. rs := service.Class{}.STTBasicAdd(token, q.ShopID, q.JsonStr, sign)
  663. rst := a.toWebFunc(rs)
  664. return rst, nil
  665. }
  666. // STTBasicEdit 商家课程表总览编辑
  667. func (a Api) STTBasicEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  668. // 获取token,并验证签名函数
  669. token, q, sign := a.webToGoVerify(ctx, r)
  670. rs := service.Class{}.STTBasicEdit(token, q.ShopID, q.JsonStr, sign)
  671. if !a.checkRs(rs) {
  672. rst := a.toWebFunc(rs)
  673. return rst, nil
  674. }
  675. rst := a.toWebFunc(rs)
  676. return rst, nil
  677. }
  678. // STTBasicStatusEdit 商家课程表总览状态修改
  679. func (a Api) STTBasicStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  680. // 获取token,并验证签名函数
  681. token, q, sign := a.webToGoVerify(ctx, r)
  682. rs := service.Class{}.STTBasicStatusEdit(token, q.ShopID, q.JsonStr, sign)
  683. rst := a.toWebFunc(rs)
  684. return rst, nil
  685. }
  686. // STTBasicPreview 商家课程表详情预览
  687. func (a Api) STTBasicPreview(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  688. // 获取token,并验证签名函数
  689. token, q, sign := a.webToGoVerify(ctx, r)
  690. rs := service.Class{}.STTBasicPreview(token, q.ShopID, q.JsonStr, sign)
  691. rst := a.toWebFunc(rs)
  692. return rst, nil
  693. }
  694. // STTBasicCopy 商家课程表模板复制
  695. func (a Api) STTBasicCopy(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  696. // 获取token,并验证签名函数
  697. token, q, sign := a.webToGoVerify(ctx, r)
  698. rs := service.Class{}.STTBasicCopy(token, q.ShopID, q.JsonStr, sign)
  699. rst := a.toWebFunc(rs)
  700. return rst, nil
  701. }
  702. // STTBasicOfflineEdit 商家课程表上下线状态修改
  703. func (a Api) STTBasicOfflineEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  704. // 获取token,并验证签名函数
  705. token, q, sign := a.webToGoVerify(ctx, r)
  706. rs := service.Class{}.STTBasicOfflineEdit(token, q.ShopID, q.JsonStr, sign)
  707. rst := a.toWebFunc(rs)
  708. return rst, nil
  709. }
  710. // STTDetailListQuery 商家课程表详情列表查询
  711. func (a Api) STTDetailListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  712. // 获取token,并验证签名函数
  713. token, q, sign := a.webToGoVerify(ctx, r)
  714. rs := service.Class{}.STTDetailListQuery(token, q.ShopID, q.JsonStr, sign)
  715. rst := a.toWebFunc(rs)
  716. return rst, nil
  717. }
  718. // STTBasicDetailBatchSave 商家课程表详情批量保存
  719. func (a Api) STTBasicDetailBatchSave(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  720. // 获取token,并验证签名函数
  721. token, q, sign := a.webToGoVerify(ctx, r)
  722. rs := service.Class{}.STTBasicDetailBatchSave(token, q.ShopID, q.JsonStr, sign)
  723. rst := a.toWebFunc(rs)
  724. return rst, nil
  725. }
  726. // STTDetailAllowDelCheck 商家课程表详情判断是否可删除
  727. func (a Api) STTDetailAllowDelCheck(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  728. // 获取token,并验证签名函数
  729. token, q, sign := a.webToGoVerify(ctx, r)
  730. rs := service.Class{}.STTDetailAllowDelCheck(token, q.ShopID, q.JsonStr, sign)
  731. rst := a.toWebFunc(rs)
  732. return rst, nil
  733. }
  734. // ----------------------- 商家上下课管理 ---------------------------------------------
  735. // CourseDetailQuery 课程管理查询
  736. func (a Api) CourseDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  737. // 获取token,并验证签名函数
  738. token, q, sign := a.webToGoVerify(ctx, r)
  739. rs := service.Course{}.CourseDetailQuery(token, q.ShopID, q.JsonStr, sign)
  740. rst := a.toWebFunc(rs)
  741. return rst, nil
  742. }
  743. // ClassListByOrderDate 某日课程表查询
  744. func (a Api) ClassListByOrderDate(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  745. // 获取token,并验证签名函数
  746. token, q, sign := a.webToGoVerify(ctx, r)
  747. rs := service.Course{}.ClassListByOrderDate(token, q.ShopID, q.JsonStr, sign)
  748. rst := a.toWebFunc(rs)
  749. return rst, nil
  750. }
  751. // ClassStartPrepare 上课准备
  752. func (a Api) ClassStartPrepare(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  753. // 获取token,并验证签名函数
  754. token, q, sign := a.courseToGoVerify(ctx, r)
  755. rs := service.Course{}.ClassStartPrepare(token, q.ShopID, q.JsonStr, sign)
  756. if !a.checkRs(rs) {
  757. rst := a.toWebFunc(rs)
  758. return rst, nil
  759. }
  760. if q.IsHr == 1 {
  761. hrRs := service.Hr{}.HrClassStartPrepare(token, q.ShopID, q.JsonStr, sign)
  762. if !a.checkRs(hrRs) {
  763. rst := a.toWebFunc(hrRs)
  764. return rst, nil
  765. }
  766. }
  767. if q.IsScore == 1 {
  768. // todo 调用评分系统接口
  769. if !a.checkRs(rs) {
  770. rst := a.toWebFunc(rs)
  771. return rst, nil
  772. }
  773. }
  774. rst := a.toWebFunc(rs)
  775. return rst, nil
  776. }
  777. // ClassStartPrepareEdit 上课准备修改
  778. func (a Api) ClassStartPrepareEdit(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  779. // 获取token,并验证签名函数
  780. token, q, sign := a.courseToGoVerify(ctx, r)
  781. rs := service.Course{}.ClassStartPrepareEdit(token, q.ShopID, q.JsonStr, sign)
  782. if !a.checkRs(rs) {
  783. rst := a.toWebFunc(rs)
  784. return rst, nil
  785. }
  786. if q.IsHr == 1 {
  787. hrRs := service.Hr{}.ClassStartPrepareEdit(token, q.ShopID, q.JsonStr, sign)
  788. if !a.checkRs(hrRs) {
  789. rst := a.toWebFunc(rs)
  790. return rst, nil
  791. }
  792. }
  793. if q.IsScore == 1 {
  794. // todo 调用评分系统接口
  795. if !a.checkRs(rs) {
  796. rst := a.toWebFunc(rs)
  797. return rst, nil
  798. }
  799. }
  800. rst := a.toWebFunc(rs)
  801. return rst, nil
  802. }
  803. // VipClassDetailQuery 会员上课详情查询
  804. func (a Api) VipClassDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  805. // 获取token,并验证签名函数
  806. token, q, sign := a.webToGoVerify(ctx, r)
  807. rs := service.Course{}.VipClassDetailQuery(token, q.ShopID, q.JsonStr, sign)
  808. rst := a.toWebFunc(rs)
  809. return rst, nil
  810. }
  811. // VipClassDetailAdd 会员上课详情添加-上课未预约
  812. func (a Api) VipClassDetailAdd(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  813. // 获取token,并验证签名函数
  814. token, q, sign := a.courseToGoVerify(ctx, r)
  815. rs := service.Course{}.VipClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
  816. if !a.checkRs(rs) {
  817. rst := a.toWebFunc(rs)
  818. return rst, nil
  819. }
  820. if q.IsHr == 1 {
  821. hrRs := service.Hr{}.HrClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
  822. if !a.checkRs(hrRs) {
  823. rst := a.toWebFunc(hrRs)
  824. return rst, nil
  825. }
  826. }
  827. if q.IsScore == 1 {
  828. // todo 调用评分系统接口
  829. }
  830. rst := a.toWebFunc(rs)
  831. return rst, nil
  832. }
  833. // VipClassDetailDel 会员上课详情删除
  834. func (a Api) VipClassDetailDel(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  835. // 获取token,并验证签名函数
  836. token, q, sign := a.courseToGoVerify(ctx, r)
  837. // 删除应该是先删除心率跟评分库,再去删除基础库数据
  838. if q.IsHr == 1 {
  839. hrRs := service.Hr{}.HrClassDetailDel(token, q.ShopID, q.JsonStr, sign)
  840. if !a.checkRs(hrRs) {
  841. rst := a.toWebFunc(hrRs)
  842. return rst, nil
  843. }
  844. }
  845. if q.IsScore == 1 {
  846. // todo 调用评分系统接口
  847. }
  848. rs := service.Course{}.VipClassDetailDel(token, q.ShopID, q.JsonStr, sign)
  849. if !a.checkRs(rs) {
  850. rst := a.toWebFunc(rs)
  851. return rst, nil
  852. }
  853. rst := a.toWebFunc(rs)
  854. return rst, nil
  855. }
  856. // TmpClassDetailAdd 临时会员上课详情添加
  857. func (a Api) TmpClassDetailAdd(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  858. // 获取token,并验证签名函数
  859. token, q, sign := a.courseToGoVerify(ctx, r)
  860. rs := service.Course{}.TmpClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
  861. if !a.checkRs(rs) {
  862. rst := a.toWebFunc(rs)
  863. return rst, nil
  864. }
  865. if q.IsHr == 1 {
  866. hrRs := service.Hr{}.TmpClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
  867. if !a.checkRs(hrRs) {
  868. rst := a.toWebFunc(hrRs)
  869. return rst, nil
  870. }
  871. }
  872. if q.IsScore == 1 {
  873. // todo 调用评分系统接口
  874. }
  875. rst := a.toWebFunc(rs)
  876. return rst, nil
  877. }
  878. // TmpClassDetailDel 临时会员上课详情删除
  879. func (a Api) TmpClassDetailDel(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  880. // 获取token,并验证签名函数
  881. token, q, sign := a.courseToGoVerify(ctx, r)
  882. // 删除应该是先删除心率跟评分库,再去删除基础库数据
  883. if q.IsHr == 1 {
  884. hrRs := service.Hr{}.HrClassDetailDel(token, q.ShopID, q.JsonStr, sign)
  885. if !a.checkRs(hrRs) {
  886. rst := a.toWebFunc(hrRs)
  887. return rst, nil
  888. }
  889. }
  890. if q.IsScore == 1 {
  891. // todo 调用评分系统接口
  892. }
  893. rs := service.Course{}.TmpClassDetailDel(token, q.ShopID, q.JsonStr, sign)
  894. if !a.checkRs(rs) {
  895. rst := a.toWebFunc(rs)
  896. return rst, nil
  897. }
  898. rst := a.toWebFunc(rs)
  899. return rst, nil
  900. }
  901. // VipClassDetailStatueEdit 会员上课详情状态修改
  902. func (a Api) VipClassDetailStatueEdit(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  903. // 获取token,并验证签名函数
  904. token, q, sign := a.courseToGoVerify(ctx, r)
  905. rs := service.Course{}.VipClassDetailStatueEdit(token, q.ShopID, q.JsonStr, sign)
  906. if !a.checkRs(rs) {
  907. rst := a.toWebFunc(rs)
  908. return rst, nil
  909. }
  910. if q.IsHr == 1 {
  911. hrRs := service.Hr{}.HrClassDetailStatusEdit(token, q.ShopID, q.JsonStr, sign)
  912. if !a.checkRs(hrRs) {
  913. rst := a.toWebFunc(hrRs)
  914. return rst, nil
  915. }
  916. }
  917. if q.IsScore == 1 {
  918. // todo 调用评分系统接口
  919. }
  920. rst := a.toWebFunc(rs)
  921. return rst, nil
  922. }
  923. // ClassStartConfirm 确认上课
  924. func (a Api) ClassStartConfirm(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  925. // 获取token,并验证签名函数
  926. token, q, sign := a.courseToGoVerify(ctx, r)
  927. rs := service.Course{}.ClassStartConfirm(token, q.ShopID, q.JsonStr, sign)
  928. if !a.checkRs(rs) {
  929. rst := a.toWebFunc(rs)
  930. return rst, nil
  931. }
  932. if q.IsScore == 1 {
  933. // todo 调用评分系统接口
  934. }
  935. if q.IsHr == 1 {
  936. hrRs := service.Hr{}.HrClassStartConfirm(token, q.ShopID, q.JsonStr, sign)
  937. if !a.checkRs(hrRs) {
  938. rst := a.toWebFunc(hrRs)
  939. return rst, nil
  940. }
  941. // 心率库修改成功后,调用接口获取上课需要的心率带sn,显示单元eqSn信息,生成Redis
  942. redisRs := service.HrRedis{}.ClassStartR1AndOnClassByUUStdID(token, q.ShopID, q.UUStdID)
  943. if !a.checkRs(redisRs) {
  944. rst := a.toWebFunc(redisRs)
  945. return rst, nil
  946. }
  947. }
  948. rst := a.toWebFunc(rs)
  949. return rst, nil
  950. }
  951. // ClassOverConfirm 确认下课
  952. func (a Api) ClassOverConfirm(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  953. // 获取token,并验证签名函数
  954. token, q, sign := a.webToGoVerify(ctx, r)
  955. rs := service.Course{}.ClassOverConfirm(token, q.ShopID, q.JsonStr, sign)
  956. rst := a.toWebFunc(rs)
  957. return rst, nil
  958. }
  959. // ClassGiveUpConfirm 关闭课程
  960. func (a Api) ClassGiveUpConfirm(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  961. // 获取token,并验证签名函数
  962. token, q, sign := a.courseToGoVerify(ctx, r)
  963. rs := service.Course{}.ClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
  964. if !a.checkRs(rs) {
  965. rst := a.toWebFunc(rs)
  966. return rst, nil
  967. }
  968. if q.IsHr == 1 {
  969. hrRs := service.Hr{}.HrClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
  970. if !a.checkRs(hrRs) {
  971. rst := a.toWebFunc(hrRs)
  972. return rst, nil
  973. }
  974. }
  975. if q.IsScore == 1 {
  976. // todo 调用评分系统接口
  977. }
  978. rst := a.toWebFunc(rs)
  979. return rst, nil
  980. }
  981. // AfterClassAddClassDetail 关闭课程
  982. func (a Api) AfterClassAddClassDetail(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  983. // 获取token,并验证签名函数
  984. token, q, sign := a.courseToGoVerify(ctx, r)
  985. var rs string
  986. // 因为是上课后追加的人,已经在基础库中添加,所以只需要在心率与评分中加入
  987. //rs := service.Course{}.ClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
  988. if q.IsHr == 1 {
  989. rs = service.Hr{}.AfterClassAddClassDetail(token, q.ShopID, q.JsonStr, sign)
  990. if !a.checkRs(rs) {
  991. rst := a.toWebFunc(rs)
  992. return rst, nil
  993. }
  994. }
  995. if q.IsScore == 1 {
  996. // todo 调用评分系统接口
  997. }
  998. rst := a.toWebFunc(rs)
  999. return rst, nil
  1000. }
  1001. // ----------------------- 商家预约管理 ---------------------------------------------
  1002. // OrderListQuery 预约记录查询
  1003. func (a Api) OrderListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1004. // 获取token,并验证签名函数
  1005. token, q, sign := a.webToGoVerify(ctx, r)
  1006. rs := service.Order{}.OrderListQuery(token, q.ShopID, q.JsonStr, sign)
  1007. rst := a.toWebFunc(rs)
  1008. return rst, nil
  1009. }
  1010. // OrderAddByManager 管理员预约添加
  1011. func (a Api) OrderAddByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1012. // 获取token,并验证签名函数
  1013. token, q, sign := a.webToGoVerify(ctx, r)
  1014. rs := service.Order{}.OrderAddByManager(token, q.ShopID, q.JsonStr, sign)
  1015. rst := a.toWebFunc(rs)
  1016. return rst, nil
  1017. }
  1018. // OrderCancelByManager 管理员预约取消
  1019. func (a Api) OrderCancelByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1020. // 获取token,并验证签名函数
  1021. token, q, sign := a.webToGoVerify(ctx, r)
  1022. rs := service.Order{}.OrderCancelByManager(token, q.ShopID, q.JsonStr, sign)
  1023. rst := a.toWebFunc(rs)
  1024. return rst, nil
  1025. }
  1026. // OrderStatistics 商家预约统计
  1027. func (a Api) OrderStatistics(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1028. // 获取token,并验证签名函数
  1029. token, q, sign := a.webToGoVerify(ctx, r)
  1030. rs := service.Order{}.OrderStatistics(token, q.ShopID, q.JsonStr, sign)
  1031. rst := a.toWebFunc(rs)
  1032. return rst, nil
  1033. }
  1034. // ClassOrderQuery 可预约课程预约列表查询
  1035. func (a Api) ClassOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1036. // 获取token,并验证签名函数
  1037. token, q, sign := a.webToGoVerify(ctx, r)
  1038. rs := service.Order{}.ClassOrderQuery(token, q.ShopID, q.JsonStr, sign)
  1039. rst := a.toWebFunc(rs)
  1040. return rst, nil
  1041. }
  1042. // VipUserOrderQuery 会员预约列表查询
  1043. func (a Api) VipUserOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1044. // 获取token,并验证签名函数
  1045. token, q, sign := a.webToGoVerify(ctx, r)
  1046. rs := service.Order{}.VipUserOrderQuery(token, q.ShopID, q.JsonStr, sign)
  1047. rst := a.toWebFunc(rs)
  1048. return rst, nil
  1049. }
  1050. // UserOrderQueryByStd 查询课程预约用户列表
  1051. func (a Api) UserOrderQueryByStd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1052. // 获取token,并验证签名函数
  1053. token, q, sign := a.webToGoVerify(ctx, r)
  1054. rs := service.Order{}.UserOrderQueryByStd(token, q.ShopID, q.JsonStr, sign)
  1055. rst := a.toWebFunc(rs)
  1056. return rst, nil
  1057. }
  1058. // ----------------------- 商家心率管理 ---------------------------------------------
  1059. // HrSensorsPublicQuery 公共心率带查询
  1060. func (a Api) HrSensorsPublicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1061. // 获取token,并验证签名函数
  1062. token, q, sign := a.webToGoVerify(ctx, r)
  1063. rs := service.Hr{}.HrSensorsPublicQuery(token, q.ShopID, q.JsonStr, sign)
  1064. rst := a.toWebFunc(rs)
  1065. return rst, nil
  1066. }
  1067. // HrSensorsPvtQuery 私有心率带查询
  1068. func (a Api) HrSensorsPvtQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1069. // 获取token,并验证签名函数
  1070. token, q, sign := a.webToGoVerify(ctx, r)
  1071. rs := service.Hr{}.HrSensorsPvtQuery(token, q.ShopID, q.JsonStr, sign)
  1072. rst := a.toWebFunc(rs)
  1073. return rst, nil
  1074. }
  1075. // AddHrSensors 公共心率带添加
  1076. func (a Api) AddHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1077. // 获取token,并验证签名函数
  1078. token, q, sign := a.webToGoVerify(ctx, r)
  1079. rs := service.Hr{}.AddHrSensors(token, q.ShopID, q.JsonStr, sign)
  1080. rst := a.toWebFunc(rs)
  1081. return rst, nil
  1082. }
  1083. // AddPvtHrSensors 私有心率带添加
  1084. func (a Api) AddPvtHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1085. // 获取token,并验证签名函数
  1086. token, q, sign := a.webToGoVerify(ctx, r)
  1087. rs := service.Hr{}.AddPvtHrSensors(token, q.ShopID, q.JsonStr, sign)
  1088. rst := a.toWebFunc(rs)
  1089. return rst, nil
  1090. }
  1091. // EditHrSensors 心率带编辑
  1092. func (a Api) EditHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1093. // 获取token,并验证签名函数
  1094. token, q, sign := a.webToGoVerify(ctx, r)
  1095. rs := service.Hr{}.EditHrSensors(token, q.ShopID, q.JsonStr, sign)
  1096. rst := a.toWebFunc(rs)
  1097. return rst, nil
  1098. }
  1099. // HrSensorsDel 心率带删除
  1100. func (a Api) HrSensorsDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1101. // 获取token,并验证签名函数
  1102. token, q, sign := a.webToGoVerify(ctx, r)
  1103. rs := service.Hr{}.HrSensorsDel(token, q.ShopID, q.JsonStr, sign)
  1104. rst := a.toWebFunc(rs)
  1105. return rst, nil
  1106. }
  1107. // PKGroupChg 修改PK分队
  1108. func (a Api) PKGroupChg(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1109. // 获取token,并验证签名函数
  1110. token, q, sign := a.webToGoVerify(ctx, r)
  1111. rs := service.Hr{}.PKGroupChg(token, q.ShopID, q.JsonStr, sign)
  1112. rst := a.toWebFunc(rs)
  1113. return rst, nil
  1114. }
  1115. // BindHrSensor 绑定心率带
  1116. func (a Api) BindHrSensor(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1117. // 获取token,并验证签名函数
  1118. token, q, sign := a.webToGoVerify(ctx, r)
  1119. rs := service.Hr{}.BindHrSensor(token, q.ShopID, q.JsonStr, sign)
  1120. rst := a.toWebFunc(rs)
  1121. return rst, nil
  1122. }
  1123. // UnBindHrSensor 解绑心率带
  1124. func (a Api) UnBindHrSensor(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1125. // 获取token,并验证签名函数
  1126. token, q, sign := a.webToGoVerify(ctx, r)
  1127. rs := service.Hr{}.UnBindHrSensor(token, q.ShopID, q.JsonStr, sign)
  1128. rst := a.toWebFunc(rs)
  1129. return rst, nil
  1130. }
  1131. // ----------------------- 评分管理 ---------------------------------------------
  1132. // ----------------------- 微信管理 ---------------------------------------------
  1133. // GenVerifyImageByWinXin 微信登陆获取图片验证码
  1134. func (Api) GenVerifyImageByWinXin(ctx context.Context, r *pb.GenVerifyImageRequest) (*pb.GenVerifyImageReply, error) {
  1135. //height := int(r.Height)
  1136. //width := int(r.Width)
  1137. id, pic := service.VerifyCode{}.GenImage(int(r.Height), int(r.Width))
  1138. return &pb.GenVerifyImageReply{
  1139. CodeId: id,
  1140. ImageBase64: pic,
  1141. }, nil
  1142. }
  1143. // GenPhoneVerifyCodeByWeiXin 微信登陆获取短信验证码
  1144. func (a Api) GenPhoneVerifyCodeByWeiXin(ctx context.Context, r *pb.GenPhoneVerifyCodeRequestWX) (*pb.StandardReply, error) {
  1145. ip := a.getRemoteIp(ctx)
  1146. rs := service.VerifyCode{}.GetPhoneVFCode(
  1147. r.SId,
  1148. r.Account, ip, global.TemplateCode, r.CodeId, r.ImgCode, r.VerifyType, time.Duration(global.SmsExpireNano))
  1149. rst := a.toWebFunc(rs)
  1150. return rst, nil
  1151. }
  1152. // UserListenMsg Grpc-Web总线机制
  1153. func (Api) UserListenMsg(_ *pb.DefaultRequest, stream pb.Api_UserListenMsgServer) (err error) {
  1154. // TODO 验证并获取 userId
  1155. userId := 0
  1156. channel := service.MsgBus{}.AddListener(userId)
  1157. defer func() {
  1158. service.MsgBus{}.RemoveListener(userId)
  1159. }()
  1160. for {
  1161. select {
  1162. case msg := <-channel:
  1163. {
  1164. pbMsg := &pb.Msg{
  1165. UserIdSend: int64(msg.UserIdSend),
  1166. Title: msg.Title,
  1167. Content: msg.Content,
  1168. }
  1169. err = stream.Send(pbMsg)
  1170. if err != nil {
  1171. // 接收不到不会err信息,可做异常处理
  1172. return
  1173. }
  1174. }
  1175. case <-stream.Context().Done():
  1176. {
  1177. return
  1178. }
  1179. }
  1180. }
  1181. }
  1182. //// WeiXinSignIn 微信登陆
  1183. //func (a Api) WeiXinSignIn(ctx context.Context, r *pb.WeiXinSignInRequest) (*pb.SignInReply, error) {
  1184. //
  1185. //
  1186. // rs := service.Wx{}.WeiXinSignIn(token, q.ShopID, q.JsonStr, sign)
  1187. //
  1188. // return &pb.SignInReply{Token: rs}, nil
  1189. //}