Przeglądaj źródła

Merge branch 'master' of http://git.shengws.com/zhangbj/scrm-go

zhengchengwu 5 lat temu
rodzic
commit
94d2d3193f

+ 6 - 0
controllers/base_controller.go Wyświetl plik

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	service "SCRM/service/admin_service"
5
+	"SCRM/utils"
5 6
 
6 7
 	"github.com/astaxie/beego"
7 8
 )
@@ -21,20 +22,25 @@ func (this *BaseController) GetAdminUserInfo() *service.AdminUserInfo {
21 22
 
22 23
 func (this *BaseController) ErrorLog(format string, a ...interface{}) {
23 24
 	//beego.Error(fmt.Sprintf(format, a...))
25
+	utils.ErrorLog(format, a...)
24 26
 }
25 27
 
26 28
 func (this *BaseController) WarnLog(format string, a ...interface{}) {
27 29
 	//beego.Warn(fmt.Sprintf(format, a...))
30
+	utils.WarningLog(format, a...)
28 31
 }
29 32
 
30 33
 func (this *BaseController) InfoLog(format string, a ...interface{}) {
31 34
 	//beego.Info(fmt.Sprintf(format, a...))
35
+	utils.InfoLog(format, a...)
32 36
 }
33 37
 
34 38
 func (this *BaseController) DebugLog(format string, a ...interface{}) {
35 39
 	//beego.Debug(fmt.Sprintf(format, a...))
40
+	utils.InfoLog(format, a...)
36 41
 }
37 42
 
38 43
 func (this *BaseController) TraceLog(format string, a ...interface{}) {
39 44
 	//beego.Trace(fmt.Sprintf(format, a...))
45
+	utils.TraceLog(format, a...)
40 46
 }

+ 215 - 0
controllers/marketing_tool/activity_controller.go Wyświetl plik

@@ -5,6 +5,8 @@ import (
5 5
 	"SCRM/enums"
6 6
 	"SCRM/models"
7 7
 	"SCRM/service/marketing_tool_service"
8
+	"SCRM/utils"
9
+	"encoding/json"
8 10
 	"time"
9 11
 
10 12
 	"github.com/astaxie/beego"
@@ -12,6 +14,8 @@ import (
12 14
 
13 15
 func ActivityCtlRegistRouters() {
14 16
 	beego.Router("/api/activities", &ActivityAPIController{}, "get:Activities")
17
+	beego.Router("/api/activity", &ActivityAPIController{}, "get:GetActivity")
18
+	beego.Router("/api/activity/submit", &ActivityAPIController{}, "post:ActivitySubmit")
15 19
 }
16 20
 
17 21
 type ActivityAPIController struct {
@@ -114,3 +118,214 @@ func (this *ActivityAPIController) _convertToUnapprovedActivityViewJSON(activity
114 118
 	json["start_time"] = activity.StartTime
115 119
 	return json
116 120
 }
121
+
122
+// /api/activity [get]
123
+// @param id:int
124
+func (this *ActivityAPIController) GetActivity() {
125
+	activityID, _ := this.GetInt64("id")
126
+	if activityID <= 0 {
127
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
128
+		return
129
+	}
130
+
131
+	adminUserInfo := this.GetAdminUserInfo()
132
+	activity, getActivityErr := marketing_tool_service.GetActivityWithID(adminUserInfo.CurrentOrgId, activityID)
133
+	if getActivityErr != nil {
134
+		this.ErrorLog("获取活动失败:%v", getActivityErr)
135
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
136
+		return
137
+	} else if activity == nil {
138
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeActivityNotExist)
139
+		return
140
+	}
141
+
142
+	paragraph, getParagraphErr := marketing_tool_service.GetActivityParagraphByActivityID(activity.Id)
143
+	if getParagraphErr != nil {
144
+		this.ErrorLog("获取活动段落失败:%v", getParagraphErr)
145
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
146
+		return
147
+	}
148
+
149
+	paragraphTitle := ""
150
+	paragraphContent := ""
151
+	if paragraph != nil {
152
+		paragraphTitle = paragraph.Title
153
+		paragraphContent = paragraph.Text
154
+	}
155
+
156
+	this.ServeSuccessJSON(map[string]interface{}{
157
+		"activity": activity,
158
+		"paragraph": map[string]interface{}{
159
+			"title":   paragraphTitle,
160
+			"content": paragraphContent,
161
+		},
162
+	})
163
+}
164
+
165
+// /api/activity/submit [post]
166
+// @param publish:bool 是否发布
167
+// @data 如下格式
168
+/*
169
+{
170
+	id?:int
171
+	title:string
172
+	subtitle:string
173
+	poster_photo:string
174
+	address:string
175
+	limit_num?:int
176
+	sign_up_deadline:string ("yyyy-MM-dd HH:mm")
177
+	start_time:string ("yyyy-MM-dd HH:mm")
178
+	phone_number?:string
179
+	sign_up_notice?:string
180
+
181
+	paragraph: {
182
+		title:string
183
+		content:string
184
+	}
185
+}
186
+*/
187
+func (this *ActivityAPIController) ActivitySubmit() {
188
+	publish, _ := this.GetBool("publish")
189
+
190
+	var activityForm ActivityForm
191
+	parseErr := json.Unmarshal(this.Ctx.Input.RequestBody, &activityForm)
192
+	if parseErr != nil {
193
+		this.ErrorLog("解析 activity form 失败:%v", parseErr)
194
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
195
+		return
196
+	}
197
+
198
+	adminUserInfo := this.GetAdminUserInfo()
199
+	var activity *models.Activity
200
+	if activityForm.ID > 0 {
201
+		var getActivityErr error
202
+		activity, getActivityErr = marketing_tool_service.GetActivityWithID(adminUserInfo.CurrentOrgId, activityForm.ID)
203
+		if getActivityErr != nil {
204
+			this.ErrorLog("获取活动失败:%v", getActivityErr)
205
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
206
+			return
207
+		} else if activity == nil || activity.Status == 9 {
208
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeActivityNotExist)
209
+			return
210
+		}
211
+	}
212
+	if len(activityForm.Title) == 0 || len(activityForm.Subtitle) == 0 || len(activityForm.PosterPhoto) == 0 || len(activityForm.Address) == 0 || len(activityForm.SignUpDeadline) == 0 || len(activityForm.StartTime) == 0 {
213
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
214
+		return
215
+	}
216
+	timeFmt := "2006-01-02 15:04"
217
+	signUpDeadlineTime, parseSUDErr := utils.ParseTimeStringToTime(timeFmt, activityForm.SignUpDeadline)
218
+	if parseSUDErr != nil {
219
+		this.ErrorLog("解析报名截止时间失败:%v", parseSUDErr)
220
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
221
+		return
222
+	}
223
+	activityTime, parseActivityTimeErr := utils.ParseTimeStringToTime(timeFmt, activityForm.StartTime)
224
+	if parseActivityTimeErr != nil {
225
+		this.ErrorLog("解析活动开始时间失败:%v", parseActivityTimeErr)
226
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
227
+		return
228
+	}
229
+
230
+	if len(activityForm.PhoneNumber) > 0 {
231
+		if utils.PhoneRegexp().MatchString(activityForm.PhoneNumber) == false {
232
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
233
+			return
234
+		}
235
+	}
236
+	if activityForm.LimitNum < 0 {
237
+		activityForm.LimitNum = 0
238
+	}
239
+
240
+	if activity == nil {
241
+		activity = &models.Activity{
242
+			UserOrgId:        adminUserInfo.CurrentOrgId,
243
+			UserAppId:        adminUserInfo.CurrentAppId,
244
+			Title:            activityForm.Title,
245
+			Subtitle:         activityForm.Subtitle,
246
+			Address:          activityForm.Address,
247
+			SignUpDeadline:   signUpDeadlineTime.Unix(),
248
+			SignUpNotice:     activityForm.SignUpNotice,
249
+			StartTime:        activityTime.Unix(),
250
+			PosterPhoto:      activityForm.PosterPhoto,
251
+			PosterPhotoThumb: activityForm.PosterPhoto,
252
+			LimitNum:         activityForm.LimitNum,
253
+			PhoneNumber:      activityForm.PhoneNumber,
254
+			CreateTime:       time.Now().Unix(),
255
+		}
256
+	} else {
257
+		activity.Title = activityForm.Title
258
+		activity.Subtitle = activityForm.Subtitle
259
+		activity.Address = activityForm.Address
260
+		activity.SignUpDeadline = signUpDeadlineTime.Unix()
261
+		activity.SignUpNotice = activityForm.SignUpNotice
262
+		activity.StartTime = activityTime.Unix()
263
+		activity.PosterPhoto = activityForm.PosterPhoto
264
+		activity.PosterPhotoThumb = activityForm.PosterPhoto
265
+		activity.LimitNum = activityForm.LimitNum
266
+		activity.PhoneNumber = activityForm.PhoneNumber
267
+	}
268
+	activity.ModifyTime = time.Now().Unix()
269
+	if publish {
270
+		activity.Status = 1
271
+	} else {
272
+		activity.Status = 4
273
+	}
274
+
275
+	var paragraph *models.ActivityParagraph
276
+	if activity.Id > 0 {
277
+		var getPErr error
278
+		paragraph, getPErr = marketing_tool_service.GetActivityParagraphByActivityID(activity.Id)
279
+		if getPErr != nil {
280
+			this.ErrorLog("获取活动段落失败:%v", getPErr)
281
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
282
+			return
283
+		}
284
+	}
285
+	if len(activityForm.Paragraph.Title) > 0 {
286
+		if paragraph == nil {
287
+			paragraph = &models.ActivityParagraph{
288
+				Title:      activityForm.Paragraph.Title,
289
+				Text:       activityForm.Paragraph.Content,
290
+				Status:     1,
291
+				CreateTime: time.Now().Unix(),
292
+				ModifyTime: time.Now().Unix(),
293
+			}
294
+		} else {
295
+			paragraph.Title = activityForm.Paragraph.Title
296
+			paragraph.Text = activityForm.Paragraph.Content
297
+			paragraph.ModifyTime = time.Now().Unix()
298
+		}
299
+	} else {
300
+		if paragraph != nil {
301
+			paragraph.Status = 0
302
+			paragraph.ModifyTime = time.Now().Unix()
303
+		}
304
+	}
305
+
306
+	saveErr := marketing_tool_service.SaveActivityAndParagraph(activity, paragraph)
307
+	if saveErr != nil {
308
+		this.ErrorLog("保存活动失败:%v", saveErr)
309
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
310
+		return
311
+	}
312
+
313
+	wxShareModel, getWxShareErr := marketing_tool_service.GetActivityWxShareByActivityID(activity.Id)
314
+	if getWxShareErr != nil {
315
+		this.ErrorLog("获取活动微信分享信息失败:%v", getWxShareErr)
316
+	} else if wxShareModel != nil {
317
+		wxShareModel.ModifyTime = time.Now().Unix()
318
+		wxShareModel.Status = 1
319
+		wxShareModel.Title = activity.Title
320
+		wxShareModel.Subtitle = activity.Subtitle
321
+		wxShareModel.Image = activity.PosterPhoto
322
+		saveWxShareErr := marketing_tool_service.SaveActivityWxShare(wxShareModel)
323
+		if saveWxShareErr != nil {
324
+			this.ErrorLog("更新活动微信分享信息失败:%v", saveWxShareErr)
325
+		}
326
+	}
327
+
328
+	this.ServeSuccessJSON(map[string]interface{}{
329
+		"activity_id": activity.Id,
330
+	})
331
+}

+ 19 - 0
controllers/marketing_tool/activity_vms.go Wyświetl plik

@@ -0,0 +1,19 @@
1
+package marketing_tool
2
+
3
+type ActivityForm struct {
4
+	ID             int64  `json:"id"`
5
+	Title          string `json:"title"`
6
+	Subtitle       string `json:"subtitle"`
7
+	PosterPhoto    string `json:"poster_photo"`
8
+	Address        string `json:"address"`
9
+	LimitNum       int    `json:"limit_num"`
10
+	SignUpDeadline string `json:"sign_up_deadline"`
11
+	StartTime      string `json:"start_time"`
12
+	PhoneNumber    string `json:"phone_number"`
13
+	SignUpNotice   string `json:"sign_up_notice"`
14
+
15
+	Paragraph struct {
16
+		Title   string `json:"title"`
17
+		Content string `json:"content"`
18
+	} `json:"paragraph"`
19
+}

+ 4 - 202
enums/error_code.go Wyświetl plik

@@ -44,63 +44,9 @@ const ( // ErrorCode
44 44
 	ErrorCodeCannotRemoveRole       = 9006
45 45
 	ErrorCodeRoleMobileIsSuperAdmin = 9007
46 46
 
47
-	ErrorCodeGetQiniuUpToken                = 1001
48
-	ErrorCodeCreatePatient                  = 1002
49
-	ErrorCodeDialysisNoExist                = 1003
50
-	ErrorCodeIdCardNoExist                  = 1004
51
-	ErrorCodePatientNoExist                 = 1005
52
-	ErrorCodeUpdatePatient                  = 1006
53
-	ErrorCodeDialysisSolutionExist          = 1007
54
-	ErrorCodeDialysisSolutionCreate         = 1008
55
-	ErrorCodeDialysisSolutionUpdate         = 1009
56
-	ErrorCodeDialysisSolutionNotExist       = 1010
57
-	ErrorCodeParentDialysisSolutionNotExist = 1011
58
-	ErrorCodeAlReadyHadChildSolution        = 1012
59
-	ErrorCodeCanntCreateChildChildSolution  = 1013
60
-	ErrorCodeDialysisSolutionUsed           = 1014
61
-	ErrorCodeCreateDryWeightFail            = 1015
62
-	ErrorCodeCreateDoctorAdviceFail         = 1016
63
-	ErrorCodeDoctorAdviceNotExist           = 1017
64
-	ErrorCodeUpdateDoctorAdviceFail         = 1018
65
-	ErrorCodeLongTimeAdviceNotCanntEdit     = 1019
66
-	ErrorCodeAdviceStoped                   = 1020
67
-	ErrorCodeParentAdviceNotExist           = 1021
68
-	ErrorCodeStopAdviceFail                 = 1022
69
-	ErrorCodeDeleteAdviceFail               = 1023
70
-	ErrorCodeDialysisSolutionDelete         = 1024
71
-	ErrorCodeDeviceNumberNotTheZone         = 1025
72
-	ErrorCodeCreateScheduleFail             = 1026
73
-	ErrorCodeCantSetScheduleAgainOneDay     = 1027
74
-	ErrorCodeCantSetScheduleBeforeNow       = 1028
75
-	ErrorCodeScheduleNotExist               = 1029
76
-	ErrorCodeDeleteScheduleFail             = 1030
77
-	ErrorCodeChangeScheduleFail             = 1031
78
-	ErrorCodePatientPhoneUsed               = 1032
79
-	ErrorCodeAdviceExced                    = 1033
80
-	ErrorCodeAdviceChecked                  = 1034
81
-	ErrorCodePointScheduleExist             = 1035
82
-	ErrorCodeExceAndCheckNotOneUser         = 1036
83
-	ErrorCodeCanotEditOtherAdvice           = 1037
84
-	ErrorCodeEditLapsetoFail                = 1038
85
-	ErrorCodeAdviceCheckBeforeExce          = 1039
86
-	ErrorCodeAdviceExceBeforeStart          = 1040
87
-	ErrorCodeDelScheduleFailByDialysis      = 1041
88
-	ErrorCodeNotSelectLapsetoType           = 1042
89
-	ErrorCodeNotSelectLapsetoTime           = 1043
47
+	ErrorCodeActivityNotExist = 9100
90 48
 
91
-	ErrorCodeInspectionDateExit    = 1201
92
-	ErrorCodeInspectionAddFail     = 1202
93
-	ErrorCodeInspectionEditFail    = 1204
94
-	ErrorCodeInspectionDateNotExit = 1203
95
-	ErrorCodeInspectionDeleteFail  = 1205
96
-
97
-	ErrorCodeMonitorCreate                  = 1128
98
-	ErrorCodeMonitorNotExist                = 1129
99
-	ErrorCodeMonitorUpdate                  = 1130
100
-	ErrorDialysisOrderNoStart               = 1132
101
-	ErrorDialysisOrderNoEND                 = 1133
102
-	ErrorDialysisOrderRepeatStart           = 1134
103
-	ErrorCodeDialysisPermissionDeniedModify = 1135
49
+	ErrorCodeGetQiniuUpToken = 1001
104 50
 
105 51
 	ErrorCodeNotSubscibe       = 4003
106 52
 	ErrorCodeServeNotExist     = 4004
@@ -109,50 +55,6 @@ const ( // ErrorCode
109 55
 	ErrorCodeHetongHad         = 4007
110 56
 	ErrorCodeCreateHetongFail  = 4008
111 57
 	ErrorCodePatientReachLimit = 4009
112
-
113
-	ErrorCodeDeviceZoneNotExist                      = 9021
114
-	ErrorCodeDeviceZoneNameRepeat                    = 9022
115
-	ErrorCodeDeviceGroupNotExist                     = 9023
116
-	ErrorCodeDeviceGroupNameRepeat                   = 9024
117
-	ErrorCodeDeviceNumberNotExist                    = 9025
118
-	ErrorCodeDeviceNumberRepeat                      = 9026
119
-	ErrorCodeDeviceNotExist                          = 9027
120
-	ErrorCodeDeviceZoneCannotDisable                 = 9028
121
-	ErrorCodeDeviceNumberCannotDisableCuzDevice      = 9029
122
-	ErrorCodeDeviceNumberCannotDisableCuzSchedule    = 9030
123
-	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate = 9031
124
-
125
-	ErrorCommitFail = 90000
126
-
127
-	ErrorCodeCreateStockInFail = 20001
128
-
129
-	ErrorCodeScheduleTemplateNotExist = 10001
130
-
131
-	ErrorCodeSystemError  = 6666
132
-	ErrorCodeProductError = 6667
133
-	ErrorCodeFieldExist   = 100001
134
-	ErrorCodeCreateConfig = 100002
135
-	ErrorCodeUpdateConfig = 100003
136
-
137
-	ErrorCodeDoubleCheckWrong     = 200003
138
-	ErrorCodeDoubleCheckUserWrong = 200004
139
-	ErrorCodeGoodNoStockInError   = 200005
140
-	ErrorCodeCancelStockFail      = 200006
141
-	ErrorCodeDeleteGoodTypeFail   = 200007
142
-	ErrorCodeDeleteGoodInfoFail   = 200008
143
-	ErrorCodeDeleteFail           = 200009
144
-
145
-	ErrorCodeKeyFail                 = 200010
146
-	ErrorCodeDeleteStockInRecordFail = 200011
147
-	ErrorCodeNameWrong               = 200012
148
-
149
-	ErrorCodeParamEmptyWrong       = 200013
150
-	ErrorCodeParamAdviceEmptyWrong = 200014
151
-
152
-	ErrorCodeParamTemplateNOEXISTWrong = 200015
153
-
154
-	ErrorCodeDeleteDealerWrong       = 200016
155
-	ErrorCodeDeleteManufacturerWrong = 200017
156 58
 )
157 59
 
158 60
 var ErrCodeMsgs = map[int]string{
@@ -197,68 +99,9 @@ var ErrCodeMsgs = map[int]string{
197 99
 	ErrorCodeCannotRemoveRole:       "存在该角色的管理员,不能删除该角色",
198 100
 	ErrorCodeRoleMobileIsSuperAdmin: "该手机号已注册为超级管理员",
199 101
 
200
-	ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
201
-	ErrorCodeCreatePatient:   "创建患者失败",
202
-	ErrorCodeDialysisNoExist: "患者透析号重复!",
203
-	ErrorCodeIdCardNoExist:   "身份证号重复!",
204
-	ErrorCodePatientNoExist:  "患者信息不存在!",
205
-	ErrorCodeUpdatePatient:   "修改患者信息失败",
206
-
207
-	ErrorCodeDialysisSolutionExist:          "该处方已经存在",
208
-	ErrorCodeDialysisSolutionCreate:         "创建处方失败",
209
-	ErrorCodeDialysisSolutionUpdate:         "修改处方失败",
210
-	ErrorCodeDialysisSolutionNotExist:       "该处方不存在",
211
-	ErrorCodeParentDialysisSolutionNotExist: "上级处方不存在",
212
-	ErrorCodeAlReadyHadChildSolution:        "所选处方已经存在子方案",
213
-	ErrorCodeCanntCreateChildChildSolution:  "子方案不能添加子方案",
214
-	ErrorCodeDialysisSolutionUsed:           "处方已被使用,不能删除",
215
-	ErrorCodeCreateDryWeightFail:            "添加干体重失败",
216
-	ErrorCodeCreateDoctorAdviceFail:         "添加医嘱失败",
217
-	ErrorCodeUpdateDoctorAdviceFail:         "修改医嘱信息失败",
218
-	ErrorCodeDoctorAdviceNotExist:           "医嘱不存在",
219
-	ErrorCodeLongTimeAdviceNotCanntEdit:     "长期医嘱不能修改!",
220
-	ErrorCodeAdviceStoped:                   "所选医嘱已停止",
221
-	ErrorCodeParentAdviceNotExist:           "上级医嘱不存在",
222
-	ErrorCodeDeleteAdviceFail:               "删除医嘱失败",
223
-	ErrorCodeStopAdviceFail:                 "停止医嘱失败",
224
-	ErrorCodeDialysisSolutionDelete:         "删除方案失败",
225
-	ErrorCodeDeviceNumberNotTheZone:         "所选机号不在选择分区中",
226
-	ErrorCodeCreateScheduleFail:             "添加排班失败",
227
-	ErrorCodeCantSetScheduleAgainOneDay:     "同一天不可有两次排班",
228
-	ErrorCodeCantSetScheduleBeforeNow:       "不能给今天之前的日期排班",
229
-	ErrorCodeScheduleNotExist:               "排班不存在",
230
-	ErrorCodePointScheduleExist:             "所先位置排班已经存在",
231
-	ErrorCodeDeleteScheduleFail:             "取消排班失败",
232
-	ErrorCodeChangeScheduleFail:             "修改排班失败",
233
-	ErrorCodePatientPhoneUsed:               "手机号已经存在",
234
-	ErrorCodeAdviceExced:                    "医嘱已经执行",
235
-	ErrorCodeAdviceCheckBeforeExce:          "核对医嘱不能在执行医嘱之前",
236
-	ErrorCodeAdviceExceBeforeStart:          "执行医嘱不能在开始之前",
237
-	ErrorCodeAdviceChecked:                  "医嘱已经核对",
238
-	ErrorCodeExceAndCheckNotOneUser:         "核对与执行不能是同一人",
239
-	ErrorCodeCanotEditOtherAdvice:           "不能修改非本人添加的医嘱",
240
-	ErrorCodeEditLapsetoFail:                "转归失败",
241
-	ErrorCodeDelScheduleFailByDialysis:      "已经上机透析,不能取消排班",
242
-	ErrorCodeNotSelectLapsetoType:           "请选择转归状态",
243
-	ErrorCodeNotSelectLapsetoTime:           "请选择转归时间",
244
-
245
-	ErrorCodeInspectionDateExit:    "当天已经存在检验检查记录",
246
-	ErrorCodeInspectionAddFail:     "添加记录失败",
247
-	ErrorCodeInspectionDateNotExit: "当天不存在检验检查记录",
248
-	ErrorCodeInspectionEditFail:    "修改记录失败",
249
-	ErrorCodeInspectionDeleteFail:  "删除记录失败",
102
+	ErrorCodeActivityNotExist: "活动不存在",
250 103
 
251
-	ErrorCodeDeviceZoneNotExist:                      "设备分区不存在",
252
-	ErrorCodeDeviceZoneNameRepeat:                    "该分区名已存在",
253
-	ErrorCodeDeviceGroupNotExist:                     "设备分组不存在",
254
-	ErrorCodeDeviceGroupNameRepeat:                   "该分组名已存在",
255
-	ErrorCodeDeviceNumberNotExist:                    "机号不存在",
256
-	ErrorCodeDeviceNumberRepeat:                      "该机号已存在",
257
-	ErrorCodeDeviceNotExist:                          "该设备不存在",
258
-	ErrorCodeDeviceZoneCannotDisable:                 "该分区存在床位号,不能删除",
259
-	ErrorCodeDeviceNumberCannotDisableCuzDevice:      "该床位存在设备,不能删除",
260
-	ErrorCodeDeviceNumberCannotDisableCuzSchedule:    "该床位尚有排班安排,不能删除",
261
-	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate: "排班模板在该床位尚有排班安排,不能删除",
104
+	ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
262 105
 
263 106
 	ErrorCodeNotSubscibe:       "没有订阅服务或服务已过期,请先购买服务!",
264 107
 	ErrorCodeServeNotExist:     "服务订单不存在!",
@@ -267,47 +110,6 @@ var ErrCodeMsgs = map[int]string{
267 110
 	ErrorCodeHetongHad:         "合同已经存在!",
268 111
 	ErrorCodeCreateHetongFail:  "合同创建失败",
269 112
 	ErrorCodePatientReachLimit: "患者数已达到当前服务版本病人数,需要升级到更高的版本",
270
-
271
-	ErrorCodeMonitorCreate:                  "创建监测失败",
272
-	ErrorCodeMonitorNotExist:                "监测记录不存在",
273
-	ErrorCodeMonitorUpdate:                  "修改监测失败",
274
-	ErrorCodeDialysisPermissionDeniedModify: "您没有权限修改其他医护的数据!",
275
-
276
-	ErrorDialysisOrderNoStart:     "尚未上机,无法执行下机操作",
277
-	ErrorDialysisOrderNoEND:       "已处于下机状态",
278
-	ErrorDialysisOrderRepeatStart: "已上机",
279
-	//ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
280
-
281
-	ErrorCodeSystemError:              "系统异常",
282
-	ErrorCodeProductError:             "该服务商品已丢失",
283
-	ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
284
-
285
-	ErrorCodeCreateStockInFail: "入库失败",
286
-	//ErrorCodeSystemError:  "系统异常",
287
-	//ErrorCodeProductError: "该服务商品已丢失",
288
-	ErrorCodeFieldExist:   "配置字段已存在",
289
-	ErrorCodeCreateConfig: "创建配置失败",
290
-	ErrorCodeUpdateConfig: "修改配置失败",
291
-
292
-	ErrorCommitFail:               "提交失败",
293
-	ErrorCodeDoubleCheckWrong:     "核对已完成, 无法再次提交",
294
-	ErrorCodeDoubleCheckUserWrong: "你已完成核对,不能重复核对",
295
-	ErrorCodeGoodNoStockInError:   "该商品尚未入库",
296
-
297
-	ErrorCodeCancelStockFail:    "出库退库失败",
298
-	ErrorCodeDeleteGoodTypeFail: "该类型存在商品信息,无法删除",
299
-	ErrorCodeDeleteGoodInfoFail: "该商品已经入库无法删除",
300
-
301
-	ErrorCodeDeleteFail: "删除失败",
302
-
303
-	ErrorCodeKeyFail:                 "关键字不能为空",
304
-	ErrorCodeDeleteStockInRecordFail: "该记录已经有出库或退货操作,无法删除",
305
-	ErrorCodeNameWrong:               "该模版名字已存在",
306
-	ErrorCodeParamEmptyWrong:         "模版名称不能为空",
307
-	ErrorCodeParamAdviceEmptyWrong:   "医嘱名称不能为空",
308
-
309
-	ErrorCodeDeleteDealerWrong:       "该经销商所属商品已入库无法删除",
310
-	ErrorCodeDeleteManufacturerWrong: "该厂商所属商品已入库无法删除",
311 113
 }
312 114
 
313 115
 type SGJError struct {

+ 11 - 11
models/activity_models.go Wyświetl plik

@@ -2,7 +2,7 @@ package models
2 2
 
3 3
 // 表
4 4
 type Activity struct {
5
-	Id               int    `gorm:"column:id" json:"id"`                                 // 活动 ID
5
+	Id               int64  `gorm:"column:id" json:"id"`                                 // 活动 ID
6 6
 	Title            string `json:"title"`                                               // 活动标题
7 7
 	Subtitle         string `json:"subtitle"`                                            // 活动副标题
8 8
 	CityId           int    `gorm:"column:city_id" json:"city_id"`                       // 活动地点 ID
@@ -24,8 +24,8 @@ type Activity struct {
24 24
 	IsRecommend      int8   `gorm:"column:is_recommend;" json:"is_recommend"`            // 0:未推荐;1:已推荐
25 25
 	CreateTime       int64  `gorm:"column:ctime" json:"-"`                               // 创建时间
26 26
 	ModifyTime       int64  `gorm:"column:mtime" json:"-"`                               // 修改时间
27
-	UserOrgId        int    `gorm:"column:user_org_id" json:"-"`                         // 所属发布机构 ID
28
-	UserAppId        int    `gorm:"column:user_app_id" json:"-"`                         // 所属发布应用 ID
27
+	UserOrgId        int64  `gorm:"column:user_org_id" json:"-"`                         // 所属发布机构 ID
28
+	UserAppId        int64  `gorm:"column:user_app_id" json:"-"`                         // 所属发布应用 ID
29 29
 	CommentNum       int    `gorm:"column:comment_num;" json:"comment_num"`              // 评论数
30 30
 	StarNum          int    `gorm:"column:star_num" json:"star_num"`                     // 点赞书
31 31
 	ReadNum          int    `gorm:"column:read_num;" json:"read_num"`                    // 阅读数
@@ -36,14 +36,14 @@ func (Activity) TableName() string {
36 36
 }
37 37
 
38 38
 type ActivityParagraph struct {
39
-	Id         int `gorm:"PRIMARY_KEY;AUTO_INCREMENT"` // 记录 ID
40
-	ActivityId int `gorm:"column:activity_id"`         // 活动 ID
41
-	Title      string
42
-	Text       string
43
-	Image      string
44
-	Status     int8  // 状态 0.无效 1.有效
45
-	CreateTime int64 `gorm:"column:ctime"` // 创建时间
46
-	ModifyTime int64 `gorm:"column:mtime"` // 修改时间
39
+	Id         int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`  // 记录 ID
40
+	ActivityId int64  `gorm:"column:activity_id" json:"activity_id"` // 活动 ID
41
+	Title      string `json:"title"`
42
+	Text       string `json:"text"`
43
+	// Image      string `json:"image"` // 该字段实际上已经没用了
44
+	Status     int8  `json:"-"`                     // 状态 0.无效 1.有效
45
+	CreateTime int64 `gorm:"column:ctime" json:"-"` // 创建时间
46
+	ModifyTime int64 `gorm:"column:mtime" json:"-"` // 修改时间
47 47
 }
48 48
 
49 49
 func (ActivityParagraph) TableName() string {

+ 76 - 0
service/marketing_tool_service/activity_service.go Wyświetl plik

@@ -4,6 +4,8 @@ import (
4 4
 	"SCRM/models"
5 5
 	"SCRM/service"
6 6
 	"time"
7
+
8
+	"github.com/jinzhu/gorm"
7 9
 )
8 10
 
9 11
 func GetValidActivities(orgID int64, appID int64, keyWord string, page int, count int) ([]*models.Activity, int64, error) {
@@ -88,3 +90,77 @@ func GetDidEndedActivities(orgID int64, appID int64, keyWord string, page int, c
88 90
 		return nil, 0, err
89 91
 	}
90 92
 }
93
+
94
+func GetActivityWithID(orgID int64, activityID int64) (*models.Activity, error) {
95
+	var activity models.Activity
96
+	err := service.PatientReadDB().Model(&models.Activity{}).Where("user_org_id = ? and id = ?", orgID, activityID).First(&activity).Error
97
+	if err != nil {
98
+		if err == gorm.ErrRecordNotFound {
99
+			return nil, nil
100
+		} else {
101
+			return nil, err
102
+		}
103
+	}
104
+	return &activity, nil
105
+}
106
+
107
+func GetActivityParagraphByActivityID(activityID int64) (*models.ActivityParagraph, error) {
108
+	var paragraph models.ActivityParagraph
109
+	err :=
110
+		service.PatientReadDB().Model(&models.ActivityParagraph{}).
111
+			Where("activity_id = ? and status = 1", activityID).
112
+			First(&paragraph).
113
+			Error
114
+	if err != nil {
115
+		if err == gorm.ErrRecordNotFound {
116
+			return nil, nil
117
+		} else {
118
+			return nil, err
119
+		}
120
+	}
121
+	return &paragraph, nil
122
+}
123
+
124
+func GetActivityWxShareByActivityID(activityID int64) (*models.ActivityWxShare, error) {
125
+	var model models.ActivityWxShare
126
+	err :=
127
+		service.PatientReadDB().Model(&models.ActivityWxShare{}).
128
+			Where("activity_id = ?", activityID).
129
+			First(&model).
130
+			Error
131
+	if err != nil {
132
+		if err == gorm.ErrRecordNotFound {
133
+			return nil, nil
134
+		} else {
135
+			return nil, err
136
+		}
137
+	}
138
+	return &model, nil
139
+}
140
+
141
+func SaveActivityAndParagraph(activity *models.Activity, paragraph *models.ActivityParagraph) error {
142
+	tx := service.PatientWriteDB().Begin()
143
+	saveActivityErr := tx.Save(activity).Error
144
+	if saveActivityErr != nil {
145
+		tx.Rollback()
146
+		return saveActivityErr
147
+	}
148
+	if paragraph != nil {
149
+		if paragraph.Id == 0 {
150
+			paragraph.ActivityId = activity.Id
151
+		}
152
+
153
+		saveParagraphErr := tx.Save(paragraph).Error
154
+		if saveParagraphErr != nil {
155
+			tx.Rollback()
156
+			return saveParagraphErr
157
+		}
158
+	}
159
+
160
+	tx.Commit()
161
+	return nil
162
+}
163
+
164
+func SaveActivityWxShare(model *models.ActivityWxShare) error {
165
+	return service.PatientWriteDB().Save(model).Error
166
+}