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

100 line
2.8 KiB

  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. "applet/app/admin/md"
  5. svc "applet/app/admin/svc/order"
  6. md2 "applet/app/customer/md"
  7. svc2 "applet/app/customer/svc"
  8. "applet/app/db"
  9. "applet/app/db/model"
  10. "applet/app/e"
  11. "applet/app/enum"
  12. "fmt"
  13. "github.com/gin-gonic/gin"
  14. "time"
  15. )
  16. // Demo 测试
  17. func Demo(c *gin.Context) {
  18. var req md.CentralKitchenForSchoolOrderRefundAuditReq
  19. err := c.ShouldBindJSON(&req)
  20. if err != nil {
  21. err = validate.HandleValidateErr(err)
  22. err1 := err.(e.E)
  23. e.OutErr(c, err1.Code, err1.Error())
  24. return
  25. }
  26. err1 := svc.CentralKitchenForSchoolOrderRefundAudit(c, req)
  27. if err1 != nil {
  28. fmt.Println(err1.Error())
  29. e.OutErr(c, e.ERR, err1.Error())
  30. return
  31. }
  32. e.OutSuc(c, "success", nil)
  33. return
  34. sysCfgDb := db.SysCfgDb{}
  35. sysCfgDb.Set()
  36. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey)
  37. //调用支付宝进行退款
  38. err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{
  39. Config: struct {
  40. PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"`
  41. PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"`
  42. PayAliPublicKey string `json:"pay_ali_public_key" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"`
  43. }{
  44. PayAliAppId: sysCfg[enum.OpenAlipayAppid],
  45. PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey],
  46. PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey],
  47. },
  48. OutTradeNo: "800169659125681442",
  49. RefundAmount: "180.00",
  50. RefundReason: "央厨订餐退款",
  51. OutRequestNo: "r_800169659125681442_1705546121",
  52. AppAuthToken: "202308BB8ef30019cd8d4a40a3853192c397dX35",
  53. })
  54. if err6 != nil {
  55. fmt.Println(err6.Error())
  56. }
  57. return
  58. qrcodeWithBatchRecordsDb := db.AdminDb{}
  59. qrcodeWithBatchRecordsDb.Set()
  60. data, _, err := qrcodeWithBatchRecordsDb.GetAdminRolePermission(1001)
  61. if err != nil {
  62. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  63. return
  64. }
  65. e.OutSuc(c, data, nil)
  66. go GoOnExecuting()
  67. return
  68. }
  69. func DemoV1(c *gin.Context) {
  70. centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{}
  71. centralKitchenForSchoolUserRefundDayDb.Set(0)
  72. var m []model.CentralKitchenForSchoolUserRefundDay
  73. if err := centralKitchenForSchoolUserRefundDayDb.Db.Where("state =1").Desc("id").Find(&m); err != nil {
  74. e.OutErr(c, e.ERR, err.Error())
  75. return
  76. }
  77. var recordsId = map[int]bool{}
  78. var repeatIds []int
  79. for _, v := range m {
  80. if recordsId[v.RecordsId] {
  81. repeatIds = append(repeatIds, v.Id)
  82. //centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayDelete(v.Id)
  83. }
  84. recordsId[v.RecordsId] = true
  85. }
  86. e.OutSuc(c, repeatIds, nil)
  87. }
  88. func GoOnExecuting() {
  89. for i := 0; i < 20; i++ {
  90. time.Sleep(1 * time.Second)
  91. fmt.Println(i)
  92. }
  93. }