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

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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": "1",
  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. utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
  190. err1 = json.Unmarshal(bytes, &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. utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
  226. err = json.Unmarshal(bytes, &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 CurlEducateSceneKidsClose(args md.CurlEducateSceneKidsCloseReq) (err error, resp interface{}) {
  304. utils.FilePutContents("CurlEducateSceneKidsClose", utils.SerializeStr(map[string]interface{}{
  305. "args": args,
  306. }))
  307. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  308. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneKidsClose"
  309. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  310. "config": map[string]string{
  311. "ali_app_id": args.Config.AliAppId,
  312. "ali_private_key": args.Config.AliPrivateKey,
  313. "ali_public_key": args.Config.AliPublicKey,
  314. },
  315. "cert_no": args.CertNo,
  316. "school_stdcode": args.SchoolStdCode,
  317. "user_id": args.UserId,
  318. "parent_uid": args.ParentUid,
  319. }), nil)
  320. if err1 != nil {
  321. return
  322. }
  323. var result struct {
  324. Code int `json:"code"`
  325. Msg string `json:"msg"`
  326. Data interface{} `json:"data"`
  327. }
  328. utils.FilePutContents("CurlEducateSceneKidsClose", utils.SerializeStr(result))
  329. err = json.Unmarshal(bytes, &result)
  330. if err != nil {
  331. return
  332. }
  333. if result.Code != 0 {
  334. if result.Msg != "" {
  335. err = errors.New(result.Msg)
  336. return
  337. }
  338. err = errors.New("请求智慧餐厅支付 异常/失败")
  339. return
  340. }
  341. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  342. if err != nil {
  343. return
  344. }
  345. return nil, result.Data
  346. }
  347. func CurlEducateFacepayClose(args md.CurlEducateFacepayCloseReq) (err error, resp interface{}) {
  348. utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(map[string]interface{}{
  349. "args": args,
  350. }))
  351. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  352. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateFacepayClose"
  353. bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  354. "config": map[string]string{
  355. "ali_app_id": args.Config.AliAppId,
  356. "ali_private_key": args.Config.AliPrivateKey,
  357. "ali_public_key": args.Config.AliPublicKey,
  358. },
  359. "school_stdcode": args.SchoolStdCode,
  360. "face_uid": args.FaceUid,
  361. }), nil)
  362. if err1 != nil {
  363. return
  364. }
  365. var result struct {
  366. Code int `json:"code"`
  367. Msg string `json:"msg"`
  368. Data interface{} `json:"data"`
  369. }
  370. utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(result))
  371. err = json.Unmarshal(bytes, &result)
  372. if err != nil {
  373. return
  374. }
  375. if result.Code != 0 {
  376. if result.Msg != "" {
  377. err = errors.New(result.Msg)
  378. return
  379. }
  380. err = errors.New("请求智慧餐厅支付 异常/失败")
  381. return
  382. }
  383. err = json.Unmarshal(utils.Serialize(result.Data), &resp)
  384. if err != nil {
  385. return
  386. }
  387. return nil, result.Data
  388. }
  389. func CurlEducateSceneTokenCreateForApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  390. utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(map[string]interface{}{
  391. "args": args,
  392. }))
  393. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  394. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  395. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  396. "config": map[string]string{
  397. "ali_app_id": args.Config.AliAppId,
  398. "ali_private_key": args.Config.AliPrivateKey,
  399. "ali_public_key": args.Config.AliPublicKey,
  400. },
  401. "cert_no": args.CertNo,
  402. "school_std_code": args.SchoolStdCode,
  403. "student_name": args.StudentName,
  404. "out_user_id": args.OutUserId,
  405. "cert_type": "1",
  406. "sub_code": "SCHOOL_FACE_PASS_NAVIGATE",
  407. }), nil)
  408. if err != nil {
  409. return
  410. }
  411. var result struct {
  412. Code int `json:"code"`
  413. Msg string `json:"msg"`
  414. Data interface{} `json:"data"`
  415. }
  416. utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(result))
  417. err = json.Unmarshal(bytes, &result)
  418. if err != nil {
  419. return
  420. }
  421. if result.Code != 0 {
  422. if result.Msg != "" {
  423. err = errors.New(result.Msg)
  424. return
  425. }
  426. err = errors.New("请求智慧餐厅支付 异常/失败")
  427. return
  428. }
  429. return nil, result.Data
  430. }
  431. func CurlEducateSceneTokenCreateForConcentratedCollectApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) {
  432. utils.FilePutContents("CurlEducateSceneTokenCreateForConcentratedCollectApplet", utils.SerializeStr(map[string]interface{}{
  433. "args": args,
  434. }))
  435. //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
  436. url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
  437. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  438. "config": map[string]string{
  439. "ali_app_id": args.Config.AliAppId,
  440. "ali_private_key": args.Config.AliPrivateKey,
  441. "ali_public_key": args.Config.AliPublicKey,
  442. },
  443. "cert_no": args.CertNo,
  444. "school_std_code": args.SchoolStdCode,
  445. "student_name": args.StudentName,
  446. "out_user_id": args.OutUserId,
  447. "cert_type": "1",
  448. "sub_code": "SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT",
  449. "operator_user_id": args.OperatorUserId, //采集人员的支付宝会员标识。(当sub_code为SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT时,当前参数必选)
  450. }), nil)
  451. if err != nil {
  452. return
  453. }
  454. var result struct {
  455. Code int `json:"code"`
  456. Msg string `json:"msg"`
  457. Data interface{} `json:"data"`
  458. }
  459. utils.FilePutContents("CurlEducateSceneTokenCreateForConcentratedCollectApplet", utils.SerializeStr(result))
  460. err = json.Unmarshal(bytes, &result)
  461. if err != nil {
  462. return
  463. }
  464. if result.Code != 0 {
  465. if result.Msg != "" {
  466. err = errors.New(result.Msg)
  467. return
  468. }
  469. err = errors.New("请求智慧餐厅支付 异常/失败")
  470. return
  471. }
  472. return nil, result.Data
  473. }
  474. func CurlEducateFacepayApply(args md.CurlEducateFacepayApplyReq) (err error, resp interface{}) {
  475. utils.FilePutContents("CurlEducateFacepayApply", utils.SerializeStr(map[string]interface{}{
  476. "args": args,
  477. }))
  478. //1、TODO::alipay.commerce.educate.facepay.apply(人脸开通支付申请)
  479. url := cfg.SmartCanteenPay + "/alipay/faceScanPay/educateFacepayApply"
  480. bytes, err := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
  481. "config": map[string]string{
  482. "ali_app_id": args.Config.AliAppId,
  483. "ali_private_key": args.Config.AliPrivateKey,
  484. "ali_public_key": args.Config.AliPublicKey,
  485. },
  486. "face_uid": args.FaceUid,
  487. "school_std_code": args.SchoolStdCode,
  488. "face_open_id": args.FaceOpenId,
  489. }), nil)
  490. if err != nil {
  491. return
  492. }
  493. var result struct {
  494. Code int `json:"code"`
  495. Msg string `json:"msg"`
  496. Data interface{} `json:"data"`
  497. }
  498. utils.FilePutContents("CurlEducateFacepayApply", utils.SerializeStr(result))
  499. err = json.Unmarshal(bytes, &result)
  500. if err != nil {
  501. return
  502. }
  503. if result.Code != 0 {
  504. if result.Msg != "" {
  505. err = errors.New(result.Msg)
  506. return
  507. }
  508. err = errors.New("请求智慧餐厅支付 异常/失败")
  509. return
  510. }
  511. return nil, result.Data
  512. }
  513. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(args md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq) (err error, resp interface{}) {
  514. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterSignUpInfo"
  515. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSignUpInfo", utils.SerializeStr(map[string]interface{}{
  516. "args": args,
  517. }))
  518. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  519. if err != nil {
  520. return
  521. }
  522. var result struct {
  523. Code int `json:"code"`
  524. Msg string `json:"msg"`
  525. Data interface{} `json:"data"`
  526. }
  527. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterSignUpInfo", utils.SerializeStr(result))
  528. err = json.Unmarshal(bytes, &result)
  529. if err != nil {
  530. return
  531. }
  532. if result.Code != 0 {
  533. if result.Msg != "" {
  534. err = errors.New(result.Msg)
  535. return
  536. }
  537. err = errors.New("请求智慧餐厅支付 异常/失败")
  538. return
  539. }
  540. return nil, result.Data
  541. }
  542. func CurlSelfSupportForSchoolOrderDebtRepay(args md.CurlSelfSupportForSchoolOrderDebtRepay) (err error, resp interface{}) {
  543. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtRepay"
  544. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(map[string]interface{}{
  545. "args": args,
  546. }))
  547. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  548. if err != nil {
  549. return
  550. }
  551. var result struct {
  552. Code int `json:"code"`
  553. Msg string `json:"msg"`
  554. Data interface{} `json:"data"`
  555. }
  556. err = json.Unmarshal(bytes, &result)
  557. if err != nil {
  558. return
  559. }
  560. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(result))
  561. if result.Code != 0 {
  562. if result.Msg != "" {
  563. err = errors.New(result.Msg)
  564. return
  565. }
  566. err = errors.New("请求智慧餐厅支付 异常/失败")
  567. return
  568. }
  569. mMap, ok := result.Data.(map[string]interface{})
  570. utils.FilePutContents("CurlSelfSupportForSchoolOrderDebtRepay", utils.SerializeStr(mMap))
  571. if ok {
  572. if mMap["code"] == "10000" {
  573. //TODO::更新订单状态
  574. selfSupportForSchoolOrdDb := db.SelfSupportForSchoolOrd{}
  575. selfSupportForSchoolOrdDb.Set(args.OutOrderNo)
  576. ord, err1 := selfSupportForSchoolOrdDb.GetSelfSupportForSchoolOrd()
  577. if err1 != nil {
  578. err = err1
  579. return
  580. }
  581. ord.OrderStatus = 2
  582. selfSupportForSchoolOrdDb.SelfSupportForSchoolOrdUpdate(ord, "order_status")
  583. }
  584. }
  585. return nil, result.Data
  586. }
  587. func CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo(args md.CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo) (err error, resp interface{}) {
  588. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtPageQueryDebtInfo"
  589. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo", utils.SerializeStr(map[string]interface{}{
  590. "args": args,
  591. }))
  592. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  593. if err != nil {
  594. return
  595. }
  596. var result struct {
  597. Code int `json:"code"`
  598. Msg string `json:"msg"`
  599. Data interface{} `json:"data"`
  600. }
  601. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtPageQueryDebtInfo", utils.SerializeStr(result))
  602. err = json.Unmarshal(bytes, &result)
  603. if err != nil {
  604. return
  605. }
  606. if result.Code != 0 {
  607. if result.Msg != "" {
  608. err = errors.New(result.Msg)
  609. return
  610. }
  611. err = errors.New("请求智慧餐厅支付 异常/失败")
  612. return
  613. }
  614. return nil, result.Data
  615. }
  616. func CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList(args md.CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList) (err error, resp interface{}) {
  617. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiRosterPageQueryBlackList"
  618. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList", utils.SerializeStr(map[string]interface{}{
  619. "args": args,
  620. }))
  621. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  622. if err != nil {
  623. return
  624. }
  625. var result struct {
  626. Code int `json:"code"`
  627. Msg string `json:"msg"`
  628. Data interface{} `json:"data"`
  629. }
  630. utils.FilePutContents("CurlAlipayPlanetEcocampusApiRosterPageQueryBlackList", utils.SerializeStr(result))
  631. err = json.Unmarshal(bytes, &result)
  632. if err != nil {
  633. return
  634. }
  635. if result.Code != 0 {
  636. if result.Msg != "" {
  637. err = errors.New(result.Msg)
  638. return
  639. }
  640. err = errors.New("请求智慧餐厅支付 异常/失败")
  641. return
  642. }
  643. return nil, result.Data
  644. }
  645. func CurlAlipayPlanetEcocampusApiDebtCancel(args md.CurlAlipayPlanetEcocampusApiDebtCancel) (err error, resp interface{}) {
  646. url := cfg.SmartCanteenPay + "/alipay/bPass/alipayPlanetEcocampusApiDebtCancel"
  647. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtCancel", utils.SerializeStr(map[string]interface{}{
  648. "args": args,
  649. }))
  650. bytes, err := utils.CurlPost(url, utils.Serialize(args), nil)
  651. if err != nil {
  652. return
  653. }
  654. var result struct {
  655. Code int `json:"code"`
  656. Msg string `json:"msg"`
  657. Data interface{} `json:"data"`
  658. }
  659. utils.FilePutContents("CurlAlipayPlanetEcocampusApiDebtCancel", utils.SerializeStr(result))
  660. err = json.Unmarshal(bytes, &result)
  661. if err != nil {
  662. return
  663. }
  664. if result.Code != 0 {
  665. if result.Msg != "" {
  666. err = errors.New(result.Msg)
  667. return
  668. }
  669. err = errors.New("请求智慧餐厅支付 异常/失败")
  670. return
  671. }
  672. return nil, result.Data
  673. }