|
@@ -2,6 +2,7 @@ package services
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
@@ -253,6 +254,28 @@ func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanc
|
|
|
var itemsAdd []*models.CygxActivitySignupDetail
|
|
|
var itemsUpdate []*models.CygxActivitySignupDetail
|
|
|
|
|
|
+ var mobiles []string
|
|
|
+ mobileMap := make(map[string]bool)
|
|
|
+ mobileUserMap := make(map[string]int)
|
|
|
+ for _, v := range itemsDetail {
|
|
|
+ if !mobileMap[v.Mobile] {
|
|
|
+ mobiles = append(mobiles, v.Mobile)
|
|
|
+ }
|
|
|
+ mobileMap[v.Mobile] = true
|
|
|
+ }
|
|
|
+ //mobiles = make([]string, 0)
|
|
|
+ //mobiles = append(mobiles, "13054631616")
|
|
|
+ //根据手机号获取这些用户的信息
|
|
|
+ listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listUser {
|
|
|
+ mobileUserMap[v.Mobile] = v.UserId
|
|
|
+ }
|
|
|
+
|
|
|
for _, v := range itemsDetail {
|
|
|
var item = new(models.CygxActivitySignupDetail)
|
|
|
item.ActivityId = v.ActivityId
|
|
@@ -279,6 +302,7 @@ func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanc
|
|
|
item.UseridEntity = v.UseridEntity
|
|
|
item.ActivityTime = v.ActivityTime
|
|
|
item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
|
|
|
+ item.UserId = mobileUserMap[v.Mobile]
|
|
|
|
|
|
if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", item.Mobile)]; !ok {
|
|
|
itemsAdd = append(itemsAdd, item)
|
|
@@ -308,3 +332,46 @@ func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanc
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// var err error
|
|
|
+// defer func() {
|
|
|
+// if err != nil {
|
|
|
+// fmt.Println(err)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+// var condition string
|
|
|
+// var pars []interface{}
|
|
|
+// condition = " AND user_id = 0 AND company_id > 1 AND mobile != '' "
|
|
|
+// signUpDetailList, e := models.GetSignupDetailList(condition, pars)
|
|
|
+// if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+// err = errors.New("GetSignupDetailList, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+// var mobiles []string
|
|
|
+// mobileMap := make(map[string]bool)
|
|
|
+// for _, v := range signUpDetailList {
|
|
|
+// if !mobileMap[v.Mobile] {
|
|
|
+// mobiles = append(mobiles, v.Mobile)
|
|
|
+// }
|
|
|
+// mobileMap[v.Mobile] = true
|
|
|
+// }
|
|
|
+// //mobiles = make([]string, 0)
|
|
|
+// //mobiles = append(mobiles, "13054631616")
|
|
|
+// //根据手机号获取这些用户的信息
|
|
|
+// listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
|
|
|
+// if e != nil {
|
|
|
+// err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
|
|
|
+// return
|
|
|
+// }
|
|
|
+//
|
|
|
+// var itemsUpdate []*models.CygxActivitySignupDetail
|
|
|
+// for _, v := range listUser {
|
|
|
+// item := new(models.CygxActivitySignupDetail)
|
|
|
+// item.UserId = v.UserId
|
|
|
+// item.Mobile = v.Mobile
|
|
|
+// itemsUpdate = append(itemsUpdate, item)
|
|
|
+// }
|
|
|
+// fmt.Println(len(itemsUpdate))
|
|
|
+// err = models.UpdateActivitySignupDetailMultiMobileAndUserId(itemsUpdate)
|
|
|
+//}
|