pdd
This commit is contained in:
@@ -3,6 +3,7 @@ package cms
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tbunionapi"
|
||||
"math"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -1967,25 +1968,54 @@ func GetUnionActList(ctx *jxcontext.Context, vendorID, actType int) (actList []*
|
||||
|
||||
func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType int) (link string, err error) {
|
||||
var (
|
||||
job = &model.Job{}
|
||||
db = dao.GetDB()
|
||||
sid string //推广位ID,美团为userID,淘宝饿了么本地化暂时是固定的京西推广位ID,pdd为表中推广位ID
|
||||
job = &model.Job{}
|
||||
db = dao.GetDB()
|
||||
sid string //推广位ID,美团为userID,淘宝饿了么本地化暂时是固定的京西推广位ID,pdd为表中推广位ID
|
||||
userID = ctx.GetUserID()
|
||||
userBinds []*model.UserUnionBind
|
||||
)
|
||||
job.ID = jobID
|
||||
if err = dao.GetEntity(db, job); err != nil {
|
||||
return "", err
|
||||
}
|
||||
vendorID := job.VendorID
|
||||
handler := partner.GetHandler(vendorID)
|
||||
//1、建推广位(本地和平台)
|
||||
|
||||
if userBinds, err = dao.GetUserUnionBind(db, userID, vendorID); err != nil {
|
||||
return "", err
|
||||
}
|
||||
//本地已有推广位
|
||||
if len(userBinds) > 0 {
|
||||
sid = userBinds[0].UnionID
|
||||
} else {
|
||||
userBind := &model.UserUnionBind{
|
||||
UserID: userID,
|
||||
VendorID: vendorID,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(userBind, ctx.GetUserName())
|
||||
if handler != nil {
|
||||
if sid, err = handler.CreateUnionPosition(ctx, userID); err == nil {
|
||||
if sid == "" {
|
||||
sid = userID
|
||||
if vendorID == model.VendorIDTB {
|
||||
sid = utils.Int2Str(tbunionapi.JxAdzoneID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
userBind.UnionID = sid
|
||||
dao.CreateEntity(db, userBind)
|
||||
}
|
||||
//2、分享链接
|
||||
if handler := partner.GetHandler(job.VendorID); handler != nil {
|
||||
link, err = handler.ShareUnionLink(ctx, linkType, job.UnionActID, sid, ctx.GetUserID())
|
||||
if job.VendorID == model.VendorIDMTWM || job.VendorID == model.VendorIDTB {
|
||||
if linkType == partner.LinkTypeWeiXinMini {
|
||||
if resBinary, _, err := jxutils.DownloadFileByURL(link + "?imageView2/1/w/150/h/150/q/75"); err == nil {
|
||||
if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+link[strings.LastIndex(link, "/")+1:len(link)]); err == nil {
|
||||
if err == nil {
|
||||
link = jxutils.MixWatermarkImg(downloadURL, job.UnionImg, job.UnionQrcodePosition)
|
||||
if handler != nil {
|
||||
if link, err = handler.ShareUnionLink(ctx, linkType, job.UnionActID, sid, userID); err == nil {
|
||||
if vendorID == model.VendorIDMTWM || vendorID == model.VendorIDTB {
|
||||
if linkType == partner.LinkTypeWeiXinMini {
|
||||
if resBinary, _, err := jxutils.DownloadFileByURL(link + "?imageView2/1/w/150/h/150/q/75"); err == nil {
|
||||
if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+link[strings.LastIndex(link, "/")+1:len(link)]); err == nil {
|
||||
if err == nil {
|
||||
link = jxutils.MixWatermarkImg(downloadURL, job.UnionImg, job.UnionQrcodePosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ func init() {
|
||||
partner.HandlerMap[model.VendorIDJDShop] = unionHandler
|
||||
}
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, userID string) (link string, err error) {
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string) (link string, err error) {
|
||||
|
||||
return "jds", err
|
||||
}
|
||||
@@ -25,3 +25,7 @@ func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionAct
|
||||
func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (actList []*partner.ActivityList, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s *UnionHandler) CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error) {
|
||||
return sID, err
|
||||
}
|
||||
|
||||
@@ -44,3 +44,7 @@ func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (act
|
||||
}
|
||||
return actList, err
|
||||
}
|
||||
|
||||
func (s *UnionHandler) CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error) {
|
||||
return sID, err
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ func init() {
|
||||
type UnionInterface interface {
|
||||
ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string) (link string, err error)
|
||||
GetUnionActList(ctx *jxcontext.Context, actType int) (result []*ActivityList, err error)
|
||||
CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error)
|
||||
//GetUnionCouponList(ctx *jxcontext.Context)
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,27 @@
|
||||
package pdd
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/pddapi"
|
||||
"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.HandlerMap[model.VendorIDPDD] = unionHandler
|
||||
}
|
||||
|
||||
func getAPI() (apiobj *pddapi.API) {
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "pddunionCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||
api.PddAPI.SetCookieWithStr(configs[0].Value)
|
||||
}
|
||||
return api.PddAPI
|
||||
}
|
||||
|
||||
18
business/jxstore/partner/pdd/union.go
Normal file
18
business/jxstore/partner/pdd/union.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package pdd
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
)
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string) (link string, err error) {
|
||||
return link, err
|
||||
}
|
||||
|
||||
func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (actList []*partner.ActivityList, err error) {
|
||||
return actList, err
|
||||
}
|
||||
|
||||
func (s *UnionHandler) CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error) {
|
||||
return sID, err
|
||||
}
|
||||
@@ -42,3 +42,7 @@ func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (act
|
||||
}
|
||||
return actList, err
|
||||
}
|
||||
|
||||
func (s *UnionHandler) CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error) {
|
||||
return sID, err
|
||||
}
|
||||
|
||||
@@ -394,3 +394,21 @@ func GetUserAllWaitRealCashPrice(db *DaoDB, userID string) (price int, err error
|
||||
err = GetRow(db, &result, sql, sqlParams)
|
||||
return result.Price, err
|
||||
}
|
||||
func GetUserUnionBind(db *DaoDB, userID string, vendorID int) (userBinds []*model.UserUnionBind, err error) {
|
||||
sql := `
|
||||
SELECT * FROM user_union_bind WHERE deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if userID != "" {
|
||||
sql += " AND user_id = ?"
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
if vendorID != -1 {
|
||||
sql += " AND vendor_id = ?"
|
||||
sqlParams = append(sqlParams, vendorID)
|
||||
}
|
||||
err = GetRows(db, &userBinds, sql, sqlParams)
|
||||
return userBinds, err
|
||||
}
|
||||
|
||||
@@ -266,4 +266,7 @@ mtUnionAppKey = "b6481f92b47918cd6e42e7ea4fae6084"
|
||||
mtUnionAppSecret = "84d390777ddf691ff092e744ba26bfdd"
|
||||
|
||||
tbUnionAppKey = "32724809"
|
||||
tbUnionAppSecret = "2c2bce02eab860d486f68aa59a0127d9"
|
||||
tbUnionAppSecret = "2c2bce02eab860d486f68aa59a0127d9"
|
||||
|
||||
pddAppKey = "f9d95aaf5856485eabf39588f69a86de"
|
||||
pddAppSecret = "fa40c1fe356eebc1376ace1d2380ed44e553c602"
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/pddapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tbunionapi"
|
||||
"io/ioutil"
|
||||
|
||||
@@ -45,6 +46,7 @@ import (
|
||||
var (
|
||||
MtUnionAPI *mtunionapi.API
|
||||
TbUnionAPI *tbunionapi.API
|
||||
PddAPI *pddapi.API
|
||||
|
||||
JdEclpAPI *jdeclpapi.API
|
||||
JdShopAPI *jdshopapi.API
|
||||
@@ -90,6 +92,7 @@ func init() {
|
||||
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", ""))
|
||||
|
||||
if !beego.AppConfig.DefaultBool("disableJdEclp", false) {
|
||||
JdEclpAPI = jdeclpapi.New(beego.AppConfig.String("jdEclpAccessToken"), beego.AppConfig.String("jdEclpAppKey"), beego.AppConfig.String("jdEclpAppSecret"))
|
||||
|
||||
Reference in New Issue
Block a user