From 29065aa419c1ce61258c002faa571140634999fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 8 May 2020 11:00:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B7=E6=96=B0=E4=BA=AC=E4=B8=9C=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E8=AE=A2=E5=8D=95=E7=BB=93=E7=AE=97=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/orderman_ext.go | 22 ++++++++++++++++++++ business/jxstore/misc/misc.go | 7 +++++++ conf/app.conf | 3 +++ controllers/jx_order.go | 15 +++++++++++++ globals/globals.go | 7 ++++--- routers/commentsRouter_controllers.go | 9 ++++++++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 1063a2c90..7fe6e6c67 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -7,6 +7,8 @@ import ( "strings" "time" + "git.rosy.net.cn/jx-callback/globals/api" + "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/baseapi/utils" @@ -1345,3 +1347,23 @@ func GetMatterStoreOrderCount(ctx *jxcontext.Context, storeID int) (result *Orde // orderCount.Count = 1000 return orderCount, err } + +func RefreshJdShopOrdersEarningPrice(ctx *jxcontext.Context, orderStartTime, orderEndTime string) (err error) { + var ( + db = dao.GetDB() + ) + results, err := api.JdAPI.GetJdShopOrders(orderStartTime, orderEndTime, globals.JdOrgCode, globals.JdLoginName) + if err != nil { + return err + } + for _, v := range results.BillList.Result { + if v.DueAmount != 0 { + order := &model.GoodsOrder{} + order.VendorOrderID = utils.Int64ToStr(v.OrderID) + order.EarningPrice = utils.Float64TwoInt64(v.DueAmount * 100) + order.NewEarningPrice = utils.Float64TwoInt64(v.DueAmount * 100) + dao.UpdateEntity(db, order, "EarningPrice", "NewEarningPrice") + } + } + return err +} diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 319c5c941..d7412594e 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -129,6 +129,7 @@ var ( JdStorePageCookie string yinbaoCookie string feiePageCookie string + jdStorePageEarning string ) func GetImportantTaskID(taskName string) string { @@ -281,6 +282,9 @@ func Init() { if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil { JdStorePageCookie = configs[0].Value } + if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageEarning", model.ConfigTypeCookie, ""); err == nil { + jdStorePageEarning = configs[0].Value + } if configs, err := dao.QueryConfigs(dao.GetDB(), "jd2StorePageCookie", model.ConfigTypeCookie, ""); err == nil { jd2StorePageCookie = configs[0].Value } @@ -303,6 +307,7 @@ func Init() { api.MtwmAPI.SetCookieWithStr(mtwmCookieStr) api.MtpsAPI.SetCookie("token", mtpsStoreToken) api.JdAPI.SetJdCookie(JdStorePageCookie) + api.JdAPI.SetCookie("user", jdStorePageEarning) api.JdPageAPI.SetCookie(jdapi.AccessStorePageCookieName, JdStorePageCookie) api.JdPageAPI.SetCookie(jdapi.AccessStorePageCookieName2, JdStorePageCookie) api.FeieAPI.SetCookieWithStr(feiePageCookie) @@ -386,6 +391,8 @@ func doDailyWork() { localjx.RefreshAllMatterOrderStatus(jxcontext.AdminCtx) //同步银豹到京西 cms.CurVendorSync.SyncStoreSkusFromYb(jxcontext.AdminCtx, nil, true, true) + //刷新京东商城订单结算价 + orderman.RefreshJdShopOrdersEarningPrice(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -3).Format("20060102"), time.Now().Format("20060102")) } func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) { diff --git a/conf/app.conf b/conf/app.conf index 7225e3543..aa1ba819b 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -167,6 +167,7 @@ getYLYTokenURL = "http://www.jxc4.com/v2/sys/GetYLYToken" EnableDocs = false jdOrgCode = "320406" +jdLoginName = "jd_jxcs1223" jdToken = "77e703b7-7997-441b-a12a-2e522efb117a" jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" @@ -237,6 +238,7 @@ EnableDocs = false dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxgy?charset=utf8mb4&loc=Local&parseTime=true" jdOrgCode = "339032" +jdLoginName = "jd_jxgy" jdToken = "c45e6510-00ba-4be2-977e-bcb9c9792cc7" jdAppKey = "5d5577a2506f41b8b4ec520ba83490f5" jdSecret = "0b01b9eeb15b41dab1c3d05d95c17a26" @@ -380,6 +382,7 @@ enableWscStoreWrite = false enableYbStoreWrite = true jdOrgCode = "320406" +jdLoginName = "jd_jxcs1223" jdToken = "77e703b7-7997-441b-a12a-2e522efb117a" jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" diff --git a/controllers/jx_order.go b/controllers/jx_order.go index ddb0eed3a..28c1cc51b 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -1016,3 +1016,18 @@ func (c *OrderController) GetMatterStoreOrderCount() { return retVal, "", err }) } + +// @Title 刷新京东商城订单结算价 +// @Description 刷新京东商城订单结算价 +// @Param token header string true "认证token" +// @Param fromTime formData string true "订单起始时间 格式:20060102" +// @Param toTime formData string false "订单结束时间" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /RefreshJdShopOrdersEarningPrice [put] +func (c *OrderController) RefreshJdShopOrdersEarningPrice() { + c.callRefreshJdShopOrdersEarningPrice(func(params *tOrderRefreshJdShopOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) { + err = orderman.RefreshJdShopOrdersEarningPrice(params.Ctx, params.FromTime, params.ToTime) + return retVal, "", err + }) +} diff --git a/globals/globals.go b/globals/globals.go index 48aa35b91..b368ac083 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -54,8 +54,9 @@ var ( WxpayNotifyURL string TLPayNotifyURL string - JdOrgCode string - Jd2OrgCode string + JdOrgCode string + Jd2OrgCode string + JdLoginName string IsStoreSkuAct bool IsAddEvent bool @@ -124,7 +125,7 @@ func Init() { TLPayNotifyURL = beego.AppConfig.DefaultString("tonglianPayNotifyURL", "") JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "") Jd2OrgCode = beego.AppConfig.DefaultString("jd2OrgCode", "") - + JdLoginName = beego.AppConfig.DefaultString("jdLoginName", "") IsAddEvent = beego.AppConfig.DefaultBool("addEvent", false) IsStoreSkuAct = !IsProductEnv() } diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 0e14fee14..b7349c580 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1152,6 +1152,15 @@ func init() { Filters: 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: "RefreshJdShopOrdersEarningPrice", + Router: `/RefreshJdShopOrdersEarningPrice`, + AllowHTTPMethods: []string{"put"}, + MethodParams: param.Make(), + Filters: 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: "RefreshOrderFinancial",