123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658 |
- package members
-
- import (
- base_ctl "SCRM/controllers"
- "SCRM/enums"
- "SCRM/models"
- "SCRM/service/member_service"
- "SCRM/utils"
- "encoding/json"
- "fmt"
- "reflect"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func MemberCtlRegistRouters() {
- beego.Router("/api/members", &MembersAPIController{}, "get:GetMembers")
- beego.Router("/api/members/all", &MembersAPIController{}, "get:GetAllMembers")
- beego.Router("/api/member/create", &MembersAPIController{}, "Post:CreateMember")
- beego.Router("/api/member/edit", &MembersAPIController{}, "Put:EditMember")
- beego.Router("/api/members/delete", &MembersAPIController{}, "Delete:DeleteMembers")
- }
-
- type MembersAPIController struct {
- base_ctl.BaseAuthAPIController
- }
-
- func (c *MembersAPIController) GetMembers() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- searchKey := c.GetString("search", "")
- level, _ := c.GetInt64("level", 0)
- source, _ := c.GetInt64("source", 0)
- tag, _ := c.GetInt64("tag", 0)
- init, _ := c.GetInt64("init", 0)
- fmt.Println("level", level, "source", source)
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02 15:04:05"
-
- var isStartTime bool
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := utils.ParseTimeStringToTime(timeLayout, startTime+" 00:00:00")
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "开始时间错误")
- return
- }
- isStartTime = true
- theStartTIme = theTime.Unix()
- }
- var isEndTime bool
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := utils.ParseTimeStringToTime(timeLayout, endTime+" 23:59:59")
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "结束时间错误")
- return
- }
- isEndTime = true
- theEndtTIme = theTime.Unix()
- }
-
- members, total, err := member_service.GetMemberList(adminUserInfo.CurrentOrgId, page, limit, level, source, tag, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
-
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "获取会员列表失败")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- if init == 1 {
- cards, err := member_service.GetCardList(adminUserInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "获取会员卡列表失败")
- return
- }
- returnData["cards"] = cards
-
- tags, err := member_service.GetTagList(adminUserInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "获取标签列表失败")
- return
- }
- returnData["tags"] = tags
-
- illness, err := member_service.GetIllnessList()
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "获取病种列表失败")
- return
- }
- returnData["illness"] = illness
- }
- returnData["members"] = members
- returnData["total"] = total
-
- c.ServeSuccessJSON(returnData)
- return
- }
-
- func (c *MembersAPIController) GetAllMembers() {
-
- adminUserInfo := c.GetAdminUserInfo()
- members, err := member_service.GetAllMemberList(adminUserInfo.CurrentOrgId)
- fmt.Println("members是什么",members)
- fmt.Println("资讯管理错误是什么",err)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "获取列表失败")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["members"] = members
-
- c.ServeSuccessJSON(returnData)
- return
- }
-
- func (c *MembersAPIController) CreateMember() {
-
- adminUserInfo := c.GetAdminUserInfo()
- timeNow := time.Now().Unix()
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- var member member_service.Members
-
- if dataBody["name"] == nil || reflect.TypeOf(dataBody["name"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:姓名")
- return
- }
- name, _ := dataBody["name"].(string)
- if len(name) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
- return
- }
- member.Name = name
-
- if dataBody["mobile"] == nil || reflect.TypeOf(dataBody["mobile"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:手机号")
- return
- }
- mobile, _ := dataBody["mobile"].(string)
- if len(mobile) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "手机号不能为空")
- return
- }
- if !utils.CheckMobile(mobile) {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "手机号格式不正确")
- return
- }
- member.Mobile = mobile
-
- if dataBody["gender"] == nil || reflect.TypeOf(dataBody["gender"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:性别")
- return
- }
- gender := int64(dataBody["gender"].(float64))
-
- if gender != 1 && gender != 2 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "性别选择不正确")
- return
- }
- member.Gender = gender
-
- if dataBody["birthday"] == nil || reflect.TypeOf(dataBody["birthday"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:生日")
- return
- }
- birthday, _ := dataBody["birthday"].(string)
- if len(birthday) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
- return
- }
-
- timeLayout := "2006-01-02 15:04:05"
- theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
- return
- }
- member.Birthday = theTime.Unix()
-
- if dataBody["province_id"] == nil || reflect.TypeOf(dataBody["province_id"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:地区(省)")
- return
- }
- provinceID := int64(dataBody["province_id"].(float64))
- if provinceID <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择地区")
- return
- }
- member.ProvinceId = provinceID
-
- if dataBody["city_id"] == nil || reflect.TypeOf(dataBody["city_id"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:地区(市)")
- return
- }
- cityID := int64(dataBody["city_id"].(float64))
- if cityID <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择地区")
- return
- }
- member.CityId = cityID
-
- if dataBody["district_id"] == nil || reflect.TypeOf(dataBody["district_id"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:地区(区/县)")
- return
- }
- districtID := int64(dataBody["district_id"].(float64))
- if districtID <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择地区")
- return
- }
- member.DistrictId = districtID
-
- if dataBody["illness"] == nil || reflect.TypeOf(dataBody["illness"]).String() != "[]interface {}" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:病种")
- return
- }
- illnessInters := dataBody["illness"].([]interface{})
- if len(illnessInters) <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择病种")
- return
- }
- member.Illness = make([]*member_service.CustomerIllness, 0)
- for _, illnessInter := range illnessInters {
- id := int64(illnessInter.(float64))
- var illItem member_service.CustomerIllness
- illItem.UserOrgId = adminUserInfo.CurrentOrgId
- illItem.IllnessId = id
- illItem.Status = 1
- illItem.UpdatedTime = timeNow
- illItem.CreatedTime = timeNow
- member.Illness = append(member.Illness, &illItem)
- }
-
- if dataBody["ill_date"] == nil || reflect.TypeOf(dataBody["ill_date"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:患病时间")
- return
- }
- illDate, _ := dataBody["ill_date"].(string)
- if len(illDate) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患病时间格式不正确")
- return
- }
-
- illDateTime, err := utils.ParseTimeStringToTime(timeLayout, illDate+" 00:00:00")
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患病时间格式不正确")
- return
- }
- member.IllDate = illDateTime.Unix()
-
- if dataBody["treat_type"] == nil || reflect.TypeOf(dataBody["treat_type"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:治疗方式")
- return
- }
- treatType := int64(dataBody["treat_type"].(float64))
- if treatType <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择治疗方式")
- return
- }
- member.TreatType = treatType
-
- if dataBody["tags"] != nil && reflect.TypeOf(dataBody["tags"]).String() == "[]interface {}" {
- tagsInters := dataBody["tags"].([]interface{})
- if len(tagsInters) > 0 {
- member.UserTags = make([]*models.UserTagLinks, 0)
- for _, tagsInter := range tagsInters {
- id := int64(tagsInter.(float64))
- var tagItem models.UserTagLinks
- tagItem.TagId = id
- tagItem.UserOrgId = adminUserInfo.CurrentOrgId
- tagItem.Status = 1
- tagItem.UpdatedTime = timeNow
- tagItem.CreatedTime = timeNow
- member.UserTags = append(member.UserTags, &tagItem)
- }
- }
- }
-
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark, _ := dataBody["remark"].(string)
- if len(remark) > 0 {
- member.Remark = remark
- }
- }
-
- if dataBody["avatar"] != nil && reflect.TypeOf(dataBody["avatar"]).String() == "string" {
- avatar, _ := dataBody["avatar"].(string)
- if len(avatar) > 0 {
- member.Avatar = avatar
- }
- }
-
- customer, err := member_service.GetCustomerByMobile(adminUserInfo.CurrentOrgId, member.Mobile)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加会员失败:("+err.Error()+")")
- return
- }
- if customer != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加会员失败:(已经存在该手机号的客户)")
- return
- }
-
- member.UserOrgId = adminUserInfo.CurrentOrgId
- member.Status = 1
- member.CreatedTime = timeNow
- member.UpdatedTime = timeNow
- member.Sources = 7
-
- user, err := member_service.GetUserByMobile(member.Mobile)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加会员失败:("+err.Error()+")")
- return
- }
- if user != nil {
- member.UserId = user.ID
- err = member_service.CreateMember(&member)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加会员失败:("+err.Error()+")")
- return
- }
- } else {
- var userData models.User
- userData.Avatar = member.Avatar
- userData.AvatarThumb = member.Avatar
- userData.Username = member.Name
- userData.Remarkname = member.Name
- userData.Mobile = member.Mobile
- userData.Gender = member.Gender
- userData.ProvinceId = member.ProvinceId
- userData.CityId = member.CityId
- userData.Address = member.Address
- userData.Birthday = member.Birthday
- userData.TreatType = member.TreatType
- userData.Relationship = member.Relationship
- userData.IllnessId = member.Illness[0].IllnessId
- userData.Sources = member.Sources
- userData.Status = 1
- userData.CreatedTime = timeNow
- userData.UpdatedTime = timeNow
-
- err = member_service.CreateMemberWithUser(&member, &userData)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加会员失败:("+err.Error()+")")
- return
- }
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["member"] = member
- c.ServeSuccessJSON(returnData)
- return
-
- }
-
- func (c *MembersAPIController) EditMember() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误:id")
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
-
- member, err := member_service.GetOnlyMemberByID(adminUserInfo.CurrentOrgId, id)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
- return
- }
- if member == nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:(会员记录不存在)")
- return
- }
-
- timeNow := time.Now().Unix()
-
- dataBody := make(map[string]interface{}, 0)
- err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- if dataBody["name"] == nil || reflect.TypeOf(dataBody["name"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:姓名")
- return
- }
- name, _ := dataBody["name"].(string)
- if len(name) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
- return
- }
- member.Name = name
-
- if dataBody["mobile"] == nil || reflect.TypeOf(dataBody["mobile"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:手机号")
- return
- }
- mobile, _ := dataBody["mobile"].(string)
- if len(mobile) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "手机号不能为空")
- return
- }
- if !utils.CheckMobile(mobile) {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "手机号格式不正确")
- return
- }
- changeMobile := true
- if member.Mobile == mobile {
- changeMobile = false
- }
- member.Mobile = mobile
-
- if dataBody["gender"] == nil || reflect.TypeOf(dataBody["gender"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:性别")
- return
- }
- gender := int64(dataBody["gender"].(float64))
-
- if gender != 1 && gender != 2 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "性别选择不正确")
- return
- }
- member.Gender = gender
-
- if dataBody["birthday"] == nil || reflect.TypeOf(dataBody["birthday"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:生日")
- return
- }
- birthday, _ := dataBody["birthday"].(string)
- if len(birthday) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
- return
- }
-
- timeLayout := "2006-01-02 15:04:05"
- theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
- return
- }
- member.Birthday = theTime.Unix()
-
- if dataBody["province_id"] == nil || reflect.TypeOf(dataBody["province_id"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:地区(省)")
- return
- }
- provinceID := int64(dataBody["province_id"].(float64))
- if provinceID <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择地区")
- return
- }
- member.ProvinceId = provinceID
-
- if dataBody["city_id"] == nil || reflect.TypeOf(dataBody["city_id"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:地区(市)")
- return
- }
- cityID := int64(dataBody["city_id"].(float64))
- if cityID <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择地区")
- return
- }
- member.CityId = cityID
-
- if dataBody["district_id"] == nil || reflect.TypeOf(dataBody["district_id"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:地区(区/县)")
- return
- }
- districtID := int64(dataBody["district_id"].(float64))
- if districtID <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择地区")
- return
- }
- member.DistrictId = districtID
-
- if dataBody["illness"] == nil || reflect.TypeOf(dataBody["illness"]).String() != "[]interface {}" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:病种")
- return
- }
- illnessInters := dataBody["illness"].([]interface{})
- if len(illnessInters) <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择病种")
- return
- }
- member.Illness = make([]*member_service.CustomerIllness, 0)
- illnessIDS := make([]int64, 0)
- illnessIDMap := make(map[int64]int64, 0)
- for _, illnessInter := range illnessInters {
- id := int64(illnessInter.(float64))
- illnessIDS = append(illnessIDS, id)
- illnessIDMap[id] = id
- }
- allIllness, err := member_service.GetMemberAllIllness(adminUserInfo.CurrentOrgId, member.ID)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
- return
- }
- oldIllIDMap := make(map[int64]int64, 0)
- for _, illItem := range allIllness {
- item := *illItem
- item.Status = 1
- if _, exist := illnessIDMap[item.IllnessId]; !exist {
- item.Status = 0
- item.UpdatedTime = timeNow
- }
- member.Illness = append(member.Illness, &item)
- oldIllIDMap[item.IllnessId] = item.IllnessId
- }
-
- for _, id := range illnessIDMap {
- if _, exist := oldIllIDMap[id]; exist {
- continue
- }
- var illItem member_service.CustomerIllness
- illItem.UserOrgId = adminUserInfo.CurrentOrgId
- illItem.IllnessId = id
- illItem.Status = 1
- illItem.UpdatedTime = timeNow
- illItem.CreatedTime = timeNow
- member.Illness = append(member.Illness, &illItem)
- }
-
- if dataBody["ill_date"] == nil || reflect.TypeOf(dataBody["ill_date"]).String() != "string" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:患病时间")
- return
- }
- illDate, _ := dataBody["ill_date"].(string)
- if len(illDate) == 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患病时间格式不正确")
- return
- }
-
- illDateTime, err := utils.ParseTimeStringToTime(timeLayout, illDate+" 00:00:00")
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患病时间格式不正确")
- return
- }
- member.IllDate = illDateTime.Unix()
-
- if dataBody["treat_type"] == nil || reflect.TypeOf(dataBody["treat_type"]).String() != "float64" {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:治疗方式")
- return
- }
- treatType := int64(dataBody["treat_type"].(float64))
- if treatType <= 0 {
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "请选择治疗方式")
- return
- }
- member.TreatType = treatType
-
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark, _ := dataBody["remark"].(string)
- if len(remark) > 0 {
- member.Remark = remark
- }
- }
-
- if dataBody["avatar"] != nil && reflect.TypeOf(dataBody["avatar"]).String() == "string" {
- avatar, _ := dataBody["avatar"].(string)
- if len(avatar) > 0 {
- member.Avatar = avatar
- }
- }
-
- if changeMobile {
- customer, err := member_service.GetCustomerByMobile(adminUserInfo.CurrentOrgId, member.Mobile)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
- return
- }
- if customer != nil && customer.ID != member.ID {
- c.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:(已经存在该手机号的客户)")
- return
- }
- }
- member.UpdatedTime = timeNow
-
- err = member_service.EditMember(member)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
- return
- }
-
- illness := member.Illness
- member.Illness = make([]*member_service.CustomerIllness, 0)
- for _, ill := range illness {
- illItem := *ill
- if illItem.Status == 0 {
- continue
- }
- member.Illness = append(member.Illness, &illItem)
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["member"] = member
- c.ServeSuccessJSON(returnData)
- return
-
- }
-
- func (c *MembersAPIController) DeleteMembers() {
- adminUserInfo := c.GetAdminUserInfo()
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- idsInters := dataBody["ids"].([]interface{})
- if len(idsInters) == 0 {
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
- return
- }
- }
-
- ids := make([]int64, 0)
- for _, idsInter := range idsInters {
- id := int64(idsInter.(float64))
- ids = append(ids, id)
- }
-
- err = member_service.DeleteMembers(adminUserInfo.CurrentOrgId, ids)
- if err != nil {
- c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:("+err.Error()+")")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
-
- c.ServeSuccessJSON(returnData)
- return
- }
|