diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index fb0793001..f1b7ebbec 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -2,6 +2,7 @@ package orderman import ( "fmt" + "math" "strconv" "strings" "time" @@ -1209,10 +1210,16 @@ func GetMatterStoreOrderCount(ctx *jxcontext.Context, storeID int) (result *Orde err = dao.GetRows(db, &orderPays, sql, sqlParams) if len(orderPays) != 0 { orderPay := orderPays[0] - if time.Now().Sub(*orderPay.PayFinishedAt).Hours() < 24*7 { - flag = false + stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "") + if len(stores) > 0 { + store := stores[0] + if store.IsBoughtMatter == model.YES { + flag = false + } else { + flag = true + } } else { - flag = true + flag = false } orderTime = *orderPay.PayFinishedAt } else { @@ -1235,6 +1242,7 @@ func GetMatterStoreOrderCount(ctx *jxcontext.Context, storeID int) (result *Orde if err != nil { return nil, err } + orderCount.Count = int(utils.Float64TwoInt64(math.Ceil(utils.Int2Float64(orderCount.Count) * 1.5))) orderCount.Flag = flag // orderCount.Count = 1000 return orderCount, err diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 6f9588ec4..a69bd8b2a 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -3083,3 +3083,17 @@ func DisabledStoreWithoutVendor(ctx *jxcontext.Context, isContinueWhenError, isA } return hint, err } + +func CleanStoreIsBoughtMatter(ctx *jxcontext.Context) (err error) { + //每周一凌晨1点清空 + if int(time.Now().Weekday()) != 1 { + return err + } + db := dao.GetDB() + sql := ` + UPDATE store SET is_bought_matter = ? + ` + sqlParam := []interface{}{model.NO} + _, err = dao.ExecuteSQL(db, sql, sqlParam) + return err +} diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index f4d4bdd7d..af71a3f54 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -209,6 +209,9 @@ func Init() { ScheduleTimerFunc("SendNoCatSkusToOperater", func() { cms.SendNoCatSkusToOperater(jxcontext.AdminCtx) }, autoPayForPopluarManList) + ScheduleTimerFunc("CleanStoreIsBoughtMatter", func() { + cms.CleanStoreIsBoughtMatter(jxcontext.AdminCtx) + }, priceReferTimeList) } ScheduleTimerFunc("AutoSaleStoreSku", func() { cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false) diff --git a/business/model/store.go b/business/model/store.go index a6020cca4..16e0caa81 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -337,7 +337,8 @@ type Store struct { OperatorPhone3 string `orm:"size(16)" json:"operatorPhone3"` // 饿百运营人电话 OperatorRole3 string `orm:"size(32)" json:"operatorRole3"` // 饿百运营人组(角色) - PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告) + PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告) + IsBoughtMatter int `json:"isBoughtMatter"` //这周是否申请过物料 } func (*Store) TableUnique() [][]string { diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index ce2693ddf..296d4087b 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -900,6 +900,12 @@ func orderSolutionForWuLiao(order *model.GoodsOrder) (err error) { cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID) } } + stores, err := dao.GetStoreList(db, []int{order.FromStoreID}, nil, nil, nil, "") + if len(stores) > 0 { + store := stores[0] + store.IsBoughtMatter = model.YES + dao.UpdateEntity(db, store, "IsBoughtMatter") + } } return err } @@ -983,6 +989,38 @@ func CancelMatterOrder(db *dao.DaoDB, order *model.GoodsOrder, reason string) (e } } } + stores, _ := dao.GetStoreList(db, []int{order.FromStoreID}, nil, nil, nil, "") + if len(stores) > 0 { + //如果这周还买过其他物料,则不刷新是否购买标志 + var ( + orderPays []*model.OrderPay + day int + ) + sql := ` + SELECT b.* + FROM goods_order a + JOIN order_pay b ON a.vendor_order_id = b.vendor_order_id + WHERE IF(a.store_id = 0, a.jx_store_id, a.store_id) = 666666 + AND a.from_store_id = ? + AND a.status >= ? AND a.status <> ? + AND b.status = ? + AND b.pay_finished_at <= NOW() AND b.pay_finished_at >= ? + ` + weekInt := int(time.Now().Weekday()) + if weekInt == 0 { + day = 7 + } else { + day = weekInt + } + lastTime := utils.Str2Time(time.Now().AddDate(0, 0, day-1).Format("2006-01-02") + "01:00:00") + sqlParams := []interface{}{order.FromStoreID, model.OrderStatusDelivering, model.OrderStatusCanceled, model.PayStatusYes, lastTime} + err = dao.GetRows(db, &orderPays, sql, sqlParams) + if len(orderPays) == 0 { + store := stores[0] + store.IsBoughtMatter = model.NO + dao.UpdateEntity(db, store, "IsBoughtMatter") + } + } } return err }