物料订单一周内不能重复下单
This commit is contained in:
@@ -55,7 +55,8 @@ type OrderSkusAccept 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) {
|
||||
@@ -1173,41 +1174,47 @@ func GetOrdersAccept(ctx *jxcontext.Context, storeID int) (result []*OrderSkusAc
|
||||
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 (
|
||||
db = dao.GetDB()
|
||||
goodsOrder *model.GoodsOrder
|
||||
orderCount *OrderCount
|
||||
orderTime time.Time
|
||||
orderPay *model.OrderPay
|
||||
orderCount = &OrderCount{}
|
||||
)
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM goods_order
|
||||
WHERE IF(store_id = 0,jx_store_id,store_id) = 666666
|
||||
AND from_store_id = ?
|
||||
ORDER BY order_created_at DESC
|
||||
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 = ?
|
||||
ORDER BY b.pay_finished_at DESC
|
||||
LIMIT 1
|
||||
`
|
||||
sqlParams := []interface{}{storeID}
|
||||
err = dao.GetRow(db, &goodsOrder, sql, sqlParams)
|
||||
if goodsOrder != nil {
|
||||
orderTime = goodsOrder.OrderFinishedAt
|
||||
sqlParams := []interface{}{storeID, model.OrderStatusFinished}
|
||||
err = dao.GetRow(db, &orderPay, sql, sqlParams)
|
||||
if orderPay != nil {
|
||||
if time.Now().Sub(*orderPay.PayFinishedAt).Hours() < 24*7 {
|
||||
orderCount.Flag = false
|
||||
} else {
|
||||
orderCount.Flag = true
|
||||
}
|
||||
} else {
|
||||
orderTime = time.Now().AddDate(0, -1, 0)
|
||||
orderCount.Flag = true
|
||||
}
|
||||
sql2 := `
|
||||
SELECT COUNT(*) count
|
||||
FROM goods_order
|
||||
WHERE IF(store_id = 0,jx_store_id,store_id) = ?
|
||||
AND order_created_at <= NOW() AND order_created_at >= ?
|
||||
AND status = ?
|
||||
`
|
||||
sqlParams2 := []interface{}{
|
||||
storeID,
|
||||
orderTime,
|
||||
time.Now().AddDate(0, 0, -7),
|
||||
model.OrderStatusFinished,
|
||||
}
|
||||
err = dao.GetRow(db, &orderCount, sql2, sqlParams2)
|
||||
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()
|
||||
)
|
||||
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就直接发单
|
||||
var (
|
||||
goodsNos []string
|
||||
@@ -624,10 +628,7 @@ func orderSolutionForWuLiao(order *model.GoodsOrder) (err error) {
|
||||
quantities []string
|
||||
)
|
||||
err = changeOrderStatus(order.VendorOrderID, model.OrderStatusDelivering, "")
|
||||
if err != nil || len(goods) == 0 {
|
||||
return err
|
||||
}
|
||||
for _, v := range goods[0].Skus {
|
||||
for _, v := range orderSkus {
|
||||
skus, err := dao.GetSkus(db, []int{v.SkuID}, nil, nil, nil, nil)
|
||||
if err != nil || len(skus) == 0 {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user