- 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:
|
||||
|
||||
@@ -159,6 +159,7 @@ func (c *CmsController) GetProductInfoByBarCode() {
|
||||
// @Param storeID query int true "京西门店ID"
|
||||
// @Param lastOrderTime query string true "最后订单时间"
|
||||
// @Param lastOrderSeqID query string true "最后订单流水ID"
|
||||
// @Param waitingSecond query int false "等待时间"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetNewOrderMsg [get]
|
||||
@@ -167,7 +168,7 @@ func (c *CmsController) GetNewOrderMsg() {
|
||||
timeList, err := jxutils.BatchStr2Time(params.LastOrderTime)
|
||||
if err == nil {
|
||||
lastOrderSeqID := utils.Str2Int64WithDefault(params.LastOrderSeqID, 0)
|
||||
retVal, err = msghub.GetMsg(params.Ctx, params.StoreID, timeList[0], lastOrderSeqID, nil)
|
||||
retVal, err = msghub.GetMsg(params.Ctx, params.StoreID, timeList[0], lastOrderSeqID, nil, params.WaitingSecond)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego"
|
||||
@@ -299,3 +300,19 @@ func (c *OrderController) RefreshOrderRealMobile() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 设置订单打印状态
|
||||
// @Description 同步商家SKU类别
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorOrderID formData string true "订单/运单ID"
|
||||
// @Param vendorID formData int true "订单/运单所属厂商ID)"
|
||||
// @Param isPrinted formData bool true "是否打印"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /SetOrderPrintStatus [put]
|
||||
func (c *OrderController) SetOrderPrintStatus() {
|
||||
c.callSetOrderPrintStatus(func(params *tOrderSetOrderPrintStatusParams) (retVal interface{}, errCode string, err error) {
|
||||
err = dao.SetOrderPrintFlag(dao.GetDB(), params.VendorOrderID, params.VendorID, params.IsPrinted)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -519,6 +519,14 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
beego.ControllerComments{
|
||||
Method: "SetOrderPrintStatus",
|
||||
Router: `/SetOrderPrintStatus`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CancelPromotion",
|
||||
|
||||
Reference in New Issue
Block a user