diff --git a/api/mobile/customer_user.go b/api/mobile/customer_user.go index bd5b7713721d1245ff36afc04220e8f0425b9b52..e341f70fc7bc0f6d5e0c8d8d7e7874130902b8ab 100644 --- a/api/mobile/customer_user.go +++ b/api/mobile/customer_user.go @@ -31,28 +31,41 @@ func GetCustomerUserList(c *gin.Context) { } func ExportMsgExcel(c *gin.Context) { - var req request.GetCustomerUserListReq - _ = c.ShouldBindQuery(&req) + reqData := request.GetCustomerUserListReq{} + _ = c.ShouldBindQuery(&reqData) + reqData.MocId = 1 + + fileName := "鐢ㄦ埛鐭摼鍒楄〃" + time.Now().Format("20060102") + + //region := []string{"骞夸笢", "绂忓缓", "姹熻タ", "瀹夊窘", "骞胯タ", "鏂扮枂", "澶╂触", "灞辫タ", "璐靛窞", "鍚夋灄", "鍖椾含", "涓婃捣", "榛戦緳姹�"} + regionIn := "'骞夸笢','绂忓缓','姹熻タ','瀹夊窘','骞胯タ','鏂扮枂','澶╂触','灞辫タ','璐靛窞','鍚夋灄','鍖椾含','涓婃捣','榛戦緳姹�'" + + f := excelize.NewFile() + + codeList := service.GetVcodeList(reqData.MocId) + + //for _, v := range region { + req := request.GetCustomerUserListReq{} + req.RegionIn = regionIn + //req.UserType = 2 req.PageSize = 99999 _, list, _ := service.GetCustomerUserList(req) - codeList := service.GetVcodeList(req.MocId) - - fileName := "鐢ㄦ埛鐭摼鍒楄〃" + time.Now().Format("20060102") - f := excelize.NewFile() + sheetName := "鐢ㄦ埛鐭摼鍒楄〃" // Create a new sheet. - index := f.NewSheet(fileName) + index := f.NewSheet(sheetName) - f.SetCellValue(fileName, "A1", "鐢ㄦ埛ID") - f.SetCellValue(fileName, "B1", "鐢ㄦ埛鍚嶇О") - f.SetCellValue(fileName, "C1", "鐪�") - f.SetCellValue(fileName, "D1", "甯�") - f.SetCellValue(fileName, "E1", "鍖�") - f.SetCellValue(fileName, "F1", "宸ヤ綔浜哄憳") - f.SetCellValue(fileName, "G1", "宸ヤ綔浜哄憳鐢佃瘽") - f.SetCellValue(fileName, "H1", "鐭摼") + f.SetCellValue(sheetName, "A1", "鐢ㄦ埛ID") + f.SetCellValue(sheetName, "B1", "鐢ㄦ埛鍚嶇О") + f.SetCellValue(sheetName, "C1", "鐪�") + f.SetCellValue(sheetName, "D1", "甯�") + f.SetCellValue(sheetName, "E1", "鍖�") + f.SetCellValue(sheetName, "F1", "宸ヤ綔浜哄憳") + f.SetCellValue(sheetName, "G1", "宸ヤ綔浜哄憳鐢佃瘽") + f.SetCellValue(sheetName, "H1", "鏄惁璇嗗埆") + f.SetCellValue(sheetName, "I1", "鐭摼") for k, v := range list { url := "" @@ -63,19 +76,27 @@ func ExportMsgExcel(c *gin.Context) { url = global.GVA_CONFIG.Common.Url + "/" + service.GetVcode(v.Id, req.MocId) } + userType := "鏈瘑鍒�" + if v.UserType == 1 { + userType = "宸茶瘑鍒�" + } + a := strconv.Itoa(k + 2) - f.SetCellValue(fileName, "A"+a, v.Id) - f.SetCellValue(fileName, "B"+a, v.UserName) - f.SetCellValue(fileName, "C"+a, v.Region) - f.SetCellValue(fileName, "D"+a, v.City) - f.SetCellValue(fileName, "E"+a, v.Zone) - f.SetCellValue(fileName, "F"+a, v.WorkerName) - f.SetCellValue(fileName, "G"+a, v.WorkerMobile) - f.SetCellValue(fileName, "H"+a, url) + f.SetCellValue(sheetName, "A"+a, v.Id) + f.SetCellValue(sheetName, "B"+a, v.UserName) + f.SetCellValue(sheetName, "C"+a, v.Region) + f.SetCellValue(sheetName, "D"+a, v.City) + f.SetCellValue(sheetName, "E"+a, v.Zone) + f.SetCellValue(sheetName, "F"+a, v.WorkerName) + f.SetCellValue(sheetName, "G"+a, v.WorkerMobile) + f.SetCellValue(sheetName, "H"+a, userType) + f.SetCellValue(sheetName, "I"+a, url) } // Set active sheet of the workbook. f.SetActiveSheet(index) + + //} // Save xlsx file by the given path. if err := f.SaveAs("./" + fileName + ".csv"); err != nil { fmt.Println(err) @@ -87,3 +108,7 @@ func ExportMsgExcel(c *gin.Context) { c.File("./" + fileName + ".csv") return } + +func msgExcel(req request.GetCustomerUserListReq) { + +} diff --git a/config.yaml b/config.yaml index 8d9c70eaed4d16629227ac974d9c014212156bd9..b37b3d7daec5bc956596556383330219d41baf03 100755 --- a/config.yaml +++ b/config.yaml @@ -116,7 +116,7 @@ encrypt: key: "75SIQyfvwHDU0GbO" common: type: "2" - url: "https://tdt.pet-dbc.cn" + url: "dt.pet-dbc.cn" sms: smsname: "dbc" diff --git a/model/request/customer_user.go b/model/request/customer_user.go index 54d69bb668046fe45663963be00c3f85afe8d78c..7d3114afa3d2e849e2b3ec853ec5972a3c5d06d3 100644 --- a/model/request/customer_user.go +++ b/model/request/customer_user.go @@ -5,6 +5,7 @@ type GetCustomerUserListReq struct { MocId int `gorm:"type:int(255)" json:"moc_id"` UserName string `gorm:"type:string(255)" json:"user_name"` Region string `gorm:"type:string(255)" json:"region"` + RegionIn string `gorm:"type:string(255)" json:"region_in"` City string `gorm:"type:string(255)" json:"city"` Zone string `gorm:"type:string(255)" json:"zone"` Address string `gorm:"type:string(255)" json:"address"` diff --git a/online/config.yaml b/online/config.yaml index 7d9ba921279dc575df6f7bc9f94b4ce430d98b36..6af1698cfb44adf049cbe9aeb72898f8d640a716 100755 --- a/online/config.yaml +++ b/online/config.yaml @@ -116,7 +116,7 @@ encrypt: key: "75SIQyfvwHDU0GbO" common: type: "2" - url: "https://dt.pet-dbc.cn/" + url: "dt.pet-dbc.cn" sms: smsname: "dbc" diff --git a/service/customer_user.go b/service/customer_user.go index 527f1db287b1ad142823b6d9db88bfb0dc86c6ca..e8af2a6586e89fb1ca057a580270cd7cbc5896db 100755 --- a/service/customer_user.go +++ b/service/customer_user.go @@ -29,10 +29,18 @@ func GetCustomerUserList(req request.GetCustomerUserListReq) (error, []request.G orderby := " id asc " + if req.UserType != 0 { + conditions += " AND user_type = " + strconv.Itoa(req.UserType) + } + if req.UserName != "" { conditions += " AND user_name like '%" + req.UserName + "%'" } + if req.RegionIn != "" { + conditions += " AND region in (" + req.RegionIn + ")" + } + if req.Region != "" { conditions += " AND region like '%" + req.Region + "%'" }