- new field GoodsOrder.Flag

- SetOrderPrintStatus
This commit is contained in:
gazebo
2019-03-06 12:22:41 +08:00
parent 19b49a030c
commit acc3cd5731
7 changed files with 81 additions and 15 deletions

View File

@@ -180,6 +180,9 @@ const (
OrderDeliveryFlagMaskScheduleDisabled = 1 // 禁止三方配送调度 OrderDeliveryFlagMaskScheduleDisabled = 1 // 禁止三方配送调度
OrderDeliveryFlagMaskPurcahseDisabled = 2 // 购物平台已不配送(一般为门店配送类型本身为自配送,或已经转自配送) OrderDeliveryFlagMaskPurcahseDisabled = 2 // 购物平台已不配送(一般为门店配送类型本身为自配送,或已经转自配送)
) )
const (
OrderFlagMaskPrinted = 1 // 已经打印
)
func IsPurchaseVendorExist(vendorID int) bool { func IsPurchaseVendorExist(vendorID int) bool {
_, ok := VendorNames[vendorID] _, ok := VendorNames[vendorID]

View File

@@ -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 t2.actual_fee, t2.desired_fee, t2.waybill_created_at, t2.waybill_finished_at
FROM goods_order t1 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 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 > ? 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 <= ?;
LIMIT 50;
` `
sqlParams := []interface{}{ sqlParams := []interface{}{
storeID, storeID,
orderTime, orderTime,
lastOrderSeqID, lastOrderSeqID,
model.OrderStatusDelivering,
} }
return orderList, GetRows(db, &orderList, sql, sqlParams...) 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
}

View File

@@ -46,15 +46,16 @@ type GoodsOrder struct {
StatusTime time.Time `orm:"type(datetime)" json:"-"` // last status time StatusTime time.Time `orm:"type(datetime)" json:"-"` // last status time
PickDeadline time.Time `orm:"type(datetime)" json:"pickDeadline"` PickDeadline time.Time `orm:"type(datetime)" json:"pickDeadline"`
ModelTimeInfo `json:"-"` ModelTimeInfo `json:"-"`
OriginalData string `orm:"-" json:"-"` OriginalData string `orm:"-" json:"-"` // 只是用于传递数据
Skus []*OrderSku `orm:"-" json:"-"` Skus []*OrderSku `orm:"-" json:"-"`
SkuPmFee int64 `json:"-"` //门店商品活动总支出 Flag int8 `json:"flag"` //非运单调整相关的其它状态
OrderPmFee int64 `json:"-"` //门店订单活动支出 SkuPmFee int64 `json:"-"` //门店商品活动支出
SkuPmSubsidy int64 `json:"-"` //平台商品活动总补贴 OrderPmFee int64 `json:"-"` //门店订单活动支出
OrderPmSubsidy int64 `json:"-"` //平台订单活动补贴 SkuPmSubsidy int64 `json:"-"` //平台商品活动补贴
BoxFee int64 `json:"-"` //餐盒费 OrderPmSubsidy int64 `json:"-"` //平台订单活动补贴
PlatformFeeRate int16 `json:"-"` //平台 BoxFee int64 `json:"-"` //餐盒
BillStoreFreightFee int64 `json:"-"` //需要回调,门店所承担的运 PlatformFeeRate int16 `json:"-"` //平台
BillStoreFreightFee int64 `json:"-"` //需要回调,门店所承担的运费
} }
func (o *GoodsOrder) TableUnique() [][]string { func (o *GoodsOrder) TableUnique() [][]string {

View File

@@ -20,8 +20,10 @@ const (
) )
const ( const (
maxGetOrderTimeDuration = 2 * time.Hour maxGetOrderTimeDuration = 24 * time.Hour
pollingDuration = 5 * time.Minute minPollingDuration = 1 * time.Minute
defPollingDuration = 5 * time.Minute
maxPollingDuration = 10 * time.Minute
) )
var ( 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) { func getPendingOrderList(storeID int, lastOrderTime time.Time, lastOrderSeqID int64) (orderList []*model.GoodsOrderExt, err error) {
if !jxutils.IsTimeEmpty(lastOrderTime) { if !jxutils.IsTimeEmpty(lastOrderTime) {
if time.Now().Sub(lastOrderTime) > maxGetOrderTimeDuration { 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) orderList, err = dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
} }
return orderList, err 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) orderList, err := getPendingOrderList(storeID, lastOrderTime, lastOrderSeqID)
if err == nil { if err == nil {
if len(orderList) == 0 { if len(orderList) == 0 {
chan2Listen := make(chan *ServerMsg, 1) chan2Listen := make(chan *ServerMsg, 1)
registerChan(storeID, chan2Listen) 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) timer := time.NewTimer(pollingDuration)
select { select {
case msg2, ok := <-chan2Listen: case msg2, ok := <-chan2Listen:

View File

@@ -159,6 +159,7 @@ func (c *CmsController) GetProductInfoByBarCode() {
// @Param storeID query int true "京西门店ID" // @Param storeID query int true "京西门店ID"
// @Param lastOrderTime query string true "最后订单时间" // @Param lastOrderTime query string true "最后订单时间"
// @Param lastOrderSeqID query string true "最后订单流水ID" // @Param lastOrderSeqID query string true "最后订单流水ID"
// @Param waitingSecond query int false "等待时间"
// @Success 200 {object} controllers.CallResult // @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult
// @router /GetNewOrderMsg [get] // @router /GetNewOrderMsg [get]
@@ -167,7 +168,7 @@ func (c *CmsController) GetNewOrderMsg() {
timeList, err := jxutils.BatchStr2Time(params.LastOrderTime) timeList, err := jxutils.BatchStr2Time(params.LastOrderTime)
if err == nil { if err == nil {
lastOrderSeqID := utils.Str2Int64WithDefault(params.LastOrderSeqID, 0) 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 return retVal, "", err
}) })

View File

@@ -10,6 +10,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" "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/jxutils"
"git.rosy.net.cn/jx-callback/business/model" "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/business/partner"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego" "github.com/astaxie/beego"
@@ -299,3 +300,19 @@ func (c *OrderController) RefreshOrderRealMobile() {
return retVal, "", err 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
})
}

View File

@@ -519,6 +519,14 @@ func init() {
MethodParams: param.Make(), MethodParams: param.Make(),
Params: nil}) 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
beego.ControllerComments{ beego.ControllerComments{
Method: "CancelPromotion", Method: "CancelPromotion",