智慧食堂
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 28 KiB

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 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  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 CurlAlipayTradeRefund(args md.CurlAlipayTradeRefundReq) (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 CurlEducateSceneTokenQuery(args md.CurlEducateSceneTokenReq, userIdentity *model.UserIdentity, userToken, schoolName string) (err error, resp interface{}) {
  162. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(map[string]interface{}{
  163. "args": args,
  164. }))
  165. if userToken == "" {
  166. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  167. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  168. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  169. "config": map[string]string{
  170. "ali_app_id": args.Config.AliAppId,
  171. "ali_private_key": args.Config.AliPrivateKey,
  172. "ali_public_key": args.Config.AliPublicKey,
  173. },
  174. "cert_no": args.CertNo,
  175. "school_std_code": args.SchoolStdCode,
  176. "student_name": args.StudentName,
  177. "out_user_id": args.OutUserId,
  178. "cert_type": args.CertType,
  179. "sub_code": "SCHOOL_FACE_PASS_QUERY",
  180. }), nil)
  181. if err1 != nil {
  182. return
  183. }
  184. var result struct {
  185. Code int `json:"code"`
  186. Msg string `json:"msg"`
  187. Data interface{} `json:"data"`
  188. }
  189. err1 = json.Unmarshal(bytes, &result)
  190. utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
  191. if err1 != nil {
  192. return
  193. }
  194. if result.Code != 0 {
  195. if result.Msg != "" {
  196. err1 = errors.New(result.Msg)
  197. return
  198. }
  199. err1 = errors.New("请求智慧餐厅支付 异常/失败")
  200. return
  201. }
  202. resultMap, ok := result.Data.(map[string]interface{})
  203. if !ok {
  204. err1 = errors.New("获取 user_token 失败")
  205. return
  206. }
  207. if resultMap["code"].(string) != "10000" {
  208. return nil, resultMap
  209. }
  210. userToken = resultMap["token"].(string)
  211. }
  212. //2、TODO::查询用户一脸通行开通状态:根据获取到的用户信息token,使用 alipay.commerce.educate.scene.token.query 接口查询用户人脸采集状态
  213. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenQuery"
  214. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]string{
  215. "user_token": userToken,
  216. }), nil)
  217. if err != nil {
  218. return
  219. }
  220. var result1 struct {
  221. Code int `json:"code"`
  222. Msg string `json:"msg"`
  223. Data interface{} `json:"data"`
  224. }
  225. err = json.Unmarshal(bytes, &result1)
  226. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
  227. if err != nil {
  228. return
  229. }
  230. if result1.Code != 0 {
  231. if result1.Msg != "" {
  232. err = errors.New(result1.Msg)
  233. return
  234. }
  235. err = errors.New("请求智慧餐厅支付 异常/失败")
  236. return
  237. }
  238. // 更新/新增 `self_support_for_user_facel_info`
  239. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  240. selfSupportForUserFaceInfoDb.Set(userIdentity.Id)
  241. info, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
  242. if err != nil {
  243. return
  244. }
  245. now := time.Now().Format("2006-01-02 15:04:05")
  246. var res map[string]string
  247. utils.Unserialize([]byte(utils.SerializeStr(result1.Data)), &res)
  248. if info == nil {
  249. var concentrateSchoolFacePassStatus = 1
  250. if res["school_face_pass_status"] == "OPEN" {
  251. concentrateSchoolFacePassStatus = 3
  252. }
  253. info = &model.SelfSupportForUserFaceInfo{
  254. EnterpriseId: userIdentity.EnterpriseId,
  255. UserIdentityId: userIdentity.Id,
  256. CollectFaceType: 1,
  257. SchoolCode: res["school_code"],
  258. SchoolStdCode: res["school_std_code"],
  259. ParentUserId: res["parent_user_id"],
  260. ParentLogonId: res["parent_logon_id"],
  261. UserId: res["user_id"],
  262. SchoolFacePassStatus: res["school_face_pass_status"],
  263. SchoolFacePaymentStatus: res["school_face_payment_status"],
  264. ConcentrateSchoolFacePassStatus: concentrateSchoolFacePassStatus,
  265. CreateAt: now,
  266. UpdateAt: now,
  267. }
  268. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
  269. if err2 != nil {
  270. return err2, nil
  271. }
  272. } else {
  273. var concentrateSchoolFacePassStatus = info.ConcentrateSchoolFacePassStatus
  274. if res["school_face_pass_status"] == "OPEN" {
  275. concentrateSchoolFacePassStatus = 3
  276. }
  277. info.ParentUserId = res["parent_user_id"]
  278. info.ParentLogonId = res["parent_logon_id"]
  279. info.UserId = res["user_id"]
  280. info.SchoolFacePassStatus = res["school_face_pass_status"]
  281. info.SchoolFacePaymentStatus = res["school_face_payment_status"]
  282. info.ConcentrateSchoolFacePassStatus = concentrateSchoolFacePassStatus
  283. info.UpdateAt = now
  284. _, 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")
  285. if err2 != nil {
  286. return err2, nil
  287. }
  288. }
  289. //TODO:: school_face_pass_status && school_face_payment_status 都为 open 状态,则 签约信息同步“alipay.planet.ecocampus.api.roster.signUpInfo” 至 行业云
  290. CurlAlipayPlanetEcocampusApiRosterSignUpInfo(md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq{
  291. FaceUid: info.UserId,
  292. ParentUid: info.ParentUserId,
  293. ParentLogonId: info.ParentLogonId,
  294. RosterName: args.StudentName,
  295. OutRosterCode: args.OutUserId,
  296. SchoolCode: info.SchoolCode,
  297. SchoolName: schoolName,
  298. ScanFacePayStatus: "ON",
  299. FaceOpenStatus: "ON",
  300. })
  301. return nil, result1.Data
  302. }
  303. func CurlEducateSceneTokenQueryV2(args md.CurlEducateSceneTokenReq, userIdentity *model.UserIdentity, userToken, schoolName string) (err error, resp interface{}) {
  304. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(map[string]interface{}{
  305. "args": args,
  306. }))
  307. if userToken == "" {
  308. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  309. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  310. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  311. "config": map[string]string{
  312. "ali_app_id": args.Config.AliAppId,
  313. "ali_private_key": args.Config.AliPrivateKey,
  314. "ali_public_key": args.Config.AliPublicKey,
  315. },
  316. "cert_no": args.CertNo,
  317. "school_std_code": args.SchoolStdCode,
  318. "student_name": args.StudentName,
  319. "out_user_id": args.OutUserId,
  320. "cert_type": args.CertType,
  321. "sub_code": "SCHOOL_FACE_PASS_QUERY",
  322. }), nil)
  323. if err1 != nil {
  324. return
  325. }
  326. var result struct {
  327. Code int `json:"code"`
  328. Msg string `json:"msg"`
  329. Data interface{} `json:"data"`
  330. }
  331. err1 = json.Unmarshal(bytes, &result)
  332. utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
  333. if err1 != nil {
  334. return
  335. }
  336. if result.Code != 0 {
  337. if result.Msg != "" {
  338. err1 = errors.New(result.Msg)
  339. return
  340. }
  341. err1 = errors.New("请求智慧餐厅支付 异常/失败")
  342. return
  343. }
  344. resultMap, ok := result.Data.(map[string]interface{})
  345. if !ok {
  346. err1 = errors.New("获取 user_token 失败")
  347. return
  348. }
  349. if resultMap["code"].(string) != "10000" {
  350. return nil, resultMap
  351. }
  352. userToken = resultMap["token"].(string)
  353. }
  354. //2、TODO::查询用户一脸通行开通状态:根据获取到的用户信息token,使用 alipay.commerce.educate.scene.token.query 接口查询用户人脸采集状态
  355. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenQuery"
  356. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]string{
  357. "user_token": userToken,
  358. }), nil)
  359. if err != nil {
  360. return
  361. }
  362. var result1 struct {
  363. Code int `json:"code"`
  364. Msg string `json:"msg"`
  365. Data interface{} `json:"data"`
  366. }
  367. err = json.Unmarshal(bytes, &result1)
  368. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
  369. if err != nil {
  370. return
  371. }
  372. if result1.Code != 0 {
  373. if result1.Msg != "" {
  374. err = errors.New(result1.Msg)
  375. return
  376. }
  377. err = errors.New("请求智慧餐厅支付 异常/失败")
  378. return
  379. }
  380. return nil, result1.Data
  381. // 更新/新增 `self_support_for_user_facel_info`
  382. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  383. selfSupportForUserFaceInfoDb.Set(userIdentity.Id)
  384. info, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
  385. if err != nil {
  386. return
  387. }
  388. now := time.Now().Format("2006-01-02 15:04:05")
  389. var res map[string]string
  390. utils.Unserialize([]byte(utils.SerializeStr(result1.Data)), &res)
  391. if info == nil {
  392. var concentrateSchoolFacePassStatus = 1
  393. if res["school_face_pass_status"] == "OPEN" {
  394. concentrateSchoolFacePassStatus = 3
  395. }
  396. info = &model.SelfSupportForUserFaceInfo{
  397. EnterpriseId: userIdentity.EnterpriseId,
  398. UserIdentityId: userIdentity.Id,
  399. CollectFaceType: 1,
  400. SchoolCode: res["school_code"],
  401. SchoolStdCode: res["school_std_code"],
  402. ParentUserId: res["parent_user_id"],
  403. ParentLogonId: res["parent_logon_id"],
  404. UserId: res["user_id"],
  405. SchoolFacePassStatus: res["school_face_pass_status"],
  406. SchoolFacePaymentStatus: res["school_face_payment_status"],
  407. ConcentrateSchoolFacePassStatus: concentrateSchoolFacePassStatus,
  408. CreateAt: now,
  409. UpdateAt: now,
  410. }
  411. _, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
  412. if err2 != nil {
  413. return err2, nil
  414. }
  415. } else {
  416. var concentrateSchoolFacePassStatus = info.ConcentrateSchoolFacePassStatus
  417. if res["school_face_pass_status"] == "OPEN" {
  418. concentrateSchoolFacePassStatus = 3
  419. }
  420. info.ParentUserId = res["parent_user_id"]
  421. info.ParentLogonId = res["parent_logon_id"]
  422. info.UserId = res["user_id"]
  423. info.SchoolFacePassStatus = res["school_face_pass_status"]
  424. info.SchoolFacePaymentStatus = res["school_face_payment_status"]
  425. info.ConcentrateSchoolFacePassStatus = concentrateSchoolFacePassStatus
  426. info.UpdateAt = now
  427. _, 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")
  428. if err2 != nil {
  429. return err2, nil
  430. }
  431. }
  432. //TODO:: school_face_pass_status && school_face_payment_status 都为 open 状态,则 签约信息同步“alipay.planet.ecocampus.api.roster.signUpInfo” 至 行业云
  433. CurlAlipayPlanetEcocampusApiRosterSignUpInfo(md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq{
  434. FaceUid: info.UserId,
  435. ParentUid: info.ParentUserId,
  436. ParentLogonId: info.ParentLogonId,
  437. RosterName: args.StudentName,
  438. OutRosterCode: args.OutUserId,
  439. SchoolCode: info.SchoolCode,
  440. SchoolName: schoolName,
  441. ScanFacePayStatus: "ON",
  442. FaceOpenStatus: "ON",
  443. })
  444. return nil, result1.Data
  445. }
  446. func CurlEducateSceneKidsClose(args md.CurlEducateSceneKidsCloseReq) (err error, resp interface{}) {
  447. utils.FilePutContents("CurlEducateSceneKidsClose", utils.SerializeStr(map[string]interface{}{
  448. "args": args,
  449. }))
  450. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  451. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneKidsClose"
  452. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  453. "config": map[string]string{
  454. "ali_app_id": args.Config.AliAppId,
  455. "ali_private_key": args.Config.AliPrivateKey,
  456. "ali_public_key": args.Config.AliPublicKey,
  457. },
  458. "cert_no": args.CertNo,
  459. "school_stdcode": args.SchoolStdCode,
  460. "user_id": args.UserId,
  461. "parent_uid": args.ParentUid,
  462. }), nil)
  463. if err1 != nil {
  464. return
  465. }
  466. var result struct {
  467. Code int `json:"code"`
  468. Msg string `json:"msg"`
  469. Data interface{} `json:"data"`
  470. }
  471. utils.FilePutContents("CurlEducateSceneKidsClose", utils.SerializeStr(result))
  472. err = json.Unmarshal(bytes, &result)
  473. if err != nil {
  474. return
  475. }
  476. if result.Code != 0 {
  477. if result.Msg != "" {
  478. err = errors.New(result.Msg)
  479. return
  480. }
  481. err = errors.New("请求智慧餐厅支付 异常/失败")
  482. return
  483. }
  484. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  485. if err != nil {
  486. return
  487. }
  488. return nil, result.Data
  489. }
  490. func CurlEducateFacepayClose(args md.CurlEducateFacepayCloseReq) (err error, resp interface{}) {
  491. utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(map[string]interface{}{
  492. "args": args,
  493. }))
  494. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  495. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateFacepayClose"
  496. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  497. "config": map[string]string{
  498. "ali_app_id": args.Config.AliAppId,
  499. "ali_private_key": args.Config.AliPrivateKey,
  500. "ali_public_key": args.Config.AliPublicKey,
  501. },
  502. "school_stdcode": args.SchoolStdCode,
  503. "face_uid": args.FaceUid,
  504. }), nil)
  505. if err1 != nil {
  506. return
  507. }
  508. var result struct {
  509. Code int `json:"code"`
  510. Msg string `json:"msg"`
  511. Data interface{} `json:"data"`
  512. }
  513. utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(result))
  514. err = json.Unmarshal(bytes, &result)
  515. if err != nil {
  516. return
  517. }
  518. if result.Code != 0 {
  519. if result.Msg != "" {
  520. err = errors.New(result.Msg)
  521. return
  522. }
  523. err = errors.New("请求智慧餐厅支付 异常/失败")
  524. return
  525. }
  526. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  527. if err != nil {
  528. return
  529. }
  530. return nil, result.Data
  531. }
  532. func CurlEducateSceneTokenCreateForApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  533. utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(map[string]interface{}{
  534. "args": args,
  535. }))
  536. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  537. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  538. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  539. "config": map[string]string{
  540. "ali_app_id": args.Config.AliAppId,
  541. "ali_private_key": args.Config.AliPrivateKey,
  542. "ali_public_key": args.Config.AliPublicKey,
  543. },
  544. "cert_no": args.CertNo,
  545. "school_std_code": args.SchoolStdCode,
  546. "student_name": args.StudentName,
  547. "out_user_id": args.OutUserId,
  548. "cert_type": args.CertType,
  549. "sub_code": "SCHOOL_FACE_PASS_NAVIGATE",
  550. }), nil)
  551. if err != nil {
  552. return
  553. }
  554. var result struct {
  555. Code int `json:"code"`
  556. Msg string `json:"msg"`
  557. Data interface{} `json:"data"`
  558. }
  559. err = json.Unmarshal(bytes, &result)
  560. if err != nil {
  561. return
  562. }
  563. utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(result))
  564. if result.Code != 0 {
  565. if result.Msg != "" {
  566. err = errors.New(result.Msg)
  567. return
  568. }
  569. err = errors.New("请求智慧餐厅支付 异常/失败")
  570. return
  571. }
  572. return nil, result.Data
  573. }
  574. func CurlEducateSceneTokenCreateForConcentratedCollectApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  575. utils.FilePutContents("CurlEducateSceneTokenCreateForConcentratedCollectApplet", utils.SerializeStr(map[string]interface{}{
  576. "args": args,
  577. }))
  578. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  579. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  580. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  581. "config": map[string]string{
  582. "ali_app_id": args.Config.AliAppId,
  583. "ali_private_key": args.Config.AliPrivateKey,
  584. "ali_public_key": args.Config.AliPublicKey,
  585. },
  586. "cert_no": args.CertNo,
  587. "school_std_code": args.SchoolStdCode,
  588. "student_name": args.StudentName,
  589. "out_user_id": args.OutUserId,
  590. "cert_type": args.CertType,
  591. "sub_code": "SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT",
  592. "operator_user_id": args.OperatorUserId, //采集人员的支付宝会员标识。(当sub_code为SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT时,当前参数必选)
  593. }), nil)
  594. if err != nil {
  595. return
  596. }
  597. var result struct {
  598. Code int `json:"code"`
  599. Msg string `json:"msg"`
  600. Data interface{} `json:"data"`
  601. }
  602. utils.FilePutContents("CurlEducateSceneTokenCreateForConcentratedCollectApplet", utils.SerializeStr(result))
  603. err = json.Unmarshal(bytes, &result)
  604. if err != nil {
  605. return
  606. }
  607. if result.Code != 0 {
  608. if result.Msg != "" {
  609. err = errors.New(result.Msg)
  610. return
  611. }
  612. err = errors.New("请求智慧餐厅支付 异常/失败")
  613. return
  614. }
  615. return nil, result.Data
  616. }
  617. func CurlEducateFacepayApply(args md.CurlEducateFacepayApplyReq) (err error, resp interface{}) {
  618. utils.FilePutContents("CurlEducateFacepayApply", utils.SerializeStr(map[string]interface{}{
  619. "args": args,
  620. }))
  621. //1、TODO::alipay.commerce.educate.facepay.apply(人脸开通支付申请)
  622. url := cfg.SmartCanteenPay + "/alipay/faceScanPay/educateFacepayApply"
  623. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  624. "config": map[string]string{
  625. "ali_app_id": args.Config.AliAppId,
  626. "ali_private_key": args.Config.AliPrivateKey,
  627. "ali_public_key": args.Config.AliPublicKey,
  628. },
  629. "face_uid": args.FaceUid,
  630. "school_std_code": args.SchoolStdCode,
  631. "face_open_id": args.FaceOpenId,
  632. }), nil)
  633. if err != nil {
  634. return
  635. }
  636. var result struct {
  637. Code int `json:"code"`
  638. Msg string `json:"msg"`
  639. Data interface{} `json:"data"`
  640. }
  641. utils.FilePutContents("CurlEducateFacepayApply", utils.SerializeStr(result))
  642. err = json.Unmarshal(bytes, &result)
  643. if err != nil {
  644. return
  645. }
  646. if result.Code != 0 {
  647. if result.Msg != "" {
  648. err = errors.New(result.Msg)
  649. return
  650. }
  651. err = errors.New("请求智慧餐厅支付 异常/失败")
  652. return
  653. }
  654. return nil, result.Data
  655. }
  656. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(args md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq) (err error, resp interface{}) {
  657. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterSignUpInfo"
  658. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSignUpInfo", utils.SerializeStr(map[string]interface{}{
  659. "args": args,
  660. }))
  661. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  662. if err != nil {
  663. return
  664. }
  665. var result struct {
  666. Code int `json:"code"`
  667. Msg string `json:"msg"`
  668. Data interface{} `json:"data"`
  669. }
  670. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSignUpInfo", utils.SerializeStr(result))
  671. err = json.Unmarshal(bytes, &result)
  672. if err != nil {
  673. return
  674. }
  675. if result.Code != 0 {
  676. if result.Msg != "" {
  677. err = errors.New(result.Msg)
  678. return
  679. }
  680. err = errors.New("请求智慧餐厅支付 异常/失败")
  681. return
  682. }
  683. return nil, result.Data
  684. }
  685. func CurlSelfSupportForSchoolOrderDebtRepay(args md.CurlSelfSupportForSchoolOrderDebtRepay) (err error, resp interface{}) {
  686. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtRepay"
  687. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(map[string]interface{}{
  688. "args": args,
  689. }))
  690. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  691. if err != nil {
  692. return
  693. }
  694. var result struct {
  695. Code int `json:"code"`
  696. Msg string `json:"msg"`
  697. Data interface{} `json:"data"`
  698. }
  699. err = json.Unmarshal(bytes, &result)
  700. if err != nil {
  701. return
  702. }
  703. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(result))
  704. if result.Code != 0 {
  705. if result.Msg != "" {
  706. err = errors.New(result.Msg)
  707. return
  708. }
  709. err = errors.New("请求智慧餐厅支付 异常/失败")
  710. return
  711. }
  712. mMap, ok := result.Data.(map[string]interface{})
  713. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(mMap))
  714. if ok {
  715. if mMap["code"] == "10000" {
  716. //TODO::更新订单状态
  717. selfSupportForSchoolOrdDb := db.SelfSupportForSchoolOrd{}
  718. selfSupportForSchoolOrdDb.Set(args.OutOrderNo)
  719. ord, err1 := selfSupportForSchoolOrdDb.GetSelfSupportForSchoolOrd()
  720. if err1 != nil {
  721. err = err1
  722. return
  723. }
  724. ord.OrderStatus = 2
  725. selfSupportForSchoolOrdDb.SelfSupportForSchoolOrdUpdate(ord, "order_status")
  726. }
  727. }
  728. return nil, result.Data
  729. }
  730. func CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo(args md.CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo) (err error, resp interface{}) {
  731. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtPageQueryDebtInfo"
  732. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo", utils.SerializeStr(map[string]interface{}{
  733. "args": args,
  734. }))
  735. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  736. if err != nil {
  737. return
  738. }
  739. var result struct {
  740. Code int `json:"code"`
  741. Msg string `json:"msg"`
  742. Data interface{} `json:"data"`
  743. }
  744. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo", utils.SerializeStr(result))
  745. err = json.Unmarshal(bytes, &result)
  746. if err != nil {
  747. return
  748. }
  749. if result.Code != 0 {
  750. if result.Msg != "" {
  751. err = errors.New(result.Msg)
  752. return
  753. }
  754. err = errors.New("请求智慧餐厅支付 异常/失败")
  755. return
  756. }
  757. return nil, result.Data
  758. }
  759. func CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList(args md.CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList) (err error, resp interface{}) {
  760. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterPageQueryBlackList"
  761. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList", utils.SerializeStr(map[string]interface{}{
  762. "args": args,
  763. }))
  764. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  765. if err != nil {
  766. return
  767. }
  768. var result struct {
  769. Code int `json:"code"`
  770. Msg string `json:"msg"`
  771. Data interface{} `json:"data"`
  772. }
  773. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList", utils.SerializeStr(result))
  774. err = json.Unmarshal(bytes, &result)
  775. if err != nil {
  776. return
  777. }
  778. if result.Code != 0 {
  779. if result.Msg != "" {
  780. err = errors.New(result.Msg)
  781. return
  782. }
  783. err = errors.New("请求智慧餐厅支付 异常/失败")
  784. return
  785. }
  786. return nil, result.Data
  787. }
  788. func CurlAlipayPlanetEcocampusApiDebtCancel(args md.CurlAlipayPlanetEcocampusApiDebtCancel) (err error, resp interface{}) {
  789. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtCancel"
  790. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtCancel", utils.SerializeStr(map[string]interface{}{
  791. "args": args,
  792. }))
  793. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  794. if err != nil {
  795. return
  796. }
  797. var result struct {
  798. Code int `json:"code"`
  799. Msg string `json:"msg"`
  800. Data interface{} `json:"data"`
  801. }
  802. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtCancel", utils.SerializeStr(result))
  803. err = json.Unmarshal(bytes, &result)
  804. if err != nil {
  805. return
  806. }
  807. if result.Code != 0 {
  808. if result.Msg != "" {
  809. err = errors.New(result.Msg)
  810. return
  811. }
  812. err = errors.New("请求智慧餐厅支付 异常/失败")
  813. return
  814. }
  815. return nil, result.Data
  816. }
  817. func CurlAlipayPlanetEcocampusApiRosterConsumeLimit(args md.CurlAlipayPlanetEcocampusApiRosterConsumeLimit) (err error, resp interface{}) {
  818. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterConsumeLimit"
  819. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterConsumeLimit", utils.SerializeStr(map[string]interface{}{
  820. "args": args,
  821. }))
  822. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  823. if err != nil {
  824. return
  825. }
  826. var result struct {
  827. Code int `json:"code"`
  828. Msg string `json:"msg"`
  829. Data interface{} `json:"data"`
  830. }
  831. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterConsumeLimit", utils.SerializeStr(result))
  832. err = json.Unmarshal(bytes, &result)
  833. if err != nil {
  834. return
  835. }
  836. if result.Code != 0 {
  837. if result.Msg != "" {
  838. err = errors.New(result.Msg)
  839. return
  840. }
  841. err = errors.New("请求智慧餐厅支付 异常/失败")
  842. return
  843. }
  844. return nil, result.Data
  845. }