wangfei 6 лет назад
Родитель
Сommit
c31dd3e6fe

+ 1
- 1
conf/app.conf Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 appname = services
2 2
 httpport = 8080
3
-runmode = prod
3
+runmode = dev
4 4
 autorender = false
5 5
 copyrequestbody = true
6 6
 EnableDocs = true

+ 2
- 2
conf/db.conf Просмотреть файл

@@ -5,8 +5,8 @@ db_type      = mysql
5 5
 con_protocol = tcp
6 6
 
7 7
 ; 数据库地址,可以使用IP
8
-db_addr      = 192.168.0.122
9
-# db_addr      = localhost
8
+# db_addr      = 192.168.0.122
9
+db_addr      = localhost
10 10
 
11 11
 ; 端口
12 12
 db_port      = 3306

+ 5
- 6
controllers/card/card.go Просмотреть файл

@@ -86,12 +86,6 @@ func (c *CardController) GetCardByID() {
86 86
 	})
87 87
 }
88 88
 
89
-// GetMyCard 获取我的卡券
90
-// 微信端
91
-func (c *CardController) GetMyCard() {
92
-
93
-}
94
-
95 89
 // SaveCard 保存卡
96 90
 func (c *CardController) SaveCard() {
97 91
 	jsnStr := c.GetString("info")
@@ -172,3 +166,8 @@ func (c *CardController) GiveCard() {
172 166
 
173 167
 	c.ResponseJSON("ok")
174 168
 }
169
+
170
+// GetCardWithCustomer 获取卡及领取信息
171
+func (c *CardController) GetCardWithCustomer() {
172
+
173
+}

+ 10
- 0
controllers/coupon/coupon.go Просмотреть файл

@@ -189,3 +189,13 @@ func (c *CouponController) GetCouponWithCustomer() {
189 189
 
190 190
 	c.ResponseJSON(couponDetail)
191 191
 }
192
+
193
+// GetCouponByCustomer 获取我的优惠券信息
194
+func (c *CouponController) GetCouponByCustomer() {
195
+	coupons, err := c.serv.GetCouponByCustomer()
196
+	if err != nil {
197
+		c.ResponseError(err)
198
+	}
199
+
200
+	c.ResponseJSON(coupons)
201
+}

+ 6
- 7
controllers/goods/order.go Просмотреть файл

@@ -102,12 +102,11 @@ func (c *GoodsController) PostOrder() {
102 102
 	}
103 103
 
104 104
 	// 订单优惠券
105
-	coupon := c.GetString("coupon")
105
+	customercouponid := c.GetString("customercouponid")
106 106
 
107 107
 	//
108 108
 	var orderInfo model.TaGoodsOrders
109 109
 	var orderDetail []model.TaGoodsOrdersDetail
110
-	var orderCoupon []model.TaGoodsOrdersCoupon
111 110
 
112 111
 	if err := json.Unmarshal([]byte(info), &orderInfo); err != nil {
113 112
 		utils.LogError("下单转换JSON失败: " + err.Error())
@@ -119,10 +118,10 @@ func (c *GoodsController) PostOrder() {
119 118
 		c.ResponseError(errors.New("详情数据格式不正确"))
120 119
 	}
121 120
 
122
-	if err := json.Unmarshal([]byte(coupon), &orderCoupon); err != nil {
123
-		utils.LogError("下单优惠转换JSON失败: " + err.Error())
124
-		c.ResponseError(errors.New("优惠数据格式不正确"))
125
-	}
121
+	// if err := json.Unmarshal([]byte(coupon), &orderCoupon); err != nil {
122
+	// 	utils.LogError("下单优惠转换JSON失败: " + err.Error())
123
+	// 	c.ResponseError(errors.New("优惠数据格式不正确"))
124
+	// }
126 125
 	cust := c.Context.Get("customer").(model.TaCustomer)
127 126
 
128 127
 	if cust.Phone == "" {
@@ -132,7 +131,7 @@ func (c *GoodsController) PostOrder() {
132 131
 		)
133 132
 	}
134 133
 
135
-	if err := c.serv.Orders(&orderInfo, orderDetail, orderCoupon); err != nil {
134
+	if err := c.serv.Orders(&orderInfo, orderDetail, customercouponid); err != nil {
136 135
 		c.ResponseError(err)
137 136
 	}
138 137
 

+ 2
- 1
controllers/user/user.go Просмотреть файл

@@ -144,7 +144,8 @@ func (c *UserController) GetUserCustomer() {
144 144
 	page, _ := c.GetInt("page")
145 145
 	pageSize, _ := c.GetInt("pagesize")
146 146
 	isrecommend := c.GetString("isrecommend")
147
-	customers, err := c.dao.GetUserCustomer(customer.UserId, isrecommend, page, pageSize)
147
+	key := c.GetString("key")
148
+	customers, err := c.dao.GetUserCustomer(customer.UserId, isrecommend, key, page, pageSize)
148 149
 	if err != nil {
149 150
 		c.ResponseError(err)
150 151
 	}

+ 106
- 0
log/common.log Просмотреть файл

@@ -3153,3 +3153,109 @@
3153 3153
 2018/09/13 19:36:36 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_Dgj9aFWEtUxeOojlCynPzMk6KposI5qyWTWRhdn_gEBHEEO7uXxaeNRZ-LfWoT8XWB6GFW_Ppk6zj8lotRj0BudhE64k4Pcv9-yuWK-LyvU7ZKqPP2CowT6qzBy0vOjKIvetxFS8yxJeN0C6LSMfAEAUBV","expires_in":7200})
3154 3154
 2018/09/13 19:36:36 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_Dgj9aFWEtUxeOojlCynPzMk6KposI5qyWTWRhdn_gEBHEEO7uXxaeNRZ-LfWoT8XWB6GFW_Ppk6zj8lotRj0BudhE64k4Pcv9-yuWK-LyvU7ZKqPP2CowT6qzBy0vOjKIvetxFS8yxJeN0C6LSMfAEAUBV expires_in:7200])
3155 3155
 2018/09/13 19:40:08 [E] 解析 Token 失败: token contains an invalid number of segments
3156
+2018/09/13 19:44:37 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3157
+2018/09/13 19:44:37 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_iIqtfkKl3xPWsB0Di0Vuh3G-4MFjcRYcJUpV3_-GgJqf_gUgurKWpCCVUaNp5tSUxK-r6ME1oe9T6jwRRW25XU9yQ-swEJsaFJNATbras2CXpfNvN_IaxPaqm3XUfua8cMPzCxVyW9z01RCgHMLiABACHG","expires_in":7200})
3158
+2018/09/13 19:44:37 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_iIqtfkKl3xPWsB0Di0Vuh3G-4MFjcRYcJUpV3_-GgJqf_gUgurKWpCCVUaNp5tSUxK-r6ME1oe9T6jwRRW25XU9yQ-swEJsaFJNATbras2CXpfNvN_IaxPaqm3XUfua8cMPzCxVyW9z01RCgHMLiABACHG expires_in:7200])
3159
+2018/09/13 19:45:02 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3160
+2018/09/13 19:45:02 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_8W6CF677zJ2lNuknzqBN0LLet81TFdU1Q1i1CsISG8_rNMotZEXs_YUHZkzrYLEfnrawtGf2dHD2Hphm1a-FDqZQfAnidZ35HQs57GbnN1YWo7GhOk5HYcsHUN_QeXyNp-C0C9loEhvAtWBJKXTbAGAZMI","expires_in":7200})
3161
+2018/09/13 19:45:02 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_8W6CF677zJ2lNuknzqBN0LLet81TFdU1Q1i1CsISG8_rNMotZEXs_YUHZkzrYLEfnrawtGf2dHD2Hphm1a-FDqZQfAnidZ35HQs57GbnN1YWo7GhOk5HYcsHUN_QeXyNp-C0C9loEhvAtWBJKXTbAGAZMI])
3162
+2018/09/13 19:48:03 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3163
+2018/09/13 19:48:03 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_IY7vtAcFD4QbSUNNxXSOybzmqrqbJ7tqoV39m3mQThmMWUDk8rOVH3khupyCWAzJmLNrh4IwglpTKvfmqp8P7vHBOnrRzviJnLuAzoK27Q0HUFaSWJeLkU0OLZxr7NK70rPXFGlOJuhjUkYdHWWcAIAUJJ","expires_in":7200})
3164
+2018/09/13 19:48:03 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_IY7vtAcFD4QbSUNNxXSOybzmqrqbJ7tqoV39m3mQThmMWUDk8rOVH3khupyCWAzJmLNrh4IwglpTKvfmqp8P7vHBOnrRzviJnLuAzoK27Q0HUFaSWJeLkU0OLZxr7NK70rPXFGlOJuhjUkYdHWWcAIAUJJ expires_in:7200])
3165
+2018/09/13 19:50:59 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3166
+2018/09/13 19:50:59 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_kWgZpldvN8AzsxDJbRxCsoQiUV0j-zAfNmXR35wHCzpLa7gJpWydRR_OtZn9c9Jh74TbH6JEoWpnqLLB-3Is8TMMoumNgcahOmqU9tl9MtmUb3xvs5EbwjhgaUZbqnkOCeyIq_59Opv6psLMKJFjAEAGFB","expires_in":7200})
3167
+2018/09/13 19:50:59 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_kWgZpldvN8AzsxDJbRxCsoQiUV0j-zAfNmXR35wHCzpLa7gJpWydRR_OtZn9c9Jh74TbH6JEoWpnqLLB-3Is8TMMoumNgcahOmqU9tl9MtmUb3xvs5EbwjhgaUZbqnkOCeyIq_59Opv6psLMKJFjAEAGFB expires_in:7200])
3168
+2018/09/13 19:51:01 [E] 开启禁止人员信息失败: 用户没有被关闭的功能!
3169
+2018/09/13 19:53:30 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3170
+2018/09/13 19:53:30 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3171
+2018/09/13 19:53:30 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_BS0IWZ0zWeKoXVfeJPpaMYFO_iWnWN26nxsyg8sOI09hwo5v3bliL9QvvcEvJBrHUuF2XI9jfVm2ExXV8WtHuLGXUCqglrLSzMNDGSPPUce1xn541jpI0Lq8RXp6IoFW8sLH34LOXRbIqHRgJQPcABAPWV","expires_in":7200})
3172
+2018/09/13 19:53:30 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_BS0IWZ0zWeKoXVfeJPpaMYFO_iWnWN26nxsyg8sOI09hwo5v3bliL9QvvcEvJBrHUuF2XI9jfVm2ExXV8WtHuLGXUCqglrLSzMNDGSPPUce1xn541jpI0Lq8RXp6IoFW8sLH34LOXRbIqHRgJQPcABAPWV])
3173
+2018/09/13 19:53:30 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_LhzqIVxv4zaXr-IKJPpaMYFO_iWnWN26nxsyg8sOI09hwo5v3bliL9QvvcGTzXuwwb5pn0xPpAJZUdGCiUnMWaF0nFlsMiQHRqsRKam4aysZ5JXZr0EEccpCBGWhTU1mUIVfdeeU17ntwWGbPTDcABATXH","expires_in":7200})
3174
+2018/09/13 19:53:30 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_LhzqIVxv4zaXr-IKJPpaMYFO_iWnWN26nxsyg8sOI09hwo5v3bliL9QvvcGTzXuwwb5pn0xPpAJZUdGCiUnMWaF0nFlsMiQHRqsRKam4aysZ5JXZr0EEccpCBGWhTU1mUIVfdeeU17ntwWGbPTDcABATXH expires_in:7200])
3175
+2018/09/13 20:04:48 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3176
+2018/09/13 20:04:48 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_SH8T2k74Zw0qxStschMU6PMLRKZH-euoblG5Wb0atLchNrYGRwCU4f2NzfasftwroGU76VDlSZ6-AhYDpp9tzHI4C6EfuKuOdp0ZvRKqAeATiuWGKQxg8sntnTiCBHAotmWafpEfXWXZAujsQSSeAEACEE","expires_in":7200})
3177
+2018/09/13 20:04:48 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_SH8T2k74Zw0qxStschMU6PMLRKZH-euoblG5Wb0atLchNrYGRwCU4f2NzfasftwroGU76VDlSZ6-AhYDpp9tzHI4C6EfuKuOdp0ZvRKqAeATiuWGKQxg8sntnTiCBHAotmWafpEfXWXZAujsQSSeAEACEE])
3178
+2018/09/13 20:32:59 [E] 用户没有设置默认案场
3179
+2018/09/13 20:33:05 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3180
+2018/09/13 20:33:06 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_wZbtngqFJE3A9a9eue2JQajFisGyMCF98aO7njjnSfYBY6ej_jkzuj8TOjqq6BUu1HmRELUGzIgjdleOlD62HCXVP9NWRu_FGWmoOgou2iSF5YXURITs6haBa06Km79Xk6gJlDJegKBJAgcKCYHdAGAQMV","expires_in":7200})
3181
+2018/09/13 20:33:06 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_wZbtngqFJE3A9a9eue2JQajFisGyMCF98aO7njjnSfYBY6ej_jkzuj8TOjqq6BUu1HmRELUGzIgjdleOlD62HCXVP9NWRu_FGWmoOgou2iSF5YXURITs6haBa06Km79Xk6gJlDJegKBJAgcKCYHdAGAQMV expires_in:7200])
3182
+2018/09/13 20:35:19 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3183
+2018/09/13 20:35:19 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_LJqz0Z53ONPP-bIOyTYuV9mdwkEzrSzGH0FKFZUFmmpMOWBnRdMsaNKpMyymcgOo4F_Rc6OdfM0FyjBH_Mt341U4tz0cMcAORrqe1GirxQ6twgkMtkNr32Wx9mYTBLiAAAGOY","expires_in":7200})
3184
+2018/09/13 20:35:19 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_LJqz0Z53ONPP-bIOyTYuV9mdwkEzrSzGH0FKFZUFmmpMOWBnRdMsaNKpMyymcgOo4F_Rc6OdfM0FyjBH_Mt341U4tz0cMcAORrqe1GirxQ6twgkMtkNr32Wx9mYTBLiAAAGOY])
3185
+2018/09/13 20:37:39 [E] 用户没有设置默认案场
3186
+2018/09/13 20:38:01 [E] 用户没有设置默认案场
3187
+2018/09/13 20:38:07 [E] 用户没有设置默认案场
3188
+2018/09/13 20:38:13 [E] 用户没有设置默认案场
3189
+2018/09/13 20:38:19 [E] 用户没有设置默认案场
3190
+2018/09/13 20:38:22 [E] 用户没有设置默认案场
3191
+2018/09/13 20:38:22 [E] 用户没有设置默认案场
3192
+2018/09/13 20:40:05 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3193
+2018/09/13 20:40:06 [E] 获取优惠券失败: Error 1054: Unknown column 'customer_id' in 'where clause'
3194
+2018/09/13 20:40:06 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_6kaC4pyrESn9k9IDmRl0kaiqTC55ev7B1qCXOQmR8cpWHTPiK8glKyz7m-oQ6TNCvnM90zz2FonlNm11KOuaIAgriSnAFqQre2v5rSVkbTT47_69S21ME1lwwkGH5yHvtQ13EvUlJRIYDueURMNhAAALGH","expires_in":7200})
3195
+2018/09/13 20:40:06 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_6kaC4pyrESn9k9IDmRl0kaiqTC55ev7B1qCXOQmR8cpWHTPiK8glKyz7m-oQ6TNCvnM90zz2FonlNm11KOuaIAgriSnAFqQre2v5rSVkbTT47_69S21ME1lwwkGH5yHvtQ13EvUlJRIYDueURMNhAAALGH expires_in:7200])
3196
+2018/09/13 20:41:53 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3197
+2018/09/13 20:41:54 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_mPUCvvEearg7i6IgT3CBfOMdXv8RbHS_9jxpq1rJ7Z1Rt89hpX40ANFqvOz3QLVbI_F10Uik5yt5sdv8FjitIvKTYTajYVA9bn-m5V3Y4l5SWZ8nM1CIlw5KOM5vfVkc53dgEsHZ5Vw3S2UOEGDgAJAUWT","expires_in":7200})
3198
+2018/09/13 20:41:54 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_mPUCvvEearg7i6IgT3CBfOMdXv8RbHS_9jxpq1rJ7Z1Rt89hpX40ANFqvOz3QLVbI_F10Uik5yt5sdv8FjitIvKTYTajYVA9bn-m5V3Y4l5SWZ8nM1CIlw5KOM5vfVkc53dgEsHZ5Vw3S2UOEGDgAJAUWT expires_in:7200])
3199
+2018/09/13 20:42:02 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3200
+2018/09/13 20:42:02 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_ub6dpq88r7-6QOehT3CBfOMdXv8RbHS_9jxpq1rJ7Z1Rt89hpX40ANFqvOwMgtk4GBu1xvl7kTXRW9A1OuCMttgLxwVq7lML6jVjz1FPYfHXqv5BMg2yelftCz6Jh5CRJ1Dhj5jHGpLPyTyKUVHgAJAYZL","expires_in":7200})
3201
+2018/09/13 20:42:02 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_ub6dpq88r7-6QOehT3CBfOMdXv8RbHS_9jxpq1rJ7Z1Rt89hpX40ANFqvOwMgtk4GBu1xvl7kTXRW9A1OuCMttgLxwVq7lML6jVjz1FPYfHXqv5BMg2yelftCz6Jh5CRJ1Dhj5jHGpLPyTyKUVHgAJAYZL expires_in:7200])
3202
+2018/09/13 20:43:15 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3203
+2018/09/13 20:43:16 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_NNHGu-xc8kpPV2GH_aDV-XhW8rSKS8MnqL8kVbwNt8JCi1xjJUa_5MnKdJ_dwiUvH0cMMSoJhJ30I3HK4M7U-E4E-d6wqMfwnngQun1IVlIIgzzUzWHNvxsmQcu2rCvPdCBvep-Rp2qi-d8oEBPiAAATQE","expires_in":7200})
3204
+2018/09/13 20:43:16 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_NNHGu-xc8kpPV2GH_aDV-XhW8rSKS8MnqL8kVbwNt8JCi1xjJUa_5MnKdJ_dwiUvH0cMMSoJhJ30I3HK4M7U-E4E-d6wqMfwnngQun1IVlIIgzzUzWHNvxsmQcu2rCvPdCBvep-Rp2qi-d8oEBPiAAATQE])
3205
+2018/09/13 20:44:37 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3206
+2018/09/13 20:44:37 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_ZfJK-FbfOkN4mkUjxXSOybzmqrqbJ7tqoV39m5kGlnEdUytTfXKqKceDbYWfUY-XoAFvTKzne-fYxsvQ-bEsQYbF1R2w1RxR6eTQow67HSz9Pta8erH-FALczyAsLZfLsiY5bWy926VNDIvQXKUcACAPCM","expires_in":7200})
3207
+2018/09/13 20:44:37 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_ZfJK-FbfOkN4mkUjxXSOybzmqrqbJ7tqoV39m5kGlnEdUytTfXKqKceDbYWfUY-XoAFvTKzne-fYxsvQ-bEsQYbF1R2w1RxR6eTQow67HSz9Pta8erH-FALczyAsLZfLsiY5bWy926VNDIvQXKUcACAPCM expires_in:7200])
3208
+2018/09/13 20:51:12 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3209
+2018/09/13 20:51:13 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_xtIPz84n6R1V5FfyHKf--29lY7qJKOPDrtvbsvvdnJaK7dWgVD9wzi0PfdbT-3-Af73LDOUvPLVkTPb7-ufLbGzCUcMV6XP2sr2bwNCgnljwy61Z1Qt7YnaDlY3ajmyqOIRnazIZAUMOHqTZIGEdACALJH","expires_in":7200})
3210
+2018/09/13 20:51:13 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_xtIPz84n6R1V5FfyHKf--29lY7qJKOPDrtvbsvvdnJaK7dWgVD9wzi0PfdbT-3-Af73LDOUvPLVkTPb7-ufLbGzCUcMV6XP2sr2bwNCgnljwy61Z1Qt7YnaDlY3ajmyqOIRnazIZAUMOHqTZIGEdACALJH expires_in:7200])
3211
+2018/09/13 20:53:37 [E] 获取人员信息失败: 当前用户没有权限查看用户信息
3212
+2018/09/13 20:53:43 [E] 获取人员信息失败: 当前用户没有权限查看用户信息
3213
+2018/09/13 21:10:11 [E] 用户没有设置默认案场
3214
+2018/09/13 21:10:11 [E] 用户没有设置默认案场
3215
+2018/09/13 21:10:13 [E] 用户没有设置默认案场
3216
+2018/09/13 21:10:14 [E] 用户没有设置默认案场
3217
+2018/09/13 21:10:16 [E] 用户没有设置默认案场
3218
+2018/09/13 21:10:16 [E] 用户没有设置默认案场
3219
+2018/09/13 21:10:30 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3220
+2018/09/13 21:10:30 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_v5AijPhl5K43Ef6DOs01VRJWnC8_hT7KXogdHLCtBf6r1skxaKMPZPO2HYC209s5IfpIMbhJW-19aavI46UPxsegNPXkf3oMK9apmqw3u2TRd7t2zWHu7m8JZBSUDnWpkhZT1jGppdQ1qZ30FAPfAGAXSH","expires_in":7200})
3221
+2018/09/13 21:10:30 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_v5AijPhl5K43Ef6DOs01VRJWnC8_hT7KXogdHLCtBf6r1skxaKMPZPO2HYC209s5IfpIMbhJW-19aavI46UPxsegNPXkf3oMK9apmqw3u2TRd7t2zWHu7m8JZBSUDnWpkhZT1jGppdQ1qZ30FAPfAGAXSH expires_in:7200])
3222
+2018/09/13 21:23:11 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3223
+2018/09/13 21:23:11 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_3HmSTWJuywI-a_o7HKf--29lY7qJKOPDrtvbsmreoAWlnmFawa_qA5t9gusJhCeZrsIroq_mxMNwdRc5-XB0B3GDSJBWH0yLt2CIggjhYt53d3yla6-7YmmQm286KYfkSQn3BA4jDxMlB_BnDJHdAGAHNL","expires_in":7200})
3224
+2018/09/13 21:23:11 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_3HmSTWJuywI-a_o7HKf--29lY7qJKOPDrtvbsmreoAWlnmFawa_qA5t9gusJhCeZrsIroq_mxMNwdRc5-XB0B3GDSJBWH0yLt2CIggjhYt53d3yla6-7YmmQm286KYfkSQn3BA4jDxMlB_BnDJHdAGAHNL expires_in:7200])
3225
+2018/09/13 21:26:30 [E] 获取人员信息失败: 当前用户没有权限查看用户信息
3226
+2018/09/13 21:49:11 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3227
+2018/09/13 21:49:11 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_TV4NeWVV119Rpq3LtC04i233yiyA6yh1smV1fcBulaHyiKhAdbKqvw-t4ikWK5GsQELaTAPbMmGsfzWutsKitZAhfak9OT8WugK8Jrn2vzG7cCTCFLilaj1_lkgeD2fJySu62Qb6EiKkBsWYQDDcACAANN","expires_in":7200})
3228
+2018/09/13 21:49:11 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_TV4NeWVV119Rpq3LtC04i233yiyA6yh1smV1fcBulaHyiKhAdbKqvw-t4ikWK5GsQELaTAPbMmGsfzWutsKitZAhfak9OT8WugK8Jrn2vzG7cCTCFLilaj1_lkgeD2fJySu62Qb6EiKkBsWYQDDcACAANN expires_in:7200])
3229
+2018/09/13 21:57:48 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3230
+2018/09/13 21:57:48 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_6LDRVxFnmaNbFuEbNtGGaDp5zNzqVEmkaiqXLC11c7E31gZQB4FySVBvu-FbgXv6owGisZmxCWQ9drO9mcWF7yN6yTREApW2f74IgjvtYt90xSaJNQuHKAckQPVDFG8edgKoqa5z2gKLXZmQLBGgAAAWMR","expires_in":7200})
3231
+2018/09/13 21:57:48 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_6LDRVxFnmaNbFuEbNtGGaDp5zNzqVEmkaiqXLC11c7E31gZQB4FySVBvu-FbgXv6owGisZmxCWQ9drO9mcWF7yN6yTREApW2f74IgjvtYt90xSaJNQuHKAckQPVDFG8edgKoqa5z2gKLXZmQLBGgAAAWMR expires_in:7200])
3232
+2018/09/13 22:16:04 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3233
+2018/09/13 22:16:04 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_X0bnR_05cDF1EIJk6iQtk40j_7cjcXS7x7gbeiq6MAIyT1w9BQUHA-bAVcu9QENZsvmyvDVKN1RgxemjZyzGdUc7rxGBxmSFPrEiaIksG-6A6OeXqSX1Hj2XXFvlj7E1SYn8fxD3yepXkDQNMLXjAIAAZL","expires_in":7200})
3234
+2018/09/13 22:16:04 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_X0bnR_05cDF1EIJk6iQtk40j_7cjcXS7x7gbeiq6MAIyT1w9BQUHA-bAVcu9QENZsvmyvDVKN1RgxemjZyzGdUc7rxGBxmSFPrEiaIksG-6A6OeXqSX1Hj2XXFvlj7E1SYn8fxD3yepXkDQNMLXjAIAAZL expires_in:7200])
3235
+2018/09/13 22:22:35 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3236
+2018/09/13 22:22:35 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_i1RdHrRFdYRz8EhrT3CBfOMdXv8RbHS_9jxpq41C0Ashe55hFecosZEI9rq7ahafIAOsb-ZsdcsSJXYhLN1N3fO5OtYMJM9biXYTXd674KTTqDf14boGnjSCMa95qPkAfMiGaisDgHKCs6-HLBVeAIAFVP","expires_in":7200})
3237
+2018/09/13 22:22:35 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_i1RdHrRFdYRz8EhrT3CBfOMdXv8RbHS_9jxpq41C0Ashe55hFecosZEI9rq7ahafIAOsb-ZsdcsSJXYhLN1N3fO5OtYMJM9biXYTXd674KTTqDf14boGnjSCMa95qPkAfMiGaisDgHKCs6-HLBVeAIAFVP expires_in:7200])
3238
+2018/09/13 22:25:00 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3239
+2018/09/13 22:25:01 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_P08kmfZziFJ68rDCQrTSheSWuAj8XAN8wpjERMKL2GCJTGxBZ9uFhKIg6YGQZc0dCpLH-zzyXRIB-SVLM9ANp6Vmwcp-uC-WY2KGxjBZ80HdMAw-7EGAyZQrtEjJBvzkMpf5yhYPMkgnkowAJRNcADABJF","expires_in":7200})
3240
+2018/09/13 22:25:01 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_P08kmfZziFJ68rDCQrTSheSWuAj8XAN8wpjERMKL2GCJTGxBZ9uFhKIg6YGQZc0dCpLH-zzyXRIB-SVLM9ANp6Vmwcp-uC-WY2KGxjBZ80HdMAw-7EGAyZQrtEjJBvzkMpf5yhYPMkgnkowAJRNcADABJF])
3241
+2018/09/13 22:31:30 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3242
+2018/09/13 22:31:31 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_P7KfstHrvVZP52ZW2IuhpSDriQBy87UH-yeqoEvrDAFetKy4BGelmb82rHGAmIHZF5IeJMTD7Mo2m2h82GgYeaf2sc1zqhQLoxh5tuKGGR5TpOQr425QJcgXkhaqfvKttovjnRVxacLybDNBEDQaAFAAZM","expires_in":7200})
3243
+2018/09/13 22:31:31 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_P7KfstHrvVZP52ZW2IuhpSDriQBy87UH-yeqoEvrDAFetKy4BGelmb82rHGAmIHZF5IeJMTD7Mo2m2h82GgYeaf2sc1zqhQLoxh5tuKGGR5TpOQr425QJcgXkhaqfvKttovjnRVxacLybDNBEDQaAFAAZM expires_in:7200])
3244
+2018/09/13 22:33:49 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3245
+2018/09/13 22:33:49 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_H1LH3h20RWG_81YkyUBsFc2YTHtD04oNF4fMTHfdkbPETFHFspbDbJD161fVoCMVP1aTijpic8e4VeMsuYea2edrlIeHfYmDpKtL0_nityyXPlws6vR7dfKZu08TdlhI60jC_42adSaUQYT-RYOjAAALSI","expires_in":7200})
3246
+2018/09/13 22:33:49 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_H1LH3h20RWG_81YkyUBsFc2YTHtD04oNF4fMTHfdkbPETFHFspbDbJD161fVoCMVP1aTijpic8e4VeMsuYea2edrlIeHfYmDpKtL0_nityyXPlws6vR7dfKZu08TdlhI60jC_42adSaUQYT-RYOjAAALSI expires_in:7200])
3247
+2018/09/13 22:36:22 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3248
+2018/09/13 22:36:22 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_r-JJBH954eqlv6esi0Vuh3G-4MFjcRYcJUpV31FwV1Nd72pKC6Wod9fN8BFfkdmiozkqzjHbQXiQFStj1YWm5eHcA9H2HBHgHqffXkVadksfk5fyw0jryenxkiCaH7XsQaEDkgPYH3R5zVBiXOSaABASJN","expires_in":7200})
3249
+2018/09/13 22:36:22 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_r-JJBH954eqlv6esi0Vuh3G-4MFjcRYcJUpV31FwV1Nd72pKC6Wod9fN8BFfkdmiozkqzjHbQXiQFStj1YWm5eHcA9H2HBHgHqffXkVadksfk5fyw0jryenxkiCaH7XsQaEDkgPYH3R5zVBiXOSaABASJN expires_in:7200])
3250
+2018/09/13 22:36:38 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3251
+2018/09/13 22:36:38 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_69WTLSXrOM6O37u9i0Vuh3G-4MFjcRYcJUpV31FwV1Nd72pKC6Wod9fN8BHGt_I9Dx_FSiPzagoAa9zWKIMQglhTrrRr2NwaWMMkTeqI0uD9Ygv_ucFRwYulk09uc-LuV7o7m4s7y1J69MbdJBUaABAMEX","expires_in":7200})
3252
+2018/09/13 22:36:38 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_69WTLSXrOM6O37u9i0Vuh3G-4MFjcRYcJUpV31FwV1Nd72pKC6Wod9fN8BHGt_I9Dx_FSiPzagoAa9zWKIMQglhTrrRr2NwaWMMkTeqI0uD9Ygv_ucFRwYulk09uc-LuV7o7m4s7y1J69MbdJBUaABAMEX expires_in:7200])
3253
+2018/09/13 22:39:40 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3254
+2018/09/13 22:39:41 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_4NByfleFyLQiOpPVrmtbkXrv6GoHX0tx6D0z5wC1NCT3bOwGt2IxRg0kdyoS85TWMHgrXhKrMS-Hx6aVePvebd06LdTfBeafS3aJpHsQfF7Go-NeFDMvSzUqcmOh3kr_YJCn5QaxYHDlwde6WZSiAEAFIB","expires_in":7200})
3255
+2018/09/13 22:39:41 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[access_token:13_4NByfleFyLQiOpPVrmtbkXrv6GoHX0tx6D0z5wC1NCT3bOwGt2IxRg0kdyoS85TWMHgrXhKrMS-Hx6aVePvebd06LdTfBeafS3aJpHsQfF7Go-NeFDMvSzUqcmOh3kr_YJCn5QaxYHDlwde6WZSiAEAFIB expires_in:7200])
3256
+2018/09/13 22:41:25 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3257
+2018/09/13 22:41:25 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_XiP8LniIoRsqX96aRouc5sin8BHZTUcYQXNEZskDvddqbNqvO93XIohkndnrl4pfWeO3DWYRmONjxBJgAbRs16ZiGeaF0BrvyXSP9IMvj-djQbWl4VyRTtY7sxrgeOmrFLPt5xc2Ih-WVyvPFGQiAEAVWG","expires_in":7200})
3258
+2018/09/13 22:41:25 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_XiP8LniIoRsqX96aRouc5sin8BHZTUcYQXNEZskDvddqbNqvO93XIohkndnrl4pfWeO3DWYRmONjxBJgAbRs16ZiGeaF0BrvyXSP9IMvj-djQbWl4VyRTtY7sxrgeOmrFLPt5xc2Ih-WVyvPFGQiAEAVWG])
3259
+2018/09/13 22:43:08 [I] 请求远程接口: %!(EXTRA string=https://api.weixin.qq.com/cgi-bin/token?appid=wx7320287e057bbeee&grant_type=client_credential&secret=6e844dc2ade439545c47569ba1707673)
3260
+2018/09/13 22:43:09 [I] 远程请求结果:%!(EXTRA string={"access_token":"13_GxgfJzv5XDJqhe4UMEnQHNxh1Po7akGhaKn5eKGzcgX8fbOqI9Jc1KWTvQ3j3rHXgQEhW8teC9hWD4MfmXnBgOpP5ym3unGtki1mDdjXSg0KgcXi6TWxk328ouEi5gj7MYPCL-kvHfn5gIYTOJLeAFAEZB","expires_in":7200})
3261
+2018/09/13 22:43:09 [I] 接口返回结果: %!(EXTRA map[string]interface {}=map[expires_in:7200 access_token:13_GxgfJzv5XDJqhe4UMEnQHNxh1Po7akGhaKn5eKGzcgX8fbOqI9Jc1KWTvQ3j3rHXgQEhW8teC9hWD4MfmXnBgOpP5ym3unGtki1mDdjXSg0KgcXi6TWxk328ouEi5gj7MYPCL-kvHfn5gIYTOJLeAFAEZB])

+ 28
- 0
models/card/card.go Просмотреть файл

@@ -274,3 +274,31 @@ func (m *CardDAO) GetCustomerCardByUser(caseid, userid string) ([]model.TaCustom
274 274
 	err := m.db.Where("case_id=?", caseid).And("sales_id=?", userid).And("status>?", models.STATUS_DEL).Find(&customerCards)
275 275
 	return customerCards, err
276 276
 }
277
+
278
+// GetCardWithCustomer 获取优惠券明细
279
+func (m *CardDAO) GetCardWithCustomer(cardid string) (*CaseUsableCard, error) {
280
+	var card = new(CaseUsableCard)
281
+	sql := `select * from ta_card where coupin_id=?`
282
+	_, err := m.db.Sql(sql, cardid).Get(&card)
283
+	if err != nil {
284
+		return nil, err
285
+	}
286
+	if card == nil || card.CardId == "" {
287
+		return nil, errors.New("无优惠券信息")
288
+	}
289
+	var customerCopons []model.TaCustomerCard
290
+	sql = `select * from ta_customer_card where card_id = ? and status>?`
291
+	err = m.db.Sql(sql, card, models.STATUS_DEL).Find(&customerCopons)
292
+	if err != nil {
293
+		return nil, err
294
+	}
295
+	card.CustomerCard = customerCopons
296
+	return card, nil
297
+}
298
+
299
+// GetCardByCustomer 获取我的体验卡
300
+func (m *CardDAO) GetCardByCustomer(orgid, customerid string) ([]model.TaCustomerCard, error) {
301
+	var cards []model.TaCustomerCard
302
+	err := m.db.Where("status>?", models.STATUS_DEL).And("customer_id=?", customerid).And("org_id=?", orgid).Find(&cards)
303
+	return cards, err
304
+}

+ 92
- 1
models/coupon/coupon.go Просмотреть файл

@@ -89,6 +89,35 @@ func (m *CouponDAO) GetCouponInfoByID(id string) (*CouponInfo, error) {
89 89
 	return cp, nil
90 90
 }
91 91
 
92
+// GetCouponInfoByCustomerCouponID 获取优惠券详情
93
+func (m *CouponDAO) GetCouponInfoByCustomerCouponID(id string) (*CouponInfo, error) {
94
+	cp := new(CouponInfo)
95
+
96
+	query := `
97
+		SELECT
98
+			a.*
99
+		FROM
100
+			ta_coupon a 
101
+			inner join ta_customer_coupon b 
102
+			on a.coupon_id = b.coupon_id
103
+		WHERE
104
+			b.customer_coupon_id = ?
105
+	`
106
+
107
+	if _, err := m.db.SQL(query, id).Get(cp); err != nil {
108
+		return nil, err
109
+	}
110
+	// 关联目标
111
+	var targes []model.TaCouponTarget
112
+	if err := m.db.Where("coupon_id=?", id).Find(&targes); err != nil {
113
+		return nil, err
114
+	}
115
+
116
+	cp.Targets = targes
117
+
118
+	return cp, nil
119
+}
120
+
92 121
 // GetCouponList 获取优惠券列表
93 122
 func (m *CouponDAO) GetCouponList(filters []string, limit []int) ([]model.TaCoupon, int64, error) {
94 123
 	var cps []model.TaCoupon
@@ -317,7 +346,7 @@ func (m *CouponDAO) GetCustomerCouponByUser(caseid, userid string) ([]model.TaCu
317 346
 }
318 347
 
319 348
 // GetCouponWithCustomer 获取优惠券明细
320
-func (m CouponDAO) GetCouponWithCustomer(couponid string) (*CaseCouponDetail, error) {
349
+func (m *CouponDAO) GetCouponWithCustomer(couponid string) (*CaseCouponDetail, error) {
321 350
 	var coupon = new(CaseCouponDetail)
322 351
 	sql := `select * from ta_coupon where coupin_id=?`
323 352
 	_, err := m.db.Sql(sql, couponid).Get(&coupon)
@@ -336,3 +365,65 @@ func (m CouponDAO) GetCouponWithCustomer(couponid string) (*CaseCouponDetail, er
336 365
 	coupon.CustomerCoupon = customerCopons
337 366
 	return coupon, nil
338 367
 }
368
+
369
+// GetCouponByCustomer 获取我的优惠券信息
370
+func (m *CouponDAO) GetCouponByCustomer(orgid, customerid string) ([]CustomerCoupon, error) {
371
+	var coupons []CustomerCoupon
372
+	sql := `select * from ta_customer_coupon where status>? and customer_id=? and org_id=?`
373
+	err := m.db.Sql(sql, models.STATUS_DEL, customerid, orgid).Find(&coupons)
374
+	// err := m.db.Where("status>?", models.STATUS_DEL).And("customer_id=?", customerid).And("org_id=?", orgid).Find(&coupons)
375
+	for inx, coupon := range coupons {
376
+		info, err := m.GetCouponInfoByID(coupon.CouponId)
377
+		if err != nil {
378
+			return nil, err
379
+		}
380
+		coupons[inx].Coupon = info
381
+	}
382
+	return coupons, err
383
+}
384
+
385
+// GetCouponWithTarget 获取优惠券与关联信息
386
+func (m *CouponDAO) GetCouponWithTarget(ids string) ([]CouponInfo, error) {
387
+	var cp []CouponInfo
388
+
389
+	query := `
390
+		SELECT
391
+			*
392
+		FROM
393
+			ta_coupon
394
+		WHERE
395
+			coupon_id in ('` + strings.Replace(ids, ",", "','", -1) + `')
396
+	`
397
+
398
+	if err := m.db.SQL(query).Find(&cp); err != nil {
399
+		return nil, err
400
+	}
401
+
402
+	for i, c := range cp {
403
+		// 关联目标
404
+		var targes []model.TaCouponTarget
405
+		if err := m.db.Where("coupon_id=?", c.CouponId).Find(&targes); err != nil {
406
+			return nil, err
407
+		}
408
+		cp[i].Targets = targes
409
+	}
410
+
411
+	return cp, nil
412
+}
413
+
414
+// VerifyCustomerCoupon 核销客户优惠券
415
+func (m *CouponDAO) VerifyCustomerCoupon(id string) error {
416
+	var customerCoupon = model.TaCustomerCoupon{
417
+		CustomerCouponId: id,
418
+		UseDate:          time.Now(),
419
+	}
420
+	var cols = []string{
421
+		"area_name",
422
+		"area_icon",
423
+		"area_icon_white",
424
+		"order",
425
+		"case_id",
426
+	}
427
+	_, err := m.db.Cols(cols...).Where("customer_coupon_id=?", id).Update(customerCoupon)
428
+	return err
429
+}

+ 6
- 0
models/coupon/types.go Просмотреть файл

@@ -24,3 +24,9 @@ type CaseCouponDetail struct {
24 24
 	model.TaCoupon `xorm:"extends"`
25 25
 	CustomerCoupon []model.TaCustomerCoupon
26 26
 }
27
+
28
+// CustomerCoupon 用户优惠券
29
+type CustomerCoupon struct {
30
+	model.TaCustomerCoupon `xorm:"extends"`
31
+	Coupon                 *CouponInfo
32
+}

+ 32
- 28
models/goods/orders.go Просмотреть файл

@@ -73,42 +73,46 @@ func (m *GoodsDAO) SaveOrdersDetail(list []model.TaGoodsOrdersDetail, ordersID s
73 73
 }
74 74
 
75 75
 // SaveOrdersCoupon 保存订单优惠券
76
-func (m *GoodsDAO) SaveOrdersCoupon(coupons []model.TaGoodsOrdersCoupon, order *model.TaGoodsOrders) error {
76
+func (m *GoodsDAO) SaveOrdersCoupon(coupons *model.TaGoodsOrdersCoupon, order *model.TaGoodsOrders) error {
77 77
 	if order.OrdersId == "" {
78 78
 		return errors.New("内部错误, 订单事务顺序出错")
79 79
 	}
80 80
 
81
-	var couponAmount float64 = 0
82
-
83
-	// 补充优惠券表字段
84
-	for inx := range coupons {
85
-		coupons[inx].OrdersCouponId = guid.NewGUIDString()
86
-		coupons[inx].OrdersId = order.OrdersId
87
-		coupons[inx].OrdersNo = order.OrdersNo
88
-		coupons[inx].OrgId = order.OrgId
89
-		coupons[inx].Status = models.STATUS_NORMAL
90
-		coupons[inx].CreateDate = time.Now().Local()
91
-
92
-		userAmount, _ := strconv.ParseFloat(coupons[inx].UsedAmount, 64)
93
-		couponAmount += userAmount
94
-	}
95
-
96
-	// 反向更新 订单主表
97
-	totalAmount, _ := strconv.ParseFloat(order.Amount, 64)
98
-
99
-	order.CouponAmount = strconv.FormatFloat(couponAmount, 'f', -1, 32)
100
-	order.ActualAmount = strconv.FormatFloat((totalAmount - couponAmount), 'f', -1, 32)
101
-
102 81
 	if _, err := m.db.Insert(&coupons); err != nil {
103 82
 		return err
104 83
 	}
105 84
 
106
-	if _, err := m.db.
107
-		Where("orders_id=?", order.OrdersId).
108
-		Cols([]string{"coupon_amount", "actual_amount"}...).
109
-		Update(order); err != nil {
110
-		return err
111
-	}
85
+	// var couponAmount float64 = 0
86
+
87
+	// // 补充优惠券表字段
88
+	// for inx := range coupons {
89
+	// 	coupons[inx].OrdersCouponId = guid.NewGUIDString()
90
+	// 	coupons[inx].OrdersId = order.OrdersId
91
+	// 	coupons[inx].OrdersNo = order.OrdersNo
92
+	// 	coupons[inx].OrgId = order.OrgId
93
+	// 	coupons[inx].Status = models.STATUS_NORMAL
94
+	// 	coupons[inx].CreateDate = time.Now().Local()
95
+
96
+	// 	userAmount, _ := strconv.ParseFloat(coupons[inx].UsedAmount, 64)
97
+	// 	couponAmount += userAmount
98
+	// }
99
+
100
+	// // 反向更新 订单主表
101
+	// totalAmount, _ := strconv.ParseFloat(order.Amount, 64)
102
+
103
+	// order.CouponAmount = strconv.FormatFloat(couponAmount, 'f', -1, 32)
104
+	// order.ActualAmount = strconv.FormatFloat((totalAmount - couponAmount), 'f', -1, 32)
105
+
106
+	// if _, err := m.db.Insert(&coupons); err != nil {
107
+	// 	return err
108
+	// }
109
+
110
+	// if _, err := m.db.
111
+	// 	Where("orders_id=?", order.OrdersId).
112
+	// 	Cols([]string{"coupon_amount", "actual_amount"}...).
113
+	// 	Update(order); err != nil {
114
+	// 	return err
115
+	// }
112 116
 
113 117
 	return nil
114 118
 }

+ 4
- 1
models/system/user.go Просмотреть файл

@@ -340,7 +340,7 @@ func (m *UserDAO) UpdateCustomerHeadImg(customerid, username, imgurl string) err
340 340
 }
341 341
 
342 342
 // GetUserCustomer 获取我的推荐客户
343
-func (m *UserDAO) GetUserCustomer(userid, isrecommend string, page int, pageSize int) ([]model.TaCustomer, error) {
343
+func (m *UserDAO) GetUserCustomer(userid, isrecommend, key string, page int, pageSize int) ([]model.TaCustomer, error) {
344 344
 	var customers []model.TaCustomer
345 345
 	sql := `select * from ta_customer where recommend_id='` + userid + `'`
346 346
 	if isrecommend == "" {
@@ -350,6 +350,9 @@ func (m *UserDAO) GetUserCustomer(userid, isrecommend string, page int, pageSize
350 350
 			select customer_id from ta_customer_card where sales_id='` + userid + `'
351 351
 		)`
352 352
 	}
353
+	if key != "" {
354
+		sql += ` and (customer_name like '%` + key + `%' or phone like '%` + key + `%' or name like '%` + key + `%')`
355
+	}
353 356
 	offset := (page - 1) * pageSize
354 357
 	sql += ` order by create_date desc LIMIT ` + strconv.Itoa(pageSize) + ` OFFSET ` + strconv.Itoa(offset)
355 358
 	err := m.db.Sql(sql).Find(&customers)

+ 12
- 0
routers/wechat.go Просмотреть файл

@@ -1,6 +1,8 @@
1 1
 package routers
2 2
 
3 3
 import (
4
+	"spaceofcheng/services/controllers/card"
5
+	"spaceofcheng/services/controllers/coupon"
4 6
 	"spaceofcheng/services/controllers/course"
5 7
 	"spaceofcheng/services/controllers/customer"
6 8
 	"spaceofcheng/services/controllers/goods"
@@ -17,6 +19,8 @@ func getWechatRoutes() beego.LinkNamespace {
17 19
 		// 会员
18 20
 		beego.NSRouter("/customer", &customer.CustomerController{}, "get:GetCustWXByID"),
19 21
 		beego.NSRouter("/customer/user", &user.UserController{}, "get:GetUserCustomer"),
22
+		beego.NSRouter("/customer/coupon", &coupon.CouponController{}, "get:GetCouponByCustomer"),
23
+		// beego.NSRouter("/customer/card", &card.CardController{}, "get:GetCardByCustomer"),
20 24
 
21 25
 		// 下单
22 26
 		beego.NSRouter("/order/goods", &goods.GoodsController{}, "post:PostOrder"),
@@ -45,5 +49,13 @@ func getWechatRoutes() beego.LinkNamespace {
45 49
 		// 用户
46 50
 		beego.NSRouter("/user/:type", &user.UserController{}, "get:GetCaseUserByType"),
47 51
 		beego.NSRouter("/user/detail/:id", &user.UserController{}, "get:GetCaseUserByID"),
52
+
53
+		// 优惠券
54
+		beego.NSRouter("/coupon/:id", &coupon.CouponController{}, "get:GetCouponByID"),
55
+		beego.NSRouter("/coupon/detail/:id", &coupon.CouponController{}, "get:GetCouponWithCustomer"),
56
+
57
+		// 卡
58
+		beego.NSRouter("/card/:id", &card.CardController{}, "get:GetCardByID"),
59
+		beego.NSRouter("/card/detail/:id", &card.CardController{}, "get:GetCardWithCustomer"),
48 60
 	)
49 61
 }

+ 25
- 0
service/card/card.go Просмотреть файл

@@ -274,3 +274,28 @@ func (s *CardServ) GetCardByIDWithCheck(cardID string) (*card.CardInfo, error) {
274 274
 
275 275
 	return card, nil
276 276
 }
277
+
278
+// GetCardWithCustomer 获取优惠券明细
279
+func (s *CardServ) GetCardWithCustomer(cardid string) (*card.CaseUsableCard, error) {
280
+	if cardid == "" {
281
+		return nil, errors.New("没有卡信息!")
282
+	}
283
+	cardDetail, err := s.dao.GetCardDetail(cardid)
284
+	if err != nil {
285
+		utils.LogError("获取优惠券失败: " + err.Error())
286
+		return nil, errors.New("获取优惠券失败")
287
+	}
288
+	return cardDetail, nil
289
+}
290
+
291
+// GetCardByCustomer 获取我的优惠券
292
+func (s *CardServ) GetCardByCustomer() ([]model.TaCustomerCard, error) {
293
+	org := s.ctx.Get("org").(model.SysOrg)
294
+	customer := s.ctx.Get("customer").(model.TaCustomer)
295
+	cards, err := s.dao.GetCardByCustomer(org.OrgId, customer.CustomerId)
296
+	if err != nil {
297
+		utils.LogError("获取体验卡失败: " + err.Error())
298
+		return nil, errors.New("获取体验卡失败")
299
+	}
300
+	return cards, nil
301
+}

+ 13
- 1
service/coupon/coupon.go Просмотреть файл

@@ -364,7 +364,7 @@ func (s *CouponServ) GetCouponBySendType(sendtype string) ([]model.TaCoupon, err
364 364
 	coupon, err := s.dao.GetCouponBySendType(caseIDs, sendtype)
365 365
 	if err != nil {
366 366
 		utils.LogError("获取优惠券失败: " + err.Error())
367
-		return nil, errors.New("校验优惠券失败")
367
+		return nil, errors.New("获取优惠券失败")
368 368
 	}
369 369
 	return coupon, nil
370 370
 }
@@ -381,3 +381,15 @@ func (s *CouponServ) GetCouponWithCustomer(couponid string) (*coupon.CaseCouponD
381 381
 	}
382 382
 	return couponDetail, nil
383 383
 }
384
+
385
+// GetCouponByCustomer 获取我的优惠券
386
+func (s *CouponServ) GetCouponByCustomer() ([]coupon.CustomerCoupon, error) {
387
+	org := s.ctx.Get("org").(model.SysOrg)
388
+	customer := s.ctx.Get("customer").(model.TaCustomer)
389
+	coupons, err := s.dao.GetCouponByCustomer(org.OrgId, customer.CustomerId)
390
+	if err != nil {
391
+		utils.LogError("获取优惠券失败: " + err.Error())
392
+		return nil, errors.New("获取优惠券失败")
393
+	}
394
+	return coupons, nil
395
+}

+ 13
- 10
service/goods/goods.go Просмотреть файл

@@ -4,6 +4,7 @@ import (
4 4
 	"errors"
5 5
 	"spaceofcheng/services/models"
6 6
 	"spaceofcheng/services/models/cases"
7
+	"spaceofcheng/services/models/coupon"
7 8
 	"spaceofcheng/services/models/customer"
8 9
 	"spaceofcheng/services/models/goods"
9 10
 	"spaceofcheng/services/models/model"
@@ -14,21 +15,23 @@ import (
14 15
 
15 16
 // GoodsServ 系统处理
16 17
 type GoodsServ struct {
17
-	ctx     *utils.Context
18
-	dao     *goods.GoodsDAO
19
-	caseDAO *cases.CaseDAO
20
-	custDAO *customer.CustomerDAO
21
-	userDAO *system.UserDAO
18
+	ctx       *utils.Context
19
+	dao       *goods.GoodsDAO
20
+	caseDAO   *cases.CaseDAO
21
+	custDAO   *customer.CustomerDAO
22
+	userDAO   *system.UserDAO
23
+	couponDAO *coupon.CouponDAO
22 24
 }
23 25
 
24 26
 // NewGoodsServ 初始化
25 27
 func NewGoodsServ(ctx *utils.Context) *GoodsServ {
26 28
 	return &GoodsServ{
27
-		ctx:     ctx,
28
-		dao:     goods.NewGoodsDAO(ctx),
29
-		caseDAO: cases.NewCaseDAO(ctx),
30
-		custDAO: customer.NewCustomerDAO(ctx),
31
-		userDAO: system.NewUserDAO(ctx),
29
+		ctx:       ctx,
30
+		dao:       goods.NewGoodsDAO(ctx),
31
+		caseDAO:   cases.NewCaseDAO(ctx),
32
+		custDAO:   customer.NewCustomerDAO(ctx),
33
+		userDAO:   system.NewUserDAO(ctx),
34
+		couponDAO: coupon.NewCouponDAO(ctx),
32 35
 	}
33 36
 }
34 37
 

+ 72
- 22
service/goods/orders.go Просмотреть файл

@@ -20,7 +20,7 @@ import (
20 20
 func (s *GoodsServ) Orders(
21 21
 	info *model.TaGoodsOrders,
22 22
 	details []model.TaGoodsOrdersDetail,
23
-	coupons []model.TaGoodsOrdersCoupon) error {
23
+	customercouponid string) error {
24 24
 	// org := s.ctx.Get("org").(model.SysOrg)
25 25
 	cust := s.ctx.Get("customer").(model.TaCustomer)
26 26
 
@@ -48,7 +48,6 @@ func (s *GoodsServ) Orders(
48 48
 		// TODO
49 49
 	} else {
50 50
 		// 普通客户
51
-
52 51
 		account, err := s.custDAO.GetAccountByCust(info.UserId)
53 52
 		if err != nil {
54 53
 			utils.LogError("查询用户账户信息出错: " + err.Error())
@@ -56,39 +55,90 @@ func (s *GoodsServ) Orders(
56 55
 		}
57 56
 
58 57
 		// 如果是使用优惠券
59
-		if coupons != nil && len(coupons) > 0 {
58
+
59
+		if customercouponid != "" {
60 60
 			info.PayType = models.CONSUME_COUPON
61 61
 
62
-			// TODO
63
-			// 校验优惠券相关
64
-			// 优惠券默认抵消全部金额
65
-			info.ActualAmount = "0.0"
62
+			// 根据id获取优惠券信息
63
+			coupon, err := s.couponDAO.GetCouponInfoByCustomerCouponID(customercouponid)
64
+			if err != nil {
65
+				utils.LogError("查询优惠券信息失败: " + err.Error())
66
+				return errors.New("查询优惠券信息失败")
67
+			}
68
+			// 遍历优惠券可抵用的商品
69
+			var dyGoods = model.TaGoodsOrdersDetail{
70
+				Price:   "0.0",
71
+				GoodsId: "",
72
+			}
73
+			for _, detail := range details {
74
+				for _, target := range coupon.Targets {
75
+					if target.TargetId == detail.GoodsId {
76
+						dyprice, _ := strconv.ParseFloat(dyGoods.Price, 64)
77
+						detailprice, _ := strconv.ParseFloat(detail.Price, 64)
78
+						if dyprice < detailprice {
79
+							dyGoods = detail
80
+						}
81
+					}
82
+				}
83
+			}
84
+
85
+			if dyGoods.GoodsId != "" {
86
+				// 优惠券可以抵用商品
87
+				var ordersCoupon = model.TaGoodsOrdersCoupon{
88
+					OrdersId:   info.OrdersId,
89
+					OrdersNo:   info.OrdersNo,
90
+					CouponId:   coupon.CouponId,
91
+					CouponName: coupon.CouponName,
92
+					OrgId:      coupon.OrgId,
93
+					GoodsId:    dyGoods.GoodsId,
94
+					GoodsName:  dyGoods.GoodsName,
95
+					UsedAmount: dyGoods.Price,
96
+				}
97
+				if err := s.dao.SaveOrdersCoupon(&ordersCoupon, info); err != nil {
98
+					utils.LogError("保存优惠信息出错: " + err.Error())
99
+					return errors.New("保存优惠信息出错")
100
+				}
101
+				info.CouponAmount = dyGoods.Price
102
+				// info.ActualAmount = "0.0"
103
+
104
+				// 优惠券核销
105
+				err := s.couponDAO.VerifyCustomerCoupon(customercouponid)
106
+				if err != nil {
107
+					utils.LogError("优惠券核销出错: " + err.Error())
108
+					return errors.New("优惠券核销出错")
109
+				}
110
+			} else {
111
+				info.CouponAmount = "0.0"
112
+			}
66 113
 		} else {
67 114
 			// 如果是使用城币
68 115
 			info.PayType = models.CONSUME_COINCHG
69
-			accMoney, _ := strconv.ParseFloat(account.Amount, 64)
70
-			payMoney, _ := strconv.ParseFloat(info.Amount, 64)
116
+		}
71 117
 
72
-			if accMoney < payMoney {
73
-				return errors.New("账户余额不足")
74
-			}
118
+		accMoney, _ := strconv.ParseFloat(account.Amount, 64)
119
+		couponAmount, _ := strconv.ParseFloat(info.CouponAmount, 64)
120
+		payMoney, _ := strconv.ParseFloat(info.Amount, 64)
121
+		payMoney = payMoney - couponAmount
75 122
 
76
-			info.ActualAmount = strconv.FormatFloat(payMoney, 'f', -1, 64)
123
+		if accMoney < payMoney {
124
+			return errors.New("账户余额不足")
77 125
 		}
78 126
 
127
+		info.ActualAmount = strconv.FormatFloat(payMoney, 'f', -1, 64)
128
+
79 129
 		// 保存优惠券使用记录
80
-		if coupons != nil && len(coupons) > 0 {
81
-			if err := s.dao.SaveOrdersCoupon(coupons, info); err != nil {
82
-				utils.LogError("保存优惠信息出错: " + err.Error())
83
-				return errors.New("保存优惠信息出错")
84
-			}
130
+		// if coupons != nil && len(coupons) > 0 {
131
+		// 	if err := s.dao.SaveOrdersCoupon(coupons, info); err != nil {
132
+		// 		utils.LogError("保存优惠信息出错: " + err.Error())
133
+		// 		return errors.New("保存优惠信息出错")
134
+		// 	}
85 135
 
86
-			// TODO
87
-			// 核销优惠券
88
-		}
136
+		// TODO
137
+		// 核销优惠券
138
+		// }
89 139
 
90 140
 		// 如果是城币, 则插入用户账户消费记录
91
-		if info.PayType == models.CONSUME_COINCHG {
141
+		if payMoney > 0 {
92 142
 			if err := s.saveCustomerPayRec(account, info); err != nil {
93 143
 				return err
94 144
 			}

+ 2
- 2
service/user.go Просмотреть файл

@@ -379,14 +379,14 @@ func (s *UserServ) SaveUserRole(userid, roleids string) error {
379 379
 }
380 380
 
381 381
 // GetUserCustomer 获取我的推荐客户
382
-func (s *UserServ) GetUserCustomer(userid, isrecommend string, page int, pageSize int) ([]model.TaCustomer, error) {
382
+func (s *UserServ) GetUserCustomer(userid, isrecommend, key string, page int, pageSize int) ([]model.TaCustomer, error) {
383 383
 	if pageSize == 0 {
384 384
 		pageSize = PAGENUM
385 385
 	}
386 386
 	if page == 0 {
387 387
 		page = 1
388 388
 	}
389
-	customers, err := s.dao.GetUserCustomer(userid, isrecommend, page, pageSize)
389
+	customers, err := s.dao.GetUserCustomer(userid, isrecommend, key, page, pageSize)
390 390
 	return customers, err
391 391
 }
392 392