From ae8a75a975a495dd12a77dc50ccdf7ee986348fc Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Fri, 7 May 2021 16:52:59 +0800 Subject: [PATCH] aa --- business/jxstore/cms/cms.go | 3 +++ business/jxstore/partner/jds/jds.go | 27 +++++++++++++++++++++++ business/jxstore/partner/jds/union.go | 31 ++++++++++++++++----------- globals/api/api.go | 3 +++ 4 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 business/jxstore/partner/jds/jds.go diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 723b9c0db..59c37f1ea 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -108,6 +108,9 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { model.VendorIDPDD: map[int]interface{}{ 1: "进行中的活动", }, + model.VendorIDJDShop: map[int]interface{}{ + 2: "进行中", + }, }, "unionOrderStatusName": model.UnionOrderStatusName, }, diff --git a/business/jxstore/partner/jds/jds.go b/business/jxstore/partner/jds/jds.go new file mode 100644 index 000000000..17ee29a09 --- /dev/null +++ b/business/jxstore/partner/jds/jds.go @@ -0,0 +1,27 @@ +package jds + +import ( + "git.rosy.net.cn/baseapi/platformapi/jdunionapi" + "git.rosy.net.cn/jx-callback/business/jxstore/partner" + "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/globals/api" +) + +type UnionHandler struct { +} + +var ( + unionHandler *UnionHandler +) + +func init() { + partner.UnionHandlerMap[model.VendorIDJDShop] = unionHandler +} + +func getAPI() (apiobj *jdunionapi.API) { + if configs, err := dao.QueryConfigs(dao.GetDB(), "jdunionCookie", model.ConfigTypeCookie, ""); err == nil { + api.JdUnionAPI.SetCookieWithStr(configs[0].Value) + } + return api.JdUnionAPI +} diff --git a/business/jxstore/partner/jds/union.go b/business/jxstore/partner/jds/union.go index fe63f4d03..888b80c1d 100644 --- a/business/jxstore/partner/jds/union.go +++ b/business/jxstore/partner/jds/union.go @@ -1,29 +1,34 @@ package jds import ( + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxstore/partner" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - "git.rosy.net.cn/jx-callback/business/model" ) -type UnionHandler struct { -} - -var ( - unionHandler *UnionHandler -) - -func init() { - partner.UnionHandlerMap[model.VendorIDJDShop] = unionHandler -} - func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string, resourceType int, goodsID string) (link string, err error) { return "jds", err } func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (actList []*partner.ActivityList, err error) { - return + if result, err2 := getAPI().ListActivitys(); err2 == nil { + for _, v := range result { + act := &partner.ActivityList{ + ActID: v.Activityid, + ActName: v.Activityname, + ActDes: v.Remark, + Ratio: "11%", + Img: v.Imageurl, + } + act.DateBegin = utils.Str2Time(v.Activitystartdate) + act.DateEnd = utils.Str2Time(v.Activityenddate) + actList = append(actList, act) + } + } else { + err = err2 + } + return actList, err } func (s *UnionHandler) CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error) { diff --git a/globals/api/api.go b/globals/api/api.go index c537d3c5b..df0b307ba 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -1,6 +1,7 @@ package api import ( + "git.rosy.net.cn/baseapi/platformapi/jdunionapi" "git.rosy.net.cn/baseapi/platformapi/pddapi" "git.rosy.net.cn/baseapi/platformapi/tbunionapi" "io/ioutil" @@ -47,6 +48,7 @@ var ( MtUnionAPI *mtunionapi.API TbUnionAPI *tbunionapi.API PddAPI *pddapi.API + JdUnionAPI *jdunionapi.API JdEclpAPI *jdeclpapi.API JdShopAPI *jdshopapi.API @@ -93,6 +95,7 @@ func Init() { MtUnionAPI = mtunionapi.New(beego.AppConfig.DefaultString("mtUnionAppKey", ""), beego.AppConfig.DefaultString("mtUnionAppSecret", "")) TbUnionAPI = tbunionapi.New(beego.AppConfig.DefaultString("tbUnionAppKey", ""), beego.AppConfig.DefaultString("tbUnionAppSecret", "")) PddAPI = pddapi.New(beego.AppConfig.DefaultString("pddAppKey", ""), beego.AppConfig.DefaultString("pddAppSecret", "")) + JdUnionAPI = jdunionapi.New(beego.AppConfig.DefaultString("jdUnionAppKey", ""), beego.AppConfig.DefaultString("jdUnionAppSecret", "")) if !beego.AppConfig.DefaultBool("disableJdEclp", false) { JdEclpAPI = jdeclpapi.New(beego.AppConfig.String("jdEclpAccessToken"), beego.AppConfig.String("jdEclpAppKey"), beego.AppConfig.String("jdEclpAppSecret"))