智慧食堂
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 1.4 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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package svc
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/enum"
  5. "applet/app/utils"
  6. "applet/app/utils/logx"
  7. "fmt"
  8. "time"
  9. "xorm.io/xorm"
  10. )
  11. func SyncCentralKitchenForSchoolPackageOrdState(eg *xorm.Engine) {
  12. fmt.Println("sync central_kitchen_for_school_package_ord state...")
  13. defer func() {
  14. if err := recover(); err != nil {
  15. _ = logx.Error(err)
  16. }
  17. }()
  18. now := time.Now()
  19. //TODO:: 20 分钟后 取消订单
  20. expTime := now.Add(-time.Minute * time.Duration(20))
  21. expTimeStr := utils.Time2String(expTime, "")
  22. centralKitchenForSchoolPackageOrd := new(model.CentralKitchenForSchoolPackageOrd)
  23. centralKitchenForSchoolPackageOrd.State = enum.CentralKitchenForSchoolPackageOrdStateForFail
  24. affected, err := eg.Where("state =?", enum.CentralKitchenForSchoolPackageOrdStateForWait).And("create_at <= ?", expTimeStr).
  25. Cols("state").Update(centralKitchenForSchoolPackageOrd)
  26. if err != nil {
  27. _ = logx.Error(err)
  28. fmt.Println(">>>>>>>>SyncCentralKitchenForSchoolPackageOrdState_Err<<<<<<<<<<<<<<", err.Error())
  29. }
  30. fmt.Println("SyncCentralKitchenForSchoolPackageOrdState_Affected>>>>>>>>>>>>>>>", affected)
  31. return
  32. //page := 1
  33. //
  34. //for {
  35. // isEmpty, err := handleOnePage(eg, expTimeStr)
  36. // if err != nil {
  37. // _ = logx.Error(err)
  38. // break
  39. // }
  40. // if isEmpty {
  41. // break
  42. // }
  43. //
  44. // if page > 100 {
  45. // break
  46. // }
  47. //
  48. // page += 1
  49. //}
  50. }
  51. func handleOnePage(eg *xorm.Engine, expTimeStr string) (isEmpty bool, err error) {
  52. return false, nil
  53. }