This commit is contained in:
suyl
2021-04-26 10:59:56 +08:00
parent fbc4f96976
commit 29acc9232f
6 changed files with 55 additions and 20 deletions

View File

@@ -1967,24 +1967,26 @@ 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{}
sid string
jobOrderID int64
job = &model.Job{}
db = dao.GetDB()
sid string //推广位ID美团为userID淘宝饿了么本地化暂时是固定的京西推广位IDpdd为表中推广位ID
)
jobOrderID, _, err = AcceptJob(ctx, jobID, 0, 0)
if err != nil {
job.ID = jobID
if err = dao.GetEntity(db, job); err != nil {
return "", err
}
if jobOrderID != 0 {
sid = utils.Int64ToStr(jobOrderID)
}
//1、建推广位本地和平台
//2、分享链接
if handler := partner.GetHandler(job.VendorID); handler != nil {
link, err = handler.ShareUnionLink(ctx, linkType, job.UnionActID, sid)
if job.VendorID == model.VendorIDMTWM && 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)
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)
}
}
}
}

View File

@@ -8,16 +8,16 @@ import (
"strings"
)
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) {
if linkType == partner.LinkTypeWeiXinMini {
if qrCode, err := api.MtUnionAPI.MiniCode(unionActID, userID); err == nil {
if qrCode, err := api.MtUnionAPI.MiniCode(unionActID, sID); err == nil {
if qrCode != "" {
return qrCode, err
}
}
return
} else {
return api.MtUnionAPI.GenerateLink(unionActID, linkType, userID)
return api.MtUnionAPI.GenerateLink(unionActID, linkType, sID)
}
return link, err
}

View File

@@ -12,6 +12,10 @@ var (
const (
LinkTypeWeiXinMini = 5 //微信小程序二维码
LinTypeH5 = 1 //h5链接
LinTypeDeepLink = 2 //deeplink(唤起)链接
LinTypeInto = 3 //中间页唤起链接
LinTypeWx = 4 //微信小程序唤起路径
ShareTypeOther = 1 //分享给别人
ShareTypeOwn = 2 //自己领
@@ -41,7 +45,7 @@ func init() {
}
type UnionInterface interface {
ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, userID string) (link string, err error)
ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string) (link string, err error)
GetUnionActList(ctx *jxcontext.Context, actType int) (result []*ActivityList, err error)
//GetUnionCouponList(ctx *jxcontext.Context)
}

View File

@@ -1,12 +1,26 @@
package taobao
import (
"fmt"
"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/globals/api"
)
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) {
if result, err2 := api.TbUnionAPI.ActivityInfoGet(userID, utils.Int2Str(unionActID), utils.Str2Int64(sID)); err2 == nil {
switch linkType {
case partner.LinkTypeWeiXinMini:
return result.TbkActivityInfoGetResponse.Data.WxQrcodeURL, err
case partner.LinTypeH5:
return result.TbkActivityInfoGetResponse.Data.ClickURL, err
case partner.LinTypeWx:
return result.TbkActivityInfoGetResponse.Data.WxMiniprogramPath, err
default:
return link, fmt.Errorf("暂不支持此链接类型!")
}
}
return link, err
}
@@ -14,7 +28,7 @@ func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (act
if result, err2 := getAPI().GatewayUnionpub(); err2 == nil {
for _, v := range result {
act := &partner.ActivityList{
ActID: utils.Str2Int(v.Eventid),
ActID: utils.Str2Int(v.Pageid),
ActName: v.Pagename,
ActDes: v.Eventenname,
Ratio: "6%",

View File

@@ -276,3 +276,17 @@ func (v *UserSearch) TableIndex() [][]string {
[]string{"Keyword"},
}
}
type UserUnionBind struct {
ModelIDCULD
UserID string `orm:"column(user_id)" json:"userID"` //用户ID
VendorID int `orm:"column(vendor_id)" json:"vendorID"` //平台ID
UnionID string `orm:"column(union_id)" json:"unionID"` //推广位ID美团为userID淘宝暂时是固定的京西推广位IDpdd为此推广位ID
}
func (v *UserUnionBind) TableUnique() [][]string {
return [][]string{
[]string{"UserID", "VendorID"},
}
}

View File

@@ -18,6 +18,7 @@ func Init() {
orm.RegisterModel(&model.UserDeliveryAddress{})
orm.RegisterModel(&model.UserCityManager{})
orm.RegisterModel(&model.UserSearch{})
orm.RegisterModel(&model.UserUnionBind{}) //联盟相关绑定
//账单
orm.RegisterModel(&model.UserBill{}, &model.BillIncome{}, &model.BillExpend{})
//支付订单