|
- package hdl
-
- import (
- "applet/app/admin/lib/validate"
- "applet/app/admin/md"
- svc "applet/app/admin/svc/order"
- md2 "applet/app/customer/md"
- svc2 "applet/app/customer/svc"
- "applet/app/db"
- "applet/app/db/model"
- "applet/app/e"
- "applet/app/enum"
- "fmt"
- "github.com/gin-gonic/gin"
- "time"
- )
-
- // Demo 测试
- func Demo(c *gin.Context) {
- var req md.CentralKitchenForSchoolOrderRefundAuditReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- err1 := svc.CentralKitchenForSchoolOrderRefundAudit(c, req)
- if err1 != nil {
- fmt.Println(err1.Error())
- e.OutErr(c, e.ERR, err1.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- sysCfgDb := db.SysCfgDb{}
- sysCfgDb.Set()
- sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey)
-
- //调用支付宝进行退款
- err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{
- Config: struct {
- PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"`
- PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"`
- PayAliPublicKey string `json:"pay_ali_public_key" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"`
- }{
- PayAliAppId: sysCfg[enum.OpenAlipayAppid],
- PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey],
- PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey],
- },
- OutTradeNo: "800169659125681442",
- RefundAmount: "180.00",
- RefundReason: "央厨订餐退款",
- OutRequestNo: "r_800169659125681442_1705546121",
- AppAuthToken: "202308BB8ef30019cd8d4a40a3853192c397dX35",
- })
- if err6 != nil {
- fmt.Println(err6.Error())
- }
- return
- qrcodeWithBatchRecordsDb := db.AdminDb{}
- qrcodeWithBatchRecordsDb.Set()
- data, _, err := qrcodeWithBatchRecordsDb.GetAdminRolePermission(1001)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, data, nil)
- go GoOnExecuting()
- return
- }
-
- func DemoV1(c *gin.Context) {
- centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{}
- centralKitchenForSchoolUserRefundDayDb.Set(0)
- var m []model.CentralKitchenForSchoolUserRefundDay
- if err := centralKitchenForSchoolUserRefundDayDb.Db.Where("state =1").Desc("id").Find(&m); err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- var recordsId = map[int]bool{}
- var repeatIds []int
- for _, v := range m {
- if recordsId[v.RecordsId] {
- repeatIds = append(repeatIds, v.Id)
- centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayDelete(v.Id)
- }
- recordsId[v.RecordsId] = true
- }
- e.OutSuc(c, repeatIds, nil)
-
- }
-
- func GoOnExecuting() {
- for i := 0; i < 20; i++ {
- time.Sleep(1 * time.Second)
- fmt.Println(i)
- }
- }
|