From 384aa5500a5f36c55373e24e79634e0e617eff4f Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Thu, 3 Jun 2021 16:19:54 +0800 Subject: [PATCH] aa --- business/jxstore/cms/store.go | 26 ++++++++++++++++------- business/jxstore/cms/user2.go | 40 ++++++++++++++++++++--------------- controllers/cms_store.go | 19 +++++++++++++++++ 3 files changed, 60 insertions(+), 25 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 892aa5fce..49b3da14f 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -4887,14 +4887,6 @@ func AuditStoreMap(ctx *jxcontext.Context, ID int, vendorOrgCode, vendorStoreID if err != nil { return err } - if auditStatus == model.StoreMapAuditStatusPass { - if storeMapAudit.VendorOrgCode == "" && vendorOrgCode == "" { - return fmt.Errorf("请选择平台账号进行绑定!") - } - if vendorStoreID == "" { - return fmt.Errorf("请输入绑定的平台门店ID!") - } - } retVal, err := GetVendorStore(ctx, storeMapAudit.VendorID, vendorOrgCode, vendorStoreID) if err != nil { return err @@ -4902,5 +4894,23 @@ func AuditStoreMap(ctx *jxcontext.Context, ID int, vendorOrgCode, vendorStoreID if retVal == nil { return fmt.Errorf("未在平台上查询到此门店,请确认平台账号和平台门店ID!") } + if auditStatus == model.StoreMapAuditStatusPass { + if storeMapAudit.VendorOrgCode == "" && vendorOrgCode == "" { + return fmt.Errorf("请选择平台账号进行绑定!") + } + if vendorStoreID == "" { + return fmt.Errorf("请输入绑定的平台门店ID!") + } + storeMap := &model.StoreMap{} + AddStoreVendorMap(ctx, db, storeMapAudit.VendorID, vendorOrgCode, storeMapAudit.StoreID, storeMap) + } else { + if comment == "" { + fmt.Errorf("审核不通过请输入原因!") + } + } + storeMapAudit.AuditStatus = auditStatus + storeMapAudit.AuditAt = time.Now() + storeMapAudit.AuditOperator = ctx.GetUserName() + dao.UpdateEntity(db, storeMapAudit, "AuditStatus", "AuditAt", "AuditOperator") return err } diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index e8b052a8e..eceb0d664 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -161,6 +161,7 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri user.Type = model.UserTypeConsumer | model.UserTypeStoreBoss // 先不区分商户与消息者 createName := ctx.GetRealRemoteIP() authType := auth2.AuthTypeMobile + mobile := &alipayapi.KeyMobile{} if manTokenInfo != nil && mobileVerifyCode == "" { manUser, err2 := dao.GetUserByID(dao.GetDB(), "user_id", manTokenInfo.GetID()) if err = err2; err != nil { @@ -217,6 +218,21 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri user.Avatar = inAuthInfo.GetAvatar() } } + //支付宝注册电话需要解密 + if user.GetMobile() != "" && user.GetName() != "" && user.GetID2() != "" { + if user.LastLoginType != "" && user.LastLoginType == alipay.AuthType { + data, _ := base64.StdEncoding.DecodeString(user.GetMobile()) + key, _ := base64.StdEncoding.DecodeString(alipay.AuthKey) + iv := []byte{} + iv = append(iv, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + if result, err := utils.AESCBCDecpryt(data, key, iv); err == nil && result != nil { + json.Unmarshal(result, &mobile) + } + user.Mobile = &mobile.Mobile + user.UserID2 = mobile.Mobile + user.Name = mobile.Mobile + } + } if err = CreateUser(user, utils.LimitUTF8StringLen(createName, 32)); err == nil { userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP()) TryAddStoreBossRole4User(ctx, user) @@ -228,7 +244,12 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri outAuthInfo, err = auth2.BindUser(inAuthInfo, user) } } else if dao.IsDuplicateError(err) { - err = auth2.ErrUserID2AlreadyExist + if user.LastLoginType != "" && user.LastLoginType == alipay.AuthType { + outAuthInfo, err = auth2.BindUser(inAuthInfo, user) + err = nil + } else { + err = auth2.ErrUserID2AlreadyExist + } } return outAuthInfo, err } @@ -401,22 +422,7 @@ func CreateUser(user *model.User, creatorName string) (err error) { if user.GetEmail() == "" { user.Email = nil } - //支付宝注册电话需要解密 - if user.GetMobile() != "" && user.GetName() != "" && user.GetID2() != "" { - if user.LastLoginType != "" && user.LastLoginType == alipay.AuthType { - mobile := &alipayapi.KeyMobile{} - data, _ := base64.StdEncoding.DecodeString(user.GetMobile()) - key, _ := base64.StdEncoding.DecodeString(alipay.AuthKey) - iv := []byte{} - iv = append(iv, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - if result, err := utils.AESCBCDecpryt(data, key, iv); err == nil && result != nil { - json.Unmarshal(result, &mobile) - } - user.Mobile = &mobile.Mobile - user.UserID2 = mobile.Mobile - user.Name = mobile.Mobile - } - } + dao.WrapAddIDCULDEntity(user, creatorName) user.UserID = utils.GetUUID() user.Status = model.UserStatusNormal diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 3fc9f3609..8f3f68af4 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -1136,3 +1136,22 @@ func (c *StoreController) AuditStoreMap() { return retVal, "", err }) } + +// @Title 查询商户申请授权 +// @Description 查询商户申请授权 +// @Param token header string true "认证token" +// @Param storeIDs query string false "门店IDs" +// @Param vendorIDs query string false "平台IDs" +// @Param auditStatuss query string false "审核状态s" +// @Param fromTime query string false "审核时间" +// @Param toTime query string false "审核时间" +// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" +// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetStoreMapAudit [get] +func (c *StoreController) GetStoreMapAudit() { + c.callGetStoreMapAudit(func(params *tStoreGetStoreMapAuditParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +}