刷新京东商城订单结算价

This commit is contained in:
苏尹岚
2020-05-08 11:00:13 +08:00
parent a247c24a08
commit 29065aa419
6 changed files with 60 additions and 3 deletions

View File

@@ -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
}

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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
})
}

View File

@@ -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()
}

View File

@@ -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",