广告平台(站长下代理使用)
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_cancel_order.go 947 B

3 months ago
3 months ago
3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package svc
  2. import (
  3. "applet/app/utils"
  4. "applet/app/utils/logx"
  5. "fmt"
  6. "time"
  7. "xorm.io/xorm"
  8. )
  9. func CancelOrder(eg *xorm.Engine, dbName string) {
  10. fmt.Println("cancel order...")
  11. defer func() {
  12. if err := recover(); err != nil {
  13. _ = logx.Error(err)
  14. }
  15. }()
  16. timeStr, err := getCancelCfg(eg, dbName)
  17. if err != nil {
  18. fmt.Println(err.Error())
  19. return
  20. }
  21. now := time.Now()
  22. // x 分钟后取消订单
  23. expTime := now.Add(-time.Hour * time.Duration(utils.StrToInt64(timeStr)))
  24. expTimeStr := utils.Time2String(expTime, "")
  25. page := 1
  26. for {
  27. isEmpty, err := handleOnePage(eg, dbName, expTimeStr)
  28. if err != nil {
  29. _ = logx.Error(err)
  30. break
  31. }
  32. if isEmpty {
  33. break
  34. }
  35. if page > 100 {
  36. break
  37. }
  38. page += 1
  39. }
  40. }
  41. func handleOnePage(eg *xorm.Engine, dbName, expTimeStr string) (isEmpty bool, err error) {
  42. return false, nil
  43. }
  44. func getCancelCfg(eg *xorm.Engine, masterId string) (string, error) {
  45. return "", nil
  46. }