智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_curl_smart_pay.go 32 KiB

1 年之前
8 月之前
1 年之前
8 月之前
1 年之前
11 月之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
8 月之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
10 月之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
8 月之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. package svc
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/customer/md"
  5. "applet/app/db"
  6. "applet/app/db/model"
  7. "applet/app/utils"
  8. "encoding/json"
  9. "errors"
  10. "time"
  11. )
  12. func AesDecrypt(args md.CurlAesDecrypt) (error, interface{}) {
  13. url := cfg.SmartCanteenPay + "/alipay/decrypt/index"
  14. utils.FilePutContents("AesDecrypt", utils.SerializeStr(map[string]interface{}{
  15. "data": args,
  16. }))
  17. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  18. if err != nil {
  19. return err, nil
  20. }
  21. var result struct {
  22. Code int `json:"code"`
  23. Msg string `json:"msg"`
  24. Data interface{} `json:"data"`
  25. }
  26. utils.FilePutContents("AesDecrypt", utils.SerializeStr(result))
  27. err = json.Unmarshal(bytes, &result)
  28. if err != nil {
  29. return err, nil
  30. }
  31. if result.Code != 0 {
  32. if result.Msg != "" {
  33. return errors.New(result.Msg), nil
  34. }
  35. return errors.New("请求智慧餐厅支付 异常/失败"), nil
  36. }
  37. return nil, result.Data
  38. }
  39. func SystemOauthToken(args md.SystemOauthTokenReq) (error, interface{}) {
  40. url := cfg.SmartCanteenPay + "/alipay/systemOauthToken/index"
  41. utils.FilePutContents("SystemOauthToken", utils.SerializeStr(map[string]interface{}{
  42. "data": args,
  43. }))
  44. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  45. if err != nil {
  46. return err, nil
  47. }
  48. var result struct {
  49. Code int `json:"code"`
  50. Msg string `json:"msg"`
  51. Data interface{} `json:"data"`
  52. }
  53. utils.FilePutContents("SystemOauthToken", utils.SerializeStr(result))
  54. err = json.Unmarshal(bytes, &result)
  55. if err != nil {
  56. return err, nil
  57. }
  58. if result.Code != 0 {
  59. if result.Msg != "" {
  60. return errors.New(result.Msg), nil
  61. }
  62. return errors.New("请求智慧餐厅支付 异常/失败"), nil
  63. }
  64. return nil, result.Data
  65. }
  66. func CurlAlipayTradeCreate(args md.CurlAlipayTradeCreateReq) (err error, resp md.CurlAlipayTradeCreateResp) {
  67. url := cfg.SmartCanteenPay + "/alipay/pay/tradeCreate"
  68. utils.FilePutContents("CurlAlipayTradeCreate", utils.SerializeStr(map[string]interface{}{
  69. "args": args,
  70. }))
  71. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  72. if err != nil {
  73. return
  74. }
  75. var result struct {
  76. Code int `json:"code"`
  77. Msg string `json:"msg"`
  78. Data interface{} `json:"data"`
  79. }
  80. utils.FilePutContents("CurlAlipayTradeCreate", utils.SerializeStr(result))
  81. err = json.Unmarshal(bytes, &result)
  82. if err != nil {
  83. return
  84. }
  85. if result.Code != 0 {
  86. if result.Msg != "" {
  87. err = errors.New(result.Msg)
  88. return
  89. }
  90. err = errors.New("请求智慧餐厅支付 异常/失败")
  91. return
  92. }
  93. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  94. if err != nil {
  95. return
  96. }
  97. return
  98. }
  99. func CurlAlipayTradeQuery(args md.CurlAlipayTradeQueryReq) (err error, resp md.CurlAlipayTradeQueryResp) {
  100. url := cfg.SmartCanteenPay + "/alipay/pay/tradeCommonQuery"
  101. utils.FilePutContents("CurlAlipayTradeQuery", utils.SerializeStr(map[string]interface{}{
  102. "args": args,
  103. }))
  104. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  105. if err != nil {
  106. return
  107. }
  108. var result struct {
  109. Code int `json:"code"`
  110. Msg string `json:"msg"`
  111. Data interface{} `json:"data"`
  112. }
  113. utils.FilePutContents("CurlAlipayTradeQuery", utils.SerializeStr(result))
  114. err = json.Unmarshal(bytes, &result)
  115. if err != nil {
  116. return
  117. }
  118. if result.Code != 0 {
  119. if result.Msg != "" {
  120. err = errors.New(result.Msg)
  121. return
  122. }
  123. err = errors.New("请求智慧餐厅支付 异常/失败")
  124. return
  125. }
  126. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  127. if err != nil {
  128. return
  129. }
  130. return
  131. }
  132. func OldCurlAlipayTradeRefund(args md.OldCurlAlipayTradeRefundReq) (err error, resp interface{}) {
  133. url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefund"
  134. utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(map[string]interface{}{
  135. "args": args,
  136. }))
  137. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  138. if err != nil {
  139. return
  140. }
  141. var result struct {
  142. Code int `json:"code"`
  143. Msg string `json:"msg"`
  144. Data interface{} `json:"data"`
  145. }
  146. utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(result))
  147. err = json.Unmarshal(bytes, &result)
  148. if err != nil {
  149. return
  150. }
  151. if result.Code != 0 {
  152. if result.Msg != "" {
  153. err = errors.New(result.Msg)
  154. return
  155. }
  156. err = errors.New("请求智慧餐厅支付 异常/失败")
  157. return
  158. }
  159. return nil, result.Data
  160. }
  161. func CurlAlipayTradeRefund(args md.CurlAlipayTradeRefundReq) (err error, resp interface{}) {
  162. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiTradeRefund"
  163. utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(map[string]interface{}{
  164. "args": args,
  165. }))
  166. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  167. if err != nil {
  168. return
  169. }
  170. var result struct {
  171. Code int `json:"code"`
  172. Msg string `json:"msg"`
  173. Data interface{} `json:"data"`
  174. }
  175. utils.FilePutContents("CurlAlipayTradeRefund", utils.SerializeStr(result))
  176. err = json.Unmarshal(bytes, &result)
  177. if err != nil {
  178. return
  179. }
  180. if result.Code != 0 {
  181. if result.Msg != "" {
  182. err = errors.New(result.Msg)
  183. return
  184. }
  185. err = errors.New("请求智慧餐厅支付 异常/失败")
  186. return
  187. }
  188. return nil, result.Data
  189. }
  190. func CurlAlipayTradeRefundQuery(args md.CurlAlipayTradeRefundQueryReq) (err error, resp interface{}) {
  191. url := cfg.SmartCanteenPay + "/alipay/pay/tradeRefundQuery"
  192. utils.FilePutContents("CurlAlipayTradeRefundQuery", utils.SerializeStr(map[string]interface{}{
  193. "args": args,
  194. }))
  195. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  196. if err != nil {
  197. return
  198. }
  199. var result struct {
  200. Code int `json:"code"`
  201. Msg string `json:"msg"`
  202. Data interface{} `json:"data"`
  203. }
  204. utils.FilePutContents("CurlAlipayTradeRefundQuery", utils.SerializeStr(result))
  205. err = json.Unmarshal(bytes, &result)
  206. if err != nil {
  207. return
  208. }
  209. if result.Code != 0 {
  210. if result.Msg != "" {
  211. err = errors.New(result.Msg)
  212. return
  213. }
  214. err = errors.New("请求智慧餐厅支付 异常/失败")
  215. return
  216. }
  217. return nil, result.Data
  218. }
  219. func CurlEducateSceneTokenQuery(args md.CurlEducateSceneTokenReq, userIdentity *model.UserIdentity, userToken, schoolName string) (err error, resp interface{}) {
  220. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(map[string]interface{}{
  221. "args": args,
  222. }))
  223. if userToken == "" {
  224. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  225. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  226. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  227. "config": map[string]string{
  228. "ali_app_id": args.Config.AliAppId,
  229. "ali_private_key": args.Config.AliPrivateKey,
  230. "ali_public_key": args.Config.AliPublicKey,
  231. },
  232. "cert_no": args.CertNo,
  233. "school_std_code": args.SchoolStdCode,
  234. "student_name": args.StudentName,
  235. "out_user_id": args.OutUserId,
  236. "cert_type": args.CertType,
  237. "sub_code": "SCHOOL_FACE_PASS_QUERY",
  238. }), nil)
  239. if err1 != nil {
  240. return
  241. }
  242. var result struct {
  243. Code int `json:"code"`
  244. Msg string `json:"msg"`
  245. Data interface{} `json:"data"`
  246. }
  247. err1 = json.Unmarshal(bytes, &result)
  248. utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
  249. if err1 != nil {
  250. return
  251. }
  252. if result.Code != 0 {
  253. if result.Msg != "" {
  254. err1 = errors.New(result.Msg)
  255. return
  256. }
  257. err1 = errors.New("请求智慧餐厅支付 异常/失败")
  258. return
  259. }
  260. resultMap, ok := result.Data.(map[string]interface{})
  261. if !ok {
  262. err1 = errors.New("获取 user_token 失败")
  263. return
  264. }
  265. if resultMap["code"].(string) != "10000" {
  266. return nil, resultMap
  267. }
  268. userToken = resultMap["token"].(string)
  269. }
  270. //2、TODO::查询用户一脸通行开通状态:根据获取到的用户信息token,使用 alipay.commerce.educate.scene.token.query 接口查询用户人脸采集状态
  271. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenQuery"
  272. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]string{
  273. "user_token": userToken,
  274. }), nil)
  275. if err != nil {
  276. return
  277. }
  278. var result1 struct {
  279. Code int `json:"code"`
  280. Msg string `json:"msg"`
  281. Data interface{} `json:"data"`
  282. }
  283. err = json.Unmarshal(bytes, &result1)
  284. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
  285. if err != nil {
  286. return
  287. }
  288. if result1.Code != 0 {
  289. if result1.Msg != "" {
  290. err = errors.New(result1.Msg)
  291. return
  292. }
  293. err = errors.New("请求智慧餐厅支付 异常/失败")
  294. return
  295. }
  296. // 更新/新增 `self_support_for_user_facel_info`
  297. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  298. selfSupportForUserFaceInfoDb.Set(userIdentity.Id)
  299. info, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
  300. if err != nil {
  301. return
  302. }
  303. now := time.Now().Format("2006-01-02 15:04:05")
  304. var res map[string]string
  305. utils.Unserialize([]byte(utils.SerializeStr(result1.Data)), &res)
  306. if info == nil {
  307. var concentrateSchoolFacePassStatus = 1
  308. if res["school_face_pass_status"] == "OPEN" {
  309. concentrateSchoolFacePassStatus = 3
  310. }
  311. info = &model.SelfSupportForUserFaceInfo{
  312. EnterpriseId: userIdentity.EnterpriseId,
  313. UserIdentityId: userIdentity.Id,
  314. CollectFaceType: 1,
  315. SchoolCode: res["school_code"],
  316. SchoolStdCode: res["school_std_code"],
  317. ParentUserId: res["parent_user_id"],
  318. ParentLogonId: res["parent_logon_id"],
  319. UserId: res["user_id"],
  320. SchoolFacePassStatus: res["school_face_pass_status"],
  321. SchoolFacePaymentStatus: res["school_face_payment_status"],
  322. ConcentrateSchoolFacePassStatus: concentrateSchoolFacePassStatus,
  323. CreateAt: now,
  324. UpdateAt: now,
  325. }
  326. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
  327. if err2 != nil {
  328. return err2, nil
  329. }
  330. } else {
  331. var concentrateSchoolFacePassStatus = info.ConcentrateSchoolFacePassStatus
  332. if res["school_face_pass_status"] == "OPEN" {
  333. concentrateSchoolFacePassStatus = 3
  334. }
  335. info.ParentUserId = res["parent_user_id"]
  336. info.ParentLogonId = res["parent_logon_id"]
  337. info.UserId = res["user_id"]
  338. info.SchoolFacePassStatus = res["school_face_pass_status"]
  339. info.SchoolFacePaymentStatus = res["school_face_payment_status"]
  340. info.ConcentrateSchoolFacePassStatus = concentrateSchoolFacePassStatus
  341. info.UpdateAt = now
  342. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "parent_user_id", "parent_logon_id", "user_id", "school_face_pass_status", "school_face_payment_status", "concentrate_school_face_pass_status", "update_at")
  343. if err2 != nil {
  344. return err2, nil
  345. }
  346. }
  347. //TODO:: school_face_pass_status && school_face_payment_status 都为 open 状态,则 签约信息同步“alipay.planet.ecocampus.api.roster.signUpInfo” 至 行业云
  348. CurlAlipayPlanetEcocampusApiRosterSignUpInfo(md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq{
  349. FaceUid: info.UserId,
  350. ParentUid: info.ParentUserId,
  351. ParentLogonId: info.ParentLogonId,
  352. RosterName: args.StudentName,
  353. OutRosterCode: args.OutUserId,
  354. SchoolCode: info.SchoolCode,
  355. SchoolName: schoolName,
  356. ScanFacePayStatus: "ON",
  357. FaceOpenStatus: "ON",
  358. })
  359. return nil, result1.Data
  360. }
  361. func CurlEducateSceneTokenQueryV2(args md.CurlEducateSceneTokenReq, userIdentity *model.UserIdentity, userToken, schoolName string) (err error, resp interface{}) {
  362. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(map[string]interface{}{
  363. "args": args,
  364. }))
  365. if userToken == "" {
  366. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  367. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  368. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  369. "config": map[string]string{
  370. "ali_app_id": args.Config.AliAppId,
  371. "ali_private_key": args.Config.AliPrivateKey,
  372. "ali_public_key": args.Config.AliPublicKey,
  373. },
  374. "cert_no": args.CertNo,
  375. "school_std_code": args.SchoolStdCode,
  376. "student_name": args.StudentName,
  377. "out_user_id": args.OutUserId,
  378. "cert_type": args.CertType,
  379. "sub_code": "SCHOOL_FACE_PASS_QUERY",
  380. }), nil)
  381. if err1 != nil {
  382. return
  383. }
  384. var result struct {
  385. Code int `json:"code"`
  386. Msg string `json:"msg"`
  387. Data interface{} `json:"data"`
  388. }
  389. err1 = json.Unmarshal(bytes, &result)
  390. utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
  391. if err1 != nil {
  392. return
  393. }
  394. if result.Code != 0 {
  395. if result.Msg != "" {
  396. err1 = errors.New(result.Msg)
  397. return
  398. }
  399. err1 = errors.New("请求智慧餐厅支付 异常/失败")
  400. return
  401. }
  402. resultMap, ok := result.Data.(map[string]interface{})
  403. if !ok {
  404. err1 = errors.New("获取 user_token 失败")
  405. return
  406. }
  407. if resultMap["code"].(string) != "10000" {
  408. return nil, resultMap
  409. }
  410. userToken = resultMap["token"].(string)
  411. }
  412. //2、TODO::查询用户一脸通行开通状态:根据获取到的用户信息token,使用 alipay.commerce.educate.scene.token.query 接口查询用户人脸采集状态
  413. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenQuery"
  414. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]string{
  415. "user_token": userToken,
  416. }), nil)
  417. if err != nil {
  418. return
  419. }
  420. var result1 struct {
  421. Code int `json:"code"`
  422. Msg string `json:"msg"`
  423. Data interface{} `json:"data"`
  424. }
  425. err = json.Unmarshal(bytes, &result1)
  426. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
  427. if err != nil {
  428. return
  429. }
  430. if result1.Code != 0 {
  431. if result1.Msg != "" {
  432. err = errors.New(result1.Msg)
  433. return
  434. }
  435. err = errors.New("请求智慧餐厅支付 异常/失败")
  436. return
  437. }
  438. return nil, result1.Data
  439. // 更新/新增 `self_support_for_user_facel_info`
  440. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  441. selfSupportForUserFaceInfoDb.Set(userIdentity.Id)
  442. info, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
  443. if err != nil {
  444. return
  445. }
  446. now := time.Now().Format("2006-01-02 15:04:05")
  447. var res map[string]string
  448. utils.Unserialize([]byte(utils.SerializeStr(result1.Data)), &res)
  449. if info == nil {
  450. var concentrateSchoolFacePassStatus = 1
  451. if res["school_face_pass_status"] == "OPEN" {
  452. concentrateSchoolFacePassStatus = 3
  453. }
  454. info = &model.SelfSupportForUserFaceInfo{
  455. EnterpriseId: userIdentity.EnterpriseId,
  456. UserIdentityId: userIdentity.Id,
  457. CollectFaceType: 1,
  458. SchoolCode: res["school_code"],
  459. SchoolStdCode: res["school_std_code"],
  460. ParentUserId: res["parent_user_id"],
  461. ParentLogonId: res["parent_logon_id"],
  462. UserId: res["user_id"],
  463. SchoolFacePassStatus: res["school_face_pass_status"],
  464. SchoolFacePaymentStatus: res["school_face_payment_status"],
  465. ConcentrateSchoolFacePassStatus: concentrateSchoolFacePassStatus,
  466. CreateAt: now,
  467. UpdateAt: now,
  468. }
  469. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
  470. if err2 != nil {
  471. return err2, nil
  472. }
  473. } else {
  474. var concentrateSchoolFacePassStatus = info.ConcentrateSchoolFacePassStatus
  475. if res["school_face_pass_status"] == "OPEN" {
  476. concentrateSchoolFacePassStatus = 3
  477. }
  478. info.ParentUserId = res["parent_user_id"]
  479. info.ParentLogonId = res["parent_logon_id"]
  480. info.UserId = res["user_id"]
  481. info.SchoolFacePassStatus = res["school_face_pass_status"]
  482. info.SchoolFacePaymentStatus = res["school_face_payment_status"]
  483. info.ConcentrateSchoolFacePassStatus = concentrateSchoolFacePassStatus
  484. info.UpdateAt = now
  485. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "parent_user_id", "parent_logon_id", "user_id", "school_face_pass_status", "school_face_payment_status", "concentrate_school_face_pass_status", "update_at")
  486. if err2 != nil {
  487. return err2, nil
  488. }
  489. }
  490. //TODO:: school_face_pass_status && school_face_payment_status 都为 open 状态,则 签约信息同步“alipay.planet.ecocampus.api.roster.signUpInfo” 至 行业云
  491. CurlAlipayPlanetEcocampusApiRosterSignUpInfo(md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq{
  492. FaceUid: info.UserId,
  493. ParentUid: info.ParentUserId,
  494. ParentLogonId: info.ParentLogonId,
  495. RosterName: args.StudentName,
  496. OutRosterCode: args.OutUserId,
  497. SchoolCode: info.SchoolCode,
  498. SchoolName: schoolName,
  499. ScanFacePayStatus: "ON",
  500. FaceOpenStatus: "ON",
  501. })
  502. return nil, result1.Data
  503. }
  504. func CurlEducateSceneKidsClose(args md.CurlEducateSceneKidsCloseReq) (err error, resp interface{}) {
  505. utils.FilePutContents("CurlEducateSceneKidsClose", utils.SerializeStr(map[string]interface{}{
  506. "args": args,
  507. }))
  508. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  509. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneKidsClose"
  510. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  511. "config": map[string]string{
  512. "ali_app_id": args.Config.AliAppId,
  513. "ali_private_key": args.Config.AliPrivateKey,
  514. "ali_public_key": args.Config.AliPublicKey,
  515. },
  516. "cert_no": args.CertNo,
  517. "school_stdcode": args.SchoolStdCode,
  518. "user_id": args.UserId,
  519. "parent_uid": args.ParentUid,
  520. }), nil)
  521. if err1 != nil {
  522. return
  523. }
  524. var result struct {
  525. Code int `json:"code"`
  526. Msg string `json:"msg"`
  527. Data interface{} `json:"data"`
  528. }
  529. utils.FilePutContents("CurlEducateSceneKidsClose", utils.SerializeStr(result))
  530. err = json.Unmarshal(bytes, &result)
  531. if err != nil {
  532. return
  533. }
  534. if result.Code != 0 {
  535. if result.Msg != "" {
  536. err = errors.New(result.Msg)
  537. return
  538. }
  539. err = errors.New("请求智慧餐厅支付 异常/失败")
  540. return
  541. }
  542. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  543. if err != nil {
  544. return
  545. }
  546. return nil, result.Data
  547. }
  548. func CurlEducateFacepayClose(args md.CurlEducateFacepayCloseReq) (err error, resp interface{}) {
  549. utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(map[string]interface{}{
  550. "args": args,
  551. }))
  552. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  553. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateFacepayClose"
  554. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  555. "config": map[string]string{
  556. "ali_app_id": args.Config.AliAppId,
  557. "ali_private_key": args.Config.AliPrivateKey,
  558. "ali_public_key": args.Config.AliPublicKey,
  559. },
  560. "school_stdcode": args.SchoolStdCode,
  561. "face_uid": args.FaceUid,
  562. }), nil)
  563. if err1 != nil {
  564. return
  565. }
  566. var result struct {
  567. Code int `json:"code"`
  568. Msg string `json:"msg"`
  569. Data interface{} `json:"data"`
  570. }
  571. utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(result))
  572. err = json.Unmarshal(bytes, &result)
  573. if err != nil {
  574. return
  575. }
  576. if result.Code != 0 {
  577. if result.Msg != "" {
  578. err = errors.New(result.Msg)
  579. return
  580. }
  581. err = errors.New("请求智慧餐厅支付 异常/失败")
  582. return
  583. }
  584. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  585. if err != nil {
  586. return
  587. }
  588. return nil, result.Data
  589. }
  590. func CurlEducateSceneTokenCreateForApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  591. utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(map[string]interface{}{
  592. "args": args,
  593. }))
  594. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  595. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  596. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  597. "config": map[string]string{
  598. "ali_app_id": args.Config.AliAppId,
  599. "ali_private_key": args.Config.AliPrivateKey,
  600. "ali_public_key": args.Config.AliPublicKey,
  601. },
  602. "cert_no": args.CertNo,
  603. "school_std_code": args.SchoolStdCode,
  604. "student_name": args.StudentName,
  605. "out_user_id": args.OutUserId,
  606. "cert_type": args.CertType,
  607. "sub_code": "SCHOOL_FACE_PASS_NAVIGATE",
  608. }), nil)
  609. if err != nil {
  610. return
  611. }
  612. var result struct {
  613. Code int `json:"code"`
  614. Msg string `json:"msg"`
  615. Data interface{} `json:"data"`
  616. }
  617. err = json.Unmarshal(bytes, &result)
  618. if err != nil {
  619. return
  620. }
  621. utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(result))
  622. if result.Code != 0 {
  623. if result.Msg != "" {
  624. err = errors.New(result.Msg)
  625. return
  626. }
  627. err = errors.New("请求智慧餐厅支付 异常/失败")
  628. return
  629. }
  630. return nil, result.Data
  631. }
  632. func CurlEducateSceneTokenCreateForSchoolFacePassQuery(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  633. utils.FilePutContents("CurlEducateSceneTokenCreateForSchoolFacePassQuery", utils.SerializeStr(map[string]interface{}{
  634. "args": args,
  635. }))
  636. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  637. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  638. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  639. "config": map[string]string{
  640. "ali_app_id": args.Config.AliAppId,
  641. "ali_private_key": args.Config.AliPrivateKey,
  642. "ali_public_key": args.Config.AliPublicKey,
  643. },
  644. "cert_no": args.CertNo,
  645. "school_std_code": args.SchoolStdCode,
  646. "student_name": args.StudentName,
  647. "out_user_id": args.OutUserId,
  648. "cert_type": args.CertType,
  649. "sub_code": "SCHOOL_FACE_PASS_QUERY",
  650. "operator_user_id": args.OperatorUserId, //采集人员的支付宝会员标识。(当sub_code为SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT时,当前参数必选)
  651. }), nil)
  652. if err != nil {
  653. return
  654. }
  655. var result struct {
  656. Code int `json:"code"`
  657. Msg string `json:"msg"`
  658. Data interface{} `json:"data"`
  659. }
  660. utils.FilePutContents("CurlEducateSceneTokenCreateForSchoolFacePassQuery", utils.SerializeStr(result))
  661. err = json.Unmarshal(bytes, &result)
  662. if err != nil {
  663. return
  664. }
  665. if result.Code != 0 {
  666. if result.Msg != "" {
  667. err = errors.New(result.Msg)
  668. return
  669. }
  670. err = errors.New("请求智慧餐厅支付 异常/失败")
  671. return
  672. }
  673. return nil, result.Data
  674. }
  675. func CurlEducateSceneTokenCreateForConcentratedCollectApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  676. utils.FilePutContents("CurlEducateSceneTokenCreateForConcentratedCollectApplet", utils.SerializeStr(map[string]interface{}{
  677. "args": args,
  678. }))
  679. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  680. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  681. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  682. "config": map[string]string{
  683. "ali_app_id": args.Config.AliAppId,
  684. "ali_private_key": args.Config.AliPrivateKey,
  685. "ali_public_key": args.Config.AliPublicKey,
  686. },
  687. "cert_no": args.CertNo,
  688. "school_std_code": args.SchoolStdCode,
  689. "student_name": args.StudentName,
  690. "out_user_id": args.OutUserId,
  691. "cert_type": args.CertType,
  692. "sub_code": "SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT",
  693. "operator_user_id": args.OperatorUserId, //采集人员的支付宝会员标识。(当sub_code为SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT时,当前参数必选)
  694. }), nil)
  695. if err != nil {
  696. return
  697. }
  698. var result struct {
  699. Code int `json:"code"`
  700. Msg string `json:"msg"`
  701. Data interface{} `json:"data"`
  702. }
  703. utils.FilePutContents("CurlEducateSceneTokenCreateForConcentratedCollectApplet", utils.SerializeStr(result))
  704. err = json.Unmarshal(bytes, &result)
  705. if err != nil {
  706. return
  707. }
  708. if result.Code != 0 {
  709. if result.Msg != "" {
  710. err = errors.New(result.Msg)
  711. return
  712. }
  713. err = errors.New("请求智慧餐厅支付 异常/失败")
  714. return
  715. }
  716. return nil, result.Data
  717. }
  718. func CurlEducateFacepayApply(args md.CurlEducateFacepayApplyReq) (err error, resp interface{}) {
  719. //1、TODO::alipay.commerce.educate.facepay.apply(人脸开通支付申请)
  720. url := cfg.SmartCanteenPay + "/alipay/faceScanPay/educateFacepayApply"
  721. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  722. "config": map[string]string{
  723. "ali_app_id": args.Config.AliAppId,
  724. "ali_private_key": args.Config.AliPrivateKey,
  725. "ali_public_key": args.Config.AliPublicKey,
  726. },
  727. "face_uid": args.FaceUid,
  728. "school_std_code": args.SchoolStdCode,
  729. "face_open_id": args.FaceOpenId,
  730. }), nil)
  731. if err != nil {
  732. return
  733. }
  734. var result struct {
  735. Code int `json:"code"`
  736. Msg string `json:"msg"`
  737. Data interface{} `json:"data"`
  738. }
  739. err = json.Unmarshal(bytes, &result)
  740. if err != nil {
  741. return
  742. }
  743. utils.FilePutContents("CurlEducateFacepayApply", utils.SerializeStr(map[string]interface{}{
  744. "args": args,
  745. "result": result,
  746. }))
  747. if result.Code != 0 {
  748. if result.Msg != "" {
  749. err = errors.New(result.Msg)
  750. return
  751. }
  752. err = errors.New("请求智慧餐厅支付 异常/失败")
  753. return
  754. }
  755. return nil, result.Data
  756. }
  757. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(args md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq) (err error, resp interface{}) {
  758. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterSignUpInfo"
  759. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSignUpInfo", utils.SerializeStr(map[string]interface{}{
  760. "args": args,
  761. }))
  762. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  763. if err != nil {
  764. return
  765. }
  766. var result struct {
  767. Code int `json:"code"`
  768. Msg string `json:"msg"`
  769. Data interface{} `json:"data"`
  770. }
  771. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSignUpInfo", utils.SerializeStr(result))
  772. err = json.Unmarshal(bytes, &result)
  773. if err != nil {
  774. return
  775. }
  776. if result.Code != 0 {
  777. if result.Msg != "" {
  778. err = errors.New(result.Msg)
  779. return
  780. }
  781. err = errors.New("请求智慧餐厅支付 异常/失败")
  782. return
  783. }
  784. return nil, result.Data
  785. }
  786. func CurlSelfSupportForSchoolOrderDebtRepay(args md.CurlSelfSupportForSchoolOrderDebtRepay) (err error, resp interface{}) {
  787. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtRepay"
  788. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(map[string]interface{}{
  789. "args": args,
  790. }))
  791. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  792. if err != nil {
  793. return
  794. }
  795. var result struct {
  796. Code int `json:"code"`
  797. Msg string `json:"msg"`
  798. Data interface{} `json:"data"`
  799. }
  800. err = json.Unmarshal(bytes, &result)
  801. if err != nil {
  802. return
  803. }
  804. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(result))
  805. if result.Code != 0 {
  806. if result.Msg != "" {
  807. err = errors.New(result.Msg)
  808. return
  809. }
  810. err = errors.New("请求智慧餐厅支付 异常/失败")
  811. return
  812. }
  813. mMap, ok := result.Data.(map[string]interface{})
  814. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(mMap))
  815. if ok {
  816. if mMap["code"] == "10000" {
  817. //TODO::更新订单状态
  818. selfSupportForSchoolOrdDb := db.SelfSupportForSchoolOrd{}
  819. selfSupportForSchoolOrdDb.Set(args.OutOrderNo)
  820. ord, err1 := selfSupportForSchoolOrdDb.GetSelfSupportForSchoolOrd()
  821. if err1 != nil {
  822. err = err1
  823. return
  824. }
  825. ord.OrderStatus = 2
  826. selfSupportForSchoolOrdDb.SelfSupportForSchoolOrdUpdate(ord, "order_status")
  827. }
  828. }
  829. return nil, result.Data
  830. }
  831. func CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo(args md.CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo) (err error, resp interface{}) {
  832. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtPageQueryDebtInfo"
  833. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo", utils.SerializeStr(map[string]interface{}{
  834. "args": args,
  835. }))
  836. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  837. if err != nil {
  838. return
  839. }
  840. var result struct {
  841. Code int `json:"code"`
  842. Msg string `json:"msg"`
  843. Data interface{} `json:"data"`
  844. }
  845. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo", utils.SerializeStr(result))
  846. err = json.Unmarshal(bytes, &result)
  847. if err != nil {
  848. return
  849. }
  850. if result.Code != 0 {
  851. if result.Msg != "" {
  852. err = errors.New(result.Msg)
  853. return
  854. }
  855. err = errors.New("请求智慧餐厅支付 异常/失败")
  856. return
  857. }
  858. return nil, result.Data
  859. }
  860. func CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList(args md.CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList) (err error, resp interface{}) {
  861. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterPageQueryBlackList"
  862. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList", utils.SerializeStr(map[string]interface{}{
  863. "args": args,
  864. }))
  865. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  866. if err != nil {
  867. return
  868. }
  869. var result struct {
  870. Code int `json:"code"`
  871. Msg string `json:"msg"`
  872. Data interface{} `json:"data"`
  873. }
  874. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList", utils.SerializeStr(result))
  875. err = json.Unmarshal(bytes, &result)
  876. if err != nil {
  877. return
  878. }
  879. if result.Code != 0 {
  880. if result.Msg != "" {
  881. err = errors.New(result.Msg)
  882. return
  883. }
  884. err = errors.New("请求智慧餐厅支付 异常/失败")
  885. return
  886. }
  887. return nil, result.Data
  888. }
  889. func CurlAlipayPlanetEcocampusApiDebtCancel(args md.CurlAlipayPlanetEcocampusApiDebtCancel) (err error, resp interface{}) {
  890. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtCancel"
  891. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtCancel", utils.SerializeStr(map[string]interface{}{
  892. "args": args,
  893. }))
  894. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  895. if err != nil {
  896. return
  897. }
  898. var result struct {
  899. Code int `json:"code"`
  900. Msg string `json:"msg"`
  901. Data interface{} `json:"data"`
  902. }
  903. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtCancel", utils.SerializeStr(result))
  904. err = json.Unmarshal(bytes, &result)
  905. if err != nil {
  906. return
  907. }
  908. if result.Code != 0 {
  909. if result.Msg != "" {
  910. err = errors.New(result.Msg)
  911. return
  912. }
  913. err = errors.New("请求智慧餐厅支付 异常/失败")
  914. return
  915. }
  916. return nil, result.Data
  917. }
  918. func CurlAlipayPlanetEcocampusApiRosterSingleConsumeLimitSync(args md.CurlAlipayPlanetEcocampusApiRosterSingleConsumeLimitSync) (err error, resp interface{}) {
  919. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterSingleConsumeLimitSync"
  920. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSingleConsumeLimitSync", utils.SerializeStr(map[string]interface{}{
  921. "args": args,
  922. }))
  923. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  924. if err != nil {
  925. return
  926. }
  927. var result struct {
  928. Code int `json:"code"`
  929. Msg string `json:"msg"`
  930. Data interface{} `json:"data"`
  931. }
  932. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSingleConsumeLimitSync", utils.SerializeStr(result))
  933. err = json.Unmarshal(bytes, &result)
  934. if err != nil {
  935. return
  936. }
  937. if result.Code != 0 {
  938. if result.Msg != "" {
  939. err = errors.New(result.Msg)
  940. return
  941. }
  942. err = errors.New("请求智慧餐厅支付 异常/失败")
  943. return
  944. }
  945. return nil, result.Data
  946. }
  947. func CurlAlipayPlanetEcocampusApiFtokenQuery(args md.CurlAlipayPlanetEcocampusApiFtokenQueryReq) (err error, resp interface{}) {
  948. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiFtokenQuery"
  949. utils.FilePutContents("CurlAlipayPlanetEcocampusApiFtokenQuery", utils.SerializeStr(map[string]interface{}{
  950. "args": args,
  951. }))
  952. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  953. if err != nil {
  954. return
  955. }
  956. var result struct {
  957. Code int `json:"code"`
  958. Msg string `json:"msg"`
  959. Data interface{} `json:"data"`
  960. }
  961. utils.FilePutContents("CurlAlipayPlanetEcocampusApiFtokenQuery", utils.SerializeStr(result))
  962. err = json.Unmarshal(bytes, &result)
  963. if err != nil {
  964. return
  965. }
  966. if result.Code != 0 {
  967. if result.Msg != "" {
  968. err = errors.New(result.Msg)
  969. return
  970. }
  971. err = errors.New("请求智慧餐厅支付 异常/失败")
  972. return
  973. }
  974. return nil, result.Data
  975. }