刷新物料订单的标志,每周刷新一次,每周只能申请一次
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user