- new field GoodsOrder.Flag
- SetOrderPrintStatus
This commit is contained in:
@@ -180,6 +180,9 @@ const (
|
||||
OrderDeliveryFlagMaskScheduleDisabled = 1 // 禁止三方配送调度
|
||||
OrderDeliveryFlagMaskPurcahseDisabled = 2 // 购物平台已不配送(一般为门店配送类型本身为自配送,或已经转自配送)
|
||||
)
|
||||
const (
|
||||
OrderFlagMaskPrinted = 1 // 已经打印
|
||||
)
|
||||
|
||||
func IsPurchaseVendorExist(vendorID int) bool {
|
||||
_, ok := VendorNames[vendorID]
|
||||
|
||||
@@ -13,13 +13,38 @@ func GetStoreOrderAfterTime(db *DaoDB, storeID int, orderTime time.Time, lastOrd
|
||||
t2.actual_fee, t2.desired_fee, t2.waybill_created_at, t2.waybill_finished_at
|
||||
FROM goods_order t1
|
||||
LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id
|
||||
WHERE IF(t1.jx_store_id <> 0, t1.jx_store_id, t1.store_id) = ? AND t1.order_created_at >= ? AND t1.id > ?
|
||||
LIMIT 50;
|
||||
WHERE IF(t1.jx_store_id <> 0, t1.jx_store_id, t1.store_id) = ? AND t1.order_created_at >= ? AND t1.id > ? AND t1.status <= ?;
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
storeID,
|
||||
orderTime,
|
||||
lastOrderSeqID,
|
||||
model.OrderStatusDelivering,
|
||||
}
|
||||
return orderList, GetRows(db, &orderList, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func SetOrderPrintFlag(db *DaoDB, vendorOrderID string, vendorID int, isPrinted bool) (err error) {
|
||||
var (
|
||||
sql string
|
||||
sqlParams []interface{}
|
||||
)
|
||||
if isPrinted {
|
||||
sql = `
|
||||
UPDATE goods_order
|
||||
SET flag = flag | ?
|
||||
WHERE vendor_order_id = ? AND vendor_id = ?
|
||||
`
|
||||
sqlParams = append(sqlParams, model.OrderFlagMaskPrinted)
|
||||
} else {
|
||||
sql = `
|
||||
UPDATE goods_order
|
||||
SET flag = flag & ?
|
||||
WHERE vendor_order_id = ? AND vendor_id = ?
|
||||
`
|
||||
sqlParams = append(sqlParams, ^model.OrderFlagMaskPrinted)
|
||||
}
|
||||
sqlParams = append(sqlParams, vendorOrderID, vendorID)
|
||||
_, err = ExecuteSQL(db, sql, sqlParams...)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -46,15 +46,16 @@ type GoodsOrder struct {
|
||||
StatusTime time.Time `orm:"type(datetime)" json:"-"` // last status time
|
||||
PickDeadline time.Time `orm:"type(datetime)" json:"pickDeadline"`
|
||||
ModelTimeInfo `json:"-"`
|
||||
OriginalData string `orm:"-" json:"-"`
|
||||
OriginalData string `orm:"-" json:"-"` // 只是用于传递数据
|
||||
Skus []*OrderSku `orm:"-" json:"-"`
|
||||
SkuPmFee int64 `json:"-"` //门店商品活动总支出
|
||||
OrderPmFee int64 `json:"-"` //门店订单活动支出
|
||||
SkuPmSubsidy int64 `json:"-"` //平台商品活动总补贴
|
||||
OrderPmSubsidy int64 `json:"-"` //平台订单活动补贴
|
||||
BoxFee int64 `json:"-"` //餐盒费
|
||||
PlatformFeeRate int16 `json:"-"` //平台费
|
||||
BillStoreFreightFee int64 `json:"-"` //需要回调,门店所承担的运费
|
||||
Flag int8 `json:"flag"` //非运单调整相关的其它状态
|
||||
SkuPmFee int64 `json:"-"` //门店商品活动总支出
|
||||
OrderPmFee int64 `json:"-"` //门店订单活动支出
|
||||
SkuPmSubsidy int64 `json:"-"` //平台商品活动总补贴
|
||||
OrderPmSubsidy int64 `json:"-"` //平台订单活动补贴
|
||||
BoxFee int64 `json:"-"` //餐盒费
|
||||
PlatformFeeRate int16 `json:"-"` //平台费
|
||||
BillStoreFreightFee int64 `json:"-"` //需要回调,门店所承担的运费
|
||||
}
|
||||
|
||||
func (o *GoodsOrder) TableUnique() [][]string {
|
||||
|
||||
@@ -20,8 +20,10 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
maxGetOrderTimeDuration = 2 * time.Hour
|
||||
pollingDuration = 5 * time.Minute
|
||||
maxGetOrderTimeDuration = 24 * time.Hour
|
||||
minPollingDuration = 1 * time.Minute
|
||||
defPollingDuration = 5 * time.Minute
|
||||
maxPollingDuration = 10 * time.Minute
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -102,19 +104,28 @@ func unregisterChan(storeID int, chan2Listen chan<- *ServerMsg) {
|
||||
func getPendingOrderList(storeID int, lastOrderTime time.Time, lastOrderSeqID int64) (orderList []*model.GoodsOrderExt, err error) {
|
||||
if !jxutils.IsTimeEmpty(lastOrderTime) {
|
||||
if time.Now().Sub(lastOrderTime) > maxGetOrderTimeDuration {
|
||||
// lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
|
||||
lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
|
||||
}
|
||||
orderList, err = dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
|
||||
}
|
||||
return orderList, err
|
||||
}
|
||||
|
||||
func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOrderSeqID int64, msgTypeList []string) (msg *ServerMsg, err error) {
|
||||
func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOrderSeqID int64, msgTypeList []string, waitingSecond int) (msg *ServerMsg, err error) {
|
||||
orderList, err := getPendingOrderList(storeID, lastOrderTime, lastOrderSeqID)
|
||||
if err == nil {
|
||||
if len(orderList) == 0 {
|
||||
chan2Listen := make(chan *ServerMsg, 1)
|
||||
registerChan(storeID, chan2Listen)
|
||||
pollingDuration := defPollingDuration
|
||||
if waitingSecond != 0 {
|
||||
pollingDuration = time.Duration(waitingSecond) * time.Second
|
||||
if pollingDuration > maxPollingDuration {
|
||||
pollingDuration = maxPollingDuration
|
||||
} else if pollingDuration < minPollingDuration {
|
||||
pollingDuration = minPollingDuration
|
||||
}
|
||||
}
|
||||
timer := time.NewTimer(pollingDuration)
|
||||
select {
|
||||
case msg2, ok := <-chan2Listen:
|
||||
|
||||
Reference in New Issue
Block a user