物料订单一周内不能重复下单
This commit is contained in:
@@ -55,7 +55,8 @@ type OrderSkusAccept struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OrderCount struct {
|
type OrderCount struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"` //销量
|
||||||
|
Flag bool `json:"flag"` //true表示可以买
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int, isIncludeFake bool) (countInfo []*model.GoodsOrderCountInfo, err error) {
|
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int, isIncludeFake bool) (countInfo []*model.GoodsOrderCountInfo, err error) {
|
||||||
@@ -1173,41 +1174,47 @@ func GetOrdersAccept(ctx *jxcontext.Context, storeID int) (result []*OrderSkusAc
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMatterStoreOrderCount(ctx *jxcontext.Context, storeID int) (count int, err error) {
|
func GetMatterStoreOrderCount(ctx *jxcontext.Context, storeID int) (result *OrderCount, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
goodsOrder *model.GoodsOrder
|
orderPay *model.OrderPay
|
||||||
orderCount *OrderCount
|
orderCount = &OrderCount{}
|
||||||
orderTime time.Time
|
|
||||||
)
|
)
|
||||||
sql := `
|
sql := `
|
||||||
SELECT *
|
SELECT b.*
|
||||||
FROM goods_order
|
FROM goods_order a
|
||||||
WHERE IF(store_id = 0,jx_store_id,store_id) = 666666
|
JOIN order_pay b ON a.vendor_order_id = b.vendor_order_id
|
||||||
AND from_store_id = ?
|
WHERE IF(a.store_id = 0, a.jx_store_id, a.store_id) = 666666
|
||||||
ORDER BY order_created_at DESC
|
AND a.from_store_id = ?
|
||||||
|
ORDER BY b.pay_finished_at DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{storeID}
|
sqlParams := []interface{}{storeID, model.OrderStatusFinished}
|
||||||
err = dao.GetRow(db, &goodsOrder, sql, sqlParams)
|
err = dao.GetRow(db, &orderPay, sql, sqlParams)
|
||||||
if goodsOrder != nil {
|
if orderPay != nil {
|
||||||
orderTime = goodsOrder.OrderFinishedAt
|
if time.Now().Sub(*orderPay.PayFinishedAt).Hours() < 24*7 {
|
||||||
|
orderCount.Flag = false
|
||||||
|
} else {
|
||||||
|
orderCount.Flag = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
orderTime = time.Now().AddDate(0, -1, 0)
|
orderCount.Flag = true
|
||||||
}
|
}
|
||||||
sql2 := `
|
sql2 := `
|
||||||
SELECT COUNT(*) count
|
SELECT COUNT(*) count
|
||||||
FROM goods_order
|
FROM goods_order
|
||||||
WHERE IF(store_id = 0,jx_store_id,store_id) = ?
|
WHERE IF(store_id = 0,jx_store_id,store_id) = ?
|
||||||
AND order_created_at <= NOW() AND order_created_at >= ?
|
AND order_created_at <= NOW() AND order_created_at >= ?
|
||||||
|
AND status = ?
|
||||||
`
|
`
|
||||||
sqlParams2 := []interface{}{
|
sqlParams2 := []interface{}{
|
||||||
storeID,
|
storeID,
|
||||||
orderTime,
|
time.Now().AddDate(0, 0, -7),
|
||||||
|
model.OrderStatusFinished,
|
||||||
}
|
}
|
||||||
err = dao.GetRow(db, &orderCount, sql2, sqlParams2)
|
err = dao.GetRow(db, &orderCount, sql2, sqlParams2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return orderCount.Count, err
|
return orderCount, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -617,6 +617,10 @@ func orderSolutionForWuLiao(order *model.GoodsOrder) (err error) {
|
|||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
goods, err := dao.QueryOrders(db, order.VendorOrderID, -1, []int{model.VendorIDJX}, -1, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
goods, err := dao.QueryOrders(db, order.VendorOrderID, -1, []int{model.VendorIDJX}, -1, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||||
|
if err != nil || len(goods) == 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
orderSkus := goods[0].Skus
|
||||||
if order.Weight <= 5000 { //如果总重量小于5kg就直接发单
|
if order.Weight <= 5000 { //如果总重量小于5kg就直接发单
|
||||||
var (
|
var (
|
||||||
goodsNos []string
|
goodsNos []string
|
||||||
@@ -624,10 +628,7 @@ func orderSolutionForWuLiao(order *model.GoodsOrder) (err error) {
|
|||||||
quantities []string
|
quantities []string
|
||||||
)
|
)
|
||||||
err = changeOrderStatus(order.VendorOrderID, model.OrderStatusDelivering, "")
|
err = changeOrderStatus(order.VendorOrderID, model.OrderStatusDelivering, "")
|
||||||
if err != nil || len(goods) == 0 {
|
for _, v := range orderSkus {
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, v := range goods[0].Skus {
|
|
||||||
skus, err := dao.GetSkus(db, []int{v.SkuID}, nil, nil, nil, nil)
|
skus, err := dao.GetSkus(db, []int{v.SkuID}, nil, nil, nil, nil)
|
||||||
if err != nil || len(skus) == 0 {
|
if err != nil || len(skus) == 0 {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user