Commit 38559bff authored by haoyanbin's avatar haoyanbin

Customer

parent b6053eb1
package mobile
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/model/request"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"github.com/gin-gonic/gin"
"github.com/xuri/excelize/v2"
"go.uber.org/zap"
"strconv"
"time"
)
func GetCustomerUserList(c *gin.Context) {
var req request.GetCustomerUserListReq
_ = c.ShouldBindQuery(&req)
err, list, total := service.GetCustomerUserList(req)
reply := request.GetCustomerUserListReply{}
reply.List = list
reply.Total = total
if err != nil {
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithDetailed(reply, "获取成功", c)
}
return
}
func ExportMsgExcel(c *gin.Context) {
var req request.GetCustomerUserListReq
_ = c.ShouldBindQuery(&req)
req.PageSize = 99999
_, list, _ := service.GetCustomerUserList(req)
fileName := "用户短链列表" + time.Now().Format("20060102")
f := excelize.NewFile()
// Create a new sheet.
index := f.NewSheet(fileName)
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", "短链")
for k, v := range list {
url := "" + "?user_id=" + strconv.Itoa(v.Id) + "&moc_id=" + strconv.Itoa(req.MocId)
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)
}
// 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)
return
}
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "./"+fileName+".csv")) //fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
c.Writer.Header().Add("Content-Type", "application/octet-stream")
c.File("./" + fileName + ".csv")
return
}
package mobile
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
......@@ -8,14 +9,47 @@ import (
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"github.com/xuri/excelize/v2"
"go.uber.org/zap"
"strconv"
"time"
)
func GetSurveyUserList(c *gin.Context) {
var req request.GetSurveyUserListReq
_ = c.ShouldBindJSON(&req)
response.OkWithData(req, c)
err, list, total := service.GetSurveyUserList(req)
reply := request.GetSurveyUserListReply{}
reply.List = list
reply.Total = total
if err != nil {
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithDetailed(reply, "获取成功", c)
}
return
}
func GetSurveyLogList(c *gin.Context) {
var req request.GetSurveyLogListReq
_ = c.ShouldBindJSON(&req)
err, list, total := service.GetSurveyLogList(req)
reply := request.GetSurveyLogListReply{}
reply.List = list
reply.Total = total
if err != nil {
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithDetailed(reply, "获取成功", c)
}
return
}
......@@ -28,6 +62,7 @@ func CreateSurveyUser(c *gin.Context) {
SurveyUser := model.SurveyUser{
SurveyId: 1,
UserId: req.UserId,
MocId: req.MocId,
Contacts: req.Contacts,
ContactsMobile: req.ContactsMobile,
Reference: req.Reference,
......@@ -72,3 +107,52 @@ func CreateSurveyLog(c *gin.Context) {
}
return
}
func ExportSurveyUserExcel(c *gin.Context) {
var req request.GetSurveyUserListReq
_ = c.ShouldBindQuery(&req)
req.PageSize = 99999
_, list, _ := service.GetSurveyUserList(req)
fileName := "用户列表" + time.Now().Format("20060102")
f := excelize.NewFile()
// Create a new sheet.
index := f.NewSheet(fileName)
f.SetCellValue(fileName, "A1", "链接所属人")
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", "备注")
for k, v := range list {
a := strconv.Itoa(k + 2)
f.SetCellValue(fileName, "A"+a, v.WorkerName)
f.SetCellValue(fileName, "B"+a, v.WorkerMobile)
f.SetCellValue(fileName, "C"+a, v.WorkerMobile)
f.SetCellValue(fileName, "D"+a, v.WorkerMobile)
f.SetCellValue(fileName, "E"+a, v.WorkerMobile)
f.SetCellValue(fileName, "F"+a, v.WorkerMobile)
f.SetCellValue(fileName, "G"+a, v.WorkerMobile)
f.SetCellValue(fileName, "H"+a, v.WorkerMobile)
}
// 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)
return
}
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "./"+fileName+".csv")) //fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
c.Writer.Header().Add("Content-Type", "application/octet-stream")
c.File("./" + fileName + ".csv")
return
}
......@@ -450,52 +450,3 @@ func GetRegoinList(c *gin.Context) {
response.OkWithDetailed(gin.H{"region": reply}, "设置成功", c)
}
}
func UserVipInfo(c *gin.Context) {
userId := getUserID(c)
var reply model.VipUser
var err error
if service.IsVipUser(int(userId)) == 1 {
err, reply = service.GetVipUser(int(userId))
if err != nil {
fmt.Println(err)
}
}
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
return
}
//用户操作日志
//userReportLog := model.UserReportLog{
// UserId: getUserID(c),
// ReportMainOrginId: "",
// Api: "/mobile/userInfo",
// Req: "",
// Reply: "",
//}
//service.CreateUserReportLog(userReportLog)
response.OkWithData(gin.H{"reply": reply}, c)
return
}
func GetUserName(c *gin.Context) {
var req request.GetUserNameReq
_ = c.ShouldBindJSON(&req)
var err error
//积分信息
err, userData := service.GetUserName(req.Mobile)
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
return
}
response.OkWithData(userData, c)
return
}
......@@ -116,6 +116,7 @@ encrypt:
key: "75SIQyfvwHDU0GbO"
common:
type: "2"
url: ""
sms:
smsname: "dbc"
......
......@@ -42,6 +42,7 @@ func Routers() *gin.Engine {
router.InitPointsPublicRouter(PublicGroup)
router.InitCommonPublicRouter(PublicGroup)
router.InitSurveyPublicRouter(PublicGroup)
router.InitCustoemrUserPublicRouter(PublicGroup)
}
AdminPublicGroup := Router.Group("")
......@@ -56,6 +57,7 @@ func Routers() *gin.Engine {
router.InitVipRouter(MobileGroup)
router.InitPointsRouter(MobileGroup)
router.InitSurveyRouter(MobileGroup)
router.InitCustoemrUserRouter(MobileGroup)
}
PrivateGroup := Router.Group("")
PrivateGroup.Use(middleware.JWTAuth())
......
package model
type CustomerUser struct {
Id int `gorm:"type:int(255)" json:"id"`
UserName string `gorm:"type:string(255)" json:"user_name"`
Region string `gorm:"type:string(255)" json:"region"`
City string `gorm:"type:string(255)" json:"city"`
Zone string `gorm:"type:string(255)" json:"zone"`
Address string `gorm:"type:string(255)" json:"address"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
WorkerPosition string `gorm:"type:string(255)" json:"worker_position"`
WorkerName string `gorm:"type:string(255)" json:"worker_name"`
WorkerMobile string `gorm:"type:string(255)" json:"worker_mobile"`
UserSource string `gorm:"type:string(255)" json:"user_source"`
UserType int `gorm:"type:int(255)" json:"user_type"`
CreateTime string `gorm:"type:string(255)" json:"create_time"`
UpdateTime string `gorm:"type:string(255)" json:"update_time"`
}
package request
type GetCustomerUserListReq struct {
PageInfo
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"`
City string `gorm:"type:string(255)" json:"city"`
Zone string `gorm:"type:string(255)" json:"zone"`
Address string `gorm:"type:string(255)" json:"address"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
WorkerPosition string `gorm:"type:string(255)" json:"worker_position"`
WorkerName string `gorm:"type:string(255)" json:"worker_name"`
WorkerMobile string `gorm:"type:string(255)" json:"worker_mobile"`
UserSource string `gorm:"type:string(255)" json:"user_source"`
UserType int `gorm:"type:int(255)" json:"user_type"`
CreateTime string `gorm:"type:string(255)" json:"create_time"`
}
type GetCustomerUserListReply struct {
List []GetCustomerUserList `json:"list"`
Total int64 `json:"total"`
}
type GetCustomerUserList struct {
Id int `gorm:"type:int(255)" json:"id"`
UserName string `gorm:"type:string(255)" json:"user_name"`
Region string `gorm:"type:string(255)" json:"region"`
City string `gorm:"type:string(255)" json:"city"`
Zone string `gorm:"type:string(255)" json:"zone"`
Address string `gorm:"type:string(255)" json:"address"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
WorkerPosition string `gorm:"type:string(255)" json:"worker_position"`
WorkerName string `gorm:"type:string(255)" json:"worker_name"`
WorkerMobile string `gorm:"type:string(255)" json:"worker_mobile"`
UserSource string `gorm:"type:string(255)" json:"user_source"`
UserType int `gorm:"type:int(255)" json:"user_type"`
CreateTime string `gorm:"type:string(255)" json:"create_time"`
}
......@@ -6,6 +6,7 @@ type CreateSurveyUserReq struct {
Data []model.SurveyUserData `json:"data"`
SurveyId int `gorm:"type:int(255)" json:"survey_id"`
UserId int `gorm:"type:int(255)" json:"user_id"`
MocId int `gorm:"type:int(255)" json:"moc_id"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
Reference string `gorm:"type:string(255)" json:"reference"`
......@@ -13,25 +14,59 @@ type CreateSurveyUserReq struct {
}
type GetSurveyUserListReq struct {
Mobile string `json:"mobile" form:"mobile"`
PageInfo
MocId int `gorm:"type:int(255)" json:"moc_id"`
Region string `gorm:"type:string(255)" json:"region"`
City string `gorm:"type:string(255)" json:"city"`
Zone string `gorm:"type:string(255)" json:"zone"`
Address string `gorm:"type:string(255)" json:"address"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
Reference string `gorm:"type:string(255)" json:"reference"`
ReferenceMobile string `gorm:"type:string(255)" json:"reference_mobile"`
StartCreateTime string `json:"start_create_time" form:"start_create_time"`
EndCreateTime string `json:"end_create_time" form:"end_create_time"`
}
type GetSurveyUserListReply struct {
Data []model.SurveyUserData `gorm:"-" json:"data"`
SurveyId int `gorm:"type:int(255)" json:"survey_id"`
UserId int `gorm:"type:int(255)" json:"user_id"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
List []GetSurveyUserList `json:"list"`
Total int64 `json:"total"`
}
type GetSurveyUserList struct {
Data []model.SurveyUserData `gorm:"-" json:"data"`
SurveyId int `gorm:"type:int(255)" json:"survey_id"`
UserId int `gorm:"type:int(255)" json:"user_id"`
MocId int `gorm:"type:int(255)" json:"moc_id"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
Reference string `gorm:"type:string(255)" json:"reference"`
ReferenceMobile string `gorm:"type:string(255)" json:"reference_mobile"`
WorkerName string `gorm:"type:string(255)" json:"worker_name"`
WorkerMobile string `gorm:"type:string(255)" json:"worker_mobile"`
}
type GetSurveyLogListReq struct {
PageInfo
Mobile string `json:"mobile" form:"mobile"`
UserId int `gorm:"type:int(255)" json:"user_id"`
MocId int `gorm:"type:int(255)" json:"moc_id"`
WorkerName string `gorm:"type:string(255)" json:"worker_name"`
WorkerMobile string `gorm:"type:string(255)" json:"worker_mobile"`
Region string `gorm:"type:string(255)" json:"region"`
City string `gorm:"type:string(255)" json:"city"`
Zone string `gorm:"type:string(255)" json:"zone"`
StartCreateTime string `json:"start_create_time" form:"start_create_time"`
EndCreateTime string `json:"end_create_time" form:"end_create_time"`
}
type GetSurveyLogListReply struct {
List []GetSurveyLogList `json:"list"`
Total int64 `json:"total"`
}
type GetSurveyLogList struct {
Mobile string `json:"mobile" form:"mobile"`
MaxPage string `gorm:"type:string(255)" json:"max_page"`
WorkerName string `gorm:"type:string(255)" json:"worker_name"`
WorkerMobile string `gorm:"type:string(255)" json:"worker_mobile"`
}
......@@ -5,6 +5,7 @@ type SurveyUser struct {
Id int `gorm:"type:int(255)" json:"id"`
SurveyId int `gorm:"type:int(255)" json:"survey_id"`
UserId int `gorm:"type:int(255)" json:"user_id"`
MocId int `gorm:"type:int(255)" json:"moc_id"`
Contacts string `gorm:"type:string(255)" json:"contacts"`
ContactsMobile string `gorm:"type:string(255)" json:"contacts_mobile"`
Reference string `gorm:"type:string(255)" json:"reference"`
......@@ -28,6 +29,7 @@ type SurveyUserData struct {
type SurveyLog struct {
Id int `gorm:"type:int(255)" json:"id"`
UserId int `gorm:"type:int(255)" json:"user_id"`
MocId int `gorm:"type:int(255)" json:"moc_id"`
Page int `gorm:"type:int(255)" json:"page"`
CreateTime string `gorm:"type:string(255)" json:"create_time"`
Country string `gorm:"type:string(255)" json:"country"`
......
package router
import (
"gin-vue-admin/api/mobile"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func InitCustoemrUserRouter(Router *gin.RouterGroup) {
DataVipCommentRouter := Router.Group("customer").Use(middleware.OperationRecord())
{
DataVipCommentRouter.POST("getCustomerUserList", mobile.GetCustomerUserList)
}
}
func InitCustoemrUserPublicRouter(Router *gin.RouterGroup) {
DataVipCommentRouter := Router.Group("customer").Use(middleware.OperationRecord())
{
DataVipCommentRouter.GET("exportMsgExcel", mobile.ExportMsgExcel)
}
}
......@@ -10,6 +10,7 @@ func InitSurveyRouter(Router *gin.RouterGroup) {
DataVipCommentRouter := Router.Group("survey").Use(middleware.OperationRecord())
{
DataVipCommentRouter.POST("getSurveyUserList", mobile.GetSurveyUserList)
DataVipCommentRouter.POST("getSurveyLogList", mobile.GetSurveyLogList)
}
}
......@@ -18,6 +19,6 @@ func InitSurveyPublicRouter(Router *gin.RouterGroup) {
{
DataVipCommentRouter.POST("create", mobile.CreateSurveyUser)
DataVipCommentRouter.POST("createLog", mobile.CreateSurveyLog)
DataVipCommentRouter.GET("exportSurveyUserExcel", mobile.ExportSurveyUserExcel)
}
}
......@@ -10,13 +10,12 @@ import (
func InitMobileUserLoginRouter(Router *gin.RouterGroup) {
UserRouter := Router.Group("mobile")
{
UserRouter.POST("login", mobile.Login) // 用户注册账号
UserRouter.POST("register", mobile.Register) // 用户注册账号
UserRouter.POST("getOpenid", mobile.GetOpenid) // 用户注册账号
UserRouter.POST("getUserName", mobile.GetUserName) // 用户注册账号
UserRouter.POST("sendCode", mobile.SendCode) // 用户注册账号
UserRouter.POST("checkCode", mobile.CheckCode) // 用户注册账号
UserRouter.POST("msgData", mobile.MsgData) // 用户注册账号
UserRouter.POST("login", mobile.Login) // 用户注册账号
UserRouter.POST("register", mobile.Register) // 用户注册账号
UserRouter.POST("getOpenid", mobile.GetOpenid) // 用户注册账号
UserRouter.POST("sendCode", mobile.SendCode) // 用户注册账号
UserRouter.POST("checkCode", mobile.CheckCode) // 用户注册账号
UserRouter.POST("msgData", mobile.MsgData) // 用户注册账号
}
}
func InitMobileUserPublicRouter(Router *gin.RouterGroup) {
......
......@@ -11,7 +11,6 @@ func InitVipRouter(Router *gin.RouterGroup) {
DataVipCommentRouter := Router.Group("vip").Use(middleware.OperationRecord())
{
DataVipCommentRouter.POST("getVipList", mobile.GetVipList)
DataVipCommentRouter.POST("userVipInfo", mobile.UserVipInfo)
DataVipCommentRouter.POST("openVip", mobile.OpenVip)
}
}
......
package service
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/model/request"
"strconv"
)
func GetCustomerUserList(req request.GetCustomerUserListReq) (error, []request.GetCustomerUserList, int64) {
pagesize := 10
page := 1
if req.PageSize != 0 {
pagesize = req.PageSize
}
if req.Page != 0 {
page = req.Page
}
currentpage := pagesize * (page - 1)
list := make([]request.GetCustomerUserList, 0)
table := " customer_user"
field := " user_name, region, city, zone, address, contacts, contacts_mobile" +
", worker_position, worker_name, worker_mobile, user_source, user_type, create_time "
conditions := ""
orderby := " id asc "
if req.UserName != "" {
conditions += " AND user_name like '%" + req.UserName + "%'"
}
if req.Region != "" {
conditions += " AND region like '%" + req.Region + "%'"
}
if req.City != "" {
conditions += " AND city like '%" + req.City + "%'"
}
if req.Zone != "" {
conditions += " AND zone like '%" + req.Zone + "%'"
}
if req.WorkerName != "" {
conditions += " AND worker_name like '%" + req.WorkerName + "%'"
}
if req.WorkerMobile != "" {
conditions += " AND worker_mobile like '%" + req.WorkerMobile + "%'"
}
//@@总条数,总页数
var totalItem int64 = 0
sqlStr := "SELECT count(id) as totalItem FROM " + table + " where 1=1 " + conditions
global.GVA_DB.Raw(sqlStr).Count(&totalItem) //获取总条数
sqlStr2 := "SELECT " + field +
" FROM " + table +
" WHERE 1>0 " + conditions +
" ORDER BY " + orderby +
" LIMIT " + strconv.Itoa(currentpage) + "," + strconv.Itoa(pagesize)
global.GVA_DB.Raw(sqlStr2).Scan(&list)
if global.GVA_DB.Error != nil {
fmt.Println(sqlStr2)
return global.GVA_DB.Error, nil, 0
}
return nil, list, totalItem
}
......@@ -4,6 +4,7 @@ import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"strconv"
)
func CreateSurveyUser(req model.SurveyUser) (error, int) {
......@@ -21,48 +22,146 @@ func CreateSurveyLog(req model.SurveyLog) error {
return err
}
func IsSurveyLog(userId string) int {
var line int64
func GetSurveyUserList(req request.GetSurveyUserListReq) (error, []request.GetSurveyUserList, int64) {
pagesize := 10
page := 1
if req.PageSize != 0 {
pagesize = req.PageSize
}
if req.Page != 0 {
page = req.Page
}
currentpage := pagesize * (page - 1)
list := make([]request.GetSurveyUserList, 0)
table := " survey_user as sur " +
" left join customer_user as cu on sur.user_id=cu.id "
field := " sur.id, sur.user_id, sur.moc_id, sur.contacts, sur.contacts_mobile" +
", sur.reference, sur.reference_mobile, sur.create_time" +
", sur.country, sur.area, sur.region, sur.city" +
", cu.worker_name, cu.worker_mobile "
conditions := ""
sqlStr := "SELECT count(id) as line " +
" FROM report_evalute" +
" where report_main_orgin_id = ? AND delflag=0"
orderby := " sur.create_time desc "
global.GVA_DB.Raw(sqlStr, userId).Find(&line)
if global.GVA_DB.Error != nil || line > 0 {
return 1
if req.MocId != 0 {
conditions += " AND sur.moc_id = " + strconv.Itoa(currentpage)
}
return 2
}
func UpdateSurveyLog(req model.SurveyLog, orginId string) error {
err := global.GVA_DB.Table("report_evalute").Where("report_main_orgin_id=?", orginId).Updates(&req).Error
return err
if req.Region != "" {
conditions += " AND region like '%" + req.Region + "%'"
}
if req.City != "" {
conditions += " AND city like '%" + req.City + "%'"
}
if req.Contacts != "" {
conditions += " AND contacts like '%" + req.Contacts + "%'"
}
if req.ContactsMobile != "" {
conditions += " AND contacts_mobile like '%" + req.ContactsMobile + "%'"
}
if req.Reference != "" {
conditions += " AND reference like '%" + req.Reference + "%'"
}
if req.ReferenceMobile != "" {
conditions += " AND reference_mobile like '%" + req.ReferenceMobile + "%'"
}
if req.StartCreateTime != "" {
conditions += " AND sur.create_time >'" + req.StartCreateTime + "'"
}
if req.EndCreateTime != "" {
conditions += " AND sur.create_time <='" + req.EndCreateTime + "'"
}
//@@总条数,总页数
var totalItem int64 = 0
sqlStr := "SELECT count(vo.id) as totalItem FROM " + table + " where 1=1 " + conditions
global.GVA_DB.Raw(sqlStr).Count(&totalItem) //获取总条数
sqlStr2 := "SELECT " + field +
" FROM " + table +
" WHERE 1>0 " + conditions +
" ORDER BY " + orderby +
" LIMIT " + strconv.Itoa(currentpage) + "," + strconv.Itoa(pagesize)
global.GVA_DB.Raw(sqlStr2).Scan(&list)
if global.GVA_DB.Error != nil {
return global.GVA_DB.Error, nil, 0
}
return nil, list, totalItem
}
func GetSurveyUserList(req request.GetSurveyUserListReq) (error, []model.SurveyUser) {
bannerList := make([]model.SurveyUser, 0)
func GetSurveyLogList(req request.GetSurveyLogListReq) (error, []request.GetSurveyLogList, int64) {
pagesize := 10
page := 1
if req.PageSize != 0 {
pagesize = req.PageSize
}
if req.Page != 0 {
page = req.Page
}
currentpage := pagesize * (page - 1)
list := make([]request.GetSurveyLogList, 0)
table := " survey_log as sl " +
" left join customer_user as cu on sur.user_id=cu.id "
field := " sur.id, sur.user_id, sur.moc_id, sur.contacts, sur.contacts_mobile" +
", sur.reference, sur.reference_mobile, sur.create_time" +
", sur.country, sur.area, sur.region, sur.city" +
", cu.worker_name, cu.worker_mobile "
field := " sur.id, sur.contacts, sur.contacts_mobile, sur.create_time, su.mobile, su.nick_name "
conditions := ""
table := " survey_user as sur left join sys_users as su on sur.user_id = su.id "
orderby := " sur.create_time desc "
conditions := " "
if req.MocId != 0 {
conditions += " AND sur.moc_id = " + strconv.Itoa(currentpage)
}
if req.Region != "" {
conditions += " AND region like '%" + req.Region + "%'"
}
if req.Mobile != "" {
conditions += " AND su.mobile = " + req.Mobile
if req.City != "" {
conditions += " AND city like '%" + req.City + "%'"
}
orderby := " sur.id desc "
if req.StartCreateTime != "" {
conditions += " AND sur.create_time >'" + req.StartCreateTime + "'"
}
if req.EndCreateTime != "" {
conditions += " AND sur.create_time <='" + req.EndCreateTime + "'"
}
//@@总条数,总页数
var totalItem int64 = 0
sqlStr := "SELECT count(vo.id) as totalItem FROM " + table + " where 1=1 " + conditions
global.GVA_DB.Raw(sqlStr).Count(&totalItem) //获取总条数
sqlStr := "SELECT " + field +
sqlStr2 := "SELECT " + field +
" FROM " + table +
" WHERE 1>0 " + conditions +
" ORDER BY " + orderby
" ORDER BY " + orderby +
" LIMIT " + strconv.Itoa(currentpage) + "," + strconv.Itoa(pagesize)
global.GVA_DB.Raw(sqlStr).Scan(&bannerList)
global.GVA_DB.Raw(sqlStr2).Scan(&list)
if global.GVA_DB.Error != nil {
return global.GVA_DB.Error, nil
return global.GVA_DB.Error, nil, 0
}
return nil, bannerList
return nil, list, totalItem
}
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