Browse Source

Merge branch 'fix_cygx3.1' of hongze/hongze_cygx into master

hongze 3 years ago
parent
commit
0c4d17de7c
6 changed files with 75 additions and 21 deletions
  1. 4 2
      controllers/activity.go
  2. 9 6
      models/activity.go
  3. 29 11
      models/activity_signup.go
  4. 1 0
      models/wx_user.go
  5. 29 2
      services/activity.go
  6. 3 0
      services/task.go

+ 4 - 2
controllers/activity.go

@@ -630,9 +630,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		br.Ret = 408
 		return
 	}
-	fmt.Println(user.Mobile)
 	uid := user.UserId
-	//var signupStatus string
 	signupStatus := ""
 	var req models.ActivitySingnupRep
 	resp := new(models.SignupStatus)
@@ -890,6 +888,8 @@ func (this *ActivityCoAntroller) SignupAdd() {
 					item.CompanyName = user.CompanyName
 					item.SignupType = signupType
 					item.DoFailType = item.FailType
+					item.OutboundMobile = user.Mobile
+					item.CountryCode = user.CountryCode
 					//添加报名信息,但是不加入日程
 					_, errSignup := models.AddActivitySignupNoSchedule(item)
 					if errSignup != nil {
@@ -922,6 +922,8 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				item.SignupType = signupType
 				item.FailType = 0
 				item.DoFailType = 0
+				item.OutboundMobile = user.Mobile
+				item.CountryCode = user.CountryCode
 				_, errSignup := models.AddActivitySignup(item)
 				if errSignup != nil {
 					br.Msg = "操作失败"

+ 9 - 6
models/activity.go

@@ -388,20 +388,23 @@ WHERE
 }
 
 type SignupExportRep struct {
-	Mobile      string `description:"手机号"`
-	CompanyName string `description:"公司名称"`
-	RealName    string `description:"姓名"`
-	CountryCode string `description:"区号"`
+	Mobile         string `description:"手机号"`
+	CompanyName    string `description:"公司名称"`
+	RealName       string `description:"姓名"`
+	CountryCode    string `description:"区号"`
+	OutboundMobile string `description:"外呼手机号"`
+	SellerName     string `description:"销售姓名"`
 }
 
 func GetSignupExport(activityId int) (item []*SignupExportRep, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT s.*  ,a.is_limit_people,u.real_name ,u.country_code
+	sql := `SELECT s.*  ,a.is_limit_people,u.real_name,p.seller_name
 			FROM
 			cygx_activity_signup AS s
 			LEFT JOIN wx_user AS u ON u.user_id = s.user_id
 			LEFT JOIN cygx_activity AS a ON a.activity_id = s.activity_id
-			WHERE a.activity_id = ?  AND s.fail_type = 0`
+			LEFT JOIN company_product AS p ON p.company_id = u.company_id 
+			WHERE a.activity_id = ?  AND s.fail_type = 0  `
 	_, err = o.Raw(sql, activityId).QueryRows(&item)
 	return
 }

+ 29 - 11
models/activity_signup.go

@@ -7,17 +7,19 @@ import (
 )
 
 type CygxActivitySignup struct {
-	Id          int       `orm:"column(id);pk"`
-	ActivityId  int       `description:"活动ID"`
-	UserId      int       `description:"用户ID"`
-	CreateTime  time.Time `description:"创建时间"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司id"`
-	CompanyName string    `description:"公司名称"`
-	FailType    int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
-	SignupType  int       `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
-	DoFailType  int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	Id             int       `orm:"column(id);pk"`
+	ActivityId     int       `description:"活动ID"`
+	UserId         int       `description:"用户ID"`
+	CreateTime     time.Time `description:"创建时间"`
+	Mobile         string    `description:"手机号"`
+	Email          string    `description:"邮箱"`
+	CompanyId      int       `description:"公司id"`
+	CompanyName    string    `description:"公司名称"`
+	FailType       int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	SignupType     int       `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
+	DoFailType     int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	OutboundMobile string    `description:"外呼手机号"`
+	CountryCode    string    `description:"手机国家区号"`
 }
 
 type SignupStatus struct {
@@ -302,3 +304,19 @@ func AddActivitySignupByRestrict(item *CygxActivitySignup) (lastId int64, err er
 	lastId, err = o.Insert(itemLog)
 	return
 }
+
+//列表
+func GetActivitySignupListAll() (items []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_signup `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改是否推送消息状态
+func UPdateSignup(item *CygxActivitySignup) (err error) {
+	sql := ` UPDATE cygx_activity_signup SET  outbound_mobile= ? , country_code=86  WHERE id = ?`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, item.Mobile, item.Id).Exec()
+	return
+}

+ 1 - 0
models/wx_user.go

@@ -75,6 +75,7 @@ type WxUserItem struct {
 	SessionKey      string    `description:"微信小程序会话密钥"`
 	CompanyName     string    `description:"公司名称"`
 	IsRegister      int       `description:"是否注册:1:已注册,0:未注册"`
+	CountryCode     string    `description:"手机国家区号"`
 	Source          int
 }
 

+ 29 - 2
services/activity.go

@@ -196,18 +196,20 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 		cellA := rowTitle.AddCell()
 		cellA.Value = "姓名"
 		cellB := rowTitle.AddCell()
-		cellB.Value = "手机号"
+		cellB.Value = "外呼号码"
 		cellC := rowTitle.AddCell()
 		cellC.Value = "国际代码"
 		cellD := rowTitle.AddCell()
 		cellD.Value = "公司名称"
+		cellE := rowTitle.AddCell()
+		cellE.Value = "所属销售"
 
 		for _, item := range list {
 			row := sheet.AddRow()
 			cellA := row.AddCell()
 			cellA.Value = item.RealName
 			cellB := row.AddCell()
-			cellB.Value = item.Mobile
+			cellB.Value = item.OutboundMobile
 			cellC := row.AddCell()
 			if item.CountryCode == "" {
 				cellC.Value = "86"
@@ -216,6 +218,8 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 			}
 			cellD := row.AddCell()
 			cellD.Value = item.CompanyName
+			cellE := row.AddCell()
+			cellE.Value = item.SellerName
 		}
 		errFile = xlsxFile.Save(downLoadnFilePath)
 		if errFile != nil {
@@ -250,3 +254,26 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 	fmt.Println("发送附件完成")
 	return
 }
+
+func EditOutboundMobile(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("发送失败,Err:", err.Error())
+		}
+	}()
+
+	list, err := models.GetActivitySignupListAll()
+	if err != nil {
+		fmt.Println("GetActivitySendMsgListAll Err:", err.Error())
+		return
+	}
+	for _, v := range list {
+		err = models.UPdateSignup(v)
+		fmt.Println("修改:", strconv.Itoa(v.Id))
+		if err != nil {
+			fmt.Println("发送失败,Err:", err.Error()+strconv.Itoa(v.Id))
+		}
+	}
+	fmt.Println("修改完成")
+	return
+}

+ 3 - 0
services/task.go

@@ -50,6 +50,9 @@ func Task() {
 	//预约外呼名单,会前1小时自动发送邮件给专家组
 	sendEmailFileToExpert := task.NewTask("sendEmailFileToExpert", "0 */5 8-22 * * *", SendEmailFileToExpert) //预约外呼名单,会前1小时自动发送邮件给专家组
 	task.AddTask("sendEmailFileToExpert", sendEmailFileToExpert)
+
+	//editOutboundMobile := task.NewTask("editOutboundMobile", "0 */1 8-22 * * *", EditOutboundMobile) //同步外呼号码与手机号
+	//task.AddTask("sendEmailFileToExpert", editOutboundMobile)
 	//UpdateActivitySattus()
 	task.StartTask()
 	fmt.Println("end")