胡轶钦 6 years ago
parent
commit
3b96ce72f6

+ 1
- 1
controllers/bodycheck/bodycheck.go View File

@@ -49,7 +49,7 @@ func (c *BodyCheckController) GetQrcodeURL() {
49 49
 				"Message": "获取二维码失败: " + err.Error(),
50 50
 			})
51 51
 		}
52
-		qrCodes[qrcodePrefix+EquipmentID] = qrcode
52
+		// qrCodes[qrcodePrefix+EquipmentID] = qrcode
53 53
 	}
54 54
 
55 55
 	c.ResponseOtherEndPoint(map[string]interface{}{

+ 227
- 0
controllers/calendar/calendar.go View File

@@ -0,0 +1,227 @@
1
+package calendar
2
+
3
+import (
4
+	"encoding/json"
5
+	"errors"
6
+	"spaceofcheng/services/controllers"
7
+	"spaceofcheng/services/models"
8
+	"spaceofcheng/services/models/model"
9
+	"spaceofcheng/services/service/calendar"
10
+	"spaceofcheng/services/utils"
11
+	"strings"
12
+
13
+	"github.com/astaxie/beego"
14
+)
15
+
16
+// CaseController 信息
17
+type CalendarController struct {
18
+	dao *calendar.CalendarServ
19
+	controllers.BaseController
20
+}
21
+
22
+// Constructor 初始化 Controller
23
+// @Title Constructor
24
+// @Description 初始化 Controller, 系统自动调用
25
+func (c *CalendarController) Constructor() {
26
+	c.dao = calendar.NewCalendarServ(c.Context)
27
+}
28
+
29
+type CalendarImg struct {
30
+	CalendarImg string
31
+	CustomerImg string
32
+	ImgName     string
33
+	Sort        int
34
+}
35
+type Calendar struct {
36
+	ModelName string
37
+	Email     string
38
+	CaseId    string
39
+	Imgs      []CalendarImg
40
+}
41
+
42
+func (c *CalendarController) GetCalendarList() {
43
+	caseIDs := c.GetString("caseid")
44
+	if caseIDs == "" {
45
+		cases := c.Context.Get("cases").([]model.SysUserCase)
46
+		caseIDs = c.GetCaseIDs(cases)
47
+	}
48
+	name := c.GetString("name")
49
+	phone := c.GetString("phone")
50
+	makeStatus := c.GetString("makeStatus")
51
+	page, _ := c.GetInt("page")
52
+	pageSize, _ := c.GetInt("pagesize")
53
+	list, err := c.dao.GetCalendarList(caseIDs, name, phone, makeStatus, page, pageSize)
54
+	if err != nil {
55
+		c.ResponseError(err)
56
+	}
57
+	c.ResponseJSON(list)
58
+}
59
+
60
+func (c *CalendarController) ChangeMakeStaus() {
61
+	calendarIds := c.GetString(":calendarIds")
62
+	calendar := strings.Split(calendarIds, ",")
63
+	beego.Error(calendar)
64
+	for i := 0; i < len(calendar); i++ {
65
+		err := c.dao.ChangeMakeStaus(calendar[i])
66
+		if err != nil {
67
+			c.ResponseError(err)
68
+		}
69
+	}
70
+	c.ResponseJSON("修改成功")
71
+}
72
+
73
+func (c *CalendarController) DownloadImg() {
74
+	calendarId := c.GetString(":calendarId")
75
+	imgType := c.GetString(":imgType")
76
+	list, err := c.dao.GetCalendarImgs(calendarId)
77
+	if err != nil {
78
+		c.ResponseError(err)
79
+	}
80
+	var files []utils.NetFile
81
+	var zf string
82
+	if imgType == "user" {
83
+		for i := 0; i < len(list); i++ {
84
+			if list[i].CustomerImg != "" {
85
+				var file = utils.NetFile{
86
+					URI:  list[i].CustomerImg,
87
+					Name: list[i].ImgName + ".jpeg",
88
+				}
89
+				files = append(files, file)
90
+			}
91
+
92
+		}
93
+		zf = "客户照片.zip"
94
+	} else {
95
+		for i := 0; i < len(list); i++ {
96
+			if list[i].CalendarImg != "" {
97
+				var file = utils.NetFile{
98
+					URI:  list[i].CalendarImg,
99
+					Name: list[i].ImgName + ".jpeg",
100
+				}
101
+				files = append(files, file)
102
+			}
103
+
104
+		}
105
+		zf = "电子台历.zip"
106
+	}
107
+	c.SaveNetFilesToZip(files, zf)
108
+}
109
+func (c *CalendarController) GetCalendarListFront() {
110
+	cust := c.Context.Get("customer").(model.TaCustomer)
111
+	page, _ := c.GetInt("page")
112
+	pageSize, _ := c.GetInt("pagesize")
113
+	list, err := c.dao.GetCalendarListFront(cust.CustomerId, page, pageSize)
114
+	if err != nil {
115
+		c.ResponseError(err)
116
+	}
117
+	c.ResponseJSON(list)
118
+}
119
+
120
+func (c *CalendarController) GetCalendarListExcel() {
121
+	caseIDs := c.GetString("caseid")
122
+	if caseIDs == "" {
123
+		cases := c.Context.Get("cases").([]model.SysUserCase)
124
+		caseIDs = c.GetCaseIDs(cases)
125
+	}
126
+	name := c.GetString("name")
127
+	phone := c.GetString("phone")
128
+	list, err := c.dao.GetCalendarListExcel(caseIDs, name, phone)
129
+	if err != nil {
130
+		c.ResponseError(err)
131
+	}
132
+	excel, err := utils.NewTinyXLSXEngine()
133
+	if err != nil {
134
+		utils.LogError("初始化Excel服务失败: " + err.Error())
135
+		c.ResponseError(errors.New("初始化Excel服务失败"))
136
+	}
137
+	excel.SetCell(excel.InsertRow(), []string{
138
+		"模板",
139
+		"姓名",
140
+		"昵称",
141
+		"手机号",
142
+		"邮箱",
143
+		"定制时间",
144
+		"状态",
145
+	})
146
+	for _, item := range list {
147
+		row := excel.InsertRow()
148
+		makeStatus := ""
149
+		switch item.MakeStatus {
150
+		case models.CALENDAR_MAKING:
151
+			makeStatus = "制作中"
152
+			break
153
+		case models.CALENDAR_FINISH:
154
+			makeStatus = "制作完成"
155
+			break
156
+		}
157
+		excel.SetCell(row, []string{
158
+			item.ModelName,
159
+			item.Name,
160
+			item.CustomerName,
161
+			item.Phone,
162
+			item.Email,
163
+			item.CreateDate.Format("2006-01-02 03:04:05 PM"),
164
+			makeStatus,
165
+		})
166
+	}
167
+	c.SaveToExcel("日历定制记录.xlsx", excel)
168
+}
169
+func (c *CalendarController) GetCalendarFrontDetailById() {
170
+	calendarId := c.GetString(":calendarId")
171
+	detail, err := c.dao.GetCalendarFrontDetailById(calendarId)
172
+	if err != nil {
173
+		c.ResponseError(err)
174
+	}
175
+	c.ResponseJSON(detail)
176
+}
177
+
178
+func (c *CalendarController) AddCalendar() {
179
+	cust := c.Context.Get("customer").(model.TaCustomer)
180
+	org := c.Context.Get("org").(model.SysOrg)
181
+	calendarJson := c.GetString("Calendar")
182
+	calendar := Calendar{}
183
+	err := json.Unmarshal([]byte(calendarJson), &calendar)
184
+	if err != nil {
185
+		c.ResponseError(err)
186
+	}
187
+	utils.LogInfo("↓↓↓↓_________________________↓↓↓↓parse calendar↓↓↓↓___________________↓↓↓↓")
188
+	utils.LogInfo(calendar)
189
+	receicveCalendar := model.TaCustomerCalendar{
190
+		CaseId:    calendar.CaseId,
191
+		ModelName: calendar.ModelName,
192
+		Email:     calendar.Email,
193
+	}
194
+	receiveImgs := calendar.Imgs
195
+	receicveCalendar.CustomerId = cust.CustomerId
196
+	receicveCalendar.OrgId = org.OrgId
197
+	customerCalendar, err := c.dao.AddCalendar(receicveCalendar)
198
+	if err != nil {
199
+		c.ResponseError(err)
200
+	}
201
+	var calendarImgs []model.TaCalendarImg
202
+	for i := 0; i < len(receiveImgs); i++ {
203
+		var calendarImg = model.TaCalendarImg{
204
+			CalendarImg: receiveImgs[i].CalendarImg,
205
+			CustomerImg: receiveImgs[i].CustomerImg,
206
+			ImgName:     receiveImgs[i].ImgName,
207
+			Sort:        receiveImgs[i].Sort,
208
+		}
209
+		calendarImgs = append(calendarImgs, calendarImg)
210
+	}
211
+	utils.LogInfo("↓↓↓↓_________________________↓↓↓↓calendar imgs↓↓↓↓___________________↓↓↓↓")
212
+	utils.LogInfo(calendarImgs)
213
+	err = c.dao.AddCalendarImg(calendarImgs, customerCalendar.CustomerCalendarId)
214
+	if err != nil {
215
+		c.ResponseError(err)
216
+	}
217
+	c.ResponseJSON("添加成功")
218
+
219
+}
220
+func (c *CalendarController) IsCustomerAttend() {
221
+	cust := c.Context.Get("customer").(model.TaCustomer)
222
+	flag, err := c.dao.IsCustomerAttend(cust.CustomerId)
223
+	if err != nil {
224
+		c.ResponseError(err)
225
+	}
226
+	c.ResponseJSON(flag)
227
+}

+ 2
- 1
controllers/flashbuy/flashbuy.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"errors"
6 6
 	"net/http"
7 7
 	"spaceofcheng/services/controllers"
8
+	flashmodel "spaceofcheng/services/models/flashbuy"
8 9
 	"spaceofcheng/services/models/model"
9 10
 	"spaceofcheng/services/service/flashbuy"
10 11
 	"spaceofcheng/services/utils"
@@ -167,7 +168,7 @@ func (c *FlashBuyController) SaveFlashBuy() {
167 168
 	if jsnStr == "" {
168 169
 		c.ResponseError(errors.New("未接收到保存内容"))
169 170
 	}
170
-	info := model.TaFlashBuy{}
171
+	info := flashmodel.FlashBuyDetial{}
171 172
 	if err := json.Unmarshal([]byte(jsnStr), &info); err != nil {
172 173
 		utils.LogError("抢购数据转换失败: " + err.Error())
173 174
 		c.ResponseError(err)

+ 3
- 0
controllers/luckdraw/luckdraw.go View File

@@ -12,6 +12,8 @@ import (
12 12
 	"spaceofcheng/services/service/luckdraw"
13 13
 	"spaceofcheng/services/utils"
14 14
 	"strconv"
15
+
16
+	"github.com/astaxie/beego"
15 17
 )
16 18
 
17 19
 // LuckdrawController 应用
@@ -135,6 +137,7 @@ func (c *LuckDrawController) GetLuckDrawByID() {
135 137
 	if err != nil {
136 138
 		c.ResponseError(err)
137 139
 	}
140
+	beego.Error(luckdraw)
138 141
 	c.ResponseJSON(luckdraw)
139 142
 }
140 143
 

+ 51
- 0
models/activityinfo/activityinfo.go View File

@@ -0,0 +1,51 @@
1
+package activityinfo
2
+
3
+import (
4
+	"spaceofcheng/services/models"
5
+	"spaceofcheng/services/models/model"
6
+	"spaceofcheng/services/utils"
7
+
8
+	"github.com/go-xorm/xorm"
9
+)
10
+
11
+// ActivityinfoDao 当前数据库操作对象
12
+type ActivityinfoDao struct {
13
+	ctx *utils.Context
14
+	db  *xorm.Session
15
+}
16
+
17
+// NewDAO 初始化DAO
18
+func NewActivityinfoDao(ctx *utils.Context) *ActivityinfoDao {
19
+	return &ActivityinfoDao{
20
+		ctx: ctx,
21
+		db:  ctx.DB,
22
+	}
23
+}
24
+
25
+func (m *ActivityinfoDao) AddActivityInfo(info model.TaActivityShareInfo) error {
26
+	info.ActivityShareInfoId = utils.GetGUID()
27
+	info.Status = models.STATUS_NORMAL
28
+	_, err := m.db.Insert(info)
29
+	return err
30
+}
31
+
32
+// func (m *ActivityinfoDao) UpdateActivityInfo(info model.TaActivityShareInfo) error {
33
+// 	var cols = []string{
34
+// 		"activity_main_img",
35
+// 		"activity_title",
36
+// 		"share_img",
37
+// 		"share_content",
38
+// 	}
39
+// 	_, err := m.db.Cols(cols...).Where("activity_id = ?", info.ActivityId).And("activity_type = ?", info.ActivityType).Update(info)
40
+// 	return err
41
+// }
42
+
43
+// func (m *ActivityinfoDao) IsInfoExist(activityId string) (bool, error) {
44
+// 	flag, err := m.db.Exist(&model.TaActivityShareInfo{ActivityId: activityId})
45
+// 	return flag, err
46
+// }
47
+
48
+func (m *ActivityinfoDao) DeleteInfo(activityId string) error {
49
+	_, err := m.db.Delete(&model.TaActivityShareInfo{ActivityId: activityId})
50
+	return err
51
+}

+ 222
- 0
models/calendar/calendar.go View File

@@ -0,0 +1,222 @@
1
+package calendar
2
+
3
+import (
4
+	"spaceofcheng/services/models"
5
+	"spaceofcheng/services/models/model"
6
+	"spaceofcheng/services/utils"
7
+	"strconv"
8
+	"strings"
9
+	"time"
10
+
11
+	"github.com/go-xorm/xorm"
12
+)
13
+
14
+// CalendarDAO 当前数据库操作对象
15
+type CalendarDAO struct {
16
+	ctx *utils.Context
17
+	db  *xorm.Session
18
+}
19
+
20
+// NewCalendarDAO New Inst
21
+func NewCalendarDAO(ctx *utils.Context) *CalendarDAO {
22
+	return &CalendarDAO{
23
+		ctx: ctx,
24
+		db:  ctx.DB,
25
+	}
26
+}
27
+
28
+type CalendarList struct {
29
+	model.TaCustomerCalendar `xorm:"extends"`
30
+	Name                     string
31
+	Phone                    string
32
+	CustomerName             string
33
+}
34
+
35
+type CalendarFrontDetail struct {
36
+	model.TaCustomerCalendar `xorm:"extends"`
37
+	CaseName                 string
38
+	Imgs                     []model.TaCalendarImg
39
+}
40
+
41
+type CalendarListFront struct {
42
+	model.TaCustomerCalendar `xorm:"extends"`
43
+	CaseName                 string
44
+}
45
+
46
+// GetCalendarList 后台日历列表
47
+func (m *CalendarDAO) GetCalendarList(caseid, name, phone, makeStatus string, page, pageSize int) ([]CalendarList, error) {
48
+	var calendar []CalendarList
49
+	sql := `SELECT
50
+	a.*,
51
+	b.NAME,
52
+	b.phone,
53
+	b.customer_name 
54
+FROM
55
+	ta_customer_calendar a
56
+	INNER JOIN ta_customer b ON a.customer_id = b.customer_id 
57
+WHERE
58
+	a.STATUS > ` + strconv.Itoa(models.STATUS_DEL) + `
59
+	and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
60
+	if name != "" {
61
+		sql += ` and b.name like '%` + name + `%'`
62
+	}
63
+	if phone != "" {
64
+		sql += ` and b.phone like '%` + phone + `%'`
65
+	}
66
+	if makeStatus != "" {
67
+		sql += `and a.make_status = '` + makeStatus + `'`
68
+	}
69
+	sql += ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
70
+	err := m.db.Sql(sql).Find(&calendar)
71
+	return calendar, err
72
+}
73
+
74
+// GetCalendarListCount 后台日历列表数量
75
+func (m *CalendarDAO) GetCalendarListCount(caseid, name, phone, makeStatus string) (int, error) {
76
+	var calendar []CalendarList
77
+	sql := `SELECT
78
+	a.*,
79
+	b.NAME,
80
+	b.phone,
81
+	b.customer_name 
82
+FROM
83
+	ta_customer_calendar a
84
+	INNER JOIN ta_customer b ON a.customer_id = b.customer_id 
85
+WHERE
86
+	a.STATUS > ` + strconv.Itoa(models.STATUS_DEL) + `
87
+	and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
88
+	if name != "" {
89
+		sql += ` and b.name like '%` + name + `%'`
90
+	}
91
+	if phone != "" {
92
+		sql += ` and b.phone like '%` + phone + `%'`
93
+	}
94
+	if makeStatus != "" {
95
+		sql += `and a.make_status = '` + makeStatus + `'`
96
+	}
97
+	err := m.db.Sql(sql).Find(&calendar)
98
+	return len(calendar), err
99
+}
100
+
101
+// GetCalendarListFront 前台活动我的日历列表
102
+func (m *CalendarDAO) GetCalendarListFront(customerId string, page, pageSize int) ([]CalendarListFront, error) {
103
+	var calendar []CalendarListFront
104
+	sql := `SELECT
105
+	a.*,
106
+	b.case_name 
107
+FROM
108
+	ta_customer_calendar a
109
+	INNER JOIN sys_case b ON a.case_id = b.case_id 
110
+WHERE
111
+	customer_id = '` + customerId + `'
112
+	and a.STATUS > ` + strconv.Itoa(models.STATUS_DEL)
113
+	sql += ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
114
+	err := m.db.Sql(sql).Find(&calendar)
115
+	return calendar, err
116
+}
117
+
118
+// GetCalendarListFrontCount 前台活动我的日历列表
119
+func (m *CalendarDAO) GetCalendarListFrontCount(customerId string) (int, error) {
120
+	var calendar []CalendarListFront
121
+	sql := `SELECT
122
+	a.*,
123
+	b.case_name 
124
+FROM
125
+	ta_customer_calendar a
126
+	INNER JOIN sys_case b ON a.case_id = b.case_id 
127
+WHERE
128
+	customer_id = '` + customerId + `'
129
+	and a.STATUS > ` + strconv.Itoa(models.STATUS_DEL)
130
+	err := m.db.Sql(sql).Find(&calendar)
131
+	return len(calendar), err
132
+}
133
+
134
+// GetCalendarFrontDetailById 获取日历活动详情
135
+func (m *CalendarDAO) GetCalendarFrontDetailById(calendarId string) ([]CalendarFrontDetail, error) {
136
+	var calendar []CalendarFrontDetail
137
+	sql := `SELECT
138
+	a.*,
139
+	b.case_name 
140
+FROM
141
+	ta_customer_calendar a
142
+	INNER JOIN sys_case b ON a.case_id = b.case_id 
143
+WHERE
144
+	customer_calendar_id = '` + calendarId + `'`
145
+	err := m.db.Sql(sql).Find(&calendar)
146
+	return calendar, err
147
+}
148
+
149
+// GetCalendarFrontImgDetailById 获取日历详情图片
150
+func (m *CalendarDAO) GetCalendarFrontImgDetailById(calendarId string) ([]model.TaCalendarImg, error) {
151
+	var imgs []model.TaCalendarImg
152
+	sql := `SELECT
153
+	* 
154
+FROM
155
+	ta_calendar_img 
156
+WHERE
157
+	customer_calendar_id = '` + calendarId + `'
158
+	order by sort asc`
159
+	err := m.db.Sql(sql).Find(&imgs)
160
+	return imgs, err
161
+}
162
+
163
+// AddCalendar 新增日历活动
164
+func (m *CalendarDAO) AddCalendar(calendar model.TaCustomerCalendar) (*model.TaCustomerCalendar, error) {
165
+	calendar.CustomerCalendarId = utils.GetGUID()
166
+	calendar.CreateDate = time.Now()
167
+	calendar.MakeStatus = models.CALENDAR_MAKING
168
+	calendar.Status = models.STATUS_NORMAL
169
+	_, err := m.db.Insert(calendar)
170
+	return &calendar, err
171
+}
172
+
173
+// AddCalendarImg 新增日历活动图片
174
+func (m *CalendarDAO) AddCalendarImg(img model.TaCalendarImg) error {
175
+	img.CalendarImgId = utils.GetGUID()
176
+	img.Status = models.STATUS_NORMAL
177
+	_, err := m.db.Insert(img)
178
+	return err
179
+}
180
+
181
+// ChangeMakeStaus 制作完成
182
+func (m *CalendarDAO) ChangeMakeStaus(calendarId string) error {
183
+	var calendar = model.TaCustomerCalendar{
184
+		CustomerCalendarId: calendarId,
185
+		MakeStatus:         models.CALENDAR_FINISH,
186
+	}
187
+	var cols = []string{
188
+		"make_status",
189
+	}
190
+	_, err := m.db.Cols(cols...).Where("customer_calendar_id = ?", calendar.CustomerCalendarId).Update(calendar)
191
+	return err
192
+}
193
+
194
+// GetCalendarList 后台日历列表Excel导出
195
+func (m *CalendarDAO) GetCalendarListExcel(caseid, name, phone string) ([]CalendarList, error) {
196
+	var calendar []CalendarList
197
+	sql := `SELECT
198
+	a.*,
199
+	b.NAME,
200
+	b.phone,
201
+	b.customer_name 
202
+FROM
203
+	ta_customer_calendar a
204
+	INNER JOIN ta_customer b ON a.customer_id = b.customer_id 
205
+WHERE
206
+	a.STATUS > ` + strconv.Itoa(models.STATUS_DEL) + `
207
+	and a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')`
208
+	if name != "" {
209
+		sql += ` and b.name like '%` + name + `%'`
210
+	}
211
+	if phone != "" {
212
+		sql += ` and b.phone like '%` + phone + `%'`
213
+	}
214
+	sql += ` order by a.create_date desc `
215
+	err := m.db.Sql(sql).Find(&calendar)
216
+	return calendar, err
217
+}
218
+
219
+func (m *CalendarDAO) IsCustomerAttend(customerId string) (bool, error) {
220
+	flag, err := m.db.Exist(&model.TaCustomerCalendar{CustomerId: customerId})
221
+	return flag, err
222
+}

+ 12
- 0
models/constant.go View File

@@ -240,3 +240,15 @@ const (
240 240
 	INTERVAL_WEEK  = "week"
241 241
 	INTERVAL_MONTH = "month"
242 242
 )
243
+
244
+// 活动类型
245
+const (
246
+	ACTIVITY_FLASH = "flash"
247
+	ACTIVITY_LUCK  = "luck"
248
+)
249
+
250
+// 日历制作状态
251
+const (
252
+	CALENDAR_MAKING = "making"
253
+	CALENDAR_FINISH = "finish"
254
+)

+ 1
- 1
models/course/course.go View File

@@ -713,7 +713,7 @@ WHERE
713 713
 	AND a.STATUS = ` + strconv.Itoa(models.STATUS_NORMAL) + ` 
714 714
 ORDER BY
715 715
 	a.begin_date DESC 
716
-	LIMIT` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
716
+	LIMIT ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
717 717
 	err := m.db.Sql(sql).Find(&course)
718 718
 	return course, err
719 719
 }

+ 21
- 3
models/flashbuy/flashbuy.go View File

@@ -47,6 +47,13 @@ type CustomerFlashDetail struct {
47 47
 	CaseName                 string
48 48
 	IsAttend                 int
49 49
 }
50
+type FlashBuyDetial struct {
51
+	model.TaFlashBuy `xorm:"extends"`
52
+	ActivityMainImg  string
53
+	ActivityTitle    string
54
+	ShareImg         string
55
+	ShareContent     string
56
+}
50 57
 
51 58
 func (m *FlashbuyDAO) GetFlashBuyList(caseid, flashBuyName, flashBuyStatus string, page, pageSize int) ([]FlashBuy, error) {
52 59
 	var flashBuy []FlashBuy
@@ -87,9 +94,20 @@ FROM
87 94
 	return len(flashBuy), err
88 95
 }
89 96
 
90
-func (m *FlashbuyDAO) GetFlashBuyById(flashBuyId string) (*model.TaFlashBuy, error) {
91
-	var flashBuy []model.TaFlashBuy
92
-	err := m.db.Where("flash_buy_id = ?", flashBuyId).And("status > ?", models.STATUS_DEL).Find(&flashBuy)
97
+func (m *FlashbuyDAO) GetFlashBuyById(flashBuyId string) (*FlashBuyDetial, error) {
98
+	var flashBuy []FlashBuyDetial
99
+	sql := `SELECT
100
+	a.*,
101
+	b.activity_main_img,
102
+	b.activity_title,
103
+	b.share_img,
104
+	b.share_content
105
+FROM
106
+	ta_flash_buy a
107
+	LEFT JOIN ta_activity_share_info b ON a.flash_buy_id = b.activity_id 
108
+	AND b.activity_type = '` + models.ACTIVITY_FLASH + `'
109
+	WHERE a.flash_buy_id = '` + flashBuyId + `'`
110
+	err := m.db.Sql(sql).Find(&flashBuy)
93 111
 	if err != nil {
94 112
 		return nil, err
95 113
 	}

+ 34
- 3
models/luckdraw/luckdraw.go View File

@@ -30,6 +30,10 @@ func NewDAO(ctx *utils.Context) *LuckDrawDao {
30 30
 // LuckDraw 抽奖记录
31 31
 type LuckDraw struct {
32 32
 	model.TaLuckdraw `xorm:"extends"`
33
+	ActivityMainImg  string
34
+	ActivityTitle    string
35
+	ShareImg         string
36
+	ShareContent     string
33 37
 	Prizes           []model.TaLuckdrawPrize
34 38
 	Imgs             []model.TaLuckdrawImg
35 39
 }
@@ -162,6 +166,10 @@ type PrizeWithDefaults struct {
162 166
 // LuckDrawInfo 抽奖info
163 167
 type LuckDrawInfo struct {
164 168
 	model.TaLuckdraw `xorm:"extends"`
169
+	ActivityMainImg  string
170
+	ActivityTitle    string
171
+	ShareImg         string
172
+	ShareContent     string
165 173
 	Prizes           []PrizeWithDefaults
166 174
 	Imgs             []model.TaLuckdrawImg
167 175
 }
@@ -172,11 +180,23 @@ func (m *LuckDrawDao) GetLuckDrawInfoByID(id string) (*LuckDrawInfo, error) {
172 180
 		return nil, errors.New("不存在抽奖信息!")
173 181
 	}
174 182
 	var luckdraw LuckDrawInfo
175
-	sql := `select * from ta_luckdraw where id= ?`
176
-	_, err := m.db.SQL(sql, id).Get(&luckdraw)
183
+	sql := `SELECT
184
+	a.*,
185
+	b.activity_main_img,
186
+	b.activity_title,
187
+	b.share_img,
188
+	b.share_content
189
+FROM
190
+	ta_luckdraw a
191
+	LEFT JOIN ta_activity_share_info b ON a.id = b.activity_id 
192
+	AND b.activity_type = '` + models.ACTIVITY_LUCK + `'
193
+	WHERE a.id = '` + id + `'`
194
+	beego.Error(sql)
195
+	_, err := m.db.Sql(sql).Get(&luckdraw)
177 196
 	if err != nil {
178 197
 		return nil, err
179 198
 	}
199
+
180 200
 	if luckdraw.Id == "" {
181 201
 		return nil, nil
182 202
 	}
@@ -192,6 +212,7 @@ func (m *LuckDrawDao) GetLuckDrawInfoByID(id string) (*LuckDrawInfo, error) {
192 212
 		return nil, errors.New("获取抽奖图片信息失败")
193 213
 	}
194 214
 	luckdraw.Imgs = imgs
215
+	beego.Error(luckdraw)
195 216
 	// defaults, err := m.GetLuckDrawDefault(id)
196 217
 	// if err != nil {
197 218
 	// 	utils.LogError("获取奖品内置信息失败:", err)
@@ -760,7 +781,17 @@ func (m *LuckDrawDao) GetWinning(prizes []model.TaLuckdrawPrize) (*model.TaLuckd
760 781
 // GetLuckDrawByID 获取抽奖信息
761 782
 func (m *LuckDrawDao) GetLuckDrawByID(id string) (*LuckDraw, error) {
762 783
 	var luckdraws []LuckDraw
763
-	sql := `select * from ta_luckdraw where id= ?`
784
+	sql := `SELECT
785
+	a.*,
786
+	b.activity_main_img,
787
+	b.activity_title,
788
+	b.share_img,
789
+	b.share_content
790
+FROM
791
+	ta_luckdraw a
792
+	LEFT JOIN ta_activity_share_info b ON a.id = b.activity_id 
793
+WHERE
794
+	id = ?`
764 795
 	err := m.db.SQL(sql, id).Find(&luckdraws)
765 796
 	if err != nil {
766 797
 		return nil, err

+ 6
- 3
models/message/cmscase.go View File

@@ -36,8 +36,9 @@ func (m *MessageDAO) GetCmsCaseList(name, caseids, userid string, page int, page
36 36
 // GetCmsCaseByOrg 获取列表
37 37
 func (m *MessageDAO) GetCmsCaseByOrg(orgid string) ([]CmsCase, error) {
38 38
 	var cases []CmsCase
39
-	sql := `select * from ta_cms_case where org_id='` + orgid + `' and status=` + strconv.Itoa(models.STATUS_NORMAL) + ` order by create_date desc`
39
+	sql := `select a.*,b.coordinate  from ta_cms_case a left join sys_case b on a.case_id = b.case_id where a.org_id='` + orgid + `' and a.status=` + strconv.Itoa(models.STATUS_NORMAL) + ` order by a.create_date desc`
40 40
 	err := m.db.Sql(sql).Find(&cases)
41
+	beego.Error(sql)
41 42
 	// err := m.db.Where("org_id=?", orgid).Find(&cases)
42 43
 	return cases, err
43 44
 }
@@ -60,8 +61,10 @@ func (m *MessageDAO) GetCmsCaseListCount(name, caseids, userid string) (int, err
60 61
 type CmsCase struct {
61 62
 	model.TaCmsCase `xorm:"extends"`
62 63
 	CaseAddress     string
63
-	Courses         []course.CourseDetail
64
-	CmsCaseImgs     []model.TaCmsCaseImage
64
+	Coordinate      string
65
+
66
+	Courses     []course.CourseDetail
67
+	CmsCaseImgs []model.TaCmsCaseImage
65 68
 }
66 69
 
67 70
 // GetCmsCaseByID 获取项目专题详情

+ 7
- 0
routers/common.go View File

@@ -3,6 +3,7 @@ package routers
3 3
 import (
4 4
 	"spaceofcheng/services/controllers"
5 5
 	"spaceofcheng/services/controllers/bodychecklist"
6
+	"spaceofcheng/services/controllers/calendar"
6 7
 	"spaceofcheng/services/controllers/card"
7 8
 	"spaceofcheng/services/controllers/cases"
8 9
 	"spaceofcheng/services/controllers/channel"
@@ -338,5 +339,11 @@ func getCommonRoutes(prefix string) beego.LinkNamespace {
338 339
 		beego.NSRouter("/flashbuy/verify/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "put:Verify"),
339 340
 		beego.NSRouter("/flashbuy/model", &flashbuy.FlashBuyController{}, "get:GetFlashModelList"),
340 341
 		beego.NSRouter("/flashbuy/excel/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyExcel"),
342
+
343
+		// calendar 日历活动
344
+		beego.NSRouter("/calendar", &calendar.CalendarController{}, "get:GetCalendarList"),
345
+		beego.NSRouter("/calendar/:calendarId/:imgType", &calendar.CalendarController{}, "get:DownloadImg"),
346
+		beego.NSRouter("/calendar/:calendarIds", &calendar.CalendarController{}, "put:ChangeMakeStaus"),
347
+		beego.NSRouter("/calendar/excel", &calendar.CalendarController{}, "get:GetCalendarListExcel"),
341 348
 	)
342 349
 }

+ 1
- 0
routers/guest.go View File

@@ -28,6 +28,7 @@ func getGuestRoutes(prefix string) beego.LinkNamespace {
28 28
 
29 29
 		// 课程
30 30
 		beego.NSRouter("/course/:courseid", &course.CourseController{}, "get:GetCourseByID"),
31
+		beego.NSRouter("/course", &course.CourseController{}, "get:GetCourseForWechatFront"),
31 32
 
32 33
 		// 案场
33 34
 		beego.NSRouter("/case", &cases.CaseController{}, "get:GetOrgCases"),

+ 7
- 1
routers/wechat.go View File

@@ -2,6 +2,7 @@ package routers
2 2
 
3 3
 import (
4 4
 	"spaceofcheng/services/controllers/bodycheck"
5
+	"spaceofcheng/services/controllers/calendar"
5 6
 	"spaceofcheng/services/controllers/card"
6 7
 	"spaceofcheng/services/controllers/cases"
7 8
 	"spaceofcheng/services/controllers/coupon"
@@ -41,7 +42,6 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
41 42
 		// 课程
42 43
 		beego.NSRouter("/course/user", &course.CourseController{}, "get:GetCustomerCourse"),
43 44
 		beego.NSRouter("/course/user/:id", &course.CourseController{}, "get:GetCustomerCourseByID"),
44
-		beego.NSRouter("/course/list", &course.CourseController{}, "get:GetCourseForWechatFront"),
45 45
 
46 46
 		// 商品订单
47 47
 		beego.NSRouter("/goods/user", &goods.GoodsController{}, "get:GetCustomerOrders"),
@@ -111,5 +111,11 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
111 111
 		beego.NSRouter("/customerremark/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerRemarkList"),
112 112
 		beego.NSRouter("/customerremark/search/:salesId/:customerInfo", &customerremark.CustomerRemarkController{}, "get:SearchCustomer"),
113 113
 		beego.NSRouter("/customerremark", &customerremark.CustomerRemarkController{}, "post:AddRemark"),
114
+
115
+		// 日历活动
116
+		beego.NSRouter("/calendar", &calendar.CalendarController{}, "get:GetCalendarListFront"),
117
+		beego.NSRouter("/calendar/:calendarId", &calendar.CalendarController{}, "get:GetCalendarFrontDetailById"),
118
+		beego.NSRouter("/calendar", &calendar.CalendarController{}, "post:AddCalendar"),
119
+		beego.NSRouter("/calendar/isattend/customer", &calendar.CalendarController{}, "get:IsCustomerAttend"),
114 120
 	)
115 121
 }

+ 152
- 0
service/calendar/calendar.go View File

@@ -0,0 +1,152 @@
1
+package calendar
2
+
3
+import (
4
+	"errors"
5
+	"spaceofcheng/services/models/calendar"
6
+	"spaceofcheng/services/models/model"
7
+	"spaceofcheng/services/service"
8
+	"spaceofcheng/services/utils"
9
+)
10
+
11
+// CalendarServ 系统处理
12
+type CalendarServ struct {
13
+	ctx *utils.Context
14
+	dao *calendar.CalendarDAO
15
+}
16
+
17
+// NewCalendarServ 初始化
18
+func NewCalendarServ(ctx *utils.Context) *CalendarServ {
19
+	return &CalendarServ{
20
+		ctx: ctx,
21
+		dao: calendar.NewCalendarDAO(ctx),
22
+	}
23
+}
24
+
25
+// GetCalendarList 后台日历列表
26
+func (s *CalendarServ) GetCalendarList(caseid, name, phone, makeStatus string, page, pageSize int) (map[string]interface{}, error) {
27
+	if pageSize == 0 {
28
+		pageSize = service.PAGENUM
29
+	}
30
+	list, err := s.dao.GetCalendarList(caseid, name, phone, makeStatus, page, pageSize)
31
+	if err != nil {
32
+		utils.LogError("获取日历活动列表失败: " + err.Error())
33
+		return nil, errors.New("获取日历活动列表失败")
34
+	}
35
+	total, err := s.dao.GetCalendarListCount(caseid, name, phone, makeStatus)
36
+	if err != nil {
37
+		utils.LogError("获取日历活动列表失败: " + err.Error())
38
+		return nil, errors.New("获取日历活动列表失败")
39
+	}
40
+	return map[string]interface{}{
41
+		"list":     list,
42
+		"pageSize": pageSize,
43
+		"pagenum":  total,
44
+		"page":     page,
45
+	}, nil
46
+}
47
+
48
+// GetCalendarListFront 前台活动我的日历列表
49
+func (s *CalendarServ) GetCalendarListFront(customerId string, page, pageSize int) (map[string]interface{}, error) {
50
+	if pageSize == 0 {
51
+		pageSize = service.PAGENUM
52
+	}
53
+	list, err := s.dao.GetCalendarListFront(customerId, page, pageSize)
54
+	if err != nil {
55
+		utils.LogError("获取日历活动列表失败: " + err.Error())
56
+		return nil, errors.New("获取日历活动列表失败")
57
+	}
58
+	total, err := s.dao.GetCalendarListFrontCount(customerId)
59
+	if err != nil {
60
+		utils.LogError("获取日历活动列表失败: " + err.Error())
61
+		return nil, errors.New("获取日历活动列表失败")
62
+	}
63
+	return map[string]interface{}{
64
+		"list":     list,
65
+		"pageSize": pageSize,
66
+		"pagenum":  total,
67
+		"page":     page,
68
+	}, nil
69
+}
70
+
71
+// GetCalendarFrontDetailById 获取日历活动详情
72
+func (s *CalendarServ) GetCalendarFrontDetailById(calendarId string) (*calendar.CalendarFrontDetail, error) {
73
+	list, err := s.dao.GetCalendarFrontDetailById(calendarId)
74
+	if err != nil {
75
+		utils.LogError("获取日历活动详情失败: " + err.Error())
76
+		return nil, errors.New("获取日历活动详情失败")
77
+	}
78
+	if len(list) <= 0 {
79
+		return nil, nil
80
+	}
81
+	img, err := s.dao.GetCalendarFrontImgDetailById(calendarId)
82
+	if err != nil {
83
+		utils.LogError("获取日历活动详情失败: " + err.Error())
84
+		return nil, errors.New("获取日历活动详情失败")
85
+	}
86
+	detail := list[0]
87
+	detail.Imgs = img
88
+	return &detail, nil
89
+
90
+}
91
+
92
+// ChangeMakeStaus 制作完成
93
+func (s *CalendarServ) ChangeMakeStaus(calendarId string) error {
94
+	err := s.dao.ChangeMakeStaus(calendarId)
95
+	if err != nil {
96
+		utils.LogError("修改日历活动状态失败: " + err.Error())
97
+		return errors.New("修改日历活动状态失败")
98
+	}
99
+	return nil
100
+}
101
+
102
+// GetCalendarList 后台日历列表Excel导出
103
+func (s *CalendarServ) GetCalendarListExcel(caseid, name, phone string) ([]calendar.CalendarList, error) {
104
+	list, err := s.dao.GetCalendarListExcel(caseid, name, phone)
105
+	if err != nil {
106
+		utils.LogError("获取日历excel失败: " + err.Error())
107
+		return nil, errors.New("获取日历excel失败")
108
+	}
109
+	return list, nil
110
+}
111
+
112
+// GetCalendarFrontImgDetailById 获取日历详情图片
113
+func (s *CalendarServ) GetCalendarImgs(calendarId string) ([]model.TaCalendarImg, error) {
114
+	list, err := s.dao.GetCalendarFrontImgDetailById(calendarId)
115
+	if err != nil {
116
+		utils.LogError("获取日历图片失败: " + err.Error())
117
+		return nil, errors.New("获取日历图片失败")
118
+	}
119
+	return list, nil
120
+}
121
+
122
+// AddCalendar 新增日历活动
123
+func (s *CalendarServ) AddCalendar(calendar model.TaCustomerCalendar) (*model.TaCustomerCalendar, error) {
124
+	customerCalendar, err := s.dao.AddCalendar(calendar)
125
+	if err != nil {
126
+		utils.LogError("新增日历活动失败: " + err.Error())
127
+		return nil, errors.New("新增日历活动失败")
128
+	}
129
+	return customerCalendar, nil
130
+}
131
+
132
+// AddCalendarImg 新增日历活动图片
133
+func (s *CalendarServ) AddCalendarImg(img []model.TaCalendarImg, calendarId string) error {
134
+	for i := 0; i < len(img); i++ {
135
+		img[i].CustomerCalendarId = calendarId
136
+		err := s.dao.AddCalendarImg(img[i])
137
+		if err != nil {
138
+			utils.LogError("新增日历活动失败: " + err.Error())
139
+			return errors.New("新增日历活动失败")
140
+		}
141
+	}
142
+	return nil
143
+}
144
+
145
+func (s *CalendarServ) IsCustomerAttend(customerId string) (bool, error) {
146
+	flag, err := s.dao.IsCustomerAttend(customerId)
147
+	if err != nil {
148
+		utils.LogError("查询用户是否参与失败: " + err.Error())
149
+		return false, errors.New("查询用户是否参与失败")
150
+	}
151
+	return flag, nil
152
+}

+ 38
- 5
service/flashbuy/flashbuy.go View File

@@ -4,6 +4,7 @@ import (
4 4
 	"errors"
5 5
 	"fmt"
6 6
 	"spaceofcheng/services/models"
7
+	"spaceofcheng/services/models/activityinfo"
7 8
 	"spaceofcheng/services/models/course"
8 9
 	"spaceofcheng/services/models/flashbuy"
9 10
 	"spaceofcheng/services/models/model"
@@ -11,6 +12,8 @@ import (
11 12
 	"spaceofcheng/services/service"
12 13
 	"spaceofcheng/services/utils"
13 14
 	"time"
15
+
16
+	"github.com/astaxie/beego"
14 17
 )
15 18
 
16 19
 // FlashBuyServ 系统处理
@@ -19,6 +22,7 @@ type FlashBuyServ struct {
19 22
 	dao       *flashbuy.FlashbuyDAO
20 23
 	vdao      *verify.VerifyDAO
21 24
 	courseDAO *course.CourseDAO
25
+	adao      *activityinfo.ActivityinfoDao
22 26
 }
23 27
 
24 28
 // NewFlashBuyServ 初始化
@@ -28,6 +32,7 @@ func NewFlashBuyServ(ctx *utils.Context) *FlashBuyServ {
28 32
 		dao:       flashbuy.NewFlashbuyDAO(ctx),
29 33
 		vdao:      verify.NewVerifyDAO(ctx),
30 34
 		courseDAO: course.NewCourseDAO(ctx),
35
+		adao:      activityinfo.NewActivityinfoDao(ctx),
31 36
 	}
32 37
 }
33 38
 
@@ -52,7 +57,7 @@ func (s *FlashBuyServ) GetFlashBuyList(caseid, flashBuyName, flashBuyStatus stri
52 57
 		"page":     page,
53 58
 	}, nil
54 59
 }
55
-func (s *FlashBuyServ) GetFlashBuyById(flashBuyId string) (*model.TaFlashBuy, error) {
60
+func (s *FlashBuyServ) GetFlashBuyById(flashBuyId string) (*flashbuy.FlashBuyDetial, error) {
56 61
 	flashbuy, err := s.dao.GetFlashBuyById(flashBuyId)
57 62
 	if err != nil {
58 63
 		utils.LogError("获取抢购活动信息失败: " + err.Error())
@@ -71,7 +76,7 @@ func (s *FlashBuyServ) GetFlashByUser(id string) ([]model.TaCustomerFlashBuy, er
71 76
 	return flashbuys, err
72 77
 }
73 78
 
74
-func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBuy, error) {
79
+func (s *FlashBuyServ) SaveFlashBuy(flashbuy flashbuy.FlashBuyDetial) (*model.TaFlashBuy, error) {
75 80
 	var newFlashBuy *model.TaFlashBuy
76 81
 	var err error
77 82
 	if flashbuy.CaseId == "" {
@@ -86,13 +91,41 @@ func (s *FlashBuyServ) SaveFlashBuy(flashbuy model.TaFlashBuy) (*model.TaFlashBu
86 91
 	if flashbuy.ModelId == "" {
87 92
 		return nil, utils.LogError("请选择活动模板!")
88 93
 	}
94
+	var info = model.TaActivityShareInfo{
95
+		ActivityMainImg: flashbuy.ActivityMainImg,
96
+		ActivityTitle:   flashbuy.ActivityTitle,
97
+		ActivityType:    models.ACTIVITY_FLASH,
98
+		ShareContent:    flashbuy.ShareContent,
99
+		ShareImg:        flashbuy.ShareImg,
100
+	}
89 101
 	if flashbuy.FlashBuyId == "" {
90 102
 		org := s.ctx.Get("org").(model.SysOrg)
91 103
 		flashbuy.OrgId = org.OrgId
92
-		newFlashBuy, err = s.dao.AddNewFlashBuy(flashbuy)
104
+		newFlashBuy, err = s.dao.AddNewFlashBuy(flashbuy.TaFlashBuy)
105
+		info.ActivityId = newFlashBuy.FlashBuyId
106
+		err = s.adao.AddActivityInfo(info)
107
+		if err != nil {
108
+			utils.LogError("保存抢购活动信息失败: " + err.Error())
109
+			return nil, errors.New("保存抢购活动信息失败")
110
+		}
111
+		beego.Error("_______________info___add_______________")
112
+		beego.Error(info)
93 113
 	} else {
94
-		err = s.dao.EditFlashBuy(flashbuy)
95
-		newFlashBuy = &flashbuy
114
+		err = s.dao.EditFlashBuy(flashbuy.TaFlashBuy)
115
+		newFlashBuy = &flashbuy.TaFlashBuy
116
+		err = s.adao.DeleteInfo(newFlashBuy.FlashBuyId)
117
+		if err != nil {
118
+			utils.LogError("保存抢购活动信息失败: " + err.Error())
119
+			return nil, errors.New("保存抢购活动信息失败")
120
+		}
121
+		info.ActivityId = newFlashBuy.FlashBuyId
122
+		err = s.adao.AddActivityInfo(info)
123
+		if err != nil {
124
+			utils.LogError("保存抢购活动信息失败: " + err.Error())
125
+			return nil, errors.New("保存抢购活动信息失败")
126
+		}
127
+		beego.Error("_______________info___Update_______________")
128
+		beego.Error(info)
96 129
 	}
97 130
 	if err != nil {
98 131
 		utils.LogError("保存抢购活动信息失败: " + err.Error())

+ 39
- 0
service/luckdraw/luckdraw.go View File

@@ -4,12 +4,15 @@ import (
4 4
 	"errors"
5 5
 	"fmt"
6 6
 	"spaceofcheng/services/models"
7
+	"spaceofcheng/services/models/activityinfo"
7 8
 	"spaceofcheng/services/models/course"
8 9
 	"spaceofcheng/services/models/luckdraw"
9 10
 	"spaceofcheng/services/models/model"
10 11
 	"spaceofcheng/services/service"
11 12
 	"spaceofcheng/services/utils"
12 13
 	"time"
14
+
15
+	"github.com/astaxie/beego"
13 16
 )
14 17
 
15 18
 // LuckdrawServ 系统处理
@@ -17,6 +20,7 @@ type LuckdrawServ struct {
17 20
 	ctx       *utils.Context
18 21
 	dao       *luckdraw.LuckDrawDao
19 22
 	courseDAO *course.CourseDAO
23
+	adao      *activityinfo.ActivityinfoDao
20 24
 }
21 25
 
22 26
 // NewLuckdrawServ 初始化
@@ -25,6 +29,7 @@ func NewLuckdrawServ(ctx *utils.Context) *LuckdrawServ {
25 29
 		ctx:       ctx,
26 30
 		dao:       luckdraw.NewDAO(ctx),
27 31
 		courseDAO: course.NewCourseDAO(ctx),
32
+		adao:      activityinfo.NewActivityinfoDao(ctx),
28 33
 	}
29 34
 }
30 35
 
@@ -153,6 +158,14 @@ func (s *LuckdrawServ) SaveLuckDraw(luckdraw *luckdraw.LuckDrawInfo) (*model.TaL
153 158
 	}
154 159
 	var newInfo *model.TaLuckdraw
155 160
 	var err error
161
+	var info = model.TaActivityShareInfo{
162
+		ActivityMainImg: luckdraw.ActivityMainImg,
163
+		ActivityTitle:   luckdraw.ActivityTitle,
164
+		ActivityType:    models.ACTIVITY_LUCK,
165
+		ShareContent:    luckdraw.ShareContent,
166
+		ShareImg:        luckdraw.ShareImg,
167
+	}
168
+	beego.Error(info)
156 169
 	if luckdraw.Id == "" {
157 170
 		org := s.ctx.Get("org").(model.SysOrg)
158 171
 		luckdraw.OrgId = org.OrgId
@@ -163,7 +176,15 @@ func (s *LuckdrawServ) SaveLuckDraw(luckdraw *luckdraw.LuckDrawInfo) (*model.TaL
163 176
 			utils.LogError("保存抽奖信息失败: " + err.Error())
164 177
 			return nil, errors.New("保存抽奖信息失败")
165 178
 		}
179
+		info.ActivityId = newInfo.Id
180
+		err = s.adao.AddActivityInfo(info)
181
+		if err != nil {
182
+			utils.LogError("保存抽奖信息失败: " + err.Error())
183
+			return nil, errors.New("保存抽奖信息失败")
184
+		}
166 185
 	} else {
186
+		beego.Error("____________joinNum___________")
187
+		beego.Error(luckdraw.JoinNum)
167 188
 		if luckdraw.JoinedNum > 0 {
168 189
 			var cols = []string{
169 190
 				"name",
@@ -181,6 +202,17 @@ func (s *LuckdrawServ) SaveLuckDraw(luckdraw *luckdraw.LuckDrawInfo) (*model.TaL
181 202
 				utils.LogError("更新抽奖信息失败: " + err.Error())
182 203
 				return nil, errors.New("更新抽奖信息失败")
183 204
 			}
205
+			info.ActivityId = luckdraw.Id
206
+			err = s.adao.DeleteInfo(info.ActivityId)
207
+			if err != nil {
208
+				utils.LogError("更新抽奖信息失败: " + err.Error())
209
+				return nil, errors.New("更新抽奖信息失败")
210
+			}
211
+			err = s.adao.AddActivityInfo(info)
212
+			if err != nil {
213
+				utils.LogError("更新抽奖信息失败: " + err.Error())
214
+				return nil, errors.New("更新抽奖信息失败")
215
+			}
184 216
 			return &luckdraw.TaLuckdraw, nil
185 217
 		}
186 218
 		var cols = []string{
@@ -206,6 +238,13 @@ func (s *LuckdrawServ) SaveLuckDraw(luckdraw *luckdraw.LuckDrawInfo) (*model.TaL
206 238
 			return nil, errors.New("更新抽奖信息失败")
207 239
 		}
208 240
 		newInfo = &luckdraw.TaLuckdraw
241
+		info.ActivityId = newInfo.Id
242
+		err = s.adao.DeleteInfo(info.ActivityId)
243
+		if err != nil {
244
+			utils.LogError("更新抽奖信息失败: " + err.Error())
245
+			return nil, errors.New("更新抽奖信息失败")
246
+		}
247
+		err = s.adao.AddActivityInfo(info)
209 248
 		// 删除奖品内定信息
210 249
 		err = s.dao.DelLuckDrawDefault(luckdraw.Id)
211 250
 		if err != nil {