From cea95c96cacbd59718cecc5396a79804c17002cf Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 16 May 2019 11:29:44 +0800 Subject: [PATCH] - RefreshMtpsWaybillFee --- business/jxstore/tempop/tempop.go | 28 +++++++++++++++++++++++++++ controllers/temp_op.go | 15 ++++++++++++++ routers/commentsRouter_controllers.go | 9 +++++++++ 3 files changed, 52 insertions(+) diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 0bdb71e69..fcbaf9de4 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -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 +} diff --git a/controllers/temp_op.go b/controllers/temp_op.go index c61beb02c..08facefef 100644 --- a/controllers/temp_op.go +++ b/controllers/temp_op.go @@ -215,3 +215,18 @@ func (c *TempOpController) RetrieveEbaiShopLicence() { return retVal, "", err }) } + +// @Title 刷新美团配送价格 +// @Description 刷新美团配送价格 +// @Param token header string true "认证token" +// @Param isAsync formData bool false "是否异步操作" +// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /RefreshMtpsWaybillFee [post] +func (c *TempOpController) RefreshMtpsWaybillFee() { + c.callRefreshMtpsWaybillFee(func(params *tTempopRefreshMtpsWaybillFeeParams) (retVal interface{}, errCode string, err error) { + retVal, err = tempop.RefreshMtpsWaybillFee(params.Ctx, params.IsAsync, params.IsContinueWhenError) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 98d8fafde..f34c947ed 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1366,6 +1366,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"], + beego.ControllerComments{ + Method: "RefreshMtpsWaybillFee", + Router: `/RefreshMtpsWaybillFee`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"], beego.ControllerComments{ Method: "RetrieveEbaiShopLicence",