From 4977dd6e72d3dce9c5251760e4731188cee78d11 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Mon, 17 May 2021 09:24:47 +0800 Subject: [PATCH] aa --- business/jxstore/cms/job.go | 23 ++++++++++++++++------- business/model/dao/dao_user.go | 19 +++++++++++++++++++ business/model/user.go | 1 + 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index a86bf7958..52f4db198 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -2011,13 +2011,17 @@ func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resource } } userBind.UnionID = sid - //dao.CreateEntity(db, userBind) + dao.CreateEntity(db, userBind) } //2、分享链接 if handler != nil { + var bindImg *model.UserUnionBindImg if isImg { - if userBind.UnionImg != "" { - return userBind.UnionImg, err + bindImg, _ = dao.GetUserUnionBindImg(db, userBind.UnionID, job.UnionActID) + if bindImg != nil { + if bindImg.UnionImg != "" { + return bindImg.UnionImg, err + } } } if link, err = handler.ShareUnionLink(ctx, linkType, utils.Str2Int(job.UnionActID), sid, userID, resourceType, goodsID); err == nil { @@ -2029,11 +2033,16 @@ func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType, resource link += "?imageslim" //id为0表示要新增 if userBind.ID == 0 { - userBind.UnionImg = link - dao.CreateEntity(db, userBind) + bindImgAdd := &model.UserUnionBindImg{ + UnionID: sid, + ActID: job.UnionActID, + UnionImg: link, + } + dao.WrapAddIDCULDEntity(bindImgAdd, ctx.GetUserName()) + dao.CreateEntity(db, bindImgAdd) } else { - userBind.UnionImg = link - dao.UpdateEntity(db, userBind, "UnionImg") + bindImg.UnionImg = link + dao.UpdateEntity(db, bindImg, "UnionImg") } } } diff --git a/business/model/dao/dao_user.go b/business/model/dao/dao_user.go index e2b3cbb6e..2ac167c4b 100644 --- a/business/model/dao/dao_user.go +++ b/business/model/dao/dao_user.go @@ -416,3 +416,22 @@ func GetUserUnionBind(db *DaoDB, userID string, vendorID int, unionID string) (u err = GetRows(db, &userBinds, sql, sqlParams) return userBinds, err } + +func GetUserUnionBindImg(db *DaoDB, unionID, actID string) (userBinds *model.UserUnionBindImg, err error) { + sql := ` + SELECT * FROM user_union_bind_img WHERE deleted_at = ? + ` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + } + if unionID != "" { + sql += " AND union_id = ?" + sqlParams = append(sqlParams, unionID) + } + if actID != "" { + sql += " AND act_id = ?" + sqlParams = append(sqlParams, actID) + } + err = GetRow(db, &userBinds, sql, sqlParams) + return userBinds, err +} diff --git a/business/model/user.go b/business/model/user.go index 30c2e1971..0e12ab4ba 100644 --- a/business/model/user.go +++ b/business/model/user.go @@ -295,6 +295,7 @@ type UserUnionBindImg struct { ModelIDCULD UnionID string `orm:"column(union_id)" json:"unionID"` //推广位ID,美团为userID,淘宝暂时是固定的京西推广位ID,pdd为此推广位ID + ActID string `orm:"column(act_id)" json:"actID"` //对应的活动ID UnionImg string `json:"unionImg"` //该用户对应平台的处理后的小程序二维码图,目前就美团用,避免二次上传 }