|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package svc
-
- import (
- "applet/app/db/model"
- "applet/app/enum"
- "applet/app/utils"
- "applet/app/utils/logx"
- "fmt"
- "time"
- "xorm.io/xorm"
- )
-
- func SyncCentralKitchenForSchoolPackageOrdState(eg *xorm.Engine) {
- fmt.Println("sync central_kitchen_for_school_package_ord state...")
- defer func() {
- if err := recover(); err != nil {
- _ = logx.Error(err)
- }
- }()
-
- now := time.Now()
- //TODO:: 20 分钟后 取消订单
- expTime := now.Add(-time.Minute * time.Duration(20))
- expTimeStr := utils.Time2String(expTime, "")
- centralKitchenForSchoolPackageOrd := new(model.CentralKitchenForSchoolPackageOrd)
- centralKitchenForSchoolPackageOrd.State = enum.CentralKitchenForSchoolPackageOrdStateForFail
- affected, err := eg.Where("state =?", enum.CentralKitchenForSchoolPackageOrdStateForWait).And("create_at <= ?", expTimeStr).
- Cols("state").Update(centralKitchenForSchoolPackageOrd)
- if err != nil {
- _ = logx.Error(err)
- fmt.Println(">>>>>>>>SyncCentralKitchenForSchoolPackageOrdState_Err<<<<<<<<<<<<<<", err.Error())
- }
- fmt.Println("SyncCentralKitchenForSchoolPackageOrdState_Affected>>>>>>>>>>>>>>>", affected)
- return
- //page := 1
- //
- //for {
- // isEmpty, err := handleOnePage(eg, expTimeStr)
- // if err != nil {
- // _ = logx.Error(err)
- // break
- // }
- // if isEmpty {
- // break
- // }
- //
- // if page > 100 {
- // break
- // }
- //
- // page += 1
- //}
- }
-
- func handleOnePage(eg *xorm.Engine, expTimeStr string) (isEmpty bool, err error) {
-
- return false, nil
- }
|