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