- RefreshMtpsWaybillFee
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
@@ -960,3 +962,29 @@ func RetrieveEbaiShopLicence(ctx *jxcontext.Context, isAsync, isContinueWhenErro
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func RefreshMtpsWaybillFee(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var waybillList []*model.Waybill
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetRows(db, &waybillList, `
|
||||
SELECT *
|
||||
FROM waybill
|
||||
WHERE status_time > '2019-05-10' AND waybill_vendor_id = 102 AND desired_fee > 0
|
||||
`); err == nil {
|
||||
globals.SugarLogger.Debugf("RefreshMtpsWaybillFee, count:%d", len(waybillList))
|
||||
rootTask := tasksch.NewParallelTask("RefreshMtpsWaybillFee", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
bill := batchItemList[0].(*model.Waybill)
|
||||
bill.DesiredFee, _ = delivery.CalculateBillDeliveryFee(bill)
|
||||
_, err = dao.UpdateEntity(db, bill, "DesiredFee")
|
||||
return nil, err
|
||||
}, waybillList)
|
||||
tasksch.ManageTask(rootTask).Run()
|
||||
if !isAsync {
|
||||
_, err = rootTask.GetResult(0)
|
||||
} else {
|
||||
hint = rootTask.ID
|
||||
}
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user