base.go 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  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{}.HrClassDetailDel(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. redisRs := service.HrRedis{}.ClassStartR1AndOnClassByUUStdID(token, q.ShopID, q.UUStdID)
  942. if !a.checkRs(redisRs) {
  943. rst := a.toWebFunc(redisRs)
  944. return rst, nil
  945. }
  946. }
  947. rst := a.toWebFunc(rs)
  948. return rst, nil
  949. }
  950. // ClassOverConfirm 确认下课
  951. func (a Api) ClassOverConfirm(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  952. // 获取token,并验证签名函数
  953. token, q, sign := a.webToGoVerify(ctx, r)
  954. rs := service.Course{}.ClassOverConfirm(token, q.ShopID, q.JsonStr, sign)
  955. rst := a.toWebFunc(rs)
  956. return rst, nil
  957. }
  958. // ClassGiveUpConfirm 关闭课程
  959. func (a Api) ClassGiveUpConfirm(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  960. // 获取token,并验证签名函数
  961. token, q, sign := a.courseToGoVerify(ctx, r)
  962. rs := service.Course{}.ClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
  963. if !a.checkRs(rs) {
  964. rst := a.toWebFunc(rs)
  965. return rst, nil
  966. }
  967. if q.IsHr == 1 {
  968. hrRs := service.Hr{}.HrClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
  969. if !a.checkRs(hrRs) {
  970. rst := a.toWebFunc(hrRs)
  971. return rst, nil
  972. }
  973. }
  974. if q.IsScore == 1 {
  975. // todo 调用评分系统接口
  976. }
  977. rst := a.toWebFunc(rs)
  978. return rst, nil
  979. }
  980. // AfterClassAddClassDetail 关闭课程
  981. func (a Api) AfterClassAddClassDetail(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
  982. // 获取token,并验证签名函数
  983. token, q, sign := a.courseToGoVerify(ctx, r)
  984. var rs string
  985. // 因为是上课后追加的人,已经在基础库中添加,所以只需要在心率与评分中加入
  986. //rs := service.Course{}.ClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
  987. if q.IsHr == 1 {
  988. rs = service.Hr{}.AfterClassAddClassDetail(token, q.ShopID, q.JsonStr, sign)
  989. if !a.checkRs(rs) {
  990. rst := a.toWebFunc(rs)
  991. return rst, nil
  992. }
  993. }
  994. if q.IsScore == 1 {
  995. // todo 调用评分系统接口
  996. }
  997. rst := a.toWebFunc(rs)
  998. return rst, nil
  999. }
  1000. // ----------------------- 商家预约管理 ---------------------------------------------
  1001. // OrderListQuery 预约记录查询
  1002. func (a Api) OrderListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1003. // 获取token,并验证签名函数
  1004. token, q, sign := a.webToGoVerify(ctx, r)
  1005. rs := service.Order{}.OrderListQuery(token, q.ShopID, q.JsonStr, sign)
  1006. rst := a.toWebFunc(rs)
  1007. return rst, nil
  1008. }
  1009. // OrderAddByManager 管理员预约添加
  1010. func (a Api) OrderAddByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1011. // 获取token,并验证签名函数
  1012. token, q, sign := a.webToGoVerify(ctx, r)
  1013. rs := service.Order{}.OrderAddByManager(token, q.ShopID, q.JsonStr, sign)
  1014. rst := a.toWebFunc(rs)
  1015. return rst, nil
  1016. }
  1017. // OrderCancelByManager 管理员预约取消
  1018. func (a Api) OrderCancelByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1019. // 获取token,并验证签名函数
  1020. token, q, sign := a.webToGoVerify(ctx, r)
  1021. rs := service.Order{}.OrderCancelByManager(token, q.ShopID, q.JsonStr, sign)
  1022. rst := a.toWebFunc(rs)
  1023. return rst, nil
  1024. }
  1025. // OrderStatistics 商家预约统计
  1026. func (a Api) OrderStatistics(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1027. // 获取token,并验证签名函数
  1028. token, q, sign := a.webToGoVerify(ctx, r)
  1029. rs := service.Order{}.OrderStatistics(token, q.ShopID, q.JsonStr, sign)
  1030. rst := a.toWebFunc(rs)
  1031. return rst, nil
  1032. }
  1033. // ClassOrderQuery 可预约课程预约列表查询
  1034. func (a Api) ClassOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1035. // 获取token,并验证签名函数
  1036. token, q, sign := a.webToGoVerify(ctx, r)
  1037. rs := service.Order{}.ClassOrderQuery(token, q.ShopID, q.JsonStr, sign)
  1038. rst := a.toWebFunc(rs)
  1039. return rst, nil
  1040. }
  1041. // VipUserOrderQuery 会员预约列表查询
  1042. func (a Api) VipUserOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1043. // 获取token,并验证签名函数
  1044. token, q, sign := a.webToGoVerify(ctx, r)
  1045. rs := service.Order{}.VipUserOrderQuery(token, q.ShopID, q.JsonStr, sign)
  1046. rst := a.toWebFunc(rs)
  1047. return rst, nil
  1048. }
  1049. // UserOrderQueryByStd 查询课程预约用户列表
  1050. func (a Api) UserOrderQueryByStd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1051. // 获取token,并验证签名函数
  1052. token, q, sign := a.webToGoVerify(ctx, r)
  1053. rs := service.Order{}.UserOrderQueryByStd(token, q.ShopID, q.JsonStr, sign)
  1054. rst := a.toWebFunc(rs)
  1055. return rst, nil
  1056. }
  1057. // ----------------------- 商家心率管理 ---------------------------------------------
  1058. // HrSensorsPublicQuery 公共心率带查询
  1059. func (a Api) HrSensorsPublicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1060. // 获取token,并验证签名函数
  1061. token, q, sign := a.webToGoVerify(ctx, r)
  1062. rs := service.Hr{}.HrSensorsPublicQuery(token, q.ShopID, q.JsonStr, sign)
  1063. rst := a.toWebFunc(rs)
  1064. return rst, nil
  1065. }
  1066. // HrSensorsPvtQuery 私有心率带查询
  1067. func (a Api) HrSensorsPvtQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1068. // 获取token,并验证签名函数
  1069. token, q, sign := a.webToGoVerify(ctx, r)
  1070. rs := service.Hr{}.HrSensorsPvtQuery(token, q.ShopID, q.JsonStr, sign)
  1071. rst := a.toWebFunc(rs)
  1072. return rst, nil
  1073. }
  1074. // AddHrSensors 公共心率带添加
  1075. func (a Api) AddHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1076. // 获取token,并验证签名函数
  1077. token, q, sign := a.webToGoVerify(ctx, r)
  1078. rs := service.Hr{}.AddHrSensors(token, q.ShopID, q.JsonStr, sign)
  1079. rst := a.toWebFunc(rs)
  1080. return rst, nil
  1081. }
  1082. // AddPvtHrSensors 私有心率带添加
  1083. func (a Api) AddPvtHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1084. // 获取token,并验证签名函数
  1085. token, q, sign := a.webToGoVerify(ctx, r)
  1086. rs := service.Hr{}.AddPvtHrSensors(token, q.ShopID, q.JsonStr, sign)
  1087. rst := a.toWebFunc(rs)
  1088. return rst, nil
  1089. }
  1090. // EditHrSensors 心率带编辑
  1091. func (a Api) EditHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1092. // 获取token,并验证签名函数
  1093. token, q, sign := a.webToGoVerify(ctx, r)
  1094. rs := service.Hr{}.EditHrSensors(token, q.ShopID, q.JsonStr, sign)
  1095. rst := a.toWebFunc(rs)
  1096. return rst, nil
  1097. }
  1098. // HrSensorsDel 心率带删除
  1099. func (a Api) HrSensorsDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1100. // 获取token,并验证签名函数
  1101. token, q, sign := a.webToGoVerify(ctx, r)
  1102. rs := service.Hr{}.HrSensorsDel(token, q.ShopID, q.JsonStr, sign)
  1103. rst := a.toWebFunc(rs)
  1104. return rst, nil
  1105. }
  1106. // PKGroupChg 修改PK分队
  1107. func (a Api) PKGroupChg(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1108. // 获取token,并验证签名函数
  1109. token, q, sign := a.webToGoVerify(ctx, r)
  1110. rs := service.Hr{}.PKGroupChg(token, q.ShopID, q.JsonStr, sign)
  1111. rst := a.toWebFunc(rs)
  1112. return rst, nil
  1113. }
  1114. // BindHrSensor 绑定心率带
  1115. func (a Api) BindHrSensor(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1116. // 获取token,并验证签名函数
  1117. token, q, sign := a.webToGoVerify(ctx, r)
  1118. rs := service.Hr{}.BindHrSensor(token, q.ShopID, q.JsonStr, sign)
  1119. rst := a.toWebFunc(rs)
  1120. return rst, nil
  1121. }
  1122. // UnBindHrSensor 解绑心率带
  1123. func (a Api) UnBindHrSensor(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
  1124. // 获取token,并验证签名函数
  1125. token, q, sign := a.webToGoVerify(ctx, r)
  1126. rs := service.Hr{}.UnBindHrSensor(token, q.ShopID, q.JsonStr, sign)
  1127. rst := a.toWebFunc(rs)
  1128. return rst, nil
  1129. }
  1130. // ----------------------- 评分管理 ---------------------------------------------
  1131. // ----------------------- 微信管理 ---------------------------------------------
  1132. // GenVerifyImageByWinXin 微信登陆获取图片验证码
  1133. func (Api) GenVerifyImageByWinXin(ctx context.Context, r *pb.GenVerifyImageRequest) (*pb.GenVerifyImageReply, error) {
  1134. //height := int(r.Height)
  1135. //width := int(r.Width)
  1136. id, pic := service.VerifyCode{}.GenImage(int(r.Height), int(r.Width))
  1137. return &pb.GenVerifyImageReply{
  1138. CodeId: id,
  1139. ImageBase64: pic,
  1140. }, nil
  1141. }
  1142. // GenPhoneVerifyCodeByWeiXin 微信登陆获取短信验证码
  1143. func (a Api) GenPhoneVerifyCodeByWeiXin(ctx context.Context, r *pb.GenPhoneVerifyCodeRequestWX) (*pb.StandardReply, error) {
  1144. ip := a.getRemoteIp(ctx)
  1145. rs := service.VerifyCode{}.GetPhoneVFCode(
  1146. r.SId,
  1147. r.Account, ip, global.TemplateCode, r.CodeId, r.ImgCode, r.VerifyType, time.Duration(global.SmsExpireNano))
  1148. rst := a.toWebFunc(rs)
  1149. return rst, nil
  1150. }
  1151. //// WeiXinSignIn 微信登陆
  1152. //func (a Api) WeiXinSignIn(ctx context.Context, r *pb.WeiXinSignInRequest) (*pb.SignInReply, error) {
  1153. //
  1154. //
  1155. // rs := service.Wx{}.WeiXinSignIn(token, q.ShopID, q.JsonStr, sign)
  1156. //
  1157. // return &pb.SignInReply{Token: rs}, nil
  1158. //}