Kaynağa Gözat

Merge branch 'master' into feature/v1.0.40

yuelujie 1 hafta önce
ebeveyn
işleme
d0ae403da3
2 değiştirilmiş dosya ile 19 ekleme ve 16 silme
  1. 8 13
      rpc/internal/logic/materialsavelogic.go
  2. 11 3
      service/material.go

+ 8 - 13
rpc/internal/logic/materialsavelogic.go

@@ -43,23 +43,18 @@ func (l *MaterialSaveLogic) MaterialSave(in *pb.MaterialSaveReq) (*pb.MaterialSa
 	}
 
 	//获取分发人的userid
-	userIdArr := service.GetSendUserId(in.ReceiveUserId, in.EntId)
-	if in.QrcodeUrl == "" {
-		return &pb.MaterialSaveResp{
-			ErrorCode:  1,
-			ErrorMsg:   "",
-			MsgId:      msgId,
-			MaterialId: mid,
-			UserIdArr:  userIdArr,
-		}, nil
-	}
+	userIdArr, userIdMap := service.GetSendUserId(in.ReceiveUserId, in.EntId)
 	positionArr := strings.Split(in.ReceiveUserId, ",")
-	userIdMap := service.GetUserIds(in.ReceiveUserId)
+	//userIdMap := service.GetUserIds(in.ReceiveUserId)
+	//log.Println("userIdMap", userIdMap)
 	for k, v := range strings.Split(in.ReceiveUserName, ",") {
+		personCode := service.GetPersonCode(gconv.Int64(positionArr[k]), v, userIdMap[common.IntAll(positionArr[k])])
 		if len(strings.Split(in.FileUrl, ",")) == 0 {
-			break
+			continue
+		}
+		if in.QrcodeUrl == "" {
+			continue
 		}
-		personCode := service.GetPersonCode(gconv.Int64(positionArr[k]), v, userIdMap[common.IntAll(positionArr[k])])
 		qrcodeUrl := fmt.Sprintf("%s/material/%d/%s?tp=material", IC.IC.JyWebDomain, mid, personCode)
 		//log.Println("二维码链接", qrcodeUrl)
 		for _, val := range strings.Split(in.FileUrl, ",") {

+ 11 - 3
service/material.go

@@ -59,18 +59,20 @@ func MaterialSave(in *pb.MaterialSaveReq, title, content string) (msgId, mId int
 	return msgId, mId, nil
 }
 
-func GetSendUserId(positionIds string, entId int64) []string {
+func GetSendUserId(positionIds string, entId int64) ([]string, map[int]string) {
 	//拿职位id找mgoid
 	userIdArr := []string{}
-	query := fmt.Sprintf("SELECT userid FROM data_service.user_system WHERE position_id in (%s) AND ent_id = %d", positionIds, entId)
+	res := map[int]string{}
+	query := fmt.Sprintf("SELECT userid,position_id FROM data_service.user_system WHERE  status = 1 AND position_id in (%s) AND ent_id = %d", positionIds, entId)
 	log.Println("查找分发人的sql", query)
 	useridMap := entity.JyBiTidb.SelectBySql(query)
 	if useridMap != nil && len(*useridMap) > 0 {
 		for _, val := range *useridMap {
 			userIdArr = append(userIdArr, gconv.String(val["userid"]))
+			res[common.IntAll(val["position_id"])] = common.InterfaceToStr(val["userid"])
 		}
 	}
-	return userIdArr
+	return userIdArr, res
 }
 
 func PersonImageSave(imgUrl string, msgId, positionId, materialsId int64) bool {
@@ -86,13 +88,19 @@ func PersonImageSave(imgUrl string, msgId, positionId, materialsId int64) bool {
 
 func GetPersonCode(positionId int64, name, userId string) string {
 	//根据职位id获取到对应的渠道码
+	if userId == "" {
+		log.Println("GetPersonCode userId为空", positionId, userId)
+		return ""
+	}
 	code := ""
 	data := entity.JyBiTidb.FindOne("dwd_d_userbase_belongto_rulecode", map[string]interface{}{"user_id": userId}, "code", "")
 	if data != nil && len(*data) > 0 {
 		code = gconv.String((*data)["code"])
+		log.Println("查询到code:", positionId, userId, code)
 	} else {
 		//没有code,生成一个
 		code = generateRandomString(6)
+		log.Println("生成code:", positionId, userId, code)
 		entity.JyBiMysql.Insert("dwd_d_userbase_belongto_rulecode", map[string]interface{}{
 			"code":        code,
 			"pcode":       "04",