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

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