zjxpcyc 6 years ago
parent
commit
95016217cf
81 changed files with 2501 additions and 3575 deletions
  1. 1
    0
      conf/app.conf
  2. 1
    1
      conf/log.conf
  3. 174
    0
      controllers/card/card.go
  4. 22
    0
      controllers/cases/signin.go
  5. 11
    0
      controllers/coupon/coupon.go
  6. 5
    1
      controllers/customer/customer.go
  7. 6
    6
      controllers/gymcard/gymcard.go
  8. 8
    6
      controllers/marketing/marketing.go
  9. 66
    2
      controllers/user/user.go
  10. 45
    3062
      log/common.log
  11. 35
    0
      models/bodychecklist/bodychecklist.go
  12. 276
    0
      models/card/card.go
  13. 42
    0
      models/card/image.go
  14. 44
    0
      models/card/share.go
  15. 42
    0
      models/card/target.go
  16. 7
    0
      models/cases/cases.go
  17. 13
    3
      models/cases/signin.go
  18. 14
    0
      models/constant.go
  19. 79
    7
      models/coupon/coupon.go
  20. 3
    2
      models/coupon/image.go
  21. 3
    3
      models/coupon/target.go
  22. 1
    2
      models/coupon/types.go
  23. 27
    4
      models/customer/customer.go
  24. 17
    0
      models/goods/goods.go
  25. 12
    0
      models/goods/orders.go
  26. 4
    1
      models/goods/spec.go
  27. 1
    1
      models/goods/type.go
  28. 45
    7
      models/gymcard/gymcard.go
  29. 14
    14
      models/marketing/marketing.go
  30. 3
    2
      models/marketing/work.go
  31. 15
    15
      models/model/sys_activity.go
  32. 6
    3
      models/model/sys_case_record.go
  33. 1
    1
      models/model/sys_wechat_conf.go
  34. 15
    0
      models/model/ta_body_check.go
  35. 9
    0
      models/model/ta_card_coupon_channel.go
  36. 13
    0
      models/model/ta_case_equipment.go
  37. 13
    16
      models/model/ta_checkin_record.go
  38. 20
    20
      models/model/ta_coupon.go
  39. 17
    20
      models/model/ta_coupon_card.go
  40. 0
    2
      models/model/ta_coupon_card_target.go
  41. 3
    1
      models/model/ta_coupon_give_record.go
  42. 1
    1
      models/model/ta_coupon_target.go
  43. 1
    1
      models/model/ta_course_orders_coupon.go
  44. 1
    1
      models/model/ta_customer_account.go
  45. 1
    1
      models/model/ta_customer_course.go
  46. 1
    0
      models/model/ta_customer_gym.go
  47. 9
    0
      models/model/ta_experience_card_image.go
  48. 10
    0
      models/model/ta_experience_card_share.go
  49. 0
    14
      models/model/ta_experience_card_verification.go
  50. 1
    0
      models/model/ta_forbid_user.go
  51. 2
    2
      models/model/ta_goods_orders.go
  52. 20
    0
      models/model/ta_luckdraw.go
  53. 21
    0
      models/model/ta_luckdraw_prize.go
  54. 20
    0
      models/model/ta_luckdraw_record.go
  55. 16
    0
      models/model/ta_luckdraw_writeoff.go
  56. 14
    0
      models/model/ta_presentation.go
  57. 10
    0
      models/model/ta_presentation_detail.go
  58. 14
    0
      models/model/ta_prize_detail.go
  59. 22
    0
      models/model/ta_share_lucky_record.go
  60. 25
    0
      models/model/ta_statistics_card_coupon_usage.go
  61. 8
    0
      models/model/td_check_spec.go
  62. 6
    0
      models/model/td_check_type.go
  63. 0
    7
      models/model/td_coupon_type.go
  64. 1
    1
      models/model/td_goods_type.go
  65. 8
    0
      models/model/td_luckdraw_theme.go
  66. 10
    5
      models/model/td_spec.go
  67. 11
    0
      models/model/td_wechat_conf.go
  68. 109
    8
      models/system/user.go
  69. 267
    249
      routers/common.go
  70. 49
    32
      routers/wechat.go
  71. 276
    0
      service/card/card.go
  72. 62
    1
      service/cases/signin.go
  73. 59
    9
      service/coupon/coupon.go
  74. 2
    2
      service/customer/customer.go
  75. 9
    1
      service/goods/spec.go
  76. 9
    1
      service/goods/type.go
  77. 45
    22
      service/gymcard/gymcard.go
  78. 6
    4
      service/marketing/marketing.go
  79. 1
    2
      service/marketing/work.go
  80. 236
    7
      service/user.go
  81. 5
    2
      service/verify/verify.go

+ 1
- 0
conf/app.conf View File

6
 EnableDocs = true
6
 EnableDocs = true
7
 sessionon = true
7
 sessionon = true
8
 excelpath = ./
8
 excelpath = ./
9
+clienturl = http://dev.ycjcjy.com/c-v2
9
 
10
 
10
 
11
 
11
 [cros]
12
 [cros]

+ 1
- 1
conf/log.conf View File

1
 [common]
1
 [common]
2
-filename="E:\\GoProjects\\src\\spaceofcheng\\services\\log\\common.log"
2
+filename="E:\\GoProject\\src\\spaceofcheng\\services\\log\\common.log"
3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
4
 level="debug"
4
 level="debug"

+ 174
- 0
controllers/card/card.go View File

1
+package card
2
+
3
+import (
4
+	"encoding/json"
5
+	"errors"
6
+	"net/http"
7
+	"spaceofcheng/services/controllers"
8
+	cardModel "spaceofcheng/services/models/card"
9
+	"spaceofcheng/services/service/card"
10
+	"spaceofcheng/services/utils"
11
+	"strings"
12
+)
13
+
14
+// CardController 商品
15
+type CardController struct {
16
+	serv *card.CardServ
17
+	controllers.BaseController
18
+}
19
+
20
+// Constructor 初始化 Controller
21
+// @Title Constructor
22
+// @Description 初始化 Controller, 系统自动调用
23
+func (c *CardController) Constructor() {
24
+	c.serv = card.NewCardServ(c.Context)
25
+}
26
+
27
+// ListByCase 获取卡列表
28
+func (c *CardController) ListByCase() {
29
+	caseid := c.GetString("caseid")
30
+	page, _ := c.GetInt("page")
31
+	pagesize, _ := c.GetInt("pagesize")
32
+	if page < 0 {
33
+		page = 1
34
+	}
35
+
36
+	if pagesize <= 0 {
37
+		pagesize = 10
38
+	}
39
+
40
+	list, total, err := c.serv.GetCardList(caseid, page, pagesize)
41
+	if err != nil {
42
+		c.ResponseError(err)
43
+	}
44
+
45
+	c.ResponseJSON(map[string]interface{}{
46
+		"list":     list,
47
+		"page":     page,
48
+		"pagesize": pagesize,
49
+		"pagenum":  total,
50
+	})
51
+}
52
+
53
+// GetCardByIDForAdmin 获取卡
54
+// 管理端
55
+func (c *CardController) GetCardByIDForAdmin() {
56
+	id := c.GetString(":id")
57
+	if id == "" {
58
+		c.ResponseError(errors.New("未指定卡"))
59
+	}
60
+
61
+	card, err := c.serv.GetCardByIDWithCheck(id)
62
+	if err != nil {
63
+		c.ResponseError(err)
64
+	}
65
+
66
+	c.ResponseJSON(map[string]interface{}{
67
+		"Card": card,
68
+	})
69
+}
70
+
71
+// GetCardByID 获取卡
72
+// 微信端
73
+func (c *CardController) GetCardByID() {
74
+	id := c.GetString(":id")
75
+	if id == "" {
76
+		c.ResponseError(errors.New("未指定卡"))
77
+	}
78
+
79
+	card, err := c.serv.GetCardByID(id)
80
+	if err != nil {
81
+		c.ResponseError(err)
82
+	}
83
+
84
+	c.ResponseJSON(map[string]interface{}{
85
+		"Card": card,
86
+	})
87
+}
88
+
89
+// GetMyCard 获取我的卡券
90
+// 微信端
91
+func (c *CardController) GetMyCard() {
92
+
93
+}
94
+
95
+// SaveCard 保存卡
96
+func (c *CardController) SaveCard() {
97
+	jsnStr := c.GetString("info")
98
+	if jsnStr == "" {
99
+		c.ResponseError(errors.New("未接收到保存内容"))
100
+	}
101
+
102
+	card := cardModel.CardInfo{}
103
+
104
+	if err := json.Unmarshal([]byte(jsnStr), &card); err != nil {
105
+		utils.LogError("接收卡信息失败: " + err.Error())
106
+		c.ResponseError(errors.New("接收参数失败"), http.StatusInternalServerError)
107
+	}
108
+
109
+	// TODO
110
+	// 校验各字段不能为空
111
+
112
+	// 入库
113
+	card.CardId = ""
114
+	if err := c.serv.SaveCard(&card); err != nil {
115
+		c.ResponseError(err)
116
+	}
117
+
118
+	c.ResponseJSON(map[string]interface{}{
119
+		"Card": card,
120
+	})
121
+}
122
+
123
+// UpdateCard 更新卡
124
+func (c *CardController) UpdateCard() {
125
+	jsnStr := c.GetString("info")
126
+	if jsnStr == "" {
127
+		c.ResponseError(errors.New("未接收到更新内容"))
128
+	}
129
+
130
+	id := c.GetString(":id")
131
+	if id == "" {
132
+		c.ResponseError(errors.New("未指定卡"))
133
+	}
134
+
135
+	card := cardModel.CardInfo{}
136
+
137
+	if err := json.Unmarshal([]byte(jsnStr), &card); err != nil {
138
+		utils.LogError("接收卡信息失败: " + err.Error())
139
+		c.ResponseError(errors.New("接收参数失败"), http.StatusInternalServerError)
140
+	}
141
+
142
+	// TODO
143
+	// 校验各字段不能为空
144
+
145
+	// 入库
146
+	card.CardId = id
147
+	if err := c.serv.UpdateCard(&card); err != nil {
148
+		c.ResponseError(err)
149
+	}
150
+
151
+	c.ResponseJSON(map[string]interface{}{
152
+		"Card": card,
153
+	})
154
+}
155
+
156
+// GiveCard 赠送卡
157
+func (c *CardController) GiveCard() {
158
+	id := c.GetString(":id")
159
+	if id == "" {
160
+		c.ResponseError(errors.New("未指定卡"))
161
+	}
162
+
163
+	uids := c.GetString(":users")
164
+	if uids == "" {
165
+		c.ResponseError(errors.New("未指定赠送人"))
166
+	}
167
+
168
+	err := c.serv.GiveCard(id, strings.Split(uids, ","))
169
+	if err != nil {
170
+		c.ResponseError(err)
171
+	}
172
+
173
+	c.ResponseJSON("ok")
174
+}

+ 22
- 0
controllers/cases/signin.go View File

42
 
42
 
43
 	c.ResponseJSON(res)
43
 	c.ResponseJSON(res)
44
 }
44
 }
45
+
46
+// AddSignin 存入签到记录
47
+func (c *SigninController) AddSignin() {
48
+	phone := c.GetString("phone");
49
+	openId := c.GetString("openId")
50
+	caseId := c.GetString("caseId")
51
+	activityId := c.GetString("activityId")
52
+
53
+	signin := model.TaCheckinRecord{}
54
+	signin.Phone = phone
55
+	signin.OpenId = openId
56
+
57
+	userMapping := c.Context.Get("userMap").(model.TaUserMapping)
58
+
59
+	res,err := c.dao.AddSignin(signin,caseId,activityId,&userMapping)
60
+
61
+	if err != nil {
62
+		c.ResponseError(err)
63
+	}
64
+	c.ResponseJSON(res)
65
+}
66
+

+ 11
- 0
controllers/coupon/coupon.go View File

167
 
167
 
168
 	c.ResponseJSON("ok")
168
 	c.ResponseJSON("ok")
169
 }
169
 }
170
+
171
+// GetCouponBySendType 根据类型获取优惠券
172
+func (c *CouponController) GetCouponBySendType() {
173
+	sendtype := c.GetString(":type")
174
+	coupons, err := c.serv.GetCouponBySendType(sendtype)
175
+	if err != nil {
176
+		c.ResponseError(err)
177
+	}
178
+
179
+	c.ResponseJSON(coupons)
180
+}

+ 5
- 1
controllers/customer/customer.go View File

25
 // CustWXList 获取客户列表
25
 // CustWXList 获取客户列表
26
 func (c *CustomerController) CustWXList() {
26
 func (c *CustomerController) CustWXList() {
27
 	phone := c.GetString("phone")
27
 	phone := c.GetString("phone")
28
+	username := c.GetString("username")
29
+	recommendname := c.GetString("recommendname")
30
+	begindate := c.GetString("begindate")
31
+	enddate := c.GetString("enddate")
28
 	page, _ := c.GetInt("page")
32
 	page, _ := c.GetInt("page")
29
 	pageSize, _ := c.GetInt("pagesize")
33
 	pageSize, _ := c.GetInt("pagesize")
30
 
34
 
31
-	custList, total, err := c.serv.GetCustWithWXList(phone, page, pageSize)
35
+	custList, total, err := c.serv.GetCustWithWXList(phone, username, recommendname, begindate, enddate, page, pageSize)
32
 	if err != nil {
36
 	if err != nil {
33
 		utils.LogError("获取客户列表失败: " + err.Error())
37
 		utils.LogError("获取客户列表失败: " + err.Error())
34
 		c.ResponseError(
38
 		c.ResponseError(

+ 6
- 6
controllers/gymcard/gymcard.go View File

49
 
49
 
50
 // GetGymcardDetailbyId 根据游泳健身卡ID获取游泳健身卡详情
50
 // GetGymcardDetailbyId 根据游泳健身卡ID获取游泳健身卡详情
51
 func (c *GymcardController) GetGymcardDetailbyId() {
51
 func (c *GymcardController) GetGymcardDetailbyId() {
52
-	id := c.GetString("gymcardId")
52
+	id := c.GetString(":gymcardId")
53
 	gymcard, err := c.dao.GetGymcardDetailById(id)
53
 	gymcard, err := c.dao.GetGymcardDetailById(id)
54
 	if err != nil {
54
 	if err != nil {
55
 		c.ResponseError(err)
55
 		c.ResponseError(err)
59
 
59
 
60
 // GetCustomerGymDetailById 根据客户健身卡ID获取客户健身卡详情
60
 // GetCustomerGymDetailById 根据客户健身卡ID获取客户健身卡详情
61
 func (c *GymcardController) GetCustomerGymDetailById() {
61
 func (c *GymcardController) GetCustomerGymDetailById() {
62
-	id := c.GetString("customerGymId")
62
+	id := c.GetString(":customerGymId")
63
 	customerGym, err := c.dao.GetCustomerGymDetailById(id)
63
 	customerGym, err := c.dao.GetCustomerGymDetailById(id)
64
 	if err != nil {
64
 	if err != nil {
65
 		c.ResponseError(err)
65
 		c.ResponseError(err)
69
 
69
 
70
 // GetCustomerGymByPhone 根据客户手机获取客户可用的游泳健身卡
70
 // GetCustomerGymByPhone 根据客户手机获取客户可用的游泳健身卡
71
 func (c *GymcardController) GetCustomerGymByPhone() {
71
 func (c *GymcardController) GetCustomerGymByPhone() {
72
-	phone := c.GetString("phone")
72
+	phone := c.GetString(":phone")
73
 	customerGym, err := c.dao.GetCustomerGymByPhone(phone)
73
 	customerGym, err := c.dao.GetCustomerGymByPhone(phone)
74
 	if err != nil {
74
 	if err != nil {
75
 		c.ResponseError(err)
75
 		c.ResponseError(err)
92
 
92
 
93
 // SendGymToCustomer 客户领卡
93
 // SendGymToCustomer 客户领卡
94
 func (c *GymcardController) SendGymToCustomer() {
94
 func (c *GymcardController) SendGymToCustomer() {
95
-	gymcardId := c.GetString("gymcardId")
96
-	sysuserId := c.GetString("sysuserId")
95
+	gymcardId := c.GetString(":gymcardId")
96
+	sysuserId := c.GetString(":sysuserId")
97
 	customerGym, err := c.dao.SendGymCardToUser(gymcardId, sysuserId)
97
 	customerGym, err := c.dao.SendGymCardToUser(gymcardId, sysuserId)
98
 	if err != nil {
98
 	if err != nil {
99
 		c.ResponseError(err)
99
 		c.ResponseError(err)
105
 func (c *GymcardController) VerifyCustomerGymcard() {
105
 func (c *GymcardController) VerifyCustomerGymcard() {
106
 	cases := c.Context.Get("cases").([]model.SysUserCase)
106
 	cases := c.Context.Get("cases").([]model.SysUserCase)
107
 	caseids := c.GetCaseIDs(cases)
107
 	caseids := c.GetCaseIDs(cases)
108
-	customerGymId := c.GetString("customerGymId")
108
+	customerGymId := c.GetString(":customerGymId")
109
 	err := c.dao.UpdateCustomerGym(customerGymId, caseids)
109
 	err := c.dao.UpdateCustomerGym(customerGymId, caseids)
110
 	if err != nil {
110
 	if err != nil {
111
 		c.ResponseError(err)
111
 		c.ResponseError(err)

+ 8
- 6
controllers/marketing/marketing.go View File

23
 // 获取 营销活动列表
23
 // 获取 营销活动列表
24
 func (c *MarketingController) GetMarketingList(){
24
 func (c *MarketingController) GetMarketingList(){
25
 	page, _ := c.GetInt("page")
25
 	page, _ := c.GetInt("page")
26
-	pageSize, _ := c.GetInt("pagesize")
26
+	pageSize, _ := c.GetInt("pageSize")
27
 
27
 
28
 	marketings, err := c.serv.GetMarketingList(page,pageSize)
28
 	marketings, err := c.serv.GetMarketingList(page,pageSize)
29
 	if err != nil {
29
 	if err != nil {
36
 // SaveMarketing 保存营销活动
36
 // SaveMarketing 保存营销活动
37
 func (c *MarketingController) SaveMarketing() {
37
 func (c *MarketingController) SaveMarketing() {
38
 	marketing := model.SysActivity{}
38
 	marketing := model.SysActivity{}
39
-
39
+	// 机构
40
+	//org := c.Context.Get("org").([]model.SysOrg)
40
 	// 获取值
41
 	// 获取值
41
 	activityName := c.GetString("activityName")
42
 	activityName := c.GetString("activityName")
42
 	activityType := c.GetString("activityType")
43
 	activityType := c.GetString("activityType")
43
 	resourceDesc := c.GetString("resourceDesc") // 活动描述
44
 	resourceDesc := c.GetString("resourceDesc") // 活动描述
45
+	caseId := c.GetString("CaseId")
44
 
46
 
45
 	// 赋值
47
 	// 赋值
46
 	marketing.ActivityName = activityName
48
 	marketing.ActivityName = activityName
47
 	marketing.ActivityType = activityType
49
 	marketing.ActivityType = activityType
48
 
50
 
49
-	newInfo,_, err := c.serv.SaveMarketing(marketing,resourceDesc)
51
+	newInfo,_, err := c.serv.SaveMarketing(marketing,resourceDesc,caseId)
50
 	if err != nil {
52
 	if err != nil {
51
 		c.ResponseError(err)
53
 		c.ResponseError(err)
52
 	}
54
 	}
88
 
90
 
89
 // DelMarketing 删除
91
 // DelMarketing 删除
90
 func (c *MarketingController) DelMarketing(){
92
 func (c *MarketingController) DelMarketing(){
91
-	activityId := c.GetString("activityId")
93
+	activityId := c.GetString(":activityId")
92
 	err := c.serv.DelMarketing(activityId)
94
 	err := c.serv.DelMarketing(activityId)
93
 	if err != nil {
95
 	if err != nil {
94
 		c.ResponseError(err)
96
 		c.ResponseError(err)
98
 
100
 
99
 // DelMarketing 正常
101
 // DelMarketing 正常
100
 func (c *MarketingController) DelMarketingNormal(){
102
 func (c *MarketingController) DelMarketingNormal(){
101
-	activityId := c.GetString("activityId")
103
+	activityId := c.GetString(":activityId")
102
 	err := c.serv.DelMarketingNormal(activityId)
104
 	err := c.serv.DelMarketingNormal(activityId)
103
 	if err != nil {
105
 	if err != nil {
104
 		c.ResponseError(err)
106
 		c.ResponseError(err)
108
 
110
 
109
 // DelMarketing 停用
111
 // DelMarketing 停用
110
 func (c *MarketingController) DelMarketingDisable(){
112
 func (c *MarketingController) DelMarketingDisable(){
111
-	activityId := c.GetString("activityId")
113
+	activityId := c.GetString(":activityId")
112
 	err := c.serv.DelMarketingDisable(activityId)
114
 	err := c.serv.DelMarketingDisable(activityId)
113
 	if err != nil {
115
 	if err != nil {
114
 		c.ResponseError(err)
116
 		c.ResponseError(err)

+ 66
- 2
controllers/user/user.go View File

137
 
137
 
138
 // GetUserCustomer 我的推荐客户
138
 // GetUserCustomer 我的推荐客户
139
 func (c *UserController) GetUserCustomer() {
139
 func (c *UserController) GetUserCustomer() {
140
-	userid := c.GetString(":userid")
140
+	customer := c.Context.Get("customer").(model.TaCustomer)
141
+	if customer.UserId == "" {
142
+		c.ResponseError(errors.New("无法获取推荐客户信息!"))
143
+	}
141
 	page, _ := c.GetInt("page")
144
 	page, _ := c.GetInt("page")
142
 	pageSize, _ := c.GetInt("pagesize")
145
 	pageSize, _ := c.GetInt("pagesize")
143
-	customers, err := c.dao.GetUserCustomer(userid, page, pageSize)
146
+	isrecommend := c.GetString("isrecommend")
147
+	customers, err := c.dao.GetUserCustomer(customer.UserId, isrecommend, page, pageSize)
144
 	if err != nil {
148
 	if err != nil {
145
 		c.ResponseError(err)
149
 		c.ResponseError(err)
146
 	}
150
 	}
244
 	}
248
 	}
245
 	c.ResponseJSON(user)
249
 	c.ResponseJSON(user)
246
 }
250
 }
251
+
252
+// GetForbidUsers 获取所有禁止人员信息
253
+func (c *UserController) GetForbidUsers() {
254
+	// caseid := c.GetString("caseid")
255
+	// if caseid == "" {
256
+	// 	c.ResponseError(errors.New("没有案场信息"))
257
+	// }
258
+	users, err := c.dao.GetForbidUsers()
259
+	if err != nil {
260
+		utils.LogError("获取禁止人员信息失败: " + err.Error())
261
+		c.ResponseError(errors.New("获取禁止人员信息失败"))
262
+	}
263
+	c.ResponseJSON(users)
264
+}
265
+
266
+// SaveForbidUser 保存禁止人员信息
267
+func (c *UserController) SaveForbidUser() {
268
+	userid := c.GetString(":userid")
269
+	forbidtype := c.GetString(":type")
270
+	err := c.dao.SaveForbidUser(userid, forbidtype)
271
+	if err != nil {
272
+		utils.LogError("保存禁止人员信息失败: " + err.Error())
273
+		c.ResponseError(errors.New("保存禁止人员信息失败"))
274
+	}
275
+	c.ResponseJSON("操作成功")
276
+}
277
+
278
+// OpenForbidUser 开启禁止人员
279
+func (c *UserController) OpenForbidUser() {
280
+	userid := c.GetString(":userid")
281
+	forbidtype := c.GetString(":type")
282
+	err := c.dao.OpenForbidUser(userid, forbidtype)
283
+	if err != nil {
284
+		utils.LogError("开启禁止人员信息失败: " + err.Error())
285
+		c.ResponseError(errors.New("开启禁止人员信息失败"))
286
+	}
287
+	c.ResponseJSON("操作成功")
288
+}
289
+
290
+// GetCaseUserByType 根据用户类型获取用户信息
291
+func (c *UserController) GetCaseUserByType() {
292
+	usertype := c.GetString(":type")
293
+	users, err := c.dao.GetCaseUserByType(usertype)
294
+	if err != nil {
295
+		utils.LogError("获取人员信息失败: " + err.Error())
296
+		c.ResponseError(errors.New("获取人员信息失败"))
297
+	}
298
+	c.ResponseJSON(users)
299
+}
300
+
301
+// GetCaseUserByID 根据id获取用户详情
302
+func (c *UserController) GetCaseUserByID() {
303
+	userid := c.GetString(":id")
304
+	userdetail, err := c.dao.GetCaseUserByUserID(userid)
305
+	if err != nil {
306
+		utils.LogError("获取人员信息失败: " + err.Error())
307
+		c.ResponseError(errors.New("获取人员信息失败"))
308
+	}
309
+	c.ResponseJSON(userdetail)
310
+}

+ 45
- 3062
log/common.log
File diff suppressed because it is too large
View File


+ 35
- 0
models/bodychecklist/bodychecklist.go View File

1
+package bodychecklist
2
+
3
+import (
4
+	"spaceofcheng/services/models/model"
5
+	"spaceofcheng/services/utils"
6
+
7
+	"github.com/go-xorm/xorm"
8
+)
9
+
10
+// BodychecklistDAO 当前数据库操作对象
11
+type BodychecklistDAO struct {
12
+	ctx *utils.Context
13
+	db  *xorm.Session
14
+}
15
+
16
+// NewBodychecklistDAO New Inst
17
+func NewBodychecklistDAO(ctx *utils.Context) *BodychecklistDAO {
18
+	return &BodychecklistDAO{
19
+		ctx: ctx,
20
+		db:  ctx.DB,
21
+	}
22
+}
23
+
24
+type BodyCheck struct {
25
+	model.TaBodyCheck `xorm:"extends"`
26
+	CaseName          string
27
+	Sex               string
28
+	CustomerName      string
29
+	Phone             string
30
+}
31
+
32
+// func (m *BodychecklistDAO) GetBodychecklist(caseid, phone, customerName string, page, pageSize int) ([]BodyCheck, error) {
33
+// 	var bodycheck []BodyCheck
34
+// 	sql:=``
35
+// }

+ 276
- 0
models/card/card.go View File

1
+package card
2
+
3
+import (
4
+	"errors"
5
+	"fmt"
6
+	"spaceofcheng/services/models"
7
+	"spaceofcheng/services/models/model"
8
+	"spaceofcheng/services/utils"
9
+	"strconv"
10
+	"strings"
11
+	"time"
12
+
13
+	"github.com/go-xorm/xorm"
14
+	"github.com/yl10/kit/guid"
15
+)
16
+
17
+// CardDAO 当前数据库操作对象
18
+type CardDAO struct {
19
+	ctx *utils.Context
20
+	db  *xorm.Session
21
+}
22
+
23
+// NewCardDAO New Inst
24
+func NewCardDAO(ctx *utils.Context) *CardDAO {
25
+	return &CardDAO{
26
+		ctx: ctx,
27
+		db:  ctx.DB,
28
+	}
29
+}
30
+
31
+// CardInfo 卡
32
+type CardInfo struct {
33
+	model.TaCouponCard `xorm:"extends"`
34
+	Images             []model.TaExperienceCardImage
35
+	Targets            []model.TaCouponCardTarget
36
+	Share              *model.TaExperienceCardShare
37
+}
38
+
39
+// GetCardList 获取卡列表
40
+func (m *CardDAO) GetCardList(filters []string, limit []int) ([]model.TaCouponCard, int64, error) {
41
+	var cds []model.TaCouponCard
42
+
43
+	filterString := ""
44
+	if len(filters) > 0 {
45
+		filterString = strings.Join(filters, " and ")
46
+		filterString += " and "
47
+	}
48
+
49
+	sql := `select * from ta_coupon_card where %s status > ` + strconv.Itoa(models.STATUS_DEL) + ` order by create_date desc`
50
+
51
+	total, err := utils.NewPageNaviEngine(m.ctx).GetPageList(&cds, fmt.Sprintf(sql, filterString), limit)
52
+	if err != nil {
53
+		return nil, 0, err
54
+	}
55
+
56
+	return cds, total, nil
57
+}
58
+
59
+// GetCardByID 获取卡明细
60
+func (m *CardDAO) GetCardByID(cardid string) (*CardInfo, error) {
61
+	var card []CardInfo
62
+	sql := `select * from ta_coupon_card where card_id=? and status>` + strconv.Itoa(models.STATUS_DEL)
63
+
64
+	err := m.db.Sql(sql, cardid).Find(&card)
65
+	if err != nil {
66
+		return nil, err
67
+	}
68
+	if len(card) == 0 {
69
+		return nil, nil
70
+	}
71
+	imgs, err := m.GetCardImgsByCardID(cardid)
72
+	if err != nil {
73
+		return nil, err
74
+	}
75
+	card[0].Images = imgs
76
+	targets, err := m.GetCardTargetByCardID(cardid)
77
+	if err != nil {
78
+		return nil, err
79
+	}
80
+	card[0].Targets = targets
81
+	share, err := m.GetCardShareByCardID(cardid)
82
+	if err != nil {
83
+		return nil, err
84
+	}
85
+	card[0].Share = share
86
+	return &card[0], err
87
+}
88
+
89
+// AddCard 新增卡信息
90
+func (m *CardDAO) AddCard(card *model.TaCouponCard) error {
91
+	if card.CardId == "" {
92
+		card.CardId = guid.NewGUIDString()
93
+	}
94
+
95
+	userRaw := m.ctx.Get("user")
96
+	if userRaw != nil {
97
+		user := userRaw.(model.SysUser)
98
+		card.CreateUser = user.UserId
99
+	}
100
+
101
+	card.Status = models.STATUS_NORMAL
102
+	card.CreateDate = time.Now().Local()
103
+
104
+	if _, err := m.db.Insert(card); err != nil {
105
+		return err
106
+	}
107
+
108
+	return nil
109
+}
110
+
111
+// UpdateCard 更新优惠券
112
+func (m *CardDAO) UpdateCard(card *model.TaCouponCard, cols []string) error {
113
+	if card.CardId == "" {
114
+		return errors.New("无卡信息")
115
+	}
116
+
117
+	if _, err := m.db.Cols(cols...).Where("card_id=?", card.CardId).Update(card); err != nil {
118
+		return err
119
+	}
120
+
121
+	return nil
122
+}
123
+
124
+// DeleteCard 删除卡
125
+func (m *CardDAO) DeleteCard(id string) error {
126
+	if id == "" {
127
+		return errors.New("无卡信息")
128
+	}
129
+
130
+	card := model.TaCouponCard{
131
+		CardId: id,
132
+		Status: models.STATUS_DEL,
133
+	}
134
+
135
+	if err := m.UpdateCard(&card, []string{"status"}); err != nil {
136
+		return err
137
+	}
138
+
139
+	return nil
140
+}
141
+
142
+// SaveCustomerCard 保存用户卡
143
+func (m *CardDAO) SaveCustomerCard(card *model.TaCustomerCard) error {
144
+	if card.CustomerCardId == "" {
145
+		card.CustomerCardId = guid.NewGUIDString()
146
+	}
147
+
148
+	card.Status = models.STATUS_NORMAL
149
+
150
+	if _, err := m.db.Insert(card); err != nil {
151
+		return err
152
+	}
153
+
154
+	return nil
155
+}
156
+
157
+// SaveCustomerCards 保存用户卡
158
+func (m *CardDAO) SaveCustomerCards(cards []model.TaCustomerCard) error {
159
+	for i := range cards {
160
+		if cards[i].CustomerCardId == "" {
161
+			cards[i].CustomerCardId = guid.NewGUIDString()
162
+		}
163
+
164
+		cards[i].Status = models.STATUS_NORMAL
165
+	}
166
+
167
+	if _, err := m.db.Insert(cards); err != nil {
168
+		return err
169
+	}
170
+
171
+	return nil
172
+}
173
+
174
+// CheckCustCard 检查客户是否已经有了该卡券
175
+// 如果用户有了卡券, 但是用过了,或者卡券过期了,仍然可以再次拥有
176
+func (m *CardDAO) CheckCustCard(custID, CardID string, startDate, endDate time.Time) ([]model.TaCustomerCard, error) {
177
+	var cps []model.TaCustomerCard
178
+	query := `
179
+		SELECT
180
+			*
181
+		FROM
182
+			ta_customer_card t
183
+		WHERE
184
+			t.card_id = ?
185
+		AND t.customer_id = ?
186
+		AND t.status = ?
187
+		AND (
188
+			(t.start_date BETWEEN ? AND ?)
189
+			OR (t.end_date BETWEEN ? AND ?)
190
+			OR (
191
+				t.start_date <= ?
192
+				AND t.end_date >= ?
193
+			)
194
+		)
195
+	`
196
+
197
+	if err := m.db.SQL(
198
+		query,
199
+		CardID,
200
+		models.STATUS_NORMAL,
201
+		custID,
202
+		startDate,
203
+		endDate,
204
+		startDate,
205
+		endDate,
206
+		startDate,
207
+		endDate,
208
+	).Find(&cps); err != nil {
209
+		return nil, err
210
+	}
211
+
212
+	return cps, nil
213
+}
214
+
215
+// 案场可用卡信息
216
+type CaseUsableCard struct {
217
+	model.TaCouponCard `xorm:"extends"`
218
+	CustomerCard       []model.TaCustomerCard
219
+}
220
+
221
+// GetCaseUsableCard 获取案场可用卡信息
222
+func (m *CardDAO) GetCaseUsableCard(caseid, userid string, page, pageSize int) ([]CaseUsableCard, error) {
223
+	var cards []CaseUsableCard
224
+	sql := `select * from ta_coupon_card where case_id=? and status=? and end_date>now() order by create_date limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
225
+	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL).Find(&cards)
226
+	if userid != "" {
227
+		for inx, card := range cards {
228
+			cCards, err := m.GetCustomerCardByCardAndUser(card.CardId, userid)
229
+			if err != nil {
230
+				return nil, err
231
+			}
232
+			cards[inx].CustomerCard = cCards
233
+		}
234
+	}
235
+	return cards, err
236
+}
237
+
238
+// GetCustomerCardByCardAndUser 根据卡与用户获取领取的用户信息
239
+func (m *CardDAO) GetCustomerCardByCardAndUser(cardid, userid string) ([]model.TaCustomerCard, error) {
240
+	var customerCards []model.TaCustomerCard
241
+	err := m.db.Where("card_id=?", cardid).And("sales_id=?", userid).And("status>?", models.STATUS_DEL).Find(&customerCards)
242
+	return customerCards, err
243
+}
244
+
245
+// GetCardDetail 获取卡详情
246
+func (m *CardDAO) GetCardDetail(cardid string) (*CaseUsableCard, error) {
247
+	var card = new(CaseUsableCard)
248
+	sql := `select * from ta_coupon_card where card_id=? and status>?`
249
+	_, err := m.db.Sql(sql, cardid, models.STATUS_DEL).Get(&card)
250
+	if err != nil {
251
+		return nil, err
252
+	}
253
+	if card == nil || card.CardId == "" {
254
+		return nil, errors.New("无卡信息")
255
+	}
256
+	ccards, err := m.GetCustomerCardByCard(cardid)
257
+	if err != nil {
258
+		return nil, err
259
+	}
260
+	card.CustomerCard = ccards
261
+	return card, nil
262
+}
263
+
264
+// GetCustomerCardByCard 根据卡获取领取的用户信息
265
+func (m *CardDAO) GetCustomerCardByCard(cardid string) ([]model.TaCustomerCard, error) {
266
+	var customerCards []model.TaCustomerCard
267
+	err := m.db.Where("card_id=?", cardid).And("status>?", models.STATUS_DEL).Find(&customerCards)
268
+	return customerCards, err
269
+}
270
+
271
+// GetCustomerCardByUser 根据用户获取发送的卡信息
272
+func (m *CardDAO) GetCustomerCardByUser(caseid, userid string) ([]model.TaCustomerCard, error) {
273
+	var customerCards []model.TaCustomerCard
274
+	err := m.db.Where("case_id=?", caseid).And("sales_id=?", userid).And("status>?", models.STATUS_DEL).Find(&customerCards)
275
+	return customerCards, err
276
+}

+ 42
- 0
models/card/image.go View File

1
+package card
2
+
3
+import (
4
+	"spaceofcheng/services/models"
5
+	"spaceofcheng/services/models/model"
6
+
7
+	"github.com/yl10/kit/guid"
8
+)
9
+
10
+// GetCardImgsByCardID 根据卡id获取卡图片
11
+func (m *CardDAO) GetCardImgsByCardID(cardid string) ([]model.TaExperienceCardImage, error) {
12
+	var imgs []model.TaExperienceCardImage
13
+	err := m.db.Where("card_id=?", cardid).And("status>?", models.STATUS_DEL).Find(&imgs)
14
+	return imgs, err
15
+}
16
+
17
+// UpdateImages 更新图片 -- 插入或者更新
18
+func (m *CardDAO) UpdateImages(imgs []model.TaExperienceCardImage, cardID string) error {
19
+	if imgs == nil || len(imgs) == 0 {
20
+		return nil
21
+	}
22
+
23
+	for i := range imgs {
24
+		imgs[i].CardId = cardID
25
+
26
+		if imgs[i].CardImageId == "" {
27
+			imgs[i].CardImageId = guid.NewGUIDString()
28
+			imgs[i].Status = models.STATUS_NORMAL
29
+		}
30
+	}
31
+
32
+	sql := `delete from ta_experience_card_image where card_id=?`
33
+	if _, err := m.db.Exec(sql, cardID); err != nil {
34
+		return err
35
+	}
36
+
37
+	if _, err := m.db.Insert(imgs); err != nil {
38
+		return err
39
+	}
40
+
41
+	return nil
42
+}

+ 44
- 0
models/card/share.go View File

1
+package card
2
+
3
+import (
4
+	"errors"
5
+	"spaceofcheng/services/models"
6
+	"spaceofcheng/services/models/model"
7
+
8
+	"github.com/yl10/kit/guid"
9
+)
10
+
11
+// GetCardShareByCardID 根据卡id获取体验卡对应的分享信息
12
+func (m *CardDAO) GetCardShareByCardID(cardid string) (*model.TaExperienceCardShare, error) {
13
+	var share = model.TaExperienceCardShare{}
14
+	_, err := m.db.Where("card_id=?", cardid).Get(&share)
15
+	return &share, err
16
+}
17
+
18
+// SaveCardShare 保存卡分享信息
19
+func (m *CardDAO) SaveCardShare(card *model.TaExperienceCardShare) error {
20
+	if card.CardShareId == "" {
21
+		card.CardShareId = guid.NewGUIDString()
22
+	}
23
+
24
+	card.Status = models.STATUS_NORMAL
25
+
26
+	if _, err := m.db.Insert(card); err != nil {
27
+		return err
28
+	}
29
+
30
+	return nil
31
+}
32
+
33
+// UpdateCardShare 更新卡分享信息
34
+func (m *CardDAO) UpdateCardShare(card *model.TaExperienceCardShare, cols []string) error {
35
+	if card.CardShareId == "" {
36
+		return errors.New("无卡分享信息")
37
+	}
38
+
39
+	if _, err := m.db.Cols(cols...).Where("card_share_id=?", card.CardShareId).Update(card); err != nil {
40
+		return err
41
+	}
42
+
43
+	return nil
44
+}

+ 42
- 0
models/card/target.go View File

1
+package card
2
+
3
+import (
4
+	"errors"
5
+	"spaceofcheng/services/models/model"
6
+)
7
+
8
+// GetCardTargetByCardID 根据卡id获取体验卡对应的目标信息
9
+func (m *CardDAO) GetCardTargetByCardID(cardid string) ([]model.TaCouponCardTarget, error) {
10
+	var targets []model.TaCouponCardTarget
11
+	err := m.db.Where("card_id=?", cardid).Find(&targets)
12
+	return targets, err
13
+}
14
+
15
+// UpdateTarget 更新关联内容 -- 插入或者更新
16
+func (m *CardDAO) UpdateTarget(targets []model.TaCouponCardTarget, cardID string) error {
17
+	if targets == nil || len(targets) == 0 {
18
+		return nil
19
+	}
20
+
21
+	for i := range targets {
22
+		if targets[i].TargetId == "" {
23
+			return errors.New("关联内容不能为空")
24
+		}
25
+
26
+		// TODO
27
+		// 校验关联内容是否有效
28
+
29
+		targets[i].CardId = cardID
30
+	}
31
+
32
+	// var delTargets []model.TaCouponTarget
33
+	sql := `delete from ta_coupon_card_target where card_id='` + cardID + `'`
34
+	if _, err := m.db.Exec(sql); err != nil {
35
+		return err
36
+	}
37
+	if _, err := m.db.Insert(targets); err != nil {
38
+		return err
39
+	}
40
+
41
+	return nil
42
+}

+ 7
- 0
models/cases/cases.go View File

154
 
154
 
155
 	return users, nil
155
 	return users, nil
156
 }
156
 }
157
+
158
+// GetCaseByIDs 获取案场信息
159
+func (m *CaseDAO) GetCaseByIDs(caseids string) ([]model.SysCase, error) {
160
+	var cases []model.SysCase
161
+	err := m.db.Where("status>" + strconv.Itoa(models.STATUS_DEL)).And("case_id in ('" + strings.Replace(caseids, ",", "','", -1) + "')").Find(&cases)
162
+	return cases, err
163
+}

+ 13
- 3
models/cases/signin.go View File

3
 import (
3
 import (
4
 	"spaceofcheng/services/models/model"
4
 	"spaceofcheng/services/models/model"
5
 	"spaceofcheng/services/utils"
5
 	"spaceofcheng/services/utils"
6
+	"spaceofcheng/services/models"
6
 	"strconv"
7
 	"strconv"
7
 	"strings"
8
 	"strings"
8
-
9
+	"time"
9
 	"github.com/go-xorm/xorm"
10
 	"github.com/go-xorm/xorm"
10
 )
11
 )
11
 
12
 
43
 	}
44
 	}
44
 }
45
 }
45
 
46
 
46
-// CaseInfo 案场
47
+// SigninInfo 案场
47
 type SigninInfo struct {
48
 type SigninInfo struct {
48
 	model.TaCheckinRecord `xorm:"extends"`
49
 	model.TaCheckinRecord `xorm:"extends"`
49
-	//CreateUserName string
50
+	UserId string
50
 }
51
 }
51
 
52
 
52
 /**
53
 /**
95
 	// }
96
 	// }
96
 	return signin, err
97
 	return signin, err
97
 }
98
 }
99
+
100
+// AddSignin 添加签到记录 
101
+func (m *SigninDAO) AddSignin(signin model.TaCheckinRecord)(model.TaCheckinRecord,error){
102
+	signin.CheckinId = utils.GetGUID()
103
+	signin.CreateDate = time.Now()
104
+	signin.Status = models.STATUS_NORMAL
105
+	_,err := m.db.Insert(signin)
106
+	return signin,err
107
+}

+ 14
- 0
models/constant.go View File

117
 	GIVE_GIFT_GYM            = "gym"
117
 	GIVE_GIFT_GYM            = "gym"
118
 )
118
 )
119
 
119
 
120
+// 卡券发放类型
121
+const (
122
+	GIVE_TYPE_SYSTEM  = "system"
123
+	GIVE_TYPE_CASE    = "case"
124
+	GIVE_TYPE_CHANNEL = "channel"
125
+)
126
+
120
 // 游泳健身卡种类
127
 // 游泳健身卡种类
121
 const (
128
 const (
122
 	GYM_CARD_ONCE    = "once"
129
 	GYM_CARD_ONCE    = "once"
137
 	DASH_SETTING_FOR_USER     = "user"
144
 	DASH_SETTING_FOR_USER     = "user"
138
 	DASH_SETTING_FOR_USERTYPE = "user-type"
145
 	DASH_SETTING_FOR_USERTYPE = "user-type"
139
 )
146
 )
147
+
148
+// 卡券状态
149
+const (
150
+	CARD_COUPON_RECEIVED = "received"
151
+	CARD_COUPON_USED     = "used"
152
+	CARD_COUPON_EXPIRE   = "expire"
153
+)

+ 79
- 7
models/coupon/coupon.go View File

6
 	"spaceofcheng/services/models"
6
 	"spaceofcheng/services/models"
7
 	"spaceofcheng/services/models/model"
7
 	"spaceofcheng/services/models/model"
8
 	"spaceofcheng/services/utils"
8
 	"spaceofcheng/services/utils"
9
+	"strconv"
9
 	"strings"
10
 	"strings"
10
 	"time"
11
 	"time"
11
 
12
 
45
 
46
 
46
 	query := `
47
 	query := `
47
 		SELECT
48
 		SELECT
48
-			t.*, s.coupon_type_name
49
+			*
49
 		FROM
50
 		FROM
50
-			ta_coupon t
51
-		LEFT JOIN td_coupon_type s ON t.coupon_type_id = s.coupon_type_id
51
+			ta_coupon
52
 		WHERE
52
 		WHERE
53
-			t.coupon_id = ?
53
+			coupon_id = ?
54
 	`
54
 	`
55
 
55
 
56
 	if _, err := m.db.SQL(query, id).Get(cp); err != nil {
56
 	if _, err := m.db.SQL(query, id).Get(cp); err != nil {
99
 		filterString += " and "
99
 		filterString += " and "
100
 	}
100
 	}
101
 
101
 
102
-	sql := `select * from ta_coupon where %s status = 1 order by create_date desc`
102
+	sql := `select * from ta_coupon where %s status > ` + strconv.Itoa(models.STATUS_DEL) + ` order by create_date desc`
103
 
103
 
104
 	total, err := utils.NewPageNaviEngine(m.ctx).GetPageList(&cps, fmt.Sprintf(sql, filterString), limit)
104
 	total, err := utils.NewPageNaviEngine(m.ctx).GetPageList(&cps, fmt.Sprintf(sql, filterString), limit)
105
 	if err != nil {
105
 	if err != nil {
121
 		cp.CreateUser = user.UserId
121
 		cp.CreateUser = user.UserId
122
 	}
122
 	}
123
 
123
 
124
+	org := m.ctx.Get("org").(model.SysOrg)
125
+	cp.OrgId = org.OrgId
126
+
124
 	cp.Status = models.STATUS_NORMAL
127
 	cp.Status = models.STATUS_NORMAL
125
 	cp.CreateDate = time.Now().Local()
128
 	cp.CreateDate = time.Now().Local()
126
 
129
 
216
 			)
219
 			)
217
 		)
220
 		)
218
 	`
221
 	`
219
-
220
 	if err := m.db.SQL(
222
 	if err := m.db.SQL(
221
 		query,
223
 		query,
222
 		couponID,
224
 		couponID,
223
-		models.STATUS_NORMAL,
224
 		custID,
225
 		custID,
226
+		models.STATUS_NORMAL,
225
 		startDate,
227
 		startDate,
226
 		endDate,
228
 		endDate,
227
 		startDate,
229
 		startDate,
249
 
251
 
250
 	return nil
252
 	return nil
251
 }
253
 }
254
+
255
+// GetCouponBySendType 根据类型获取优惠券
256
+func (m *CouponDAO) GetCouponBySendType(caseids, sendtype string) ([]model.TaCoupon, error) {
257
+	var coupons []model.TaCoupon
258
+	err := m.db.Where("case_id in ('"+strings.Replace(caseids, ",", "','", -1)+"')").And("send_type=?", sendtype).And("status=?", models.STATUS_NORMAL).Find(&coupons)
259
+	return coupons, err
260
+}
261
+
262
+// CaseUsableCoupon 案场可用优惠券信息
263
+type CaseUsableCoupon struct {
264
+	model.TaCoupon `xorm:"extends"`
265
+	CustomerCoupon []model.TaCustomerCoupon
266
+}
267
+
268
+// GetCaseUsableCoupon 获取案场可用优惠券信息
269
+func (m *CouponDAO) GetCaseUsableCoupon(caseid, userid string, page, pageSize int) ([]CaseUsableCoupon, error) {
270
+	var Coupons []CaseUsableCoupon
271
+	sql := `select * from ta_coupon where case_id=? and status=? and end_date>now() order by create_date limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
272
+	err := m.db.Sql(sql, caseid, models.STATUS_NORMAL).Find(&Coupons)
273
+	if userid != "" {
274
+		for inx, Coupon := range Coupons {
275
+			cCoupons, err := m.GetCustomerCouponByCouponAndUser(Coupon.CouponId, userid)
276
+			if err != nil {
277
+				return nil, err
278
+			}
279
+			Coupons[inx].CustomerCoupon = cCoupons
280
+		}
281
+	}
282
+	return Coupons, err
283
+}
284
+
285
+// GetCustomerCouponByCouponAndUser 根据优惠券与用户获取领取的用户信息
286
+func (m *CouponDAO) GetCustomerCouponByCouponAndUser(couponid, userid string) ([]model.TaCustomerCoupon, error) {
287
+	var customerCoupons []model.TaCustomerCoupon
288
+	err := m.db.Where("coupon_id=?", couponid).And("sales_id=?", userid).And("status>?", models.STATUS_DEL).Find(&customerCoupons)
289
+	return customerCoupons, err
290
+}
291
+
292
+// GetCouponDetail 获取优惠券详情
293
+func (m *CouponDAO) GetCouponDetail(couponid string) (*CaseUsableCoupon, error) {
294
+	var coupon = new(CaseUsableCoupon)
295
+	sql := `select * from ta_coupon_Coupon where coupon_id=? and status>?`
296
+	_, err := m.db.Sql(sql, couponid, models.STATUS_DEL).Get(&coupon)
297
+	if err != nil {
298
+		return nil, err
299
+	}
300
+	if coupon == nil || coupon.CouponId == "" {
301
+		return nil, errors.New("无优惠券信息")
302
+	}
303
+	cCoupons, err := m.GetCustomerCouponByCoupon(couponid)
304
+	if err != nil {
305
+		return nil, err
306
+	}
307
+	coupon.CustomerCoupon = cCoupons
308
+	return coupon, nil
309
+}
310
+
311
+// GetCustomerCouponByCoupon 根据优惠券获取领取的用户信息
312
+func (m *CouponDAO) GetCustomerCouponByCoupon(couponid string) ([]model.TaCustomerCoupon, error) {
313
+	var customerCoupons []model.TaCustomerCoupon
314
+	err := m.db.Where("coupon_id=?", couponid).And("status>?", models.STATUS_DEL).Find(&customerCoupons)
315
+	return customerCoupons, err
316
+}
317
+
318
+// GetCustomerCouponByUser 根据用户获取领取的用户信息
319
+func (m *CouponDAO) GetCustomerCouponByUser(caseid, userid string) ([]model.TaCustomerCoupon, error) {
320
+	var customerCoupons []model.TaCustomerCoupon
321
+	err := m.db.Where("case_id=?", caseid).And("sales_id=?", userid).And("status>?", models.STATUS_DEL).Find(&customerCoupons)
322
+	return customerCoupons, err
323
+}

+ 3
- 2
models/coupon/image.go View File

20
 		}
20
 		}
21
 	}
21
 	}
22
 
22
 
23
-	var delImgs []model.TaCouponImage
24
-	if _, err := m.db.Where("coupon_id=?", couponID).Delete(&delImgs); err != nil {
23
+	// var delImgs []model.TaCouponImage
24
+	sql := `delete from ta_coupon_image where coupon_id=?`
25
+	if _, err := m.db.Exec(sql, couponID); err != nil {
25
 		return err
26
 		return err
26
 	}
27
 	}
27
 
28
 

+ 3
- 3
models/coupon/target.go View File

22
 		targets[i].CouponId = couponID
22
 		targets[i].CouponId = couponID
23
 	}
23
 	}
24
 
24
 
25
-	var delTargets []model.TaCouponTarget
26
-	if _, err := m.db.Where("coupon_id=?", couponID).Delete(&delTargets); err != nil {
25
+	// var delTargets []model.TaCouponTarget
26
+	sql := `delete from ta_coupon_target where coupon_id='` + couponID + `'`
27
+	if _, err := m.db.Exec(sql); err != nil {
27
 		return err
28
 		return err
28
 	}
29
 	}
29
-
30
 	if _, err := m.db.Insert(targets); err != nil {
30
 	if _, err := m.db.Insert(targets); err != nil {
31
 		return err
31
 		return err
32
 	}
32
 	}

+ 1
- 2
models/coupon/types.go View File

12
 
12
 
13
 // CouponInfo 优惠券信息
13
 // CouponInfo 优惠券信息
14
 type CouponInfo struct {
14
 type CouponInfo struct {
15
-	model.TaCoupon
16
-	CouponTypeName string
15
+	model.TaCoupon `xorm:"extends"`
17
 	Share          model.TaCouponShare
16
 	Share          model.TaCouponShare
18
 	Targets        []model.TaCouponTarget
17
 	Targets        []model.TaCouponTarget
19
 	Images         []model.TaCouponImage
18
 	Images         []model.TaCouponImage

+ 27
- 4
models/customer/customer.go View File

27
 }
27
 }
28
 
28
 
29
 // CustWithWXList 客户列表
29
 // CustWithWXList 客户列表
30
-func (m *CustomerDAO) CustWithWXList(phone string, page ...int) ([]CustWithWX, int64, error) {
30
+func (m *CustomerDAO) CustWithWXList(phone, username, recommendname, begindate, enddate string, page ...int) ([]CustWithWX, int64, error) {
31
 	org := m.ctx.Get("org").(model.SysOrg)
31
 	org := m.ctx.Get("org").(model.SysOrg)
32
 
32
 
33
 	if phone == "" {
33
 	if phone == "" {
36
 		phone = "%" + phone + "%"
36
 		phone = "%" + phone + "%"
37
 	}
37
 	}
38
 
38
 
39
+	if username == "" {
40
+		username = "%"
41
+	} else {
42
+		username = "%" + username + "%"
43
+	}
44
+
45
+	if recommendname == "" {
46
+		recommendname = "%"
47
+	} else {
48
+		recommendname = "%" + recommendname + "%"
49
+	}
50
+
39
 	pageNum := 10
51
 	pageNum := 10
40
 	if m.ctx.Get("pageNum") != nil {
52
 	if m.ctx.Get("pageNum") != nil {
41
 		pageNum = m.ctx.Get("pageNum").(int)
53
 		pageNum = m.ctx.Get("pageNum").(int)
67
 			AND s.account_type = '` + models.ACCMAP_WECHAT + `'
79
 			AND s.account_type = '` + models.ACCMAP_WECHAT + `'
68
 		WHERE
80
 		WHERE
69
 			t.phone like ?
81
 			t.phone like ?
82
+			AND t.customer_name like ?
83
+			AND t.recommend_name like ?
70
 		AND t.status > ?
84
 		AND t.status > ?
71
-		AND t.org_id = '` + org.OrgId + `'
72
-		ORDER BY
85
+		AND t.org_id = '` + org.OrgId + `'`
86
+
87
+	if begindate != "" {
88
+		query = query + ` AND t.create_date>'` + begindate + `'`
89
+	}
90
+
91
+	if enddate != "" {
92
+		query = query + ` AND t.create_date<'` + begindate + `'`
93
+	}
94
+
95
+	query = query + ` ORDER BY
73
 			t.create_date DESC
96
 			t.create_date DESC
74
 	`
97
 	`
75
 
98
 
76
 	var cust []CustWithWX
99
 	var cust []CustWithWX
77
 
100
 
78
-	cnt, err := utils.NewPageNaviEngine(m.ctx).GetPageList(&cust, query, []int{pageNum, offset}, phone, models.STATUS_DEL)
101
+	cnt, err := utils.NewPageNaviEngine(m.ctx).GetPageList(&cust, query, []int{pageNum, offset}, phone, username, recommendname, models.STATUS_DEL)
79
 	if err != nil {
102
 	if err != nil {
80
 		return nil, 0, err
103
 		return nil, 0, err
81
 	}
104
 	}

+ 17
- 0
models/goods/goods.go View File

250
 		"goods_name",
250
 		"goods_name",
251
 		"type_id",
251
 		"type_id",
252
 		"status",
252
 		"status",
253
+		"price",
254
+		"case_id",
253
 	}
255
 	}
254
 
256
 
255
 	// 商品图片
257
 	// 商品图片
320
 	err := m.db.Where("goods_id=?", goodsid).Find(&goodsimg)
322
 	err := m.db.Where("goods_id=?", goodsid).Find(&goodsimg)
321
 	return goodsimg, err
323
 	return goodsimg, err
322
 }
324
 }
325
+
326
+// GetGoodsBySpec 根据商品规格获取商品信息
327
+func (m *GoodsDAO) GetGoodsBySpec(specid string) ([]model.TaGoods, error) {
328
+	var goods []model.TaGoods
329
+	sql := `select a.* from ta_goods a inner join ta_goods_spec b on a.goods_id=b.goods_id where a.status>` + strconv.Itoa(models.STATUS_DEL) + ` and b.spec_id='` + specid + `'`
330
+	err := m.db.Sql(sql).Find(&goods)
331
+	return goods, err
332
+}
333
+
334
+// GetGoodsByType 根据商品类型获取商品信息
335
+func (m *GoodsDAO) GetGoodsByType(typeid string) ([]model.TaGoods, error) {
336
+	var goods []model.TaGoods
337
+	err := m.db.Where("status>"+strconv.Itoa(models.STATUS_DEL)).And("type_id=?", typeid).Find(&goods)
338
+	return goods, err
339
+}

+ 12
- 0
models/goods/orders.go View File

262
 	_, err := m.db.Cols(cols...).Where("orders_id=?", orders.OrdersId).Update(orders)
262
 	_, err := m.db.Cols(cols...).Where("orders_id=?", orders.OrdersId).Update(orders)
263
 	return err
263
 	return err
264
 }
264
 }
265
+
266
+// GetOrderDetailByUser 获取用户所有下单信息
267
+func (m *GoodsDAO) GetOrderDetailByUser(caseid, userid string) ([]model.TaGoodsOrdersDetail, error) {
268
+	var details []model.TaGoodsOrdersDetail
269
+	sql := `select a.* from ta_goods_orders_detail a inner join ta_goods_orders b on a.orders_id=b.orders_id
270
+		inner join ta_customer c on b.user_id = c.customer_id
271
+	where c.user_id=? and b.status>? and b.case_id=?`
272
+	if err := m.db.Sql(sql, userid, models.STATUS_DEL, caseid).Find(&details); err != nil {
273
+		return nil, err
274
+	}
275
+	return details, nil
276
+}

+ 4
- 1
models/goods/spec.go View File

6
 	"spaceofcheng/services/utils"
6
 	"spaceofcheng/services/utils"
7
 	"strconv"
7
 	"strconv"
8
 	"strings"
8
 	"strings"
9
+	"time"
9
 )
10
 )
10
 
11
 
11
 // GetGoodsSpecCount 获取商品规格总数
12
 // GetGoodsSpecCount 获取商品规格总数
18
 // GetGoodsSpec 根据案场获取商品规格
19
 // GetGoodsSpec 根据案场获取商品规格
19
 func (m *GoodsDAO) GetGoodsSpec(caseids string, page int, pageSize int) ([]model.TdSpec, error) {
20
 func (m *GoodsDAO) GetGoodsSpec(caseids string, page int, pageSize int) ([]model.TdSpec, error) {
20
 	var goodsSpec []model.TdSpec
21
 	var goodsSpec []model.TdSpec
21
-	err := m.db.Where("status>"+strconv.Itoa(models.STATUS_DEL)).And("case_id in ('"+strings.Replace(caseids, ",", "','", -1)+"')").Limit(pageSize, (page-1)*pageSize).Find(&goodsSpec)
22
+	err := m.db.Where("status>"+strconv.Itoa(models.STATUS_DEL)).And("case_id in ('"+strings.Replace(caseids, ",", "','", -1)+"')").Desc("create_date").Limit(pageSize, (page-1)*pageSize).Find(&goodsSpec)
22
 	return goodsSpec, err
23
 	return goodsSpec, err
23
 }
24
 }
24
 
25
 
39
 func (m *GoodsDAO) AddGoodsSpec(goodsSpec *model.TdSpec) (*model.TdSpec, error) {
40
 func (m *GoodsDAO) AddGoodsSpec(goodsSpec *model.TdSpec) (*model.TdSpec, error) {
40
 	goodsSpec.SpecId = utils.GetGUID()
41
 	goodsSpec.SpecId = utils.GetGUID()
41
 	goodsSpec.Status = models.STATUS_NORMAL
42
 	goodsSpec.Status = models.STATUS_NORMAL
43
+	goodsSpec.CreateDate = time.Now()
42
 	_, err := m.db.Insert(goodsSpec)
44
 	_, err := m.db.Insert(goodsSpec)
43
 	return goodsSpec, err
45
 	return goodsSpec, err
44
 }
46
 }
47
 func (m *GoodsDAO) UpdateGoodsSpec(goodsSpec model.TdSpec) error {
49
 func (m *GoodsDAO) UpdateGoodsSpec(goodsSpec model.TdSpec) error {
48
 	var cols = []string{
50
 	var cols = []string{
49
 		"spec_name",
51
 		"spec_name",
52
+		"case_id",
50
 	}
53
 	}
51
 	_, err := m.db.Cols(cols...).Where("spec_id=?", goodsSpec.SpecId).Update(goodsSpec)
54
 	_, err := m.db.Cols(cols...).Where("spec_id=?", goodsSpec.SpecId).Update(goodsSpec)
52
 	return err
55
 	return err

+ 1
- 1
models/goods/type.go View File

25
 // GetGoodsType 根据案场获取商品类型
25
 // GetGoodsType 根据案场获取商品类型
26
 func (m *GoodsDAO) GetGoodsType(caseids string, page int, pageSize int) ([]model.TdGoodsType, error) {
26
 func (m *GoodsDAO) GetGoodsType(caseids string, page int, pageSize int) ([]model.TdGoodsType, error) {
27
 	var goodstype []model.TdGoodsType
27
 	var goodstype []model.TdGoodsType
28
-	err := m.db.Where("status>"+strconv.Itoa(models.STATUS_DEL)).And("case_id in ('"+strings.Replace(caseids, ",", "','", -1)+"')").Limit(pageSize, (page-1)*pageSize).Desc("create_date").Find(&goodstype)
28
+	err := m.db.Where("status>"+strconv.Itoa(models.STATUS_DEL)).And("case_id in ('"+strings.Replace(caseids, ",", "','", -1)+"')").Desc("create_date").Limit(pageSize, (page-1)*pageSize).Desc("create_date").Find(&goodstype)
29
 	return goodstype, err
29
 	return goodstype, err
30
 }
30
 }
31
 
31
 

+ 45
- 7
models/gymcard/gymcard.go View File

31
 	CardShareInfo       string
31
 	CardShareInfo       string
32
 	CardUseInstruction  string
32
 	CardUseInstruction  string
33
 	CardUseRule         string
33
 	CardUseRule         string
34
+	Price               string
34
 }
35
 }
35
 
36
 
36
 type Gymcard struct {
37
 type Gymcard struct {
39
 	CardShareInfo      string
40
 	CardShareInfo      string
40
 	CardUseInstruction string
41
 	CardUseInstruction string
41
 	CardUseRule        string
42
 	CardUseRule        string
43
+	ChannelId          string
42
 }
44
 }
43
 
45
 
44
 // GetGymcard 根据案场id获取游泳健身卡列表
46
 // GetGymcard 根据案场id获取游泳健身卡列表
54
 	ta_gym_card a
56
 	ta_gym_card a
55
 	INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
57
 	INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
56
 	INNER JOIN ta_card_share c ON a.gym_card_id = c.gym_card_id
58
 	INNER JOIN ta_card_share c ON a.gym_card_id = c.gym_card_id
59
+	INNER JOIN ta_card_coupon_channel d ON a.gym_card_id = d.card_coupon_id
57
 	where a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')
60
 	where a.case_id in('` + strings.Replace(caseid, ",", "','", -1) + `')
58
-	and  a.status > ` + strconv.Itoa(models.STATUS_DEL)
59
-	sql += ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
61
+	and  a.status > ` + strconv.Itoa(models.STATUS_DEL) + `
62
+	and d.card_coupon_type = '` + models.GIVE_GIFT_GYM + `'`
63
+	sql += ` order by a.create_date desc limit ` + strconv.Itoa(page) + `, ` + strconv.Itoa(pageSize)
60
 	err := m.db.Sql(sql).Find(&gymcard)
64
 	err := m.db.Sql(sql).Find(&gymcard)
61
 	return gymcard, err
65
 	return gymcard, err
62
 }
66
 }
116
 	return gymcard, err
120
 	return gymcard, err
117
 }
121
 }
118
 
122
 
123
+// AddCardChannel 新增游泳健身卡渠道
124
+func (m *GymcardDAO) AddCardChannel(gymcardId, channelId string) error {
125
+	var cardChannel model.TaCardCouponChannel
126
+	cardChannel.CardCouponChannelId = utils.GetGUID()
127
+	cardChannel.CardCouponId = gymcardId
128
+	cardChannel.CardCouponType = models.GIVE_GIFT_GYM
129
+	cardChannel.ChannelId = channelId
130
+	cardChannel.Status = models.STATUS_NORMAL
131
+	_, err := m.db.Insert(cardChannel)
132
+	return err
133
+
134
+}
135
+
119
 // AddGymcardImg 新增游泳健身卡图片
136
 // AddGymcardImg 新增游泳健身卡图片
120
 func (m *GymcardDAO) AddGymcardImg(gymcardId, imgUrl string) error {
137
 func (m *GymcardDAO) AddGymcardImg(gymcardId, imgUrl string) error {
121
 	var cardImg model.TaCardImage
138
 	var cardImg model.TaCardImage
168
 
185
 
169
 }
186
 }
170
 
187
 
188
+// DeleteCardChannel 删除健身卡渠道对应
189
+func (m *GymcardDAO) DeleteCardChannel(gymcardId string) error {
190
+	var cardChannel = model.TaCardCouponChannel{
191
+		CardCouponId: gymcardId,
192
+		Status:       models.STATUS_DEL,
193
+	}
194
+	var cols = []string{
195
+		"status",
196
+	}
197
+	_, err := m.db.Cols(cols...).Where("gym_card_id = ?", cardChannel.CardCouponId).Update(cardChannel)
198
+	return err
199
+}
200
+
171
 // DeleteCardImg 删除健身卡分享信息
201
 // DeleteCardImg 删除健身卡分享信息
172
 func (m *GymcardDAO) DeleteCardShare(gymcardId string) error {
202
 func (m *GymcardDAO) DeleteCardShare(gymcardId string) error {
173
 	var cardShare = model.TaCardShare{
203
 	var cardShare = model.TaCardShare{
221
 }
251
 }
222
 
252
 
223
 // SendGymcardToCustomer 新增用户健身卡
253
 // SendGymcardToCustomer 新增用户健身卡
224
-func (m *GymcardDAO) SendGymcardToCustomer(gymcard *model.TaGymCard, customerId string) (*model.TaCustomerGym, error) {
254
+func (m *GymcardDAO) SendGymcardToCustomer(gymcard *model.TaGymCard, customerId, salesId, salesName string) (*model.TaCustomerGym, error) {
225
 	var customerGym model.TaCustomerGym
255
 	var customerGym model.TaCustomerGym
226
 	customerGym.CustomerGymId = utils.GetGUID()
256
 	customerGym.CustomerGymId = utils.GetGUID()
227
 	customerGym.CaseId = gymcard.CaseId
257
 	customerGym.CaseId = gymcard.CaseId
234
 	customerGym.ReceiveDate = time.Now()
264
 	customerGym.ReceiveDate = time.Now()
235
 	customerGym.StartDate = gymcard.StartDate
265
 	customerGym.StartDate = gymcard.StartDate
236
 	customerGym.Status = models.STATUS_NORMAL
266
 	customerGym.Status = models.STATUS_NORMAL
267
+	customerGym.SalesId = salesId
268
+	customerGym.SalesName = salesName
237
 	_, err := m.db.Insert(customerGym)
269
 	_, err := m.db.Insert(customerGym)
238
 	return &customerGym, err
270
 	return &customerGym, err
239
 }
271
 }
269
 	b.card_image_url,
301
 	b.card_image_url,
270
 	c.card_share_info,
302
 	c.card_share_info,
271
 	c.card_use_instruction,
303
 	c.card_use_instruction,
272
-	c.card_use_rule
304
+	c.card_use_rule,
305
+	d.price
273
 FROM
306
 FROM
274
 	ta_customer_gym a
307
 	ta_customer_gym a
275
 INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
308
 INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
276
 INNER JOIN ta_card_share C oN a.gym_card_id = c.gym_card_id
309
 INNER JOIN ta_card_share C oN a.gym_card_id = c.gym_card_id
310
+INNER JOIN ta_gym_card d ON a.gym_card_id = d.gym_card_id
277
 WHERE
311
 WHERE
278
 	a.customer_id = '` + customerId + `' and a.status >` + strconv.Itoa(models.STATUS_DEL)
312
 	a.customer_id = '` + customerId + `' and a.status >` + strconv.Itoa(models.STATUS_DEL)
279
-	sql += ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
313
+	sql += ` order by a.receive_date desc limit ` + strconv.Itoa(page) + `, ` + strconv.Itoa(pageSize)
280
 	err := m.db.Sql(sql).Find(&customerGym)
314
 	err := m.db.Sql(sql).Find(&customerGym)
281
 	return customerGym, err
315
 	return customerGym, err
282
 }
316
 }
289
 	b.card_image_url,
323
 	b.card_image_url,
290
 	c.card_share_info,
324
 	c.card_share_info,
291
 	c.card_use_instruction,
325
 	c.card_use_instruction,
292
-	c.card_use_rule
326
+	c.card_use_rule,
327
+	d.price
293
 FROM
328
 FROM
294
 	ta_customer_gym a
329
 	ta_customer_gym a
295
 INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
330
 INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
296
 INNER JOIN ta_card_share C oN a.gym_card_id = c.gym_card_id
331
 INNER JOIN ta_card_share C oN a.gym_card_id = c.gym_card_id
297
 INNER JOIN ta_customer d ON a.customer_id = d.customer_id
332
 INNER JOIN ta_customer d ON a.customer_id = d.customer_id
333
+INNER JOIN ta_gym_card e ON a.gym_card_id = e.gym_card_id
298
 Where d.phone = '` + phone + `' and a.status >` + strconv.Itoa(models.STATUS_DEL)
334
 Where d.phone = '` + phone + `' and a.status >` + strconv.Itoa(models.STATUS_DEL)
299
 	err := m.db.Sql(sql).Find(&customerGym)
335
 	err := m.db.Sql(sql).Find(&customerGym)
300
 	return customerGym, err
336
 	return customerGym, err
328
 	b.card_image_url,
364
 	b.card_image_url,
329
 	c.card_share_info,
365
 	c.card_share_info,
330
 	c.card_use_instruction,
366
 	c.card_use_instruction,
331
-	c.card_use_rule
367
+	c.card_use_rule,
368
+	d.price
332
 FROM
369
 FROM
333
 	ta_customer_gym a
370
 	ta_customer_gym a
334
 INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
371
 INNER JOIN ta_card_image b ON a.gym_card_id = b.gym_card_id
335
 INNER JOIN ta_card_share C oN a.gym_card_id = c.gym_card_id
372
 INNER JOIN ta_card_share C oN a.gym_card_id = c.gym_card_id
373
+INNER JOIN ta_gym_card d ON a.gym_card_id = d.gym_card_id
336
 WHERE
374
 WHERE
337
 	a.customer_gym_id = '` + customerCardId + `' and a.status >` + strconv.Itoa(models.STATUS_DEL)
375
 	a.customer_gym_id = '` + customerCardId + `' and a.status >` + strconv.Itoa(models.STATUS_DEL)
338
 	err := m.db.Sql(sql).Find(&customerGym)
376
 	err := m.db.Sql(sql).Find(&customerGym)

+ 14
- 14
models/marketing/marketing.go View File

10
 
10
 
11
 // 活动类型
11
 // 活动类型
12
 const (
12
 const (
13
-	NEW_ACTIVITIES = 0 // 注册赠券
13
+	NEW_ACTIVITIES = 1 // 注册赠券
14
 
14
 
15
 )
15
 )
16
 
16
 
19
 	DELETE = -1 // 删除
19
 	DELETE = -1 // 删除
20
 	NORMAL = 0 // 正常
20
 	NORMAL = 0 // 正常
21
 	DISABLE = 1 // 停用
21
 	DISABLE = 1 // 停用
22
-
23
 )
22
 )
24
 
23
 
25
 // 赠券卡券
24
 // 赠券卡券
43
 	}
42
 	}
44
 }
43
 }
45
 
44
 
46
-// MarketingInfo 课程
45
+// MarketingInfo 
47
 type MarketingInfo struct {
46
 type MarketingInfo struct {
48
 	model.SysActivity `xorm:"extends"`
47
 	model.SysActivity `xorm:"extends"`
48
+	CaseName		 string
49
+	ActionId     string
50
+	ActiveType  string
51
+	ResourceType string
52
+	ResourceDesc string
49
 	Actions []model.SysActivityAction
53
 	Actions []model.SysActivityAction
50
 }
54
 }
51
 
55
 
53
 func (m *MarketingDAO) GetMarketingList(page int, pageSize int) ([]MarketingInfo ,error){
57
 func (m *MarketingDAO) GetMarketingList(page int, pageSize int) ([]MarketingInfo ,error){
54
 
58
 
55
 	var news []MarketingInfo
59
 	var news []MarketingInfo
56
-	sql := `select * from sys_activity new order by new.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + ", " + strconv.Itoa(pageSize)
60
+	//sql := `select * from sys_activity new order by new.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + ", " + strconv.Itoa(pageSize)
61
+	sql :=`SELECT sc.case_name,sa.*,sas.action_id,sas.active_type,sas.resource_type,sas.resource_desc from sys_activity sa LEFT JOIN sys_activity_action sas on sa.activity_id = sas.activity_id LEFT JOIN sys_case sc on sa.case_id = sc.case_id where sa.status != -1 order by sa.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + ", " + strconv.Itoa(pageSize)
62
+
57
 	err := m.db.Sql(sql).Find(&news)
63
 	err := m.db.Sql(sql).Find(&news)
58
 	return news, err
64
 	return news, err
59
 
65
 
72
 
78
 
73
 
79
 
74
 // AddMarketing 添加
80
 // AddMarketing 添加
75
-func (m *MarketingDAO) AddMarketing(activity *model.SysActivity) (*model.SysActivity, error) {
81
+func (m *MarketingDAO) AddMarketing(activity model.SysActivity, caseId string) (*model.SysActivity, error) {
76
 	activity.ActivityId = utils.GetGUID()
82
 	activity.ActivityId = utils.GetGUID()
77
 	activity.CreateDate = time.Now()
83
 	activity.CreateDate = time.Now()
78
 	//activity.Status = models.STATUS_NORMAL
84
 	//activity.Status = models.STATUS_NORMAL
79
 	activity.Status = NORMAL // 状态为正常
85
 	activity.Status = NORMAL // 状态为正常
80
 	org := m.ctx.Get("org").(model.SysOrg)
86
 	org := m.ctx.Get("org").(model.SysOrg)
81
 	activity.OrgId = org.OrgId
87
 	activity.OrgId = org.OrgId
82
-	caseinfo := m.ctx.Get("currentCase").(model.SysCase)
83
-	activity.CaseId = caseinfo.CaseId
84
-	//activity.CaseId = user.
88
+	activity.CaseId = caseId
85
 
89
 
86
-	_, err := m.db.Insert(activity)
90
+	_, err := m.db.Insert(&activity)
87
 
91
 
88
-	// // 添加活动动作数据
89
-	// var new model.SysActivityAction
90
-	// new.ActionId = activity.ActivityId
91
-	// new.ActiveType = activity.ActivityType
92
-	return activity, err
92
+	return &activity, err
93
 }
93
 }
94
 
94
 
95
 
95
 

+ 3
- 2
models/marketing/work.go View File

27
 }
27
 }
28
 
28
 
29
 // 添加 活动动作
29
 // 添加 活动动作
30
-func (m *WorkDAO) AddWork(action *model.SysActivityAction) (*model.SysActivityAction,error){
30
+func (m *WorkDAO) AddWork(action model.SysActivityAction) (*model.SysActivityAction,error){
31
 	action.ActionId = utils.GetGUID()
31
 	action.ActionId = utils.GetGUID()
32
+	println("service: 主键:" + action.ActionId + "活动ID"+action.ActivityId+" 活动类型-"+action.ActiveType+" 资源描述-"+action.ResourceDesc+" 资源类型-"+	action.ResourceType)
32
 	_,err := m.db.Insert(&action)
33
 	_,err := m.db.Insert(&action)
33
 
34
 
34
-	return action,err
35
+	return &action,err
35
 
36
 
36
 }
37
 }
37
 
38
 

+ 15
- 15
models/model/sys_activity.go View File

1
-package model
2
-
3
-import (
4
-	"time"
5
-)
6
-
7
-type SysActivity struct {
8
-	ActivityId   string    `xorm:"not null pk VARCHAR(64)"`
9
-	ActivityName string    `xorm:"VARCHAR(50)"`
10
-	ActivityType string    `xorm:"VARCHAR(64)"`
11
-	OrgId        string    `xorm:"VARCHAR(64)"`
12
-	CaseId       string    `xorm:"VARCHAR(64)"`
13
-	Status       int       `xorm:"SMALLINT(6)"`
14
-	CreateDate   time.Time `xorm:"DATETIME"`
15
-}
1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type SysActivity struct {
8
+	ActivityId   string    `xorm:"not null pk VARCHAR(64)"`
9
+	ActivityName string    `xorm:"VARCHAR(50)"`
10
+	ActivityType string    `xorm:"VARCHAR(64)"`
11
+	OrgId        string    `xorm:"VARCHAR(64)"`
12
+	CaseId       string    `xorm:"VARCHAR(64)"`
13
+	Status       int       `xorm:"SMALLINT(6)"`
14
+	CreateDate   time.Time `xorm:"DATETIME"`
15
+}

+ 6
- 3
models/model/sys_case_record.go View File

1
 package model
1
 package model
2
 
2
 
3
-import "time"
3
+import (
4
+	"time"
5
+)
4
 
6
 
5
 type SysCaseRecord struct {
7
 type SysCaseRecord struct {
6
 	RecordId   string    `xorm:"not null pk VARCHAR(64)"`
8
 	RecordId   string    `xorm:"not null pk VARCHAR(64)"`
7
 	CaseId     string    `xorm:"not null VARCHAR(64)"`
9
 	CaseId     string    `xorm:"not null VARCHAR(64)"`
8
-	Month      string    `xorm:"VARCHAR(20)"`
10
+	Month      string    `xorm:"VARCHAR(100)"`
9
 	Num        int       `xorm:"INT(11)"`
11
 	Num        int       `xorm:"INT(11)"`
10
-	IsOver     int       `xorm:"SMALLINT(6)"`
11
 	Status     int       `xorm:"SMALLINT(6)"`
12
 	Status     int       `xorm:"SMALLINT(6)"`
12
 	CreateDate time.Time `xorm:"DATETIME"`
13
 	CreateDate time.Time `xorm:"DATETIME"`
14
+	CreateUser string    `xorm:"VARCHAR(64)"`
15
+	IsOver     int       `xorm:"SMALLINT(6)"`
13
 }
16
 }

+ 1
- 1
models/model/sys_wechat_conf.go View File

1
 package model
1
 package model
2
 
2
 
3
 type SysWechatConf struct {
3
 type SysWechatConf struct {
4
-	ConfId string `xorm:"VARCHAR(64)"`
4
+	ConfId string `xorm:"not null pk VARCHAR(64)"`
5
 	OrgId  string `xorm:"VARCHAR(64)"`
5
 	OrgId  string `xorm:"VARCHAR(64)"`
6
 	Type   string `xorm:"comment('wechat 微信公众号 mini 小程序') VARCHAR(20)"`
6
 	Type   string `xorm:"comment('wechat 微信公众号 mini 小程序') VARCHAR(20)"`
7
 	Appid  string `xorm:"VARCHAR(50)"`
7
 	Appid  string `xorm:"VARCHAR(50)"`

+ 15
- 0
models/model/ta_body_check.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaBodyCheck struct {
8
+	Id          int       `xorm:"not null pk autoincr INT(11)"`
9
+	UserId      int       `xorm:"not null INT(11)"`
10
+	EquipmentId string    `xorm:"not null VARCHAR(100)"`
11
+	CreateDate  time.Time `xorm:"not null DATETIME"`
12
+	Status      int       `xorm:"not null comment('1为正常') INT(11)"`
13
+	CaseId      int       `xorm:"INT(11)"`
14
+	ReportUrl   string    `xorm:"TEXT"`
15
+}

+ 9
- 0
models/model/ta_card_coupon_channel.go View File

1
+package model
2
+
3
+type TaCardCouponChannel struct {
4
+	CardCouponChannelId string `xorm:"not null pk VARCHAR(64)"`
5
+	CardCouponType      string `xorm:"VARCHAR(32)"`
6
+	ChannelId           string `xorm:"VARCHAR(64)"`
7
+	CardCouponId        string `xorm:"VARCHAR(64)"`
8
+	Status              int    `xorm:"SMALLINT(6)"`
9
+}

+ 13
- 0
models/model/ta_case_equipment.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaCaseEquipment struct {
8
+	Id          int       `xorm:"not null pk autoincr INT(11)"`
9
+	CaseId      int       `xorm:"not null INT(11)"`
10
+	EquipmentId string    `xorm:"VARCHAR(200)"`
11
+	Status      int       `xorm:"INT(11)"`
12
+	CreateDate  time.Time `xorm:"DATETIME"`
13
+}

+ 13
- 16
models/model/ta_checkin_record.go View File

5
 )
5
 )
6
 
6
 
7
 type TaCheckinRecord struct {
7
 type TaCheckinRecord struct {
8
-
9
-	 CheckinId     string    `xorm:"not null pk VARCHAR(64)"` 
10
-   CaseId        string    `xorm:"VARCHAR(64)"`  
11
-   CustomerId    string    `xorm:"VARCHAR(64)"`  
12
-   Phone         string    `xorm:"VARCHAR(32)"`   
13
-   OpenId        string    `xorm:"VARCHAR(128)"`  
14
-   Name          string    `xorm:"VARCHAR(32)"`   
15
-   CustomerName  string    `xorm:"VARCHAR(32)"`  
16
-   CaseName      string    `xorm:"VARCHAR(32)"` 
17
-   ActivityId    string    `xorm:"VARCHAR(64)"`  
18
-   ActivityName  string    `xorm:"VARCHAR(64)"`  
19
-   CreateDate    time.Time `xorm:"DATETIME"`     
20
-   Status        int       `xorm:"SMALLINT(6)"`
21
-   UserId        string    `xorm:"VARCHAR(64)"`
22
-   
23
-}
8
+	CheckinId    string    `xorm:"not null pk VARCHAR(64)"`
9
+	CaseId       string    `xorm:"VARCHAR(64)"`
10
+	CustomerId   string    `xorm:"VARCHAR(64)"`
11
+	Phone        string    `xorm:"VARCHAR(32)"`
12
+	OpenId       string    `xorm:"VARCHAR(128)"`
13
+	Name         string    `xorm:"VARCHAR(32)"`
14
+	CustomerName string    `xorm:"VARCHAR(32)"`
15
+	CaseName     string    `xorm:"VARCHAR(32)"`
16
+	ActivityId   string    `xorm:"VARCHAR(64)"`
17
+	ActivityName string    `xorm:"VARCHAR(64)"`
18
+	CreateDate   time.Time `xorm:"DATETIME"`
19
+	Status       int       `xorm:"SMALLINT(6)"`
20
+}

+ 20
- 20
models/model/ta_coupon.go View File

5
 )
5
 )
6
 
6
 
7
 type TaCoupon struct {
7
 type TaCoupon struct {
8
-	CouponId     string    `xorm:"not null pk VARCHAR(64)"`
9
-	CouponName   string    `xorm:"VARCHAR(255)"`
10
-	CouponTypeId string    `xorm:"VARCHAR(64)"`
11
-	SendType     string    `xorm:"VARCHAR(20)"`
12
-	VideoUrl     string    `xorm:"TEXT"`
13
-	CoverUrl     string    `xorm:"TEXT"`
14
-	Price        string    `xorm:"DECIMAL(64)"`
15
-	IsAll        int       `xorm:"TINYINT(1)"`
16
-	StartDate    time.Time `xorm:"DATETIME"`
17
-	EndDate      time.Time `xorm:"DATETIME"`
18
-	ValidDays    int       `xorm:"INT(11)"`
19
-	TotalCount   int       `xorm:"INT(11)"`
20
-	SentCount    int       `xorm:"INT(11)"`
21
-	UsedCount    int       `xorm:"INT(11)"`
22
-	Status       int       `xorm:"comment('0未发布 1发布 2过期') SMALLINT(6)"`
23
-	CaseId       string    `xorm:"VARCHAR(64)"`
24
-	OrgId        string    `xorm:"VARCHAR(64)"`
25
-	CreateDate   time.Time `xorm:"DATETIME"`
26
-	CreateUser   string    `xorm:"VARCHAR(64)"`
27
-	IsOver       int       `xorm:"TINYINT(1)"`
8
+	CouponId   string    `xorm:"not null pk VARCHAR(64)"`
9
+	CouponName string    `xorm:"VARCHAR(255)"`
10
+	CouponType string    `xorm:"VARCHAR(20)"`
11
+	SendType   string    `xorm:"comment('case 案场 channel渠道') VARCHAR(50)"`
12
+	VideoUrl   string    `xorm:"TEXT"`
13
+	CoverUrl   string    `xorm:"TEXT"`
14
+	Price      string    `xorm:"DECIMAL(64)"`
15
+	IsAll      int       `xorm:"TINYINT(1)"`
16
+	StartDate  time.Time `xorm:"DATETIME"`
17
+	EndDate    time.Time `xorm:"DATETIME"`
18
+	ValidDays  int       `xorm:"INT(11)"`
19
+	TotalCount int       `xorm:"INT(11)"`
20
+	SentCount  int       `xorm:"INT(11)"`
21
+	UsedCount  int       `xorm:"INT(11)"`
22
+	Status     int       `xorm:"comment('0未发布 1发布 2过期') SMALLINT(6)"`
23
+	CaseId     string    `xorm:"VARCHAR(64)"`
24
+	OrgId      string    `xorm:"VARCHAR(64)"`
25
+	CreateDate time.Time `xorm:"DATETIME"`
26
+	CreateUser string    `xorm:"VARCHAR(64)"`
27
+	IsOver     int       `xorm:"TINYINT(1)"`
28
 }
28
 }

+ 17
- 20
models/model/ta_coupon_card.go View File

5
 )
5
 )
6
 
6
 
7
 type TaCouponCard struct {
7
 type TaCouponCard struct {
8
-	CardId           string    `xorm:"not null pk VARCHAR(64)"`
9
-	CardTypeId       string    `xorm:"VARCHAR(64)"`
10
-	SendType         int       `xorm:"comment('0案场 1渠道') SMALLINT(6)"`
11
-	VideoUrl         string    `xorm:"TEXT"`
12
-	CoverUrl         string    `xorm:"TEXT"`
13
-	Price            float32   `xorm:"FLOAT(64)"`
14
-	StartDate        time.Time `xorm:"DATETIME"`
15
-	EndDate          time.Time `xorm:"DATETIME"`
16
-	ShareDescription string    `xorm:"VARCHAR(255)"`
17
-	RuleDescription  string    `xorm:"VARCHAR(400)"`
18
-	UseDescription   string    `xorm:"TEXT"`
19
-	TotalCount       int       `xorm:"INT(11)"`
20
-	SentCount        int       `xorm:"INT(11)"`
21
-	UsedCount        int       `xorm:"INT(11)"`
22
-	Status           int       `xorm:"comment('0未发布 1发布 2过期') SMALLINT(6)"`
23
-	CaseId           string    `xorm:"VARCHAR(64)"`
24
-	OrgId            string    `xorm:"VARCHAR(64)"`
25
-	CreateDate       time.Time `xorm:"DATETIME"`
26
-	CreateUser       string    `xorm:"VARCHAR(64)"`
27
-	IsOver           int       `xorm:"TINYINT(1)"`
8
+	CardId     string    `xorm:"not null pk VARCHAR(64)"`
9
+	CardName   string    `xorm:"VARCHAR(50)"`
10
+	SendType   string    `xorm:"comment('case 案场 channel渠道') VARCHAR(50)"`
11
+	VideoUrl   string    `xorm:"TEXT"`
12
+	CoverUrl   string    `xorm:"TEXT"`
13
+	Price      string    `xorm:"DECIMAL(64)"`
14
+	StartDate  time.Time `xorm:"DATETIME"`
15
+	EndDate    time.Time `xorm:"DATETIME"`
16
+	TotalCount int       `xorm:"INT(11)"`
17
+	SentCount  int       `xorm:"INT(11)"`
18
+	UsedCount  int       `xorm:"INT(11)"`
19
+	Status     int       `xorm:"comment('0未发布 1发布 2过期') SMALLINT(6)"`
20
+	CaseId     string    `xorm:"VARCHAR(64)"`
21
+	OrgId      string    `xorm:"VARCHAR(64)"`
22
+	CreateDate time.Time `xorm:"DATETIME"`
23
+	CreateUser string    `xorm:"VARCHAR(64)"`
24
+	IsOver     int       `xorm:"TINYINT(1)"`
28
 }
25
 }

+ 0
- 2
models/model/ta_coupon_card_target.go View File

3
 type TaCouponCardTarget struct {
3
 type TaCouponCardTarget struct {
4
 	TargetId   string `xorm:"not null pk VARCHAR(64)"`
4
 	TargetId   string `xorm:"not null pk VARCHAR(64)"`
5
 	CardId     string `xorm:"VARCHAR(64)"`
5
 	CardId     string `xorm:"VARCHAR(64)"`
6
-	DetailId   string `xorm:"VARCHAR(64)"`
7
 	TargetName string `xorm:"VARCHAR(255)"`
6
 	TargetName string `xorm:"VARCHAR(255)"`
8
-	CardState  string `xorm:"VARCHAR(64)"`
9
 }
7
 }

+ 3
- 1
models/model/ta_coupon_give_record.go View File

1
 package model
1
 package model
2
 
2
 
3
-import "time"
3
+import (
4
+	"time"
5
+)
4
 
6
 
5
 type TaCouponGiveRecord struct {
7
 type TaCouponGiveRecord struct {
6
 	RecId      string    `xorm:"not null pk VARCHAR(64)"`
8
 	RecId      string    `xorm:"not null pk VARCHAR(64)"`

+ 1
- 1
models/model/ta_coupon_target.go View File

1
 package model
1
 package model
2
 
2
 
3
 type TaCouponTarget struct {
3
 type TaCouponTarget struct {
4
-	TargetType string `xorm:"not null pk VARCHAR(20)"`
5
 	TargetId   string `xorm:"not null pk VARCHAR(64)"`
4
 	TargetId   string `xorm:"not null pk VARCHAR(64)"`
5
+	TargetType string `xorm:"not null pk VARCHAR(64)"`
6
 	CouponId   string `xorm:"VARCHAR(64)"`
6
 	CouponId   string `xorm:"VARCHAR(64)"`
7
 	TargetName string `xorm:"VARCHAR(255)"`
7
 	TargetName string `xorm:"VARCHAR(255)"`
8
 }
8
 }

+ 1
- 1
models/model/ta_course_orders_coupon.go View File

7
 type TaCourseOrdersCoupon struct {
7
 type TaCourseOrdersCoupon struct {
8
 	OrdersCouponId string    `xorm:"not null pk VARCHAR(64)"`
8
 	OrdersCouponId string    `xorm:"not null pk VARCHAR(64)"`
9
 	OrdersId       string    `xorm:"VARCHAR(64)"`
9
 	OrdersId       string    `xorm:"VARCHAR(64)"`
10
-	CouponType     string    `xorm:"VARCHAR(20)"`
11
 	CouponId       string    `xorm:"VARCHAR(64)"`
10
 	CouponId       string    `xorm:"VARCHAR(64)"`
12
 	CouponName     string    `xorm:"VARCHAR(50)"`
11
 	CouponName     string    `xorm:"VARCHAR(50)"`
13
 	UsedAmount     string    `xorm:"DECIMAL(8,2)"`
12
 	UsedAmount     string    `xorm:"DECIMAL(8,2)"`
14
 	Status         int       `xorm:"SMALLINT(6)"`
13
 	Status         int       `xorm:"SMALLINT(6)"`
15
 	CreateDate     time.Time `xorm:"DATETIME"`
14
 	CreateDate     time.Time `xorm:"DATETIME"`
15
+	CouponType     string    `xorm:"VARCHAR(50)"`
16
 }
16
 }

+ 1
- 1
models/model/ta_customer_account.go View File

7
 type TaCustomerAccount struct {
7
 type TaCustomerAccount struct {
8
 	AccountId    string    `xorm:"not null pk VARCHAR(64)"`
8
 	AccountId    string    `xorm:"not null pk VARCHAR(64)"`
9
 	CustomerId   string    `xorm:"VARCHAR(64)"`
9
 	CustomerId   string    `xorm:"VARCHAR(64)"`
10
-	CustomerName string    `xorm:"VARCHAR(200)"`
10
+	CustomerName string    `xorm:"VARCHAR(50)"`
11
 	Amount       string    `xorm:"DECIMAL(8,2)"`
11
 	Amount       string    `xorm:"DECIMAL(8,2)"`
12
 	Points       string    `xorm:"DECIMAL(8,2)"`
12
 	Points       string    `xorm:"DECIMAL(8,2)"`
13
 	Status       int       `xorm:"SMALLINT(6)"`
13
 	Status       int       `xorm:"SMALLINT(6)"`

+ 1
- 1
models/model/ta_customer_course.go View File

11
 	OrgId            string    `xorm:"VARCHAR(64)"`
11
 	OrgId            string    `xorm:"VARCHAR(64)"`
12
 	CaseId           string    `xorm:"VARCHAR(64)"`
12
 	CaseId           string    `xorm:"VARCHAR(64)"`
13
 	CourseName       string    `xorm:"VARCHAR(50)"`
13
 	CourseName       string    `xorm:"VARCHAR(50)"`
14
-	LocationId       string    `xorm:"VARCHAR(64)"`
14
+	LocationId       string    `xorm:"CHAR(10)"`
15
 	Price            string    `xorm:"DECIMAL(8,2)"`
15
 	Price            string    `xorm:"DECIMAL(8,2)"`
16
 	CourseNum        int       `xorm:"INT(11)"`
16
 	CourseNum        int       `xorm:"INT(11)"`
17
 	JoinNum          int       `xorm:"INT(11)"`
17
 	JoinNum          int       `xorm:"INT(11)"`

+ 1
- 0
models/model/ta_customer_gym.go View File

13
 	SalesName       string    `xorm:"VARCHAR(32)"`
13
 	SalesName       string    `xorm:"VARCHAR(32)"`
14
 	StartDate       time.Time `xorm:"DATETIME"`
14
 	StartDate       time.Time `xorm:"DATETIME"`
15
 	EndDate         time.Time `xorm:"DATETIME"`
15
 	EndDate         time.Time `xorm:"DATETIME"`
16
+	CardStatus      string    `xorm:"VARCHAR(32)"`
16
 	Status          int       `xorm:"SMALLINT(6)"`
17
 	Status          int       `xorm:"SMALLINT(6)"`
17
 	ReceiveDate     time.Time `xorm:"DATETIME"`
18
 	ReceiveDate     time.Time `xorm:"DATETIME"`
18
 	GymType         string    `xorm:"VARCHAR(64)"`
19
 	GymType         string    `xorm:"VARCHAR(64)"`

+ 9
- 0
models/model/ta_experience_card_image.go View File

1
+package model
2
+
3
+type TaExperienceCardImage struct {
4
+	CardImageId  string `xorm:"not null pk VARCHAR(64)"`
5
+	CardId       string `xorm:"VARCHAR(64)"`
6
+	CardImageUrl string `xorm:"TEXT"`
7
+	Status       int    `xorm:"SMALLINT(6)"`
8
+	Sort         int    `xorm:"INT(11)"`
9
+}

+ 10
- 0
models/model/ta_experience_card_share.go View File

1
+package model
2
+
3
+type TaExperienceCardShare struct {
4
+	CardShareId        string `xorm:"not null pk VARCHAR(64)"`
5
+	CardId             string `xorm:"VARCHAR(64)"`
6
+	CardShareInfo      string `xorm:"TEXT"`
7
+	CardUseRule        string `xorm:"TEXT"`
8
+	CardUseInstruction string `xorm:"TEXT"`
9
+	Status             int    `xorm:"SMALLINT(6)"`
10
+}

+ 0
- 14
models/model/ta_experience_card_verification.go View File

1
-package model
2
-
3
-import (
4
-	"time"
5
-)
6
-
7
-type TaExperienceCardVerification struct {
8
-	ExperienceCardVerifyId   string    `xorm:"not null pk VARCHAR(64)"`
9
-	CustomerCardId           string    `xorm:"VARCHAR(64)"`
10
-	TargetId                 string    `xorm:"VARCHAR(64)"`
11
-	ExperienceCardVerifyTime time.Time `xorm:"DATETIME"`
12
-	ExperienceCardVerifyCase string    `xorm:"VARCHAR(64)"`
13
-	Status                   int       `xorm:"SMALLINT(6)"`
14
-}

+ 1
- 0
models/model/ta_forbid_user.go View File

13
 	EndDate    time.Time `xorm:"DATETIME"`
13
 	EndDate    time.Time `xorm:"DATETIME"`
14
 	Status     int       `xorm:"SMALLINT(6)"`
14
 	Status     int       `xorm:"SMALLINT(6)"`
15
 	CreateDate time.Time `xorm:"DATETIME"`
15
 	CreateDate time.Time `xorm:"DATETIME"`
16
+	CaseId     string    `xorm:"VARCHAR(64)"`
16
 }
17
 }

+ 2
- 2
models/model/ta_goods_orders.go View File

16
 	Amount     string    `xorm:"DECIMAL(8,2)"`
16
 	Amount     string    `xorm:"DECIMAL(8,2)"`
17
 	CreateDate time.Time `xorm:"DATETIME"`
17
 	CreateDate time.Time `xorm:"DATETIME"`
18
 	Status     int       `xorm:"SMALLINT(6)"`
18
 	Status     int       `xorm:"SMALLINT(6)"`
19
+	MakeStatus string    `xorm:"VARCHAR(20)"`
19
 	PayType    string    `xorm:"comment('vip VIP卡城币抵用
20
 	PayType    string    `xorm:"comment('vip VIP卡城币抵用
20
             coupon 优惠券抵用') VARCHAR(20)"`
21
             coupon 优惠券抵用') VARCHAR(20)"`
21
 	UserType     string `xorm:"VARCHAR(20)"`
22
 	UserType     string `xorm:"VARCHAR(20)"`
22
 	UserId       string `xorm:"VARCHAR(64)"`
23
 	UserId       string `xorm:"VARCHAR(64)"`
23
-	UserName     string `xorm:"VARCHAR(200)"`
24
+	UserName     string `xorm:"VARCHAR(50)"`
24
 	OrdersNum    int    `xorm:"INT(11)"`
25
 	OrdersNum    int    `xorm:"INT(11)"`
25
 	Remark       string `xorm:"TEXT"`
26
 	Remark       string `xorm:"TEXT"`
26
 	IsPay        int    `xorm:"TINYINT(1)"`
27
 	IsPay        int    `xorm:"TINYINT(1)"`
27
 	ActualAmount string `xorm:"DECIMAL(8,2)"`
28
 	ActualAmount string `xorm:"DECIMAL(8,2)"`
28
 	CouponAmount string `xorm:"DECIMAL(8,2)"`
29
 	CouponAmount string `xorm:"DECIMAL(8,2)"`
29
-	MakeStatus   string `xorm:"VARCHAR(20)"`
30
 }
30
 }

+ 20
- 0
models/model/ta_luckdraw.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaLuckdraw struct {
8
+	Id           int       `xorm:"not null pk autoincr INT(11)"`
9
+	Name         string    `xorm:"VARCHAR(50)"`
10
+	ThemeId      int       `xorm:"INT(11)"`
11
+	LuckdrawRule string    `xorm:"TEXT"`
12
+	BeginDate    time.Time `xorm:"DATETIME"`
13
+	EndDate      time.Time `xorm:"DATETIME"`
14
+	OrgId        string    `xorm:"VARCHAR(64)"`
15
+	CaseId       int       `xorm:"INT(11)"`
16
+	CreateDate   time.Time `xorm:"DATETIME"`
17
+	CreateUser   string    `xorm:"VARCHAR(64)"`
18
+	Remark       string    `xorm:"TEXT"`
19
+	Status       int       `xorm:"SMALLINT(6)"`
20
+}

+ 21
- 0
models/model/ta_luckdraw_prize.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaLuckdrawPrize struct {
8
+	Id                int       `xorm:"not null pk autoincr INT(11)"`
9
+	LuckdrawId        int       `xorm:"INT(11)"`
10
+	PrizeName         string    `xorm:"VARCHAR(50)"`
11
+	PrizeImg          string    `xorm:"TEXT"`
12
+	Stock             int       `xorm:"INT(11)"`
13
+	Remainder         int       `xorm:"INT(11)"`
14
+	Probability       int       `xorm:"INT(11)"`
15
+	PrizeDesc         string    `xorm:"TEXT"`
16
+	PrizeLink         string    `xorm:"TEXT"`
17
+	Status            int       `xorm:"SMALLINT(6)"`
18
+	IsReality         int       `xorm:"SMALLINT(6)"`
19
+	VerificationStart time.Time `xorm:"DATETIME"`
20
+	VerificationEnd   time.Time `xorm:"DATETIME"`
21
+}

+ 20
- 0
models/model/ta_luckdraw_record.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaLuckdrawRecord struct {
8
+	Id           int       `xorm:"not null pk autoincr INT(11)"`
9
+	LuckdrawId   int       `xorm:"INT(11)"`
10
+	PrizeId      int       `xorm:"INT(11)"`
11
+	PrizeName    string    `xorm:"VARCHAR(50)"`
12
+	UserId       int       `xorm:"INT(11)"`
13
+	UserName     string    `xorm:"VARCHAR(50)"`
14
+	UserHeadImg  string    `xorm:"TEXT"`
15
+	CreateDate   time.Time `xorm:"DATETIME"`
16
+	Status       int       `xorm:"SMALLINT(6)"`
17
+	WriteoffDate time.Time `xorm:"DATETIME"`
18
+	OrgId        string    `xorm:"VARCHAR(64)"`
19
+	CaseId       int       `xorm:"INT(11)"`
20
+}

+ 16
- 0
models/model/ta_luckdraw_writeoff.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaLuckdrawWriteoff struct {
8
+	Id           int       `xorm:"not null pk autoincr INT(11)"`
9
+	LuckdrawId   int       `xorm:"INT(11)"`
10
+	RecordId     int       `xorm:"INT(11)"`
11
+	WriteoffDate time.Time `xorm:"DATETIME"`
12
+	WriteoffUser int       `xorm:"INT(11)"`
13
+	Status       int       `xorm:"SMALLINT(6)"`
14
+	OrgId        string    `xorm:"VARCHAR(64)"`
15
+	CaseId       int       `xorm:"INT(11)"`
16
+}

+ 14
- 0
models/model/ta_presentation.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaPresentation struct {
8
+	Id          int       `xorm:"not null pk autoincr INT(11)"`
9
+	CheckId     int       `xorm:"not null INT(11)"`
10
+	CheckType   int       `xorm:"SMALLINT(6)"`
11
+	CheckDate   time.Time `xorm:"DATETIME"`
12
+	CheckResult string    `xorm:"TEXT"`
13
+	ReportUrl   string    `xorm:"TEXT"`
14
+}

+ 10
- 0
models/model/ta_presentation_detail.go View File

1
+package model
2
+
3
+type TaPresentationDetail struct {
4
+	Id             int    `xorm:"not null pk autoincr INT(11)"`
5
+	PresentationId int    `xorm:"not null INT(11)"`
6
+	CheckName      string `xorm:"VARCHAR(50)"`
7
+	CheckVal       string `xorm:"VARCHAR(500)"`
8
+	SpecName       string `xorm:"VARCHAR(50)"`
9
+	Remark         string `xorm:"TEXT"`
10
+}

+ 14
- 0
models/model/ta_prize_detail.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaPrizeDetail struct {
8
+	Id          int       `xorm:"not null pk autoincr INT(11)"`
9
+	PrizeId     int       `xorm:"INT(11)"`
10
+	Url         string    `xorm:"TEXT"`
11
+	Status      int       `xorm:"SMALLINT(6)"`
12
+	ReceiveId   int       `xorm:"INT(11)"`
13
+	ReceiveDate time.Time `xorm:"DATETIME"`
14
+}

+ 22
- 0
models/model/ta_share_lucky_record.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaShareLuckyRecord struct {
8
+	Id                 int       `xorm:"not null pk autoincr INT(11)"`
9
+	FromCustomerId     int       `xorm:"INT(11)"`
10
+	FromCustomerName   string    `xorm:"VARCHAR(32)"`
11
+	FromCustomerWxname string    `xorm:"VARCHAR(64)"`
12
+	FromCustomerTel    string    `xorm:"VARCHAR(32)"`
13
+	ToCustomerId       int       `xorm:"INT(11)"`
14
+	ToCustomerName     string    `xorm:"VARCHAR(32)"`
15
+	ToCustomerWxname   string    `xorm:"VARCHAR(64)"`
16
+	ToCustomerTel      string    `xorm:"VARCHAR(32)"`
17
+	CreateDate         time.Time `xorm:"DATETIME"`
18
+	CaseId             int       `xorm:"INT(11)"`
19
+	Status             int       `xorm:"SMALLINT(6)"`
20
+	LuckydrawId        int       `xorm:"INT(11)"`
21
+	LuckydrawName      string    `xorm:"VARCHAR(128)"`
22
+}

+ 25
- 0
models/model/ta_statistics_card_coupon_usage.go View File

1
+package model
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+type TaStatisticsCardCouponUsage struct {
8
+	CardCouponUsageId string    `xorm:"not null pk VARCHAR(64)"`
9
+	CardCouponType    string    `xorm:"VARCHAR(32)"`
10
+	CardCouponName    string    `xorm:"VARCHAR(64)"`
11
+	CardCouponId      string    `xorm:"VARCHAR(64)"`
12
+	UsedItemId        string    `xorm:"VARCHAR(64)"`
13
+	UsedItemName      string    `xorm:"VARCHAR(32)"`
14
+	ReceiveType       string    `xorm:"VARCHAR(32)"`
15
+	CustomerId        string    `xorm:"VARCHAR(64)"`
16
+	CustomerName      string    `xorm:"VARCHAR(64)"`
17
+	CustomerPhone     string    `xorm:"VARCHAR(100)"`
18
+	SalesId           string    `xorm:"VARCHAR(64)"`
19
+	SalesName         string    `xorm:"VARCHAR(32)"`
20
+	ValidDate         time.Time `xorm:"DATETIME"`
21
+	ReceiveDate       time.Time `xorm:"DATETIME"`
22
+	VerifyDate        time.Time `xorm:"DATETIME"`
23
+	VerifyStatus      string    `xorm:"VARCHAR(32)"`
24
+	Status            int       `xorm:"SMALLINT(6)"`
25
+}

+ 8
- 0
models/model/td_check_spec.go View File

1
+package model
2
+
3
+type TdCheckSpec struct {
4
+	Id       int    `xorm:"not null pk autoincr INT(11)"`
5
+	Name     string `xorm:"not null VARCHAR(50)"`
6
+	SortName string `xorm:"not null VARCHAR(50)"`
7
+	Standard string `xorm:"VARCHAR(50)"`
8
+}

+ 6
- 0
models/model/td_check_type.go View File

1
+package model
2
+
3
+type TdCheckType struct {
4
+	Id       int    `xorm:"not null pk autoincr INT(11)"`
5
+	TypeName string `xorm:"VARCHAR(50)"`
6
+}

+ 0
- 7
models/model/td_coupon_type.go View File

1
-package model
2
-
3
-type TdCouponType struct {
4
-	CouponTypeId   string `xorm:"not null pk VARCHAR(64)"`
5
-	CouponTypeName string `xorm:"VARCHAR(128)"`
6
-	OrgId          string `xorm:"VARCHAR(64)"`
7
-}

+ 1
- 1
models/model/td_goods_type.go View File

7
 type TdGoodsType struct {
7
 type TdGoodsType struct {
8
 	TypeId      string    `xorm:"not null pk VARCHAR(64)"`
8
 	TypeId      string    `xorm:"not null pk VARCHAR(64)"`
9
 	TypeName    string    `xorm:"VARCHAR(32)"`
9
 	TypeName    string    `xorm:"VARCHAR(32)"`
10
-	EnglishName string    `xorm:"VARCHAR(20)"`
11
 	CaseId      string    `xorm:"VARCHAR(64)"`
10
 	CaseId      string    `xorm:"VARCHAR(64)"`
12
 	OrgId       string    `xorm:"VARCHAR(64)"`
11
 	OrgId       string    `xorm:"VARCHAR(64)"`
13
 	CreateUser  string    `xorm:"VARCHAR(64)"`
12
 	CreateUser  string    `xorm:"VARCHAR(64)"`
14
 	CreateDate  time.Time `xorm:"DATETIME"`
13
 	CreateDate  time.Time `xorm:"DATETIME"`
15
 	Status      int       `xorm:"SMALLINT(6)"`
14
 	Status      int       `xorm:"SMALLINT(6)"`
15
+	EnglishName string    `xorm:"VARCHAR(20)"`
16
 }
16
 }

+ 8
- 0
models/model/td_luckdraw_theme.go View File

1
+package model
2
+
3
+type TdLuckdrawTheme struct {
4
+	Id        int    `xorm:"not null pk autoincr INT(11)"`
5
+	ThemeName string `xorm:"VARCHAR(50)"`
6
+	Status    int    `xorm:"SMALLINT(6)"`
7
+	OrgId     string `xorm:"VARCHAR(64)"`
8
+}

+ 10
- 5
models/model/td_spec.go View File

1
 package model
1
 package model
2
 
2
 
3
+import (
4
+	"time"
5
+)
6
+
3
 type TdSpec struct {
7
 type TdSpec struct {
4
-	SpecId   string `xorm:"not null pk VARCHAR(64)"`
5
-	SpecName string `xorm:"VARCHAR(50)"`
6
-	Status   int    `xorm:"SMALLINT(6)"`
7
-	OrgId    string `xorm:"VARCHAR(64)"`
8
-	CaseId   string `xorm:"VARCHAR(64)"`
8
+	SpecId     string    `xorm:"not null pk VARCHAR(64)"`
9
+	SpecName   string    `xorm:"VARCHAR(50)"`
10
+	Status     int       `xorm:"SMALLINT(6)"`
11
+	OrgId      string    `xorm:"VARCHAR(64)"`
12
+	CaseId     string    `xorm:"VARCHAR(64)"`
13
+	CreateDate time.Time `xorm:"DATETIME"`
9
 }
14
 }

+ 11
- 0
models/model/td_wechat_conf.go View File

1
+package model
2
+
3
+type TdWechatConf struct {
4
+	Appid        string `xorm:"not null pk VARCHAR(100)"`
5
+	Secret       string `xorm:"VARCHAR(100)"`
6
+	Token        string `xorm:"VARCHAR(100)"`
7
+	Aeskey       string `xorm:"VARCHAR(100)"`
8
+	Wxid         string `xorm:"VARCHAR(100)"`
9
+	MessageTplId string `xorm:"VARCHAR(200)"`
10
+	Menu         string `xorm:"TEXT"`
11
+}

+ 109
- 8
models/system/user.go View File

250
 	return err
250
 	return err
251
 }
251
 }
252
 
252
 
253
+// GetUserBelongCase 获取用户默认案场
254
+func (m *UserDAO) GetUserBelongCase(userid string) (model.SysUserCase, error) {
255
+	var usercase model.SysUserCase
256
+	_, err := m.db.Where("is_belong=1").And("user_id=?", userid).Get(&usercase)
257
+	return usercase, err
258
+}
259
+
253
 // DelUserBelongCase 删除用户的所属案场
260
 // DelUserBelongCase 删除用户的所属案场
254
 func (m *UserDAO) DelUserBelongCase(userid string) error {
261
 func (m *UserDAO) DelUserBelongCase(userid string) error {
255
 	sql := "delete from sys_user_case where is_belong=1 and user_id='" + userid + "'"
262
 	sql := "delete from sys_user_case where is_belong=1 and user_id='" + userid + "'"
333
 }
340
 }
334
 
341
 
335
 // GetUserCustomer 获取我的推荐客户
342
 // GetUserCustomer 获取我的推荐客户
336
-func (m *UserDAO) GetUserCustomer(userid string, page int, pageSize int) ([]model.TaCustomer, error) {
343
+func (m *UserDAO) GetUserCustomer(userid, isrecommend string, page int, pageSize int) ([]model.TaCustomer, error) {
337
 	var customers []model.TaCustomer
344
 	var customers []model.TaCustomer
338
-	err := m.db.Where("status>"+strconv.Itoa(models.STATUS_DEL)).And("recommend_id=?", userid).Limit(pageSize, (page-1)*pageSize).Desc("create_date").Find(&customers)
345
+	sql := `select * from ta_customer where recommend_id='` + userid + `'`
346
+	if isrecommend == "" {
347
+		sql += ` and customer_id in (
348
+			select customer_id from ta_customer_coupon where sales_id='` + userid + `'
349
+			union 
350
+			select customer_id from ta_customer_card where sales_id='` + userid + `'
351
+		)`
352
+	}
353
+	offset := (page - 1) * pageSize
354
+	sql += ` order by create_date desc LIMIT ` + strconv.Itoa(pageSize) + ` OFFSET ` + strconv.Itoa(offset)
355
+	err := m.db.Sql(sql).Find(&customers)
339
 	return customers, err
356
 	return customers, err
340
 }
357
 }
341
 
358
 
411
 	return userTypes, nil
428
 	return userTypes, nil
412
 }
429
 }
413
 
430
 
414
-// GetForbidUserByUserID 查询禁用人员
415
-func (m *UserDAO) GetForbidUserByUserID(userID string) ([]model.TaForbidUser, error) {
416
-	var fbUsers []model.TaForbidUser
431
+// CheckUserPhone 用户电话重复校验
432
+func (m *UserDAO) CheckUserPhone(userid, phone, orgid string) (bool, error) {
433
+	var users []model.SysUser
434
+	dao := m.db.Where("phone=?", phone).And("org_id=?", orgid)
435
+	if userid != "" {
436
+		dao.And("user_id <> '" + userid + "'")
437
+	}
438
+	err := dao.Find(&users)
439
+	if err != nil {
440
+		return false, err
441
+	}
442
+	if len(users) > 0 {
443
+		return false, nil
444
+	}
445
+	return true, nil
446
+}
447
+
448
+// CheckUserName 用户账户名重复校验
449
+func (m *UserDAO) CheckUserName(userid, username, orgid string) (bool, error) {
450
+	var users []model.SysUser
451
+	dao := m.db.Where("user_name=?", username).And("org_id=?", orgid)
452
+	if userid != "" {
453
+		dao.And("user_id <> '" + userid + "'")
454
+	}
455
+	err := dao.Find(&users)
456
+	if err != nil {
457
+		return false, err
458
+	}
459
+	if len(users) > 0 {
460
+		return false, nil
461
+	}
462
+	return true, nil
463
+}
417
 
464
 
418
-	if err := m.db.Where("user_id=?", userID).Find(&fbUsers); err != nil {
419
-		return nil, err
465
+// GetForbidUsers 获取所有禁止人员信息
466
+func (m *UserDAO) GetForbidUsers(caseid string) ([]model.TaForbidUser, error) {
467
+	var forbiduser []model.TaForbidUser
468
+	err := m.db.Where("case_id=?", caseid).And("(end_date is null or end_date > NOW())").And("status>" + strconv.Itoa(models.STATUS_DEL)).Find(&forbiduser)
469
+	return forbiduser, err
470
+}
471
+
472
+// GetForbidUserByUserID 获取禁止人员信息
473
+func (m *UserDAO) GetForbidUserByUserID(userid string) ([]model.TaForbidUser, error) {
474
+	var forbiduser []model.TaForbidUser
475
+	err := m.db.Where("user_id=?", userid).And("(end_date is null or end_date > NOW())").And("status>" + strconv.Itoa(models.STATUS_DEL)).Find(&forbiduser)
476
+	return forbiduser, err
477
+}
478
+
479
+// SaveForbidUser 保存禁止人员信息
480
+func (m *UserDAO) SaveForbidUser(forbid *model.TaForbidUser) error {
481
+	forbid.BeginDate = time.Now().Local()
482
+	forbid.Status = models.STATUS_NORMAL
483
+	forbid.ForbidId = utils.GetGUID()
484
+	_, err := m.db.Insert(forbid)
485
+	return err
486
+}
487
+
488
+// OpenForbidUser 取消禁止信息
489
+func (m *UserDAO) OpenForbidUser(forbid *model.TaForbidUser) error {
490
+	forbid.EndDate = time.Now().Local()
491
+	forbid.Status = models.STATUS_DEL
492
+	var col = []string{
493
+		"end_date",
494
+		"status",
420
 	}
495
 	}
496
+	_, err := m.db.Cols(col...).Where("forbid_id=?", forbid.ForbidId).Update(forbid)
497
+	return err
498
+}
499
+
500
+// UserWithCouponAndCard 用户关联卡券信息
501
+type UserWithCouponAndCard struct {
502
+	model.SysUser  `xorm:"extends"`
503
+	CustomerCoupon []model.TaCustomerCoupon
504
+	CustomerCard   []model.TaCustomerCard
505
+	OrdersDetail   []model.TaGoodsOrdersDetail
506
+}
421
 
507
 
422
-	return fbUsers, nil
508
+// GetCaseUserByType 获取案场所有销售信息
509
+func (m *UserDAO) GetCaseUserByType(caseid, usertype string) ([]UserWithCouponAndCard, error) {
510
+	var users []UserWithCouponAndCard
511
+	sql := `select a.* from sys_user a inner join sys_user_type b on a.user_id=b.user_id
512
+	inner join sys_user_case c on a.user_id=c.user_id
513
+	where a.status>? and c.case_id =? and b.type_id=?`
514
+	err := m.db.Sql(sql, models.STATUS_DEL, caseid, usertype).Find(&users)
515
+	return users, err
516
+}
517
+
518
+// GetUserDetailByID 根据id获取案场销售
519
+func (m *UserDAO) GetUserDetailByID(userid string) (*UserWithCouponAndCard, error) {
520
+	var user UserWithCouponAndCard
521
+	sql := `select * from sys_user where status>? and user_id=?`
522
+	_, err := m.db.Sql(sql, models.STATUS_DEL, userid).Get(&user)
523
+	return &user, err
423
 }
524
 }

+ 267
- 249
routers/common.go View File

1
-package routers
2
-
3
-import (
4
-	"spaceofcheng/services/controllers"
5
-	"spaceofcheng/services/controllers/cases"
6
-	"spaceofcheng/services/controllers/channel"
7
-	"spaceofcheng/services/controllers/coupon"
8
-	"spaceofcheng/services/controllers/course"
9
-	"spaceofcheng/services/controllers/customer"
10
-	"spaceofcheng/services/controllers/goods"
11
-	"spaceofcheng/services/controllers/marketing"
12
-	"spaceofcheng/services/controllers/message"
13
-	"spaceofcheng/services/controllers/system"
14
-	"spaceofcheng/services/controllers/user"
15
-	"spaceofcheng/services/controllers/verify"
16
-	"spaceofcheng/services/controllers/vipcard"
17
-
18
-	"github.com/astaxie/beego"
19
-)
20
-
21
-func getCommonRoutes() beego.LinkNamespace {
22
-	prefix := beego.AppConfig.String("api::common")
23
-
24
-	return beego.NSNamespace(prefix,
25
-		// 商品分类
26
-		beego.NSRouter("/type/goods", &goods.GoodsController{}, "get:GetGoodsType"),
27
-		beego.NSRouter("/type/goods/:typeid", &goods.GoodsController{}, "get:GetGoodsTypeByID"),
28
-		beego.NSRouter("/type/goods", &goods.GoodsController{}, "post:SaveGoodsType"),
29
-		beego.NSRouter("/type/goods/:typeid", &goods.GoodsController{}, "put:SaveGoodsType"),
30
-		beego.NSRouter("/type/goods/:typeid", &goods.GoodsController{}, "delete:DelGoodsType"),
31
-
32
-		// 商品规格
33
-		beego.NSRouter("/spec/goods", &goods.GoodsController{}, "get:GetGoodsSpec"),
34
-		beego.NSRouter("/spec/goods/:specid", &goods.GoodsController{}, "get:GetGoodsSpecByID"),
35
-		beego.NSRouter("/spec/goods", &goods.GoodsController{}, "post:SaveGoodsSpec"),
36
-		beego.NSRouter("/spec/goods/:specid", &goods.GoodsController{}, "put:SaveGoodsSpec"),
37
-		beego.NSRouter("/spec/goods/:specid", &goods.GoodsController{}, "delete:DelGoodsSpec"),
38
-
39
-		// 系统用户
40
-		beego.NSRouter("/user", &user.UserController{}, "get:GetUserList"),
41
-		beego.NSRouter("/user/:userid", &user.UserController{}, "get:GetUserByID"),
42
-		beego.NSRouter("/user", &user.UserController{}, "post:SaveUser"),
43
-		beego.NSRouter("/user", &user.UserController{}, "put:SaveUser"),
44
-		beego.NSRouter("/user/:userid", &user.UserController{}, "delete:DelUser"),
45
-		beego.NSRouter("/user/:userid/password", &user.UserController{}, "put:UpdatePassword"),
46
-		beego.NSRouter("/user/password/reset", &user.UserController{}, "put:ResetPassword"),
47
-		beego.NSRouter("/signout", &user.UserController{}, "post:SignOut"),
48
-		beego.NSRouter("/user/tel/:tel", &user.UserController{}, "get:GetUserByTel"),
49
-
50
-		// 用户类型
51
-		beego.NSRouter("/usertype", &user.UserController{}, "get:GetUserTypes"),
52
-
53
-		// 用户角色
54
-		beego.NSRouter("/userrole", &user.UserController{}, "get:GetUserRole"),
55
-		beego.NSRouter("/userrole", &user.UserController{}, "put:UserMapRole"),
56
-
57
-		// cms 位置
58
-		beego.NSRouter("/cms/location", &message.MessageController{}, "get:GetLocations"),
59
-		beego.NSRouter("/cms/location/:locationid", &message.MessageController{}, "get:GetLocationById"),
60
-		beego.NSRouter("/cms/location", &message.MessageController{}, "post:SaveLocation"),
61
-		beego.NSRouter("/cms/location/:locationid", &message.MessageController{}, "put:SaveLocation"),
62
-		beego.NSRouter("/cms/location/:locationid", &message.MessageController{}, "delete:DelLocation"),
63
-
64
-		beego.NSRouter("/cms/location/:locationid/sort", &message.MessageController{}, "put:UpdateLocationSort"),
65
-
66
-		// cms
67
-		beego.NSRouter("/cms/info", &message.MessageController{}, "get:GetCmsInfoList"),
68
-		beego.NSRouter("/cms/info/:infoid", &message.MessageController{}, "get:GetCmsInfoByID"),
69
-		beego.NSRouter("/cms/info", &message.MessageController{}, "post:SaveCmsInfo"),
70
-		beego.NSRouter("/cms/info/:infoid", &message.MessageController{}, "put:SaveCmsInfo"),
71
-		beego.NSRouter("/cms/info/:infoid", &message.MessageController{}, "delete:DelCmsInfo"),
72
-
73
-		// cms 图片
74
-		beego.NSRouter("/cms/image", &message.MessageController{}, "get:GetImgList"),
75
-		beego.NSRouter("/cms/image/:imgid", &message.MessageController{}, "get:GetImgByID"),
76
-		beego.NSRouter("/cms/image", &message.MessageController{}, "post:SaveImage"),
77
-		beego.NSRouter("/cms/image/:imgid", &message.MessageController{}, "put:SaveImage"),
78
-		beego.NSRouter("/cms/image/:imgid", &message.MessageController{}, "delete:DelImg"),
79
-
80
-		// cms 消息
81
-		beego.NSRouter("/cms/news", &message.MessageController{}, "get:GetNews"),
82
-		beego.NSRouter("/cms/news/:newsid", &message.MessageController{}, "get:GetNewsByID"),
83
-		beego.NSRouter("/cms/news", &message.MessageController{}, "post:SaveNews"),
84
-		beego.NSRouter("/cms/news/:newsid", &message.MessageController{}, "put:SaveNews"),
85
-		beego.NSRouter("/cms/news/:newsid", &message.MessageController{}, "delete:DelNews"),
86
-
87
-		// cms 案场
88
-		beego.NSRouter("/cms/case", &message.MessageController{}, "get:GetCmsCase"),
89
-		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "get:GetCmsCaseByID"),
90
-		beego.NSRouter("/cms/case", &message.MessageController{}, "post:SaveCmsCase"),
91
-		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "put:SaveCmsCase"),
92
-		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "delete:DelCmsCase"),
93
-		beego.NSRouter("/cms/caseshow/:cmscaseid", &message.MessageController{}, "put:CmsCaseShow"),
94
-		beego.NSRouter("/cms/casehide/:cmscaseid", &message.MessageController{}, "put:CmsCaseHide"),
95
-
96
-		// tag 标签
97
-		beego.NSRouter("/case/tag", &cases.CaseController{}, "get:GetTagList"),
98
-		beego.NSRouter("/case/tag/:tagid", &cases.CaseController{}, "get:GetTagByID"),
99
-		beego.NSRouter("/case/tag", &cases.CaseController{}, "post:SaveCaseTag"),
100
-		beego.NSRouter("/case/tag", &cases.CaseController{}, "put:SaveCaseTag"),
101
-		beego.NSRouter("/case/tag/:tagid", &cases.CaseController{}, "delete:DelCaseTag"),
102
-
103
-		// caseuser 案场人员
104
-		beego.NSRouter("/case/user", &cases.CaseController{}, "get:GetCaseUserByCase"),
105
-		beego.NSRouter("/case/userbytype", &cases.CaseController{}, "get:GetCaseUserByType"),
106
-		beego.NSRouter("/case/usertype", &cases.CaseController{}, "get:GetCaseUserType"),
107
-		beego.NSRouter("/case/user/:userid", &cases.CaseController{}, "get:GetCaseUserByID"),
108
-		beego.NSRouter("/case/user", &cases.CaseController{}, "post:SaveCaseUser"),
109
-		beego.NSRouter("/case/user", &cases.CaseController{}, "put:SaveCaseUser"),
110
-		beego.NSRouter("/case/user/:userid", &cases.CaseController{}, "delete:DelCaseUser"),
111
-
112
-		// equipment 体检设备
113
-		beego.NSRouter("/case/equipment", &cases.CaseController{}, "get:GetEquipmentList"),
114
-		beego.NSRouter("/case/equipment/:id", &cases.CaseController{}, "get:GetEquipmentByID"),
115
-		beego.NSRouter("/case/equipment", &cases.CaseController{}, "post:SaveCaseEquipment"),
116
-		beego.NSRouter("/case/equipment", &cases.CaseController{}, "put:SaveCaseEquipment"),
117
-		beego.NSRouter("/case/equipment/:id", &cases.CaseController{}, "delete:DelCaseEquipment"),
118
-
119
-		// case 案场
120
-		beego.NSRouter("/case/info", &cases.CaseController{}, "get:GetCaseList"),
121
-		beego.NSRouter("/case/info/:id", &cases.CaseController{}, "get:GetCaseByID"),
122
-		beego.NSRouter("/case/info", &cases.CaseController{}, "post:SaveCase"),
123
-		beego.NSRouter("/case/info", &cases.CaseController{}, "put:SaveCase"),
124
-		beego.NSRouter("/case/info/:id", &cases.CaseController{}, "delete:DelCase"),
125
-		beego.NSRouter("/case/conf/:caseid", &cases.CaseController{}, "get:GetCaseConf"),
126
-		beego.NSRouter("/case/open/:caseid", &cases.CaseController{}, "put:OpenCaseCoffee"),
127
-		beego.NSRouter("/case/close/:caseid", &cases.CaseController{}, "put:CloseCaseCoffee"),
128
-
129
-		// casekey 案场钥匙
130
-		beego.NSRouter("/case/key", &cases.CaseController{}, "get:GetKeyList"),
131
-		beego.NSRouter("/case/key", &cases.CaseController{}, "post:AddKeys"),
132
-		beego.NSRouter("/case/unlock/:keyid", &cases.CaseController{}, "put:UnLockKey"),
133
-		beego.NSRouter("/case/key/:keyid", &cases.CaseController{}, "delete:DelKey"),
134
-
135
-		// casearea 案场区域
136
-		beego.NSRouter("/case/area", &cases.CaseController{}, "get:GetCaseArea"),
137
-		beego.NSRouter("/case/area/:areaid", &cases.CaseController{}, "get:GetCaseAreaByID"),
138
-		beego.NSRouter("/case/area", &cases.CaseController{}, "post:SaveCaseArea"),
139
-		beego.NSRouter("/case/area", &cases.CaseController{}, "put:SaveCaseArea"),
140
-		beego.NSRouter("/case/area/:areaid", &cases.CaseController{}, "delete:DelCaseArea"),
141
-
142
-		// casetable 案场桌位
143
-		beego.NSRouter("/case/table", &cases.CaseController{}, "get:GetCaseTable"),
144
-		beego.NSRouter("/case/table/:tableid", &cases.CaseController{}, "get:GetCaseTableByID"),
145
-		beego.NSRouter("/case/table", &cases.CaseController{}, "post:SaveCaseTable"),
146
-		beego.NSRouter("/case/table", &cases.CaseController{}, "put:SaveCaseTable"),
147
-		beego.NSRouter("/case/table/:tableid", &cases.CaseController{}, "delete:DelCaseTable"),
148
-
149
-		// caserecord 案场月记录
150
-		beego.NSRouter("/case/record", &cases.CaseController{}, "get:GetCaseRecordList"),
151
-		beego.NSRouter("/case/record", &cases.CaseController{}, "post:SaveCaseRecord"),
152
-
153
-		// channel 渠道
154
-		beego.NSRouter("/channel", &channel.ChannelController{}, "get:GetChannelList"),
155
-		beego.NSRouter("/channel/:channelId", &channel.ChannelController{}, "get:GetChannelById"),
156
-		beego.NSRouter("/channel", &channel.ChannelController{}, "post:SaveChannel"),
157
-		beego.NSRouter("/channel", &channel.ChannelController{}, "put:SaveChannel"),
158
-		beego.NSRouter("/channel/:channelId", &channel.ChannelController{}, "delete:DeleteChannel"),
159
-
160
-		// vipcard VIP卡
161
-		beego.NSRouter("/vipcard", &vipcard.VipcardController{}, "get:GetVipList"),
162
-		beego.NSRouter("/vipcard/:code", &vipcard.VipcardController{}, "get:GetVipByCode"),
163
-		beego.NSRouter("/vipcard", &vipcard.VipcardController{}, "post:AddVipCard"),
164
-		beego.NSRouter("/vipcard/:vipCardChildCode", &vipcard.VipcardController{}, "put:UserCharge"),
165
-
166
-		// courseVerify 核销课程
167
-		beego.NSRouter("/verify/course/code/:customerCourseId", &verify.VerifyController{}, "get:GetCustomerCourseDetailListById"),
168
-		beego.NSRouter("/verify/course/tel/:tel", &verify.VerifyController{}, "get:GetCustomerCourseDetailListBytel"),
169
-		beego.NSRouter("/verify/course/:customerDetailId", &verify.VerifyController{}, "put:VerifyCourse"),
170
-
171
-		// role 角色
172
-		beego.NSRouter("/role", &system.RoleController{}, "get:GetRoleList"),
173
-		beego.NSRouter("/role/:roleid", &system.RoleController{}, "get:GetRoleByID"),
174
-		beego.NSRouter("/role", &system.RoleController{}, "post:SaveCaseRole"),
175
-		beego.NSRouter("/role", &system.RoleController{}, "put:SaveCaseRole"),
176
-		beego.NSRouter("/role/:roleid", &system.RoleController{}, "delete:DelCaseRole"),
177
-
178
-		beego.NSRouter("/rolemenu/:roleid", &system.RoleController{}, "get:GetRoleMenuByRole"),
179
-		beego.NSRouter("/rolemenu/:roleid", &system.RoleController{}, "put:SaveRoleMenus"),
180
-
181
-		// course 课程
182
-		beego.NSRouter("/coursetag", &course.CourseController{}, "get:GetCourseTagsByPage"),
183
-		// beego.NSRouter("/coursetag", &course.CourseController{}, "get:GetCourseTags"),
184
-
185
-		beego.NSRouter("/course", &course.CourseController{}, "get:GetCourseList"),
186
-		beego.NSRouter("/course/:courseid", &course.CourseController{}, "get:GetCourseByID"),
187
-		beego.NSRouter("/course", &course.CourseController{}, "post:SaveCourse"),
188
-		beego.NSRouter("/course", &course.CourseController{}, "put:SaveCourse"),
189
-		beego.NSRouter("/course/:courseid", &course.CourseController{}, "delete:DeleteCourse"),
190
-		beego.NSRouter("/course/:courseid/public", &course.CourseController{}, "put:CoursePublic"),
191
-		beego.NSRouter("/course/:courseid/unpublic", &course.CourseController{}, "put:CourseUnPublic"),
192
-		beego.NSRouter("/courseimg/:courseid", &course.CourseController{}, "get:GetCourseImgs"),
193
-		beego.NSRouter("/courseimg", &course.CourseController{}, "post:SaveCourseImg"),
194
-		beego.NSRouter("/courseimg", &course.CourseController{}, "put:SaveCourseImg"),
195
-		beego.NSRouter("/courseimg/:courseid", &course.CourseController{}, "delete:DelCourseImg"),
196
-		beego.NSRouter("/schedule", &course.CourseController{}, "get:GetCourseSchedule"),
197
-		beego.NSRouter("/detail", &course.CourseController{}, "get:GetDetails"),
198
-		beego.NSRouter("/detail/:detailid", &course.CourseController{}, "get:GetDetailByID"),
199
-		beego.NSRouter("/detail", &course.CourseController{}, "post:SaveDetail"),
200
-		beego.NSRouter("/detail", &course.CourseController{}, "put:SaveDetail"),
201
-		beego.NSRouter("/detail/:detailid", &course.CourseController{}, "delete:DelCourseDetail"),
202
-
203
-		// 商品
204
-		beego.NSRouter("/goods", &goods.GoodsController{}, "get:GetListByCase"),
205
-		beego.NSRouter("/goods/:id", &goods.GoodsController{}, "get:GetGoodsByID"),
206
-		beego.NSRouter("/goods", &goods.GoodsController{}, "post:UpdateGoods"),
207
-		beego.NSRouter("/goods/:id", &goods.GoodsController{}, "put:UpdateGoods"),
208
-		beego.NSRouter("/goods/:id", &goods.GoodsController{}, "delete:DeleteGoods"),
209
-
210
-		// 商品订单
211
-		beego.NSRouter("/order/goods", &goods.GoodsController{}, "get:GetOrderList"),
212
-		beego.NSRouter("/order/online/goods", &goods.GoodsController{}, "get:GetOnlineOrder"),
213
-		beego.NSRouter("/order/goods/record/:recordid", &goods.GoodsController{}, "get:GetOrdersByRecord"),
214
-
215
-		beego.NSRouter("/order/goods/finish/:id", &goods.GoodsController{}, "put:FinishMake"),
216
-		beego.NSRouter("/order/goods/cancel/:id", &goods.GoodsController{}, "put:CancelMake"),
217
-
218
-		// 优惠券
219
-		beego.NSRouter("/coupon", &coupon.CouponController{}, "get:ListByCase"),
220
-		beego.NSRouter("/coupon", &coupon.CouponController{}, "post:SaveCoupon"),
221
-		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "put:UpdateCoupon"),
222
-		beego.NSRouter("/coupon/:id/to/:users", &coupon.CouponController{}, "post:GiveCoupon"),
223
-
224
-		// 文件
225
-		beego.NSRouter("/file", &controllers.BaseController{}, "post:FileUpload"),
226
-
227
-		// 会员
228
-		beego.NSRouter("/customer", &customer.CustomerController{}, "get:CustWXList"),
229
-		beego.NSRouter("/customer/tel/:tel", &customer.CustomerController{}, "get:CustByTel"),
230
-
231
-		// 系统相关
232
-		beego.NSRouter("/system/init", &user.UserController{}, "get:GetEnvVars"),
233
-
234
-		// 营销活动
235
-		beego.NSRouter("/marketing/list", &marketing.MarketingController{}, "get:GetMarketingList"),
236
-		beego.NSRouter("/marketing", &marketing.MarketingController{}, "post:SaveMarketing"),
237
-		beego.NSRouter("/marketing/:activityId", &marketing.MarketingController{}, "get:GetMarketingById"),
238
-		beego.NSRouter("/marketing", &marketing.MarketingController{}, "put:UpdateMarketing"),
239
-		beego.NSRouter("/marketing/normal/:activityId", &marketing.MarketingController{}, "put:DelMarketingNormal"),
240
-		beego.NSRouter("/marketing/disable/:activityId", &marketing.MarketingController{}, "put:DelMarketingDisable"),
241
-		beego.NSRouter("/marketing/:activityId", &marketing.MarketingController{}, "delete:DelMarketing"),
242
-
243
-		// 签到
244
-		beego.NSRouter("/case/signin", &cases.SigninController{}, "get:GetSigninWhere"),
245
-
246
-		// websocket
247
-		beego.NSRouter("/websocket/:grps/:id", &controllers.BaseController{}, "get:Ws"),
248
-	)
249
-}
1
+package routers
2
+
3
+import (
4
+	"spaceofcheng/services/controllers"
5
+	"spaceofcheng/services/controllers/card"
6
+	"spaceofcheng/services/controllers/cases"
7
+	"spaceofcheng/services/controllers/channel"
8
+	"spaceofcheng/services/controllers/coupon"
9
+	"spaceofcheng/services/controllers/course"
10
+	"spaceofcheng/services/controllers/customer"
11
+	"spaceofcheng/services/controllers/goods"
12
+	"spaceofcheng/services/controllers/gymcard"
13
+	"spaceofcheng/services/controllers/marketing"
14
+	"spaceofcheng/services/controllers/message"
15
+	"spaceofcheng/services/controllers/system"
16
+	"spaceofcheng/services/controllers/user"
17
+	"spaceofcheng/services/controllers/verify"
18
+	"spaceofcheng/services/controllers/vipcard"
19
+
20
+	"github.com/astaxie/beego"
21
+)
22
+
23
+func getCommonRoutes() beego.LinkNamespace {
24
+	prefix := beego.AppConfig.String("api::common")
25
+
26
+	return beego.NSNamespace(prefix,
27
+		// 商品分类
28
+		beego.NSRouter("/type/goods", &goods.GoodsController{}, "get:GetGoodsType"),
29
+		beego.NSRouter("/type/goods/:typeid", &goods.GoodsController{}, "get:GetGoodsTypeByID"),
30
+		beego.NSRouter("/type/goods", &goods.GoodsController{}, "post:SaveGoodsType"),
31
+		beego.NSRouter("/type/goods/:typeid", &goods.GoodsController{}, "put:SaveGoodsType"),
32
+		beego.NSRouter("/type/goods/:typeid", &goods.GoodsController{}, "delete:DelGoodsType"),
33
+
34
+		// 商品规格
35
+		beego.NSRouter("/spec/goods", &goods.GoodsController{}, "get:GetGoodsSpec"),
36
+		beego.NSRouter("/spec/goods/:specid", &goods.GoodsController{}, "get:GetGoodsSpecByID"),
37
+		beego.NSRouter("/spec/goods", &goods.GoodsController{}, "post:SaveGoodsSpec"),
38
+		beego.NSRouter("/spec/goods/:specid", &goods.GoodsController{}, "put:SaveGoodsSpec"),
39
+		beego.NSRouter("/spec/goods/:specid", &goods.GoodsController{}, "delete:DelGoodsSpec"),
40
+
41
+		// 系统用户
42
+		beego.NSRouter("/user", &user.UserController{}, "get:GetUserList"),
43
+		beego.NSRouter("/user/:userid", &user.UserController{}, "get:GetUserByID"),
44
+		beego.NSRouter("/user", &user.UserController{}, "post:SaveUser"),
45
+		beego.NSRouter("/user", &user.UserController{}, "put:SaveUser"),
46
+		beego.NSRouter("/user/:userid", &user.UserController{}, "delete:DelUser"),
47
+		beego.NSRouter("/user/:userid/password", &user.UserController{}, "put:UpdatePassword"),
48
+		beego.NSRouter("/user/password/reset", &user.UserController{}, "put:ResetPassword"),
49
+		beego.NSRouter("/signout", &user.UserController{}, "post:SignOut"),
50
+		beego.NSRouter("/user/tel/:tel", &user.UserController{}, "get:GetUserByTel"),
51
+
52
+		// 用户类型
53
+		beego.NSRouter("/usertype", &user.UserController{}, "get:GetUserTypes"),
54
+
55
+		// 用户角色
56
+		beego.NSRouter("/userrole", &user.UserController{}, "get:GetUserRole"),
57
+		beego.NSRouter("/userrole", &user.UserController{}, "put:UserMapRole"),
58
+
59
+		// cms 位置
60
+		beego.NSRouter("/cms/location", &message.MessageController{}, "get:GetLocations"),
61
+		beego.NSRouter("/cms/location/:locationid", &message.MessageController{}, "get:GetLocationById"),
62
+		beego.NSRouter("/cms/location", &message.MessageController{}, "post:SaveLocation"),
63
+		beego.NSRouter("/cms/location/:locationid", &message.MessageController{}, "put:SaveLocation"),
64
+		beego.NSRouter("/cms/location/:locationid", &message.MessageController{}, "delete:DelLocation"),
65
+
66
+		beego.NSRouter("/cms/location/:locationid/sort", &message.MessageController{}, "put:UpdateLocationSort"),
67
+
68
+		// cms
69
+		beego.NSRouter("/cms/info", &message.MessageController{}, "get:GetCmsInfoList"),
70
+		beego.NSRouter("/cms/info/:infoid", &message.MessageController{}, "get:GetCmsInfoByID"),
71
+		beego.NSRouter("/cms/info", &message.MessageController{}, "post:SaveCmsInfo"),
72
+		beego.NSRouter("/cms/info/:infoid", &message.MessageController{}, "put:SaveCmsInfo"),
73
+		beego.NSRouter("/cms/info/:infoid", &message.MessageController{}, "delete:DelCmsInfo"),
74
+
75
+		// cms 图片
76
+		beego.NSRouter("/cms/image", &message.MessageController{}, "get:GetImgList"),
77
+		beego.NSRouter("/cms/image/:imgid", &message.MessageController{}, "get:GetImgByID"),
78
+		beego.NSRouter("/cms/image", &message.MessageController{}, "post:SaveImage"),
79
+		beego.NSRouter("/cms/image/:imgid", &message.MessageController{}, "put:SaveImage"),
80
+		beego.NSRouter("/cms/image/:imgid", &message.MessageController{}, "delete:DelImg"),
81
+
82
+		// cms 消息
83
+		beego.NSRouter("/cms/news", &message.MessageController{}, "get:GetNews"),
84
+		beego.NSRouter("/cms/news/:newsid", &message.MessageController{}, "get:GetNewsByID"),
85
+		beego.NSRouter("/cms/news", &message.MessageController{}, "post:SaveNews"),
86
+		beego.NSRouter("/cms/news/:newsid", &message.MessageController{}, "put:SaveNews"),
87
+		beego.NSRouter("/cms/news/:newsid", &message.MessageController{}, "delete:DelNews"),
88
+
89
+		// cms 案场
90
+		beego.NSRouter("/cms/case", &message.MessageController{}, "get:GetCmsCase"),
91
+		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "get:GetCmsCaseByID"),
92
+		beego.NSRouter("/cms/case", &message.MessageController{}, "post:SaveCmsCase"),
93
+		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "put:SaveCmsCase"),
94
+		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "delete:DelCmsCase"),
95
+		beego.NSRouter("/cms/caseshow/:cmscaseid", &message.MessageController{}, "put:CmsCaseShow"),
96
+		beego.NSRouter("/cms/casehide/:cmscaseid", &message.MessageController{}, "put:CmsCaseHide"),
97
+
98
+		// tag 标签
99
+		beego.NSRouter("/case/tag", &cases.CaseController{}, "get:GetTagList"),
100
+		beego.NSRouter("/case/tag/:tagid", &cases.CaseController{}, "get:GetTagByID"),
101
+		beego.NSRouter("/case/tag", &cases.CaseController{}, "post:SaveCaseTag"),
102
+		beego.NSRouter("/case/tag", &cases.CaseController{}, "put:SaveCaseTag"),
103
+		beego.NSRouter("/case/tag/:tagid", &cases.CaseController{}, "delete:DelCaseTag"),
104
+
105
+		// caseuser 案场人员
106
+		beego.NSRouter("/case/user", &cases.CaseController{}, "get:GetCaseUserByCase"),
107
+		beego.NSRouter("/case/userbytype", &cases.CaseController{}, "get:GetCaseUserByType"),
108
+		beego.NSRouter("/case/usertype", &cases.CaseController{}, "get:GetCaseUserType"),
109
+		beego.NSRouter("/case/user/:userid", &cases.CaseController{}, "get:GetCaseUserByID"),
110
+		beego.NSRouter("/case/user", &cases.CaseController{}, "post:SaveCaseUser"),
111
+		beego.NSRouter("/case/user", &cases.CaseController{}, "put:SaveCaseUser"),
112
+		beego.NSRouter("/case/user/:userid", &cases.CaseController{}, "delete:DelCaseUser"),
113
+
114
+		// equipment 体检设备
115
+		beego.NSRouter("/case/equipment", &cases.CaseController{}, "get:GetEquipmentList"),
116
+		beego.NSRouter("/case/equipment/:id", &cases.CaseController{}, "get:GetEquipmentByID"),
117
+		beego.NSRouter("/case/equipment", &cases.CaseController{}, "post:SaveCaseEquipment"),
118
+		beego.NSRouter("/case/equipment", &cases.CaseController{}, "put:SaveCaseEquipment"),
119
+		beego.NSRouter("/case/equipment/:id", &cases.CaseController{}, "delete:DelCaseEquipment"),
120
+
121
+		// case 案场
122
+		beego.NSRouter("/case/info", &cases.CaseController{}, "get:GetCaseList"),
123
+		beego.NSRouter("/case/info/:id", &cases.CaseController{}, "get:GetCaseByID"),
124
+		beego.NSRouter("/case/info", &cases.CaseController{}, "post:SaveCase"),
125
+		beego.NSRouter("/case/info", &cases.CaseController{}, "put:SaveCase"),
126
+		beego.NSRouter("/case/info/:id", &cases.CaseController{}, "delete:DelCase"),
127
+		beego.NSRouter("/case/conf/:caseid", &cases.CaseController{}, "get:GetCaseConf"),
128
+		beego.NSRouter("/case/open/:caseid", &cases.CaseController{}, "put:OpenCaseCoffee"),
129
+		beego.NSRouter("/case/close/:caseid", &cases.CaseController{}, "put:CloseCaseCoffee"),
130
+
131
+		// casekey 案场钥匙
132
+		beego.NSRouter("/case/key", &cases.CaseController{}, "get:GetKeyList"),
133
+		beego.NSRouter("/case/key", &cases.CaseController{}, "post:AddKeys"),
134
+		beego.NSRouter("/case/unlock/:keyid", &cases.CaseController{}, "put:UnLockKey"),
135
+		beego.NSRouter("/case/key/:keyid", &cases.CaseController{}, "delete:DelKey"),
136
+
137
+		// casearea 案场区域
138
+		beego.NSRouter("/case/area", &cases.CaseController{}, "get:GetCaseArea"),
139
+		beego.NSRouter("/case/area/:areaid", &cases.CaseController{}, "get:GetCaseAreaByID"),
140
+		beego.NSRouter("/case/area", &cases.CaseController{}, "post:SaveCaseArea"),
141
+		beego.NSRouter("/case/area", &cases.CaseController{}, "put:SaveCaseArea"),
142
+		beego.NSRouter("/case/area/:areaid", &cases.CaseController{}, "delete:DelCaseArea"),
143
+
144
+		// casetable 案场桌位
145
+		beego.NSRouter("/case/table", &cases.CaseController{}, "get:GetCaseTable"),
146
+		beego.NSRouter("/case/table/:tableid", &cases.CaseController{}, "get:GetCaseTableByID"),
147
+		beego.NSRouter("/case/table", &cases.CaseController{}, "post:SaveCaseTable"),
148
+		beego.NSRouter("/case/table", &cases.CaseController{}, "put:SaveCaseTable"),
149
+		beego.NSRouter("/case/table/:tableid", &cases.CaseController{}, "delete:DelCaseTable"),
150
+
151
+		// caserecord 案场月记录
152
+		beego.NSRouter("/case/record", &cases.CaseController{}, "get:GetCaseRecordList"),
153
+		beego.NSRouter("/case/record", &cases.CaseController{}, "post:SaveCaseRecord"),
154
+
155
+		// channel 渠道
156
+		beego.NSRouter("/channel", &channel.ChannelController{}, "get:GetChannelList"),
157
+		beego.NSRouter("/channel/:channelId", &channel.ChannelController{}, "get:GetChannelById"),
158
+		beego.NSRouter("/channel", &channel.ChannelController{}, "post:SaveChannel"),
159
+		beego.NSRouter("/channel", &channel.ChannelController{}, "put:SaveChannel"),
160
+		beego.NSRouter("/channel/:channelId", &channel.ChannelController{}, "delete:DeleteChannel"),
161
+
162
+		// vipcard VIP卡
163
+		beego.NSRouter("/vipcard", &vipcard.VipcardController{}, "get:GetVipList"),
164
+		beego.NSRouter("/vipcard/:code", &vipcard.VipcardController{}, "get:GetVipByCode"),
165
+		beego.NSRouter("/vipcard", &vipcard.VipcardController{}, "post:AddVipCard"),
166
+		beego.NSRouter("/vipcard/:vipCardChildCode", &vipcard.VipcardController{}, "put:UserCharge"),
167
+
168
+		// courseVerify 核销课程
169
+		beego.NSRouter("/verify/course/code/:customerCourseId", &verify.VerifyController{}, "get:GetCustomerCourseDetailListById"),
170
+		beego.NSRouter("/verify/course/tel/:tel", &verify.VerifyController{}, "get:GetCustomerCourseDetailListBytel"),
171
+		beego.NSRouter("/verify/course/:customerDetailId", &verify.VerifyController{}, "put:VerifyCourse"),
172
+
173
+		// gymcard 游泳健身卡
174
+		beego.NSRouter("/gymcard", &gymcard.GymcardController{}, "get:GetGymcardList"),
175
+		beego.NSRouter("/gymcard/:gymcardId", &gymcard.GymcardController{}, "get:GetGymcardDetailbyId"),
176
+		beego.NSRouter("/gymcard/:phone", &gymcard.GymcardController{}, "get:GetCustomerGymByPhone"),
177
+		beego.NSRouter("/gymcard", &gymcard.GymcardController{}, "post:SaveGymcard"),
178
+		beego.NSRouter("/gymcard", &gymcard.GymcardController{}, "put:SaveGymcard"),
179
+		beego.NSRouter("/gymcard/:customerGymId", &gymcard.GymcardController{}, "put:VerifyCustomerGymcard"),
180
+		// role 角色
181
+		beego.NSRouter("/role", &system.RoleController{}, "get:GetRoleList"),
182
+		beego.NSRouter("/role/:roleid", &system.RoleController{}, "get:GetRoleByID"),
183
+		beego.NSRouter("/role", &system.RoleController{}, "post:SaveCaseRole"),
184
+		beego.NSRouter("/role", &system.RoleController{}, "put:SaveCaseRole"),
185
+		beego.NSRouter("/role/:roleid", &system.RoleController{}, "delete:DelCaseRole"),
186
+
187
+		beego.NSRouter("/rolemenu/:roleid", &system.RoleController{}, "get:GetRoleMenuByRole"),
188
+		beego.NSRouter("/rolemenu/:roleid", &system.RoleController{}, "put:SaveRoleMenus"),
189
+
190
+		// course 课程
191
+		beego.NSRouter("/coursetag", &course.CourseController{}, "get:GetCourseTagsByPage"),
192
+		// beego.NSRouter("/coursetag", &course.CourseController{}, "get:GetCourseTags"),
193
+
194
+		beego.NSRouter("/course", &course.CourseController{}, "get:GetCourseList"),
195
+		beego.NSRouter("/course/:courseid", &course.CourseController{}, "get:GetCourseByID"),
196
+		beego.NSRouter("/course", &course.CourseController{}, "post:SaveCourse"),
197
+		beego.NSRouter("/course", &course.CourseController{}, "put:SaveCourse"),
198
+		beego.NSRouter("/course/:courseid", &course.CourseController{}, "delete:DeleteCourse"),
199
+		beego.NSRouter("/course/:courseid/public", &course.CourseController{}, "put:CoursePublic"),
200
+		beego.NSRouter("/course/:courseid/unpublic", &course.CourseController{}, "put:CourseUnPublic"),
201
+		beego.NSRouter("/courseimg/:courseid", &course.CourseController{}, "get:GetCourseImgs"),
202
+		beego.NSRouter("/courseimg", &course.CourseController{}, "post:SaveCourseImg"),
203
+		beego.NSRouter("/courseimg", &course.CourseController{}, "put:SaveCourseImg"),
204
+		beego.NSRouter("/courseimg/:courseid", &course.CourseController{}, "delete:DelCourseImg"),
205
+		beego.NSRouter("/schedule", &course.CourseController{}, "get:GetCourseSchedule"),
206
+		beego.NSRouter("/detail", &course.CourseController{}, "get:GetDetails"),
207
+		beego.NSRouter("/detail/:detailid", &course.CourseController{}, "get:GetDetailByID"),
208
+		beego.NSRouter("/detail", &course.CourseController{}, "post:SaveDetail"),
209
+		beego.NSRouter("/detail", &course.CourseController{}, "put:SaveDetail"),
210
+		beego.NSRouter("/detail/:detailid", &course.CourseController{}, "delete:DelCourseDetail"),
211
+
212
+		// 商品
213
+		beego.NSRouter("/goods", &goods.GoodsController{}, "get:GetListByCase"),
214
+		beego.NSRouter("/goods/:id", &goods.GoodsController{}, "get:GetGoodsByID"),
215
+		beego.NSRouter("/goods", &goods.GoodsController{}, "post:UpdateGoods"),
216
+		beego.NSRouter("/goods/:id", &goods.GoodsController{}, "put:UpdateGoods"),
217
+		beego.NSRouter("/goods/:id", &goods.GoodsController{}, "delete:DeleteGoods"),
218
+
219
+		// 商品订单
220
+		beego.NSRouter("/order/goods", &goods.GoodsController{}, "get:GetOrderList"),
221
+		beego.NSRouter("/order/online/goods", &goods.GoodsController{}, "get:GetOnlineOrder"),
222
+		beego.NSRouter("/order/goods/record/:recordid", &goods.GoodsController{}, "get:GetOrdersByRecord"),
223
+
224
+		beego.NSRouter("/order/goods/finish/:id", &goods.GoodsController{}, "put:FinishMake"),
225
+		beego.NSRouter("/order/goods/cancel/:id", &goods.GoodsController{}, "put:CancelMake"),
226
+
227
+		// 优惠券
228
+		beego.NSRouter("/coupon", &coupon.CouponController{}, "get:ListByCase"),
229
+		beego.NSRouter("/coupon", &coupon.CouponController{}, "post:SaveCoupon"),
230
+		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "get:GetCouponByIDForAdmin"),
231
+		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "put:UpdateCoupon"),
232
+		beego.NSRouter("/coupon/:id/to/:users", &coupon.CouponController{}, "post:GiveCoupon"),
233
+		beego.NSRouter("/coupon/type/:type", &coupon.CouponController{}, "get:GetCouponBySendType"),
234
+
235
+		// 卡
236
+		beego.NSRouter("/card", &card.CardController{}, "get:ListByCase"),
237
+		beego.NSRouter("/card", &card.CardController{}, "post:SaveCard"),
238
+		beego.NSRouter("/card/:id", &card.CardController{}, "get:GetCardByIDForAdmin"),
239
+		beego.NSRouter("/card/:id", &card.CardController{}, "put:UpdateCard"),
240
+		beego.NSRouter("/card/:id/to/:users", &card.CardController{}, "post:GiveCard"),
241
+
242
+		// 文件
243
+		beego.NSRouter("/file", &controllers.BaseController{}, "post:FileUpload"),
244
+
245
+		// 会员
246
+		beego.NSRouter("/customer", &customer.CustomerController{}, "get:CustWXList"),
247
+		beego.NSRouter("/customer/tel/:tel", &customer.CustomerController{}, "get:CustByTel"),
248
+
249
+		// 系统相关
250
+		beego.NSRouter("/system/init", &user.UserController{}, "get:GetEnvVars"),
251
+
252
+		// 营销活动
253
+		beego.NSRouter("/marketing/list", &marketing.MarketingController{}, "get:GetMarketingList"),
254
+		beego.NSRouter("/marketing", &marketing.MarketingController{}, "post:SaveMarketing"),
255
+		beego.NSRouter("/marketing/:activityId", &marketing.MarketingController{}, "get:GetMarketingById"),
256
+		beego.NSRouter("/marketing", &marketing.MarketingController{}, "put:UpdateMarketing"),
257
+		beego.NSRouter("/marketing/normal/:activityId", &marketing.MarketingController{}, "put:DelMarketingNormal"),
258
+		beego.NSRouter("/marketing/disable/:activityId", &marketing.MarketingController{}, "put:DelMarketingDisable"),
259
+		beego.NSRouter("/marketing/:activityId", &marketing.MarketingController{}, "delete:DelMarketing"),
260
+
261
+		// 签到
262
+		beego.NSRouter("/case/signin", &cases.SigninController{}, "get:GetSigninWhere"),
263
+
264
+		// websocket
265
+		beego.NSRouter("/websocket/:grps/:id", &controllers.BaseController{}, "get:Ws"),
266
+	)
267
+}

+ 49
- 32
routers/wechat.go View File

1
-package routers
2
-
3
-import (
4
-	"spaceofcheng/services/controllers/course"
5
-	"spaceofcheng/services/controllers/customer"
6
-	"spaceofcheng/services/controllers/goods"
7
-
8
-	"github.com/astaxie/beego"
9
-)
10
-
11
-func getWechatRoutes() beego.LinkNamespace {
12
-	prefix := beego.AppConfig.String("api::wechat")
13
-
14
-	return beego.NSNamespace(prefix,
15
-		// 会员
16
-		beego.NSRouter("/customer", &customer.CustomerController{}, "get:GetCustWXByID"),
17
-
18
-		// 下单
19
-		beego.NSRouter("/order/goods", &goods.GoodsController{}, "post:PostOrder"),
20
-		beego.NSRouter("/order/course", &course.CourseController{}, "post:PostOrder"),
21
-
22
-		// 课程
23
-		beego.NSRouter("/course/user", &course.CourseController{}, "get:GetCustomerCourse"),
24
-		beego.NSRouter("/course/user/:id", &course.CourseController{}, "get:GetCustomerCourseByID"),
25
-
26
-		// 商品订单
27
-		beego.NSRouter("/goods/user", &goods.GoodsController{}, "get:GetCustomerOrders"),
28
-
29
-		// 案场订单数量
30
-		beego.NSRouter("/goods/case/:caseid", &goods.GoodsController{}, "get:GetCaseOrdersNum"),
31
-	)
32
-}
1
+package routers
2
+
3
+import (
4
+	"spaceofcheng/services/controllers/course"
5
+	"spaceofcheng/services/controllers/customer"
6
+	"spaceofcheng/services/controllers/goods"
7
+	"spaceofcheng/services/controllers/gymcard"
8
+	"spaceofcheng/services/controllers/user"
9
+
10
+	"github.com/astaxie/beego"
11
+)
12
+
13
+func getWechatRoutes() beego.LinkNamespace {
14
+	prefix := beego.AppConfig.String("api::wechat")
15
+
16
+	return beego.NSNamespace(prefix,
17
+		// 会员
18
+		beego.NSRouter("/customer", &customer.CustomerController{}, "get:GetCustWXByID"),
19
+		beego.NSRouter("/customer/user", &user.UserController{}, "get:GetUserCustomer"),
20
+
21
+		// 下单
22
+		beego.NSRouter("/order/goods", &goods.GoodsController{}, "post:PostOrder"),
23
+		beego.NSRouter("/order/course", &course.CourseController{}, "post:PostOrder"),
24
+
25
+		// 课程
26
+		beego.NSRouter("/course/user", &course.CourseController{}, "get:GetCustomerCourse"),
27
+		beego.NSRouter("/course/user/:id", &course.CourseController{}, "get:GetCustomerCourseByID"),
28
+
29
+		// 商品订单
30
+		beego.NSRouter("/goods/user", &goods.GoodsController{}, "get:GetCustomerOrders"),
31
+
32
+		// 案场订单数量
33
+		beego.NSRouter("/goods/case/:caseid", &goods.GoodsController{}, "get:GetCaseOrdersNum"),
34
+
35
+		// 客户游泳健身卡
36
+		beego.NSRouter("/gymcard", &gymcard.GymcardController{}, "get:GetGymcardListByCustomerId"),
37
+		beego.NSRouter("/gymcard/:customerGymId", &gymcard.GymcardController{}, "get:GetCustomerGymDetailById"),
38
+		beego.NSRouter("/gymcard/:gymcardId/:sysuserId", &gymcard.GymcardController{}, "post:SendGymToCustomer"),
39
+
40
+		// 禁止人员
41
+		beego.NSRouter("/user/forbid", &user.UserController{}, "get:GetForbidUsers"),
42
+		beego.NSRouter("/user/forbid/:userid/:type", &user.UserController{}, "post:SaveForbidUser"),
43
+		beego.NSRouter("/user/forbid/:userid/:type", &user.UserController{}, "put:OpenForbidUser"),
44
+
45
+		// 用户
46
+		beego.NSRouter("/user/:type", &user.UserController{}, "get:GetCaseUserByType"),
47
+		beego.NSRouter("/user/detail/:id", &user.UserController{}, "get:GetCaseUserByID"),
48
+	)
49
+}

+ 276
- 0
service/card/card.go View File

1
+package card
2
+
3
+import (
4
+	"errors"
5
+	"spaceofcheng/services/models"
6
+	"spaceofcheng/services/models/card"
7
+	"spaceofcheng/services/models/customer"
8
+	"spaceofcheng/services/models/model"
9
+	"spaceofcheng/services/utils"
10
+	"strings"
11
+	"time"
12
+
13
+	"github.com/yl10/kit/guid"
14
+)
15
+
16
+// CardServ 系统处理
17
+type CardServ struct {
18
+	ctx     *utils.Context
19
+	dao     *card.CardDAO
20
+	custDao *customer.CustomerDAO
21
+}
22
+
23
+// NewCardServ 初始化
24
+func NewCardServ(ctx *utils.Context) *CardServ {
25
+	return &CardServ{
26
+		ctx:     ctx,
27
+		dao:     card.NewCardDAO(ctx),
28
+		custDao: customer.NewCustomerDAO(ctx),
29
+	}
30
+}
31
+
32
+// GetCardList 获取卡列表
33
+func (s *CardServ) GetCardList(caseID string, pagenavi ...int) ([]model.TaCouponCard, int64, error) {
34
+	filters := []string{}
35
+	if caseID != "" {
36
+		if err := utils.NewAuthEngine(s.ctx).CheckCase(caseID); err != nil {
37
+			return nil, 0, err
38
+		}
39
+
40
+		filters = []string{
41
+			"case_id='" + caseID + "'",
42
+		}
43
+	} else {
44
+		casesRaw := s.ctx.Get("cases")
45
+		if casesRaw == nil {
46
+			return nil, 0, errors.New("请设置过滤案场")
47
+		}
48
+
49
+		cases := casesRaw.([]model.SysUserCase)
50
+		caseIDs := []string{}
51
+		for _, cs := range cases {
52
+			caseIDs = append(caseIDs, cs.CaseId)
53
+		}
54
+
55
+		filters = []string{
56
+			"case_id in ('" + strings.Join(caseIDs, "','") + "')",
57
+		}
58
+	}
59
+
60
+	limit := utils.GetPageNaviLimit(pagenavi...)
61
+	res, total, err := s.dao.GetCardList(filters, limit)
62
+	if err != nil {
63
+		utils.LogError("查询卡列表失败: " + err.Error())
64
+		return nil, 0, errors.New("查询卡列表失败")
65
+	}
66
+
67
+	return res, total, nil
68
+}
69
+
70
+// EditCard 编辑卡 , 没有则新增
71
+func (s *CardServ) EditCard(card *card.CardInfo) error {
72
+	if card.CardId == "" {
73
+		return s.SaveCard(card)
74
+	} else {
75
+		return s.UpdateCard(card)
76
+	}
77
+}
78
+
79
+// SaveCard 保存卡
80
+// 字段校验没有在此函数中设置
81
+func (s *CardServ) SaveCard(cd *card.CardInfo) error {
82
+	if cd.CaseId == "" {
83
+		return errors.New("未指定案场")
84
+	}
85
+
86
+	cd.CardId = guid.NewGUIDString()
87
+
88
+	// 保存主信息
89
+	cardMain := cd.TaCouponCard
90
+	if err := s.dao.AddCard(&cardMain); err != nil {
91
+		utils.LogError("保存卡失败: " + err.Error())
92
+		return errors.New("保存卡失败")
93
+	}
94
+
95
+	// 保存图片
96
+	if err := s.dao.UpdateImages(cd.Images, cd.CardId); err != nil {
97
+		utils.LogError("保存卡图片失败: " + err.Error())
98
+		return errors.New("保存卡图片失败")
99
+	}
100
+
101
+	// 保存分享
102
+	share := cd.Share
103
+	share.CardId = cd.CardId
104
+	if err := s.dao.SaveCardShare(share); err != nil {
105
+		utils.LogError("保存卡分享失败: " + err.Error())
106
+		return errors.New("保存卡分享失败")
107
+	}
108
+
109
+	// 保存关联内容
110
+	if err := s.dao.UpdateTarget(cd.Targets, cd.CardId); err != nil {
111
+		utils.LogError("保存卡关联内容失败: " + err.Error())
112
+		return errors.New("保存卡关联内容失败")
113
+	}
114
+
115
+	return nil
116
+}
117
+
118
+// UpdateCard 更新卡
119
+// 字段校验没有在此函数中设置
120
+func (s *CardServ) UpdateCard(cd *card.CardInfo) error {
121
+	if cd.CaseId == "" {
122
+		return errors.New("未指定案场")
123
+	}
124
+
125
+	if cd.CardId == "" {
126
+		return errors.New("未指定卡")
127
+	}
128
+
129
+	// 更新主信息
130
+	cardMain := cd.TaCouponCard
131
+	if err := s.dao.UpdateCard(&cardMain, []string{"Card_name"}); err != nil {
132
+		utils.LogError("更新卡失败: " + err.Error())
133
+		return errors.New("更新卡失败")
134
+	}
135
+
136
+	// 更新图片
137
+	if err := s.dao.UpdateImages(cd.Images, cd.CardId); err != nil {
138
+		utils.LogError("更新卡图片失败: " + err.Error())
139
+		return errors.New("更新卡图片失败")
140
+	}
141
+
142
+	// 更新分享
143
+	share := cd.Share
144
+	share.CardId = cd.CardId
145
+	cols := []string{"Card_share_info", "use_rule", "use_instruction"}
146
+	if err := s.dao.UpdateCardShare(share, cols); err != nil {
147
+		utils.LogError("更新卡分享失败: " + err.Error())
148
+		return errors.New("更新卡分享失败")
149
+	}
150
+
151
+	// 关联内容 规则 不允许更新
152
+	return nil
153
+}
154
+
155
+// GiveCard 赠送卡券
156
+func (s *CardServ) GiveCard(CardID string, uids []string) error {
157
+	// 当前用户
158
+	userRaw := s.ctx.Get("user")
159
+	if userRaw == nil {
160
+		return errors.New("当前人员信息不正确, 请重试")
161
+	}
162
+	user := userRaw.(model.SysUser)
163
+
164
+	card, err := s.dao.GetCardByID(CardID)
165
+	if err != nil {
166
+		utils.LogError("获取卡失败: " + err.Error())
167
+		return errors.New("校验卡失败")
168
+	}
169
+
170
+	// 案场
171
+	if err := utils.NewAuthEngine(s.ctx).CheckCase(card.CaseId); err != nil {
172
+		return err
173
+	}
174
+
175
+	// 卡必须状态正常
176
+	if card == nil || card.CardId == "" || card.Status != models.STATUS_NORMAL {
177
+		return errors.New("卡已失效或者不存在")
178
+	}
179
+
180
+	for _, uid := range uids {
181
+		// 获取客户信息
182
+		cust, err := s.custDao.GetCustomerByID(uid)
183
+		if err != nil {
184
+			utils.LogError("查询客户信息失败: " + err.Error())
185
+			return errors.New("校验客户信息失败")
186
+		}
187
+
188
+		if err := s.GiveCardTo(&user, cust, card); err != nil {
189
+			return err
190
+		}
191
+	}
192
+
193
+	return nil
194
+}
195
+
196
+// GiveCardTo 赠送卡
197
+// 本方法会被多出调用, 方法内使用 Context 将是不安全的
198
+func (s *CardServ) GiveCardTo(from *model.SysUser, to *model.TaCustomer, card *card.CardInfo) error {
199
+	if from.UserId == "" {
200
+		return errors.New("必须指定赠送人")
201
+	}
202
+
203
+	if to.CustomerId == "" {
204
+		return errors.New("必须指定接收人")
205
+	}
206
+
207
+	// 卡必须状态正常
208
+	if card.CardId == "" || card.Status != models.STATUS_NORMAL {
209
+		return errors.New("卡已失效或者不存在")
210
+	}
211
+
212
+	// 计算卡券有效期
213
+	startDate := card.StartDate
214
+	endDate := card.EndDate
215
+
216
+	// 检查用户是否已经有了该券
217
+	custcardS, err := s.dao.CheckCustCard(to.CustomerId, card.CardId, startDate, endDate)
218
+	if err != nil {
219
+		utils.LogError("校验客户卡失败: " + err.Error())
220
+		return errors.New("校验客户卡失败")
221
+	}
222
+
223
+	if custcardS != nil && len(custcardS) > 0 {
224
+		return errors.New("客户 " + to.CustomerName + " 已经拥有该券")
225
+	}
226
+
227
+	// 放入我的卡券
228
+	custcard := model.TaCustomerCard{
229
+		CardId:           card.CardId,
230
+		CustomerCardName: card.CardName,
231
+		CustomerId:       to.CustomerId,
232
+		StartDate:        startDate,
233
+		EndDate:          endDate,
234
+		ReceiveDate:      time.Now().Local(),
235
+		CaseId:           card.CaseId,
236
+		OrgId:            card.OrgId,
237
+	}
238
+
239
+	// 入库
240
+	if err := s.dao.SaveCustomerCards([]model.TaCustomerCard{custcard}); err != nil {
241
+		utils.LogError("保存客户卡失败: " + err.Error())
242
+		return errors.New("保存客户卡失败")
243
+	}
244
+
245
+	// TODO
246
+	// 券库存处理
247
+
248
+	return nil
249
+}
250
+
251
+// GetCardByID 获取卡
252
+// 未进行权限校验, 非安全的
253
+func (s *CardServ) GetCardByID(cardID string) (*card.CardInfo, error) {
254
+	card, err := s.dao.GetCardByID(cardID)
255
+	if err != nil {
256
+		utils.LogError("获取卡失败: " + err.Error())
257
+		return nil, errors.New("校验卡失败")
258
+	}
259
+
260
+	return card, nil
261
+}
262
+
263
+// GetCardByIDWithCheck 获取卡
264
+func (s *CardServ) GetCardByIDWithCheck(cardID string) (*card.CardInfo, error) {
265
+	card, err := s.dao.GetCardByID(cardID)
266
+	if err != nil {
267
+		utils.LogError("获取卡失败: " + err.Error())
268
+		return nil, errors.New("校验卡失败")
269
+	}
270
+
271
+	if err := utils.NewAuthEngine(s.ctx).CheckCase(card.CaseId); err != nil {
272
+		return nil, err
273
+	}
274
+
275
+	return card, nil
276
+}

+ 62
- 1
service/cases/signin.go View File

2
 
2
 
3
 import (
3
 import (
4
 	"spaceofcheng/services/models/cases"
4
 	"spaceofcheng/services/models/cases"
5
+	"spaceofcheng/services/models/marketing"
5
 	"spaceofcheng/services/utils"
6
 	"spaceofcheng/services/utils"
6
-
7
+	"spaceofcheng/services/models/model"
7
 	"github.com/astaxie/beego"
8
 	"github.com/astaxie/beego"
9
+	"encoding/json"
8
 )
10
 )
9
 
11
 
10
 // SigninServ 系统处理
12
 // SigninServ 系统处理
11
 type SigninServ struct {
13
 type SigninServ struct {
12
 	ctx *utils.Context
14
 	ctx *utils.Context
13
 	dao *cases.SigninDAO
15
 	dao *cases.SigninDAO
16
+	marDao  *marketing.MarketingDAO
17
+	caseDao     *cases.CaseDAO
14
 }
18
 }
15
 
19
 
16
 // NewSigninServ 初始化
20
 // NewSigninServ 初始化
18
 	return &SigninServ{
22
 	return &SigninServ{
19
 		ctx: ctx,
23
 		ctx: ctx,
20
 		dao: cases.NewSigninDAO(ctx),
24
 		dao: cases.NewSigninDAO(ctx),
25
+		marDao: marketing.NewMarketingDAO(ctx),
26
+		caseDao: cases.NewCaseDAO(ctx),
21
 	}
27
 	}
22
 }
28
 }
23
 
29
 
47
 		"page":     page,
53
 		"page":     page,
48
 	}, err
54
 	}, err
49
 }
55
 }
56
+
57
+// 添加 签到记录
58
+func (s *SigninServ) AddSignin(signin model.TaCheckinRecord,caseId string,activityId string,userMap *model.TaUserMapping) (*model.TaCheckinRecord,error) {
59
+	if signin.OpenId == "" {
60
+		return nil, utils.LogError("没有OpenId")
61
+	}
62
+	if signin.Phone == "" {
63
+		return nil, utils.LogError("没有Phone手机号")
64
+	}
65
+	if caseId == "" {
66
+		return nil,utils.LogError("没有案场ID")
67
+	}
68
+	if activityId == ""  {
69
+		return nil,utils.LogError("没有活动ID")
70
+	}
71
+
72
+	// 获取上下文的用户
73
+	user := s.ctx.Get("user").(model.SysUser)
74
+	casesInfo,err := s.caseDao.GetCaseByID(caseId)
75
+	activityInfo,err := s.marDao.GetMarketingById(activityId)
76
+	
77
+	// 定义Map
78
+	var jsonMap = map[string]string{}
79
+	accountInfo := userMap.AccountInfo
80
+	// 转换JSON
81
+	var jsonBlob = []byte(accountInfo)
82
+	jsonErr := json.Unmarshal(jsonBlob, &jsonMap)
83
+
84
+	if jsonErr != nil {
85
+		return nil,utils.LogError("accountInfo转换json失败")
86
+	}
87
+	// openId
88
+	signin.OpenId = jsonMap["openid"]
89
+	// 微信昵称
90
+	signin.CustomerName = jsonMap["nickname"]
91
+	// 客户姓名
92
+	signin.Name = user.UserName
93
+	// 客户ID
94
+	signin.CustomerId = user.UserId
95
+
96
+	// 案场
97
+	signin.CaseId = casesInfo.CaseId
98
+	signin.CaseName = casesInfo.CaseName
99
+
100
+	// 活动
101
+	signin.ActivityId = activityInfo.ActivityId
102
+	signin.ActivityName = activityInfo.ActivityName
103
+
104
+	info, err := s.dao.AddSignin(signin)
105
+	if err != nil {
106
+		return nil,err
107
+	}
108
+
109
+	return &info,err
110
+}

+ 59
- 9
service/coupon/coupon.go View File

10
 	"strings"
10
 	"strings"
11
 	"time"
11
 	"time"
12
 
12
 
13
+	"github.com/astaxie/beego"
14
+
13
 	"github.com/yl10/kit/guid"
15
 	"github.com/yl10/kit/guid"
14
 )
16
 )
15
 
17
 
102
 	// 保存分享
104
 	// 保存分享
103
 	share := cp.Share
105
 	share := cp.Share
104
 	share.CouponId = cp.CouponId
106
 	share.CouponId = cp.CouponId
105
-	cols := []string{"coupon_share_info", "use_rule", "use_instruction"}
106
-	if err := s.dao.UpdateCouponShare(&share, cols); err != nil {
107
+	// cols := []string{"coupon_share_info", "use_rule", "use_instruction"}
108
+	if err := s.dao.SaveCouponShare(&share); err != nil {
107
 		utils.LogError("保存优惠券分享失败: " + err.Error())
109
 		utils.LogError("保存优惠券分享失败: " + err.Error())
108
 		return errors.New("保存优惠券分享失败")
110
 		return errors.New("保存优惠券分享失败")
109
 	}
111
 	}
136
 
138
 
137
 	// 更新主信息
139
 	// 更新主信息
138
 	cpMain := cp.TaCoupon
140
 	cpMain := cp.TaCoupon
139
-	if err := s.dao.UpdateCoupon(&cpMain, []string{"coupon_name"}); err != nil {
141
+	if err := s.dao.UpdateCoupon(&cpMain, []string{"coupon_name",
142
+		"coupon_type",
143
+		"send_type",
144
+		"video_url",
145
+		"cover_url",
146
+		"price",
147
+		"is_all",
148
+		"start_date",
149
+		"end_date",
150
+		"valid_days",
151
+		"total_count",
152
+		"case_id"}); err != nil {
140
 		utils.LogError("更新优惠券失败: " + err.Error())
153
 		utils.LogError("更新优惠券失败: " + err.Error())
141
 		return errors.New("更新优惠券失败")
154
 		return errors.New("更新优惠券失败")
142
 	}
155
 	}
156
 		return errors.New("更新优惠券分享失败")
169
 		return errors.New("更新优惠券分享失败")
157
 	}
170
 	}
158
 
171
 
159
-	// 关联内容 规则 不允许更新
172
+	// 保存关联内容
173
+	if err := s.dao.UpdateTarget(cp.Targets, cp.CouponId); err != nil {
174
+		utils.LogError("保存优惠券关联内容失败: " + err.Error())
175
+		return errors.New("保存优惠券关联内容失败")
176
+	}
177
+
178
+	// 保存规则
179
+	if err := s.dao.UpdateRule(cp.Rules, cp.CouponId); err != nil {
180
+		utils.LogError("保存优惠券规则失败: " + err.Error())
181
+		return errors.New("保存优惠券规则失败")
182
+	}
183
+
160
 	return nil
184
 	return nil
161
 }
185
 }
162
 
186
 
181
 	}
205
 	}
182
 
206
 
183
 	// 优惠券必须状态正常
207
 	// 优惠券必须状态正常
184
-	if cp != nil || cp.CouponId == "" || cp.Status != models.STATUS_NORMAL {
208
+	if cp == nil || cp.CouponId == "" || cp.Status != models.STATUS_NORMAL {
185
 		return errors.New("优惠券已失效或者不存在")
209
 		return errors.New("优惠券已失效或者不存在")
186
 	}
210
 	}
187
 
211
 
231
 		}
255
 		}
232
 	}
256
 	}
233
 
257
 
258
+	if cp.TotalCount < cp.SentCount+1 {
259
+		return errors.New("券已经没有库存!")
260
+	}
261
+
234
 	// 计算卡券有效期
262
 	// 计算卡券有效期
235
 	startDate := cp.StartDate
263
 	startDate := cp.StartDate
236
 	endDate := cp.EndDate
264
 	endDate := cp.EndDate
246
 		utils.LogError("校验客户优惠券失败: " + err.Error())
274
 		utils.LogError("校验客户优惠券失败: " + err.Error())
247
 		return errors.New("校验客户优惠券失败")
275
 		return errors.New("校验客户优惠券失败")
248
 	}
276
 	}
249
-
277
+	beego.Error(custCPS)
250
 	if custCPS != nil && len(custCPS) > 0 {
278
 	if custCPS != nil && len(custCPS) > 0 {
251
 		return errors.New("客户 " + to.CustomerName + " 已经拥有该券")
279
 		return errors.New("客户 " + to.CustomerName + " 已经拥有该券")
252
 	}
280
 	}
288
 
316
 
289
 	// TODO
317
 	// TODO
290
 	// 券库存处理
318
 	// 券库存处理
291
-
319
+	cp.SentCount = cp.SentCount + 1
320
+	if err := s.dao.UpdateCoupon(cp, []string{"sent_count"}); err != nil {
321
+		utils.LogError("更新优惠券库存失败: " + err.Error())
322
+		return errors.New("更新优惠券库存失败")
323
+	}
292
 	return nil
324
 	return nil
293
 }
325
 }
294
 
326
 
305
 }
337
 }
306
 
338
 
307
 // GetCouponByIDWithCheck 获取优惠券
339
 // GetCouponByIDWithCheck 获取优惠券
308
-func (s *CouponServ) GetCouponByIDWithCheck(cpID string) (*model.TaCoupon, error) {
309
-	cp, err := s.dao.GetCouponByID(cpID)
340
+func (s *CouponServ) GetCouponByIDWithCheck(cpID string) (*coupon.CouponInfo, error) {
341
+	cp, err := s.dao.GetCouponInfoByID(cpID)
310
 	if err != nil {
342
 	if err != nil {
311
 		utils.LogError("获取优惠券失败: " + err.Error())
343
 		utils.LogError("获取优惠券失败: " + err.Error())
312
 		return nil, errors.New("校验优惠券失败")
344
 		return nil, errors.New("校验优惠券失败")
318
 
350
 
319
 	return cp, nil
351
 	return cp, nil
320
 }
352
 }
353
+
354
+// GetCouponBySendType 根据发送类型获取优惠券
355
+func (s *CouponServ) GetCouponBySendType(sendtype string) ([]model.TaCoupon, error) {
356
+	cases := s.ctx.Get("cases").([]model.SysUserCase)
357
+	caseIDs := ""
358
+	for _, value := range cases {
359
+		if caseIDs != "" {
360
+			caseIDs = caseIDs + ","
361
+		}
362
+		caseIDs = caseIDs + value.CaseId
363
+	}
364
+	coupon, err := s.dao.GetCouponBySendType(caseIDs, sendtype)
365
+	if err != nil {
366
+		utils.LogError("获取优惠券失败: " + err.Error())
367
+		return nil, errors.New("校验优惠券失败")
368
+	}
369
+	return coupon, nil
370
+}

+ 2
- 2
service/customer/customer.go View File

29
 }
29
 }
30
 
30
 
31
 // GetCustWithWXList 获取客户列表
31
 // GetCustWithWXList 获取客户列表
32
-func (s *CustomerServ) GetCustWithWXList(phone string, page ...int) ([]customer.CustWithWX, int64, error) {
33
-	return s.dao.CustWithWXList(phone, page...)
32
+func (s *CustomerServ) GetCustWithWXList(phone, username, recommendname, begindate, enddate string, page ...int) ([]customer.CustWithWX, int64, error) {
33
+	return s.dao.CustWithWXList(phone, username, recommendname, begindate, enddate, page...)
34
 }
34
 }
35
 
35
 
36
 // GetCustWithWXByID 获取客户列表
36
 // GetCustWithWXByID 获取客户列表

+ 9
- 1
service/goods/spec.go View File

68
 
68
 
69
 // DelGoodsSpec 删除商品类型
69
 // DelGoodsSpec 删除商品类型
70
 func (s *GoodsServ) DelGoodsSpec(specid string) error {
70
 func (s *GoodsServ) DelGoodsSpec(specid string) error {
71
-	err := s.dao.DelGoodsSpec(specid)
71
+	goods, err := s.dao.GetGoodsBySpec(specid)
72
+	if err != nil {
73
+		utils.LogError("删除商品规格失败: " + err.Error())
74
+		return errors.New("删除商品规格失败")
75
+	}
76
+	if len(goods) > 0 {
77
+		return errors.New("已关联商品。不允许删除")
78
+	}
79
+	err = s.dao.DelGoodsSpec(specid)
72
 	if err != nil {
80
 	if err != nil {
73
 		utils.LogError("删除商品规格失败: " + err.Error())
81
 		utils.LogError("删除商品规格失败: " + err.Error())
74
 		return errors.New("删除商品规格失败")
82
 		return errors.New("删除商品规格失败")

+ 9
- 1
service/goods/type.go View File

82
 
82
 
83
 // DelGoodsType 删除商品类型
83
 // DelGoodsType 删除商品类型
84
 func (s *GoodsServ) DelGoodsType(typeid string) error {
84
 func (s *GoodsServ) DelGoodsType(typeid string) error {
85
-	err := s.dao.DelGoodsType(typeid)
85
+	goods, err := s.dao.GetGoodsByType(typeid)
86
+	if err != nil {
87
+		utils.LogError("删除商品类型失败: " + err.Error())
88
+		return errors.New("删除商品类型失败")
89
+	}
90
+	if len(goods) > 0 {
91
+		return errors.New("已关联商品。不允许删除")
92
+	}
93
+	err = s.dao.DelGoodsType(typeid)
86
 	if err != nil {
94
 	if err != nil {
87
 		utils.LogError("删除商品类型失败: " + err.Error())
95
 		utils.LogError("删除商品类型失败: " + err.Error())
88
 		return errors.New("删除商品类型失败")
96
 		return errors.New("删除商品类型失败")

+ 45
- 22
service/gymcard/gymcard.go View File

112
 	if newGym.GymCardId == "" {
112
 	if newGym.GymCardId == "" {
113
 		newGymCard = newGym.TaGymCard
113
 		newGymCard = newGym.TaGymCard
114
 		cardGym, err = s.dao.AddGymcard(newGymCard)
114
 		cardGym, err = s.dao.AddGymcard(newGymCard)
115
-		err = s.dao.AddGymcardImg(newGym.GymCardId, newGym.CardImageUrl)
116
-		newGym.TaGymCard = cardGym
117
-		err = s.dao.AddGymcardShare(newGym.GymCardId, newGym.CardShareInfo, newGym.CardUseRule, newGym.CardUseInstruction)
115
+		err = s.dao.AddGymcardImg(newGymCard.GymCardId, newGym.CardImageUrl)
116
+		err = s.dao.AddGymcardShare(newGymCard.GymCardId, newGym.CardShareInfo, newGym.CardUseRule, newGym.CardUseInstruction)
117
+		if newGym.SentType == 1 {
118
+			err = s.dao.AddCardChannel(cardGym.GymCardId, newGym.ChannelId)
119
+		}
118
 	} else {
120
 	} else {
119
 		err = s.dao.EditGymcardImg(newGym.GymCardId, newGym.CardImageUrl)
121
 		err = s.dao.EditGymcardImg(newGym.GymCardId, newGym.CardImageUrl)
120
 		err = s.dao.EditGymcardShare(newGym.GymCardId, newGym.CardShareInfo, newGym.CardUseRule, newGym.CardUseInstruction)
122
 		err = s.dao.EditGymcardShare(newGym.GymCardId, newGym.CardShareInfo, newGym.CardUseRule, newGym.CardUseInstruction)
131
 	var customerGym *model.TaCustomerGym
133
 	var customerGym *model.TaCustomerGym
132
 	customer := s.ctx.Get("customer").(model.TaCustomer)
134
 	customer := s.ctx.Get("customer").(model.TaCustomer)
133
 	var sysuser *model.SysUser
135
 	var sysuser *model.SysUser
134
-	var sendRecord *model.TaCouponGiveRecord
135
 	gymCard, err := s.dao.GetGymcardById(gymcardId)
136
 	gymCard, err := s.dao.GetGymcardById(gymcardId)
136
 	if err != nil {
137
 	if err != nil {
137
 		utils.LogError("发送游泳健身卡给客户失败" + err.Error())
138
 		utils.LogError("发送游泳健身卡给客户失败" + err.Error())
138
 		return nil, errors.New("发送游泳健身卡给客户失败")
139
 		return nil, errors.New("发送游泳健身卡给客户失败")
139
 	}
140
 	}
140
-	gymCard.SentCount = gymCard.SentCount + 1
141
-	customerGym, err = s.dao.SendGymcardToCustomer(&gymCard.TaGymCard, customer.CustomerId)
141
+	sysuser, err = s.cdao.GetUserByID(sysuserId)
142
 	if err != nil {
142
 	if err != nil {
143
 		utils.LogError("发送游泳健身卡给客户失败" + err.Error())
143
 		utils.LogError("发送游泳健身卡给客户失败" + err.Error())
144
 		return nil, errors.New("发送游泳健身卡给客户失败")
144
 		return nil, errors.New("发送游泳健身卡给客户失败")
145
 	}
145
 	}
146
-	sysuser, err = s.cdao.GetUserByID(sysuserId)
147
-	if err != nil {
148
-		utils.LogError("记录发健身卡记录失败" + err.Error())
149
-		return nil, errors.New("记录发健身卡记录失败")
150
-	}
151
-	sendRecord.FromId = sysuser.UserId
152
-	sendRecord.FromName = sysuser.RealName
153
-	sendRecord.GiftId = gymCard.GymCardId
154
-	sendRecord.GiftName = gymCard.GymCardName
155
-	sendRecord.ToId = customer.CustomerId
156
-	sendRecord.ToName = customer.CustomerName
157
-	err = s.dao.AddGiveRecord(sendRecord)
146
+	gymCard.SentCount = gymCard.SentCount + 1
147
+	customerGym, err = s.dao.SendGymcardToCustomer(&gymCard.TaGymCard, customer.CustomerId, sysuserId, sysuser.RealName)
158
 	if err != nil {
148
 	if err != nil {
159
-		utils.LogError("记录发健身卡记录失败" + err.Error())
160
-		return nil, errors.New("记录发健身卡记录失败")
149
+		utils.LogError("发送游泳健身卡给客户失败" + err.Error())
150
+		return nil, errors.New("发送游泳健身卡给客户失败")
161
 	}
151
 	}
152
+
162
 	err = s.dao.EditGymcard(&gymCard.TaGymCard)
153
 	err = s.dao.EditGymcard(&gymCard.TaGymCard)
163
 	if err != nil {
154
 	if err != nil {
164
-		utils.LogError("记录发健身卡记录失败" + err.Error())
165
-		return nil, errors.New("记录发健身卡记录失败")
155
+		utils.LogError("发送游泳健身卡给客户失败" + err.Error())
156
+		return nil, errors.New("发送游泳健身卡给客户失败")
166
 	}
157
 	}
167
 	return customerGym, nil
158
 	return customerGym, nil
168
 }
159
 }
186
 	}
177
 	}
187
 	if gymCard.GymTypeId == "once" {
178
 	if gymCard.GymTypeId == "once" {
188
 		customerGym.Status = models.STATUS_DEL
179
 		customerGym.Status = models.STATUS_DEL
180
+		customerGym.CardStatus = models.CARD_COUPON_USED
189
 		gymCard.UsedCount = gymCard.UsedCount + 1
181
 		gymCard.UsedCount = gymCard.UsedCount + 1
190
 	} else {
182
 	} else {
191
 		if customerGym.StartDate.IsZero() {
183
 		if customerGym.StartDate.IsZero() {
222
 	return err
214
 	return err
223
 
215
 
224
 }
216
 }
217
+func (s *GymcardServ) deleteGymCard(gymcardId string) error {
218
+	gymCard, err := s.dao.GetGymcardById(gymcardId)
219
+	if err != nil {
220
+		utils.LogError("删除健身卡失败" + err.Error())
221
+		return errors.New("删除健身卡失败")
222
+	}
223
+	err = s.dao.DeleteGymcard(gymcardId)
224
+	if err != nil {
225
+		utils.LogError("删除健身卡失败" + err.Error())
226
+		return errors.New("删除健身卡失败")
227
+	}
228
+	err = s.dao.DeleteCardImg(gymcardId)
229
+	if err != nil {
230
+		utils.LogError("删除健身卡失败" + err.Error())
231
+		return errors.New("删除健身卡失败")
232
+	}
233
+	err = s.dao.DeleteCardShare(gymcardId)
234
+	if err != nil {
235
+		utils.LogError("删除健身卡失败" + err.Error())
236
+		return errors.New("删除健身卡失败")
237
+	}
238
+	if gymCard.SentType == 1 {
239
+		err = s.dao.DeleteCardChannel(gymcardId)
240
+		if err != nil {
241
+			utils.LogError("删除健身卡失败" + err.Error())
242
+			return errors.New("删除健身卡失败")
243
+		}
244
+	}
245
+	return err
246
+
247
+}

+ 6
- 4
service/marketing/marketing.go View File

21
 	return &MarketingServ{
21
 	return &MarketingServ{
22
 		ctx: ctx,
22
 		ctx: ctx,
23
 		dao: marketing.NewMarketingDAO(ctx),
23
 		dao: marketing.NewMarketingDAO(ctx),
24
+		wdao: marketing.NewWorkDAO(ctx),
24
 	}
25
 	}
25
 }
26
 }
26
 
27
 
27
-// GetCustWithWXList 获取客户列表
28
+// GetMarketingList 获取活动列表
28
 func (s *MarketingServ) GetMarketingList(page int, pageSize int) (map[string]interface{}, error) {
29
 func (s *MarketingServ) GetMarketingList(page int, pageSize int) (map[string]interface{}, error) {
29
 
30
 
30
 	if pageSize == 0 {
31
 	if pageSize == 0 {
54
 /**
55
 /**
55
 * resource_desc 活动描述
56
 * resource_desc 活动描述
56
  */
57
  */
57
-func (s *MarketingServ) SaveMarketing(activity model.SysActivity, resourceDesc string) (*model.SysActivity, *model.SysActivityAction, error) {
58
+func (s *MarketingServ) SaveMarketing(activity model.SysActivity, resourceDesc string, caseId string) (*model.SysActivity, *model.SysActivityAction, error) {
58
 
59
 
59
 	var newInfo *model.SysActivity
60
 	var newInfo *model.SysActivity
60
 	var newWoke *model.SysActivityAction
61
 	var newWoke *model.SysActivityAction
61
 
62
 
62
 	var err error
63
 	var err error
63
 	// 存储 营销活动
64
 	// 存储 营销活动
64
-	newInfo, err = s.dao.AddMarketing(&activity)
65
+	newInfo, err = s.dao.AddMarketing(activity,caseId)
65
 	if err != nil {
66
 	if err != nil {
66
 		return nil, nil, err
67
 		return nil, nil, err
67
 	}
68
 	}
70
 	woke.ActivityId = newInfo.ActivityId
71
 	woke.ActivityId = newInfo.ActivityId
71
 	woke.ActiveType = newInfo.ActivityType
72
 	woke.ActiveType = newInfo.ActivityType
72
 	woke.ResourceDesc = resourceDesc
73
 	woke.ResourceDesc = resourceDesc
74
+	woke.ResourceType = "占位符"
73
 
75
 
74
 	// 存储 活动动作
76
 	// 存储 活动动作
75
-	newWoke, err = s.wdao.AddWork(&woke)
77
+	newWoke, err = s.wdao.AddWork(woke)
76
 	if err != nil {
78
 	if err != nil {
77
 		return nil, nil, err
79
 		return nil, nil, err
78
 	}
80
 	}

+ 1
- 2
service/marketing/work.go View File

24
 }
24
 }
25
 
25
 
26
 // 保存 Work
26
 // 保存 Work
27
-func (s *WorkServ) SaveWork(work *model.SysActivityAction)  (*model.SysActivityAction, error){
28
-		var newInfo *model.SysActivityAction
27
+func (s *WorkServ) SaveWork(work model.SysActivityAction)  (*model.SysActivityAction, error){
29
 		if work.ActivityId == "" {
28
 		if work.ActivityId == "" {
30
 			return nil, utils.LogError("营销编号为空!")
29
 			return nil, utils.LogError("营销编号为空!")
31
 		}
30
 		}

+ 236
- 7
service/user.go View File

3
 import (
3
 import (
4
 	"errors"
4
 	"errors"
5
 	"spaceofcheng/services/models"
5
 	"spaceofcheng/services/models"
6
+	"spaceofcheng/services/models/card"
6
 	"spaceofcheng/services/models/cases"
7
 	"spaceofcheng/services/models/cases"
8
+	"spaceofcheng/services/models/coupon"
7
 	"spaceofcheng/services/models/customer"
9
 	"spaceofcheng/services/models/customer"
10
+	"spaceofcheng/services/models/goods"
8
 	"spaceofcheng/services/models/model"
11
 	"spaceofcheng/services/models/model"
9
 	"spaceofcheng/services/models/system"
12
 	"spaceofcheng/services/models/system"
10
 	"spaceofcheng/services/utils"
13
 	"spaceofcheng/services/utils"
19
 	dao         *system.UserDAO
22
 	dao         *system.UserDAO
20
 	casedao     *cases.CaseDAO
23
 	casedao     *cases.CaseDAO
21
 	customerdao *customer.CustomerDAO
24
 	customerdao *customer.CustomerDAO
25
+	carddao     *card.CardDAO
26
+	coupondao   *coupon.CouponDAO
27
+	ordersdao   *goods.GoodsDAO
22
 }
28
 }
23
 
29
 
24
 // NewUserServ 初始化
30
 // NewUserServ 初始化
28
 		dao:         system.NewUserDAO(ctx),
34
 		dao:         system.NewUserDAO(ctx),
29
 		casedao:     cases.NewCaseDAO(ctx),
35
 		casedao:     cases.NewCaseDAO(ctx),
30
 		customerdao: customer.NewCustomerDAO(ctx),
36
 		customerdao: customer.NewCustomerDAO(ctx),
37
+		carddao:     card.NewCardDAO(ctx),
38
+		coupondao:   coupon.NewCouponDAO(ctx),
39
+		ordersdao:   goods.NewGoodsDAO(ctx),
31
 	}
40
 	}
32
 }
41
 }
33
 
42
 
64
 	user := s.ctx.Get("user").(model.SysUser)
73
 	user := s.ctx.Get("user").(model.SysUser)
65
 	user.Pwd = ""
74
 	user.Pwd = ""
66
 	// 当前用户案场
75
 	// 当前用户案场
67
-	cases := s.ctx.Get("cases").([]model.SysUserCase)
76
+	sessionCase := s.ctx.Get("cases").([]model.SysUserCase)
77
+	caseIDs := ""
78
+	for _, value := range sessionCase {
79
+		if caseIDs != "" {
80
+			caseIDs = caseIDs + ","
81
+		}
82
+		caseIDs = caseIDs + value.CaseId
83
+	}
84
+	cases, err := s.casedao.GetCaseByIDs(caseIDs)
85
+	if err != nil {
86
+		beego.Error(err)
87
+		return nil, err
88
+	}
68
 	// 当前用户角色
89
 	// 当前用户角色
69
 	roles, err := s.dao.GetUserRole(user.UserId)
90
 	roles, err := s.dao.GetUserRole(user.UserId)
70
 	if err != nil {
91
 	if err != nil {
79
 	}
100
 	}
80
 
101
 
81
 	rtn := map[string]interface{}{
102
 	rtn := map[string]interface{}{
82
-		"user":  user,
83
-		"cases": cases,
84
-		"roles": roles,
85
-		"menus": menus,
103
+		"user":      user,
104
+		"cases":     cases,
105
+		"roles":     roles,
106
+		"menus":     menus,
107
+		"clienturl": beego.AppConfig.String("clienturl"),
86
 	}
108
 	}
87
 
109
 
88
 	return rtn, nil
110
 	return rtn, nil
150
 
172
 
151
 	var err error
173
 	var err error
152
 	var newUSer *model.SysUser
174
 	var newUSer *model.SysUser
175
+
176
+	// 手机号码与用户名校验
177
+	var isok bool
178
+	isok, err = s.dao.CheckUserName(user.UserId, user.UserName, user.OrgId)
179
+	if err != nil {
180
+		beego.Error(err)
181
+		return nil, err
182
+	}
183
+	if !isok {
184
+		return nil, errors.New("用户名重复!")
185
+	}
186
+	isok, err = s.dao.CheckUserPhone(user.UserId, user.Phone, user.OrgId)
187
+	if err != nil {
188
+		beego.Error(err)
189
+		return nil, err
190
+	}
191
+	if !isok {
192
+		return nil, errors.New("手机号码重复!")
193
+	}
153
 	if user.UserId != "" {
194
 	if user.UserId != "" {
154
 		err = s.dao.UpdateUser(userInfo)
195
 		err = s.dao.UpdateUser(userInfo)
155
 		if err != nil {
196
 		if err != nil {
338
 }
379
 }
339
 
380
 
340
 // GetUserCustomer 获取我的推荐客户
381
 // GetUserCustomer 获取我的推荐客户
341
-func (s *UserServ) GetUserCustomer(userid string, page int, pageSize int) ([]model.TaCustomer, error) {
382
+func (s *UserServ) GetUserCustomer(userid, isrecommend string, page int, pageSize int) ([]model.TaCustomer, error) {
342
 	if pageSize == 0 {
383
 	if pageSize == 0 {
343
 		pageSize = PAGENUM
384
 		pageSize = PAGENUM
344
 	}
385
 	}
345
 	if page == 0 {
386
 	if page == 0 {
346
 		page = 1
387
 		page = 1
347
 	}
388
 	}
348
-	customers, err := s.dao.GetUserCustomer(userid, page, pageSize)
389
+	customers, err := s.dao.GetUserCustomer(userid, isrecommend, page, pageSize)
349
 	return customers, err
390
 	return customers, err
350
 }
391
 }
351
 
392
 
377
 	user, err := s.dao.GetUserByPhone(tel)
418
 	user, err := s.dao.GetUserByPhone(tel)
378
 	return user, err
419
 	return user, err
379
 }
420
 }
421
+
422
+// GetForbidUsers 获取所有禁止人员信息
423
+func (s *UserServ) GetForbidUsers() ([]model.TaForbidUser, error) {
424
+	customer := s.ctx.Get("customer").(model.TaCustomer)
425
+	if customer.CustomerId == "" || customer.UserId == "" {
426
+		return nil, errors.New("当前用户没有权限查看用户信息")
427
+	}
428
+	caseinfo, err := s.dao.GetUserBelongCase(customer.UserId)
429
+	if err != nil {
430
+		return nil, err
431
+	}
432
+	// if err := utils.NewAuthEngine(s.ctx).CheckCase(caseid); err != nil {
433
+	// 	return nil, err
434
+	// }
435
+	users, err := s.dao.GetForbidUsers(caseinfo.CaseId)
436
+	return users, err
437
+}
438
+
439
+// SaveForbidUser 保存禁止人员信息
440
+func (s *UserServ) SaveForbidUser(userid string, forbidtype string) error {
441
+	user, err := s.dao.GetUserByID(userid)
442
+	if err != nil {
443
+		return err
444
+	}
445
+	if user.Status != models.STATUS_NORMAL {
446
+		return errors.New("设置的用户状态异常!不允许操作!")
447
+	}
448
+
449
+	usercase, err := s.dao.GetUserBelongCase(userid)
450
+	if err != nil {
451
+		return err
452
+	}
453
+	if usercase.CaseId == "" {
454
+		return errors.New("用户不存在所属案场!不允许操作!")
455
+	}
456
+	if err := utils.NewAuthEngine(s.ctx).CheckCase(usercase.CaseId); err != nil {
457
+		return err
458
+	}
459
+	fibUsers, err := s.dao.GetForbidUserByUserID(userid)
460
+	if err != nil {
461
+		return err
462
+	}
463
+	if fibUsers != nil && len(fibUsers) > 0 {
464
+		for _, u := range fibUsers {
465
+			if u.ForbidType == forbidtype && u.Status == models.STATUS_NORMAL {
466
+				return errors.New("当前人员已经被禁止!不允许重复禁止")
467
+			}
468
+		}
469
+	}
470
+
471
+	var usertype = ""
472
+	if len(user.UserType) > 0 {
473
+		usertype = user.UserType[0].TypeId
474
+	}
475
+
476
+	var forbiduser = model.TaForbidUser{
477
+		UserId:     user.UserId,
478
+		UserType:   usertype,
479
+		ForbidType: forbidtype,
480
+		CaseId:     usercase.CaseId,
481
+	}
482
+
483
+	err = s.dao.SaveForbidUser(&forbiduser)
484
+	return err
485
+}
486
+
487
+// OpenForbidUser 开启禁止人员
488
+func (s *UserServ) OpenForbidUser(userid string, forbidtype string) error {
489
+	user, err := s.dao.GetUserByID(userid)
490
+	if err != nil {
491
+		return err
492
+	}
493
+	if user.Status != models.STATUS_NORMAL {
494
+		return errors.New("设置的用户状态异常!不允许操作!")
495
+	}
496
+
497
+	usercase, err := s.dao.GetUserBelongCase(userid)
498
+	if err != nil {
499
+		return err
500
+	}
501
+	if usercase.CaseId == "" {
502
+		return errors.New("用户不存在所属案场!不允许操作!")
503
+	}
504
+	if err := utils.NewAuthEngine(s.ctx).CheckCase(usercase.CaseId); err != nil {
505
+		return err
506
+	}
507
+	fibUsers, err := s.dao.GetForbidUserByUserID(userid)
508
+	if err != nil {
509
+		return err
510
+	}
511
+	var ishas = false
512
+	var forbiduser = model.TaForbidUser{}
513
+	if fibUsers != nil && len(fibUsers) > 0 {
514
+		for _, u := range fibUsers {
515
+			if u.ForbidType == forbidtype && u.Status == models.STATUS_NORMAL {
516
+				ishas = true
517
+				forbiduser = u
518
+			}
519
+		}
520
+	}
521
+
522
+	if !ishas {
523
+		return errors.New("用户没有被关闭的功能!")
524
+	}
525
+	err = s.dao.OpenForbidUser(&forbiduser)
526
+	return err
527
+}
528
+
529
+// GetCaseUserByType 根据用户类型获取人员信息
530
+func (s *UserServ) GetCaseUserByType(usertype string) ([]system.UserWithCouponAndCard, error) {
531
+	customer := s.ctx.Get("customer").(model.TaCustomer)
532
+	if customer.CustomerId == "" || customer.UserId == "" {
533
+		return nil, errors.New("当前用户没有权限查看用户信息")
534
+	}
535
+	caseinfo, err := s.dao.GetUserBelongCase(customer.UserId)
536
+	if err != nil {
537
+		utils.LogError("获取人员归属案场失败: " + err.Error())
538
+		return nil, errors.New("获取人员信息失败")
539
+	}
540
+
541
+	users, err := s.dao.GetCaseUserByType(caseinfo.CaseId, usertype)
542
+	if err != nil {
543
+		utils.LogError("获取人员信息失败: " + err.Error())
544
+		return nil, errors.New("获取人员信息失败")
545
+	}
546
+	for inx, user := range users {
547
+		err := s.GetUserWithDetail(caseinfo.CaseId, &user)
548
+		if err != nil {
549
+			return nil, err
550
+		}
551
+		users[inx] = user
552
+	}
553
+	return users, nil
554
+}
555
+
556
+// GetCaseUserByUserID 根据用户id获取人员信息
557
+func (s *UserServ) GetCaseUserByUserID(userid string) (*system.UserWithCouponAndCard, error) {
558
+	customer := s.ctx.Get("customer").(model.TaCustomer)
559
+	if customer.CustomerId == "" || customer.UserId == "" {
560
+		return nil, errors.New("当前用户没有权限查看用户信息")
561
+	}
562
+	caseinfo, err := s.dao.GetUserBelongCase(customer.UserId)
563
+	if err != nil {
564
+		utils.LogError("获取人员归属案场失败: " + err.Error())
565
+		return nil, errors.New("获取人员信息失败")
566
+	}
567
+	usercaseinfo, err := s.dao.GetUserBelongCase(userid)
568
+	if err != nil {
569
+		utils.LogError("获取人员归属案场失败: " + err.Error())
570
+		return nil, errors.New("获取人员信息失败")
571
+	}
572
+	if usercaseinfo.CaseId != caseinfo.CaseId {
573
+		return nil, errors.New("您没有权限查看此用户的数据!")
574
+	}
575
+	user, err := s.dao.GetUserDetailByID(userid)
576
+	if err != nil {
577
+		utils.LogError("获取人员信息失败: " + err.Error())
578
+		return nil, errors.New("获取人员信息失败")
579
+	}
580
+	err = s.GetUserWithDetail(usercaseinfo.CaseId, user)
581
+	if err != nil {
582
+		return nil, err
583
+	}
584
+	return user, nil
585
+}
586
+
587
+// GetUserWithDetail 获取用户详情
588
+func (s *UserServ) GetUserWithDetail(caseid string, user *system.UserWithCouponAndCard) error {
589
+	cards, err := s.carddao.GetCustomerCardByUser(caseid, user.UserId)
590
+	if err != nil {
591
+		utils.LogError("获取发送卡信息失败: " + err.Error())
592
+		return errors.New("获取人员信息失败")
593
+	}
594
+	user.CustomerCard = cards
595
+	coupons, err := s.coupondao.GetCustomerCouponByUser(caseid, user.UserId)
596
+	if err != nil {
597
+		utils.LogError("获取发送券信息失败: " + err.Error())
598
+		return errors.New("获取人员信息失败")
599
+	}
600
+	user.CustomerCoupon = coupons
601
+	details, err := s.ordersdao.GetOrderDetailByUser(caseid, user.UserId)
602
+	if err != nil {
603
+		utils.LogError("获取用户点单信息失败: " + err.Error())
604
+		return errors.New("获取人员信息失败")
605
+	}
606
+	user.OrdersDetail = details
607
+	return nil
608
+}

+ 5
- 2
service/verify/verify.go View File

77
 		utils.LogError("获取列表失败: " + err.Error())
77
 		utils.LogError("获取列表失败: " + err.Error())
78
 		return nil, errors.New("获取列表失败")
78
 		return nil, errors.New("获取列表失败")
79
 	}
79
 	}
80
-	customerId := customerDetail[0].CustomerId
80
+	if len(customerDetail) == 0 {
81
+		return nil, errors.New("获取列表失败")
82
+	}
83
+	customerID := customerDetail[0].CustomerId
81
 	total, err := s.dao.GetCustomerCourseListByTelCount(tel, caseids)
84
 	total, err := s.dao.GetCustomerCourseListByTelCount(tel, caseids)
82
 	if err != nil {
85
 	if err != nil {
83
 		utils.LogError("获取列表失败: " + err.Error())
86
 		utils.LogError("获取列表失败: " + err.Error())
84
 		return nil, errors.New("获取列表失败")
87
 		return nil, errors.New("获取列表失败")
85
 	}
88
 	}
86
-	customer, err := s.cdao.GetCustomerByID(customerId)
89
+	customer, err := s.cdao.GetCustomerByID(customerID)
87
 	if err != nil {
90
 	if err != nil {
88
 		utils.LogError("获取列表失败: " + err.Error())
91
 		utils.LogError("获取列表失败: " + err.Error())
89
 		return nil, errors.New("获取列表失败")
92
 		return nil, errors.New("获取列表失败")