aa
This commit is contained in:
@@ -1968,12 +1968,12 @@ func GetUnionActList(ctx *jxcontext.Context, vendorID, actType int) (actList []*
|
|||||||
|
|
||||||
func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resourceType int, goodsID string) (link string, err error) {
|
func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resourceType int, goodsID string) (link string, err error) {
|
||||||
var (
|
var (
|
||||||
job = &model.Job{}
|
job = &model.Job{}
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
sid string //推广位ID,美团为userID,淘宝饿了么本地化暂时是固定的京西推广位ID,pdd为表中推广位ID
|
sid string //推广位ID,美团为userID,淘宝饿了么本地化暂时是固定的京西推广位ID,pdd为表中推广位ID
|
||||||
//userID = ctx.GetUserID()
|
|
||||||
mobile, userID = ctx.GetMobileAndUserID()
|
mobile, userID = ctx.GetMobileAndUserID()
|
||||||
userBinds []*model.UserUnionBind
|
userBinds []*model.UserUnionBind
|
||||||
|
userBind *model.UserUnionBind
|
||||||
)
|
)
|
||||||
if jobID == 0 {
|
if jobID == 0 {
|
||||||
return "", fmt.Errorf("该活动已结束,请选择其他活动!")
|
return "", fmt.Errorf("该活动已结束,请选择其他活动!")
|
||||||
@@ -1984,6 +1984,7 @@ func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resource
|
|||||||
}
|
}
|
||||||
vendorID := job.VendorID
|
vendorID := job.VendorID
|
||||||
unionID := mobile + utils.Int2Str(jobID)
|
unionID := mobile + utils.Int2Str(jobID)
|
||||||
|
isImg := (vendorID == model.VendorIDMTWM || vendorID == model.VendorIDTB) && linkType == partner.LinkTypeWeiXinMini
|
||||||
handler := partner.GetHandler(vendorID)
|
handler := partner.GetHandler(vendorID)
|
||||||
//1、建推广位(本地和平台)
|
//1、建推广位(本地和平台)
|
||||||
if userBinds, err = dao.GetUserUnionBind(db, userID, vendorID, ""); err != nil {
|
if userBinds, err = dao.GetUserUnionBind(db, userID, vendorID, ""); err != nil {
|
||||||
@@ -1992,8 +1993,9 @@ func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resource
|
|||||||
//本地已有推广位
|
//本地已有推广位
|
||||||
if len(userBinds) > 0 {
|
if len(userBinds) > 0 {
|
||||||
sid = userBinds[0].UnionID
|
sid = userBinds[0].UnionID
|
||||||
|
userBind = userBinds[0]
|
||||||
} else {
|
} else {
|
||||||
userBind := &model.UserUnionBind{
|
userBind = &model.UserUnionBind{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
VendorID: vendorID,
|
VendorID: vendorID,
|
||||||
}
|
}
|
||||||
@@ -2009,18 +2011,29 @@ func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
userBind.UnionID = sid
|
userBind.UnionID = sid
|
||||||
dao.CreateEntity(db, userBind)
|
//dao.CreateEntity(db, userBind)
|
||||||
}
|
}
|
||||||
//2、分享链接
|
//2、分享链接
|
||||||
if handler != nil {
|
if handler != nil {
|
||||||
|
if isImg {
|
||||||
|
if userBind.UnionImg != "" {
|
||||||
|
return userBind.UnionImg, err
|
||||||
|
}
|
||||||
|
}
|
||||||
if link, err = handler.ShareUnionLink(ctx, linkType, utils.Str2Int(job.UnionActID), sid, userID, resourceType, goodsID); err == nil {
|
if link, err = handler.ShareUnionLink(ctx, linkType, utils.Str2Int(job.UnionActID), sid, userID, resourceType, goodsID); err == nil {
|
||||||
if vendorID == model.VendorIDMTWM || vendorID == model.VendorIDTB {
|
if isImg {
|
||||||
if linkType == partner.LinkTypeWeiXinMini {
|
if resBinary, _, err := jxutils.DownloadFileByURL(link); err == nil {
|
||||||
if resBinary, _, err := jxutils.DownloadFileByURL(link); err == nil {
|
if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+link[strings.LastIndex(link, "/")+1:len(link)]); 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 {
|
||||||
if err == nil {
|
link = jxutils.MixWatermarkImg(downloadURL+"?imageView2/1/w/120/h/120/q/75", job.UnionImg, job.UnionQrcodePosition)
|
||||||
link = jxutils.MixWatermarkImg(downloadURL+"?imageView2/1/w/120/h/120/q/75", job.UnionImg, job.UnionQrcodePosition)
|
link += "?imageslim"
|
||||||
link += "?imageslim"
|
//id为0表示要新增
|
||||||
|
if userBind.ID == 0 {
|
||||||
|
userBind.UnionImg = link
|
||||||
|
dao.CreateEntity(db, userBind)
|
||||||
|
} else {
|
||||||
|
userBind.UnionImg = link
|
||||||
|
dao.UpdateEntity(db, userBind, "UnionImg")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ type UserUnionBind struct {
|
|||||||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID
|
UserID string `orm:"column(user_id)" json:"userID"` //用户ID
|
||||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"` //平台ID
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"` //平台ID
|
||||||
UnionID string `orm:"column(union_id)" json:"unionID"` //推广位ID,美团为userID,淘宝暂时是固定的京西推广位ID,pdd为此推广位ID
|
UnionID string `orm:"column(union_id)" json:"unionID"` //推广位ID,美团为userID,淘宝暂时是固定的京西推广位ID,pdd为此推广位ID
|
||||||
|
UnionImg string `json:"unionImg"` //该用户对应平台的处理后的小程序二维码图,目前就美团用,避免二次上传
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *UserUnionBind) TableUnique() [][]string {
|
func (v *UserUnionBind) TableUnique() [][]string {
|
||||||
|
|||||||
Reference in New Issue
Block a user