Commit 44a625ac authored by haoyanbin's avatar haoyanbin

1

parent 3e8a66eb
......@@ -15,11 +15,6 @@ import (
"time"
)
var Moc = map[int]string{
1: "直接留资",
2: "转介绍留资",
}
func GetSurveyUserList(c *gin.Context) {
var req request.GetSurveyUserListReq
_ = c.ShouldBindJSON(&req)
......@@ -121,6 +116,8 @@ func ExportSurveyUserExcel(c *gin.Context) {
var req request.GetSurveyUserListReq
_ = c.ShouldBindQuery(&req)
mocData := service.GetMoc(1)
req.PageSize = 99999
req.Status = 1
......@@ -169,13 +166,6 @@ func ExportSurveyUserExcel(c *gin.Context) {
optionData += v2.OptionValue + " * " + strconv.Itoa(v2.OptionNum) + "; "
}
isReference := "直接留资"
moc := ""
if v.MocId == 1 {
moc = "短信"
}
url := global.GVA_CONFIG.Common.Url + "?" + v.Vcode
a := strconv.Itoa(k + 3)
......@@ -197,8 +187,8 @@ func ExportSurveyUserExcel(c *gin.Context) {
f.SetCellValue(fileName, "P"+a, "")
f.SetCellValue(fileName, "Q"+a, v.Reference)
f.SetCellValue(fileName, "R"+a, v.ReferenceMobile)
f.SetCellValue(fileName, "S"+a, isReference)
f.SetCellValue(fileName, "T"+a, moc)
f.SetCellValue(fileName, "S"+a, mocData[v.MocId])
f.SetCellValue(fileName, "T"+a, "短信")
f.SetCellValue(fileName, "U"+a, url)
}
......@@ -220,6 +210,8 @@ func ExportMocDataExcel(c *gin.Context) {
var req request.GetSurveyUserListReq
_ = c.ShouldBindQuery(&req)
mocData := service.GetMoc(1)
fileName := "数据统计" + time.Now().Format("20060102")
f := excelize.NewFile()
// Create a new sheet.
......@@ -237,7 +229,7 @@ func ExportMocDataExcel(c *gin.Context) {
f.SetCellValue(fileName, "J1", "留资率")
f.SetCellValue(fileName, "K1", "获客单价")
for k, v := range Moc {
for k, v := range mocData {
req.MocId = k
req.Status = 1
surveyCount := service.GetSurveyUserCount(req) //留资数量
......
package model
type Moc struct {
Id int `gorm:"type:int(255)" json:"id"`
Name string `gorm:"type:string(255)" json:"name"`
MocType int `gorm:"type:int(255)" json:"moc_type"`
}
package service
import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"strconv"
)
func GetMoc(mocType int) map[int]string {
list := make([]model.Moc, 0)
table := " moc "
//table := " survey_log as sl left join customer_user as cu on sl.user_id=cu.id "
field := " id, name "
conditions := ""
if mocType != 0 {
conditions += " AND moc_type = " + strconv.Itoa(mocType)
}
sqlStr2 := "SELECT " + field +
" FROM " + table +
" WHERE 1>0 " + conditions
global.GVA_DB.Raw(sqlStr2).Scan(&list)
if global.GVA_DB.Error != nil {
return nil
}
reply := make(map[int]string, 0)
for _, v := range list {
reply[v.Id] = v.Name
}
return reply
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment