123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- package cygx
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxActivitySpecialMeetingDetail struct {
- Id int `orm:"column(id);pk"`
- UserId int `description:"用户id"`
- ActivityId int `description:"活动ID"`
- CreateTime time.Time `description:"创建时间"`
- Mobile string `description:"手机号"`
- Email string `description:"邮箱号"`
- CompanyId int `description:"公司ID"`
- CompanyName string `description:"公司名称"`
- IsMeeting int `description:"是否到会 1.是 ,0否"`
- IsAirborne int `description:"是否属于空降 1.是 ,0否"`
- RealName string `description:"真实姓名"`
- }
- type CygxActivitySpecialMeetingDetailResp struct {
- Id int `description:"id"`
- UserId int `description:"用户id"`
- ActivityId int `description:"活动ID"`
- CreateTime string `description:"创建时间"`
- RealName string `description:"姓名"`
- Email string `description:"邮箱号"`
- CompanyId int `description:"公司ID"`
- CompanyName string `description:"公司名称"`
- IsMeeting int `description:"到会类型 1.是 ,0否 ,2空降"`
- IsAirborne int `description:"是否属于空降 1.是 ,0否"`
- Operation bool `description:"操作按钮,true,到会,false 未到会"`
- }
- type SpecialMeetingDetailRespList struct {
- List []*CygxActivitySpecialMeetingDetailResp
- }
- type MeetingSpeciaDoRep struct {
- UserIds string `description:"用户ID,多个ID用 , 隔开"`
- ActivityId int `description:"活动ID"`
- }
- // 列表
- func GetCygxActivitySpecialMeetingDetailListByActivity(activityId int) (items []*CygxActivitySpecialMeetingDetailResp, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT s.*
- FROM cygx_activity_special_meeting_detail as s
- WHERE 1 =1 AND s.activity_id =? `
- _, err = o.Raw(sql, activityId).QueryRows(&items)
- return
- }
- // 到会操作
- func MeetingDopecialMeet(meetingUids, noMeetingUids string, ActivityId int, items []*CygxActivitySpecialMeetingDetail, itemsBill []*CygxActivitySpecialTripBill) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- fmt.Println(err)
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- fmt.Println("ActivityId", ActivityId)
- //修改报名表的参会记录
- sql := `UPDATE cygx_activity_special_trip SET is_meeting = 0 WHERE activity_id =? `
- _, err = to.Raw(sql, ActivityId).Exec()
- if err != nil {
- return
- }
- sql = `UPDATE cygx_activity_special_trip SET is_meeting = 1 WHERE activity_id =? AND is_cancel = 0 AND user_id IN (` + meetingUids + `)`
- _, err = to.Raw(sql, ActivityId).Exec()
- if err != nil {
- return
- }
- sql = `UPDATE cygx_activity_special SET is_submit_meeting = 1 WHERE activity_id = ? `
- _, err = to.Raw(sql, ActivityId).Exec()
- if err != nil {
- return
- }
- //删除老的记录并插入新的记录
- sql = `DELETE FROM cygx_activity_special_meeting_detail WHERE activity_id = ? `
- _, err = to.Raw(sql, ActivityId).Exec()
- if err != nil {
- return
- }
- for _, v := range items {
- _, err = to.Insert(v)
- if err != nil {
- return
- }
- }
- if len(noMeetingUids) > 0 {
- sql = `UPDATE cygx_activity_special_meeting_detail SET is_meeting = 0 WHERE activity_id =? AND user_id IN (` + noMeetingUids + `)`
- _, err = to.Raw(sql, ActivityId).Exec()
- if err != nil {
- return
- }
- }
- //添加记录表的到会信息
- sql = `UPDATE cygx_activity_special_meeting_detail SET is_meeting = 1 WHERE activity_id =? AND user_id IN (` + meetingUids + `)`
- _, err = to.Raw(sql, ActivityId).Exec()
- if err != nil {
- return
- }
- //添加到会扣点流水记录
- if len(itemsBill) > 0 {
- for _, v := range itemsBill {
- _, err = to.Insert(v)
- if err != nil {
- return
- }
- }
- }
- return
- }
- // 列表
- func GetCygxActivitySpecialMeetingDetailList(condition string, pars []interface{}) (items []*CygxActivitySpecialMeetingDetail, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT s.*
- FROM cygx_activity_special_meeting_detail as s WHERE 1 =1 ` + condition
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- func GetCygxActivitySpecialMeetingDetailListByActivityId(activityId int) (item []*CygxActivitySpecialMeetingDetail, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT *
- FROM
- cygx_activity_special_trip
- WHERE activity_id = ? AND is_cancel = 0 `
- _, err = o.Raw(sql, activityId).QueryRows(&item)
- return
- }
- // 列表
- func UpdateCygxActivitySpecialMeetingDetailRealName(realName, mobile string) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- //添加记录表的到会信息
- sql := `UPDATE cygx_activity_special_meeting_detail SET real_name = ? WHERE mobile = ? `
- _, err = o.Raw(sql, realName, mobile).Exec()
- return
- }
- // 添加
- func AddCygxActivitySpecialMeetingDetail(item *CygxActivitySpecialMeetingDetail) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- _, err = o.Insert(item)
- return
- }
|