|
@@ -1,6 +1,7 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
//"hongze/hongze_admin/models"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"time"
|
|
@@ -50,7 +51,7 @@ func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取某一用户的报名的数量
|
|
|
+// 获取某一用户的报名的数量
|
|
|
func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error) {
|
|
|
sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip WHERE user_id=? AND activity_id =? `
|
|
|
o := orm.NewOrm()
|
|
@@ -58,7 +59,7 @@ func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取某一活动的报名的数量
|
|
|
+// 获取某一活动的报名的数量
|
|
|
func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{}) (count int, err error) {
|
|
|
sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip as t INNER JOIN wx_user as u on u.user_id = t.user_id WHERE 1 = 1 ` + condition
|
|
|
o := orm.NewOrm()
|
|
@@ -66,7 +67,7 @@ func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取某一活动的报名的数量 (同时关联活动类型进行获取)
|
|
|
+// 获取某一活动的报名的数量 (同时关联活动类型进行获取)
|
|
|
func GetActivitySpecialTripCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
|
|
|
sqlCount := ` SELECT COUNT(1) AS count
|
|
|
FROM
|
|
@@ -79,7 +80,7 @@ func GetActivitySpecialTripCountByActivitySpecial(condition string, pars []inter
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取空降的公司报名的记录
|
|
|
+// 获取空降的公司报名的记录
|
|
|
func GetActivitySpecialTripAirborneCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
|
|
|
sqlCount := ` SELECT COUNT(1) AS count
|
|
|
FROM
|
|
@@ -92,14 +93,58 @@ func GetActivitySpecialTripAirborneCountByActivitySpecial(condition string, pars
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//添加
|
|
|
+// 添加
|
|
|
func AddCygxActivitySpecialTrip(item *CygxActivitySpecialTrip) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
+ o, err := orm.NewOrm().Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ fmt.Println(err)
|
|
|
+ if err == nil {
|
|
|
+ o.Commit()
|
|
|
+ } else {
|
|
|
+ o.Rollback()
|
|
|
+ }
|
|
|
+ }()
|
|
|
_, err = o.Insert(item)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //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:"公司名称"`
|
|
|
+ //RealName string `description:"用户实际名称"`
|
|
|
+ //AdminId int `description:"销售/管理员ID"`
|
|
|
+ //Source int `description:"来源,1小程序,2后台添加, 3开发人员手动添加"`
|
|
|
+ //BillDetailed int `description:"流水明细,判断是进账还是出账"`
|
|
|
+ //IsValid int `description:"参会报名是否有效 1:是,0"`
|
|
|
+ //RegisterPlatform int `description:"来源 1小程序,2:网页"`
|
|
|
+ //ChartPermissionId int `description:"行业id"`
|
|
|
+
|
|
|
+ itemLog := new(CygxActivitySpecialTripBill)
|
|
|
+ itemLog.UserId = item.UserId
|
|
|
+ itemLog.ActivityId = item.ActivityId
|
|
|
+ itemLog.CreateTime = time.Now()
|
|
|
+ itemLog.Mobile = item.Mobile
|
|
|
+ itemLog.Email = item.Email
|
|
|
+ itemLog.CompanyId = item.CompanyId
|
|
|
+ itemLog.CompanyName = item.CompanyName
|
|
|
+ itemLog.Type = 1
|
|
|
+ _, err = o.Insert(itemLog)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//取消
|
|
|
+// 取消
|
|
|
func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `DELETE FROM cygx_activity_special_trip WHERE user_id=? AND activity_id=? `
|
|
@@ -107,7 +152,7 @@ func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err er
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//CancelActivitySpecialTripIsValid 处理活动报名是否有效
|
|
|
+// CancelActivitySpecialTripIsValid 处理活动报名是否有效
|
|
|
func CancelActivitySpecialTripIsValid(isValid, activityId, userId int) (err error) {
|
|
|
sql := ` UPDATE cygx_activity_special_trip SET is_valid= ?,is_cancel = 1 WHERE activity_id = ? AND user_id = ? `
|
|
|
o := orm.NewOrm()
|