Procházet zdrojové kódy

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/services into dev

胡轶钦 před 6 roky
rodič
revize
df7665720f

+ 15
- 9
controllers/auth.go Zobrazit soubor

@@ -81,15 +81,17 @@ func (c *BaseController) authWechat(serv *service.SysServ) {
81 81
 	}
82 82
 
83 83
 	// DEV MODE
84
-	wxDetail = map[string]interface{}{
85
-		"openid":     " OPENID",
86
-		" nickname":  "NICKNAME",
87
-		"sex":        "1",
88
-		"province":   "PROVINCE",
89
-		"city":       "CITY",
90
-		"country":    "COUNTRY",
91
-		"headimgurl": "http://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46",
92
-		"unionid":    "o6_bmasdasdsad6_2sgVt7hMZOPfL",
84
+	if c.RunMode == "dev" {
85
+		wxDetail = map[string]interface{}{
86
+			"openid":     " OPENID",
87
+			"nickname":   "NICKNAME",
88
+			"sex":        "1",
89
+			"province":   "PROVINCE",
90
+			"city":       "CITY",
91
+			"country":    "COUNTRY",
92
+			"headimgurl": "http://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46",
93
+			"unionid":    "o6_bmasdasdsad6_2sgVt7hMZOPfL",
94
+		}
93 95
 	}
94 96
 
95 97
 	if custID == "" && wxDetail == nil {
@@ -109,6 +111,10 @@ func (c *BaseController) authWechat(serv *service.SysServ) {
109 111
 		)
110 112
 	}
111 113
 
114
+	if userMap != nil {
115
+		c.Context.Set("userMap", *userMap)
116
+	}
117
+
112 118
 	if !c.needAuth() {
113 119
 		return
114 120
 	}

+ 1
- 0
controllers/base.go Zobrazit soubor

@@ -14,6 +14,7 @@ type BaseController struct {
14 14
 	beego.Controller
15 15
 	Context  *utils.Context
16 16
 	Configer map[string]config.Configer
17
+	RunMode  string
17 18
 }
18 19
 
19 20
 //Prepare 继承beego的

+ 3
- 0
controllers/config.go Zobrazit soubor

@@ -3,6 +3,7 @@ package controllers
3 3
 import (
4 4
 	"spaceofcheng/services/utils"
5 5
 
6
+	"github.com/astaxie/beego"
6 7
 	"github.com/astaxie/beego/config"
7 8
 )
8 9
 
@@ -14,6 +15,8 @@ const (
14 15
 )
15 16
 
16 17
 func (c *BaseController) initConfig() {
18
+	c.RunMode = beego.AppConfig.String("runmode")
19
+
17 20
 	if c.Configer == nil {
18 21
 		c.Configer = make(map[string]config.Configer)
19 22
 	}

+ 4
- 2
controllers/customer/customer.go Zobrazit soubor

@@ -116,8 +116,10 @@ func (c *CustomerController) SignUp() {
116 116
 		c.ResponseError(errors.New("请填写完整注册信息"))
117 117
 	}
118 118
 
119
-	if err := utils.ValidCaptcha(phone, captcha); err != nil {
120
-		c.ResponseError(err)
119
+	if c.RunMode != "dev" {
120
+		if err := utils.ValidCaptcha(phone, captcha); err != nil {
121
+			c.ResponseError(err)
122
+		}
121 123
 	}
122 124
 
123 125
 	userMapping := c.Context.Get("userMap").(model.TaUserMapping)

+ 8
- 0
controllers/message.go Zobrazit soubor

@@ -13,6 +13,10 @@ func (c *BaseController) SendCaptcha() {
13 13
 		c.ResponseError(errors.New("请确定手机号码"))
14 14
 	}
15 15
 
16
+	if c.RunMode == "dev" {
17
+		c.ResponseJSON("ok")
18
+	}
19
+
16 20
 	if err := utils.SendCaptcha(phone); err != nil {
17 21
 		utils.LogError(err)
18 22
 		c.ResponseError(errors.New("验证码发送失败, 请重试"))
@@ -34,6 +38,10 @@ func (c *BaseController) ValidCaptcha() {
34 38
 		c.ResponseError(errors.New("验证码不能为空"))
35 39
 	}
36 40
 
41
+	if c.RunMode == "dev" {
42
+		c.ResponseJSON("ok")
43
+	}
44
+
37 45
 	if err := utils.ValidCaptcha(phone, captcha); err != nil {
38 46
 		c.ResponseError(err)
39 47
 	}

+ 27
- 0
log/common.2018-08-23.log Zobrazit soubor

@@ -0,0 +1,27 @@
1
+2018/08/20 15:27:18 [E] 获取客户列表失败: sql: converting Exec argument $1 type: unsupported type []interface {}, a slice of interface
2
+2018/08/20 15:36:51 [E] 获取客户列表失败: sql: converting Exec argument $1 type: unsupported type []interface {}, a slice of interface
3
+2018/08/20 15:37:19 [E] 获取客户列表失败: sql: converting Exec argument $1 type: unsupported type []interface {}, a slice of interface
4
+2018/08/20 15:44:30 [E] 获取客户列表失败: Error 1248: Every derived table must have its own alias
5
+2018/08/20 15:46:35 [E] 获取客户列表失败: Error 1248: Every derived table must have its own alias
6
+2018/08/20 15:49:09 [E] 获取客户列表失败: Error 1060: Duplicate column name 'user_id'
7
+2018/08/20 15:57:45 [E] 获取客户列表失败: sql: statement expects 2 inputs; got 1
8
+2018/08/20 19:25:08 [E] 短信发送失败: 400 
9
+2018/08/20 19:27:58 [E] 短信发送失败: 400 
10
+2018/08/20 19:28:52 [E] 短信发送失败: 400 
11
+2018/08/21 13:38:17 [E] 用户没有设置默认案场
12
+2018/08/21 13:38:17 [E] 您没有该案场的权限!
13
+2018/08/21 13:39:04 [E] 用户没有设置默认案场
14
+2018/08/21 13:39:04 [E] 您没有该案场的权限!
15
+2018/08/21 13:39:09 [E] 用户没有设置默认案场
16
+2018/08/21 13:39:09 [E] 您没有该案场的权限!
17
+2018/08/21 13:39:24 [E] 用户没有设置默认案场
18
+2018/08/21 13:39:24 [E] 您没有该案场的权限!
19
+2018/08/21 13:41:04 [E] 用户没有设置默认案场
20
+2018/08/21 13:41:04 [E] 您没有该案场的权限!
21
+2018/08/21 14:26:22 [E] 用户登录失败: dial tcp 192.168.0.62:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
22
+2018/08/21 14:27:06 [E] 用户登录失败: dial tcp 192.168.0.62:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
23
+2018/08/23 19:57:03 [E] 获取人员映射账户失败: Params type error
24
+2018/08/23 19:58:00 [E] 获取人员映射账户失败: Params type error
25
+2018/08/23 19:58:39 [E] 获取人员映射账户失败: Params type error
26
+2018/08/23 20:03:16 [E] 获取人员映射账户失败: Params type error
27
+2018/08/23 20:05:14 [E] 获取人员映射账户失败: Params type error

+ 7
- 27
log/common.log Zobrazit soubor

@@ -1,27 +1,7 @@
1
-2018/08/20 15:27:18 [E] 获取客户列表失败: sql: converting Exec argument $1 type: unsupported type []interface {}, a slice of interface
2
-2018/08/20 15:36:51 [E] 获取客户列表失败: sql: converting Exec argument $1 type: unsupported type []interface {}, a slice of interface
3
-2018/08/20 15:37:19 [E] 获取客户列表失败: sql: converting Exec argument $1 type: unsupported type []interface {}, a slice of interface
4
-2018/08/20 15:44:30 [E] 获取客户列表失败: Error 1248: Every derived table must have its own alias
5
-2018/08/20 15:46:35 [E] 获取客户列表失败: Error 1248: Every derived table must have its own alias
6
-2018/08/20 15:49:09 [E] 获取客户列表失败: Error 1060: Duplicate column name 'user_id'
7
-2018/08/20 15:57:45 [E] 获取客户列表失败: sql: statement expects 2 inputs; got 1
8
-2018/08/20 19:25:08 [E] 短信发送失败: 400 
9
-2018/08/20 19:27:58 [E] 短信发送失败: 400 
10
-2018/08/20 19:28:52 [E] 短信发送失败: 400 
11
-2018/08/21 13:38:17 [E] 用户没有设置默认案场
12
-2018/08/21 13:38:17 [E] 您没有该案场的权限!
13
-2018/08/21 13:39:04 [E] 用户没有设置默认案场
14
-2018/08/21 13:39:04 [E] 您没有该案场的权限!
15
-2018/08/21 13:39:09 [E] 用户没有设置默认案场
16
-2018/08/21 13:39:09 [E] 您没有该案场的权限!
17
-2018/08/21 13:39:24 [E] 用户没有设置默认案场
18
-2018/08/21 13:39:24 [E] 您没有该案场的权限!
19
-2018/08/21 13:41:04 [E] 用户没有设置默认案场
20
-2018/08/21 13:41:04 [E] 您没有该案场的权限!
21
-2018/08/21 14:26:22 [E] 用户登录失败: dial tcp 192.168.0.62:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
22
-2018/08/21 14:27:06 [E] 用户登录失败: dial tcp 192.168.0.62:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
23
-2018/08/23 19:57:03 [E] 获取人员映射账户失败: Params type error
24
-2018/08/23 19:58:00 [E] 获取人员映射账户失败: Params type error
25
-2018/08/23 19:58:39 [E] 获取人员映射账户失败: Params type error
26
-2018/08/23 20:03:16 [E] 获取人员映射账户失败: Params type error
27
-2018/08/23 20:05:14 [E] 获取人员映射账户失败: Params type error
1
+2018/08/24 09:40:16 [E] 验证码 - 17714208769 : 648633
2
+2018/08/24 10:53:37 [E] 获取人员映射账户失败: Error 1205: Lock wait timeout exceeded; try restarting transaction
3
+2018/08/24 10:54:58 [E] 获取人员映射账户失败: Error 1205: Lock wait timeout exceeded; try restarting transaction
4
+2018/08/24 10:55:03 [E] 获取人员映射账户失败: Error 1205: Lock wait timeout exceeded; try restarting transaction
5
+2018/08/24 10:55:42 [E] 获取人员映射账户失败: Error 1205: Lock wait timeout exceeded; try restarting transaction
6
+2018/08/24 10:55:46 [E] 获取人员映射账户失败: Error 1205: Lock wait timeout exceeded; try restarting transaction
7
+2018/08/24 11:30:58 [E] 更新用户映射信息失败:Params type error

+ 1
- 1
models/customer/customer.go Zobrazit soubor

@@ -137,7 +137,7 @@ func (m *CustomerDAO) UpdateUserMapping(userMap *model.TaUserMapping, cols []str
137 137
 		return errors.New("用户映射信息不存在")
138 138
 	}
139 139
 
140
-	_, err := m.db.Where("mapping_id=?", userMap.MappingId).Cols(cols...).Update(&userMap)
140
+	_, err := m.db.Where("mapping_id=?", userMap.MappingId).Cols(cols...).Update(userMap)
141 141
 	return err
142 142
 }
143 143
 

+ 1
- 1
models/goods/orders.go Zobrazit soubor

@@ -95,7 +95,7 @@ func (m *GoodsDAO) SaveOrdersCoupon(coupons []model.TaGoodsOrdersCoupon, order *
95 95
 	if _, err := m.db.
96 96
 		Where("orders_id=?", order.OrdersId).
97 97
 		Cols([]string{"coupon_amount", "actual_amount"}...).
98
-		Update(&order); err != nil {
98
+		Update(order); err != nil {
99 99
 		return err
100 100
 	}
101 101
 

+ 1
- 1
models/system/user.go Zobrazit soubor

@@ -375,6 +375,6 @@ func (m *UserDAO) UpdateUserMapping(userMap *model.TaUserMapping, cols []string)
375 375
 		return errors.New("用户映射信息不存在")
376 376
 	}
377 377
 
378
-	_, err := m.db.Where("mapping_id=?", userMap.MappingId).Cols(cols...).Update(&userMap)
378
+	_, err := m.db.Where("mapping_id=?", userMap.MappingId).Cols(cols...).Update(userMap)
379 379
 	return err
380 380
 }

+ 10
- 12
service/customer/customer.go Zobrazit soubor

@@ -9,8 +9,6 @@ import (
9 9
 	"spaceofcheng/services/service/events"
10 10
 	"spaceofcheng/services/utils"
11 11
 	"strconv"
12
-
13
-	"github.com/astaxie/beego"
14 12
 )
15 13
 
16 14
 // CustomerServ 系统处理
@@ -38,7 +36,7 @@ func (s *CustomerServ) GetCustWithWXList(phone string, page ...int) ([]customer.
38 36
 func (s *CustomerServ) GetCustWithWXByID(custID string) (*customer.CustWithWX, error) {
39 37
 	cust, err := s.dao.GetCustWithWXByID(custID)
40 38
 	if err != nil {
41
-		beego.Error(err)
39
+		utils.LogError(err.Error())
42 40
 		return nil, err
43 41
 	}
44 42
 
@@ -53,7 +51,7 @@ func (s *CustomerServ) GetCustWithWXByID(custID string) (*customer.CustWithWX, e
53 51
 func (s *CustomerServ) GetCustUserByID(userID string) (*UserProfile, error) {
54 52
 	user, err := s.dao.GetUserByID(userID)
55 53
 	if err != nil {
56
-		beego.Error(err)
54
+		utils.LogError(err.Error())
57 55
 		return nil, err
58 56
 	}
59 57
 
@@ -79,7 +77,7 @@ func (s *CustomerServ) GetCustUserByID(userID string) (*UserProfile, error) {
79 77
 func (s *CustomerServ) BindWechatUser(userMap *model.TaUserMapping, phone string) (*model.TaCustomer, error) {
80 78
 	user, err := s.dao.GetUserByPhone(phone)
81 79
 	if err != nil {
82
-		beego.Error(err)
80
+		utils.LogError(err.Error())
83 81
 		return nil, err
84 82
 	}
85 83
 
@@ -89,7 +87,7 @@ func (s *CustomerServ) BindWechatUser(userMap *model.TaUserMapping, phone string
89 87
 
90 88
 	cust, err := s.dao.GetCustomerByPhone(phone)
91 89
 	if err != nil {
92
-		beego.Error(err)
90
+		utils.LogError(err.Error())
93 91
 		return nil, err
94 92
 	}
95 93
 
@@ -102,7 +100,7 @@ func (s *CustomerServ) BindWechatUser(userMap *model.TaUserMapping, phone string
102 100
 		wxInfo := wxInfoRaw.(map[string]interface{})
103 101
 		newCust, err := s.SaveNewCustomer(wxInfo, "", "", user.UserId)
104 102
 		if err != nil {
105
-			beego.Error(err)
103
+			utils.LogError(err.Error())
106 104
 			return nil, err
107 105
 		}
108 106
 		cust = newCust
@@ -133,7 +131,7 @@ func (s *CustomerServ) BindWechatUser(userMap *model.TaUserMapping, phone string
133 131
 func (s *CustomerServ) BindWechatCust(userMap *model.TaUserMapping, phone, caseID, userID string) (*model.TaCustomer, error) {
134 132
 	cust, err := s.dao.GetCustomerByPhone(phone)
135 133
 	if err != nil {
136
-		beego.Error(err)
134
+		utils.LogError(err.Error())
137 135
 		return nil, err
138 136
 	}
139 137
 
@@ -147,7 +145,7 @@ func (s *CustomerServ) BindWechatCust(userMap *model.TaUserMapping, phone, caseI
147 145
 		wxInfo := wxInfoRaw.(map[string]interface{})
148 146
 		newCust, err := s.SaveNewCustomer(wxInfo, caseID, userID, "")
149 147
 		if err != nil {
150
-			beego.Error(err)
148
+			utils.LogError(err.Error())
151 149
 			return nil, err
152 150
 		}
153 151
 
@@ -202,7 +200,7 @@ func (s *CustomerServ) SaveNewCustomer(wxInfo map[string]interface{}, caseID, ar
202 200
 	if caseID != "" {
203 201
 		cs, err := s.casedao.GetCaseByID(caseID)
204 202
 		if err != nil {
205
-			beego.Error(err)
203
+			utils.LogError(err.Error())
206 204
 			return nil, err
207 205
 		}
208 206
 
@@ -218,7 +216,7 @@ func (s *CustomerServ) SaveNewCustomer(wxInfo map[string]interface{}, caseID, ar
218 216
 	if arID != "" {
219 217
 		ar, err := s.dao.GetUserByID(arID)
220 218
 		if err != nil {
221
-			beego.Error(err)
219
+			utils.LogError(err.Error())
222 220
 			return nil, err
223 221
 		}
224 222
 
@@ -235,7 +233,7 @@ func (s *CustomerServ) SaveNewCustomer(wxInfo map[string]interface{}, caseID, ar
235 233
 	if userID != "" {
236 234
 		user, err := s.dao.GetUserByID(userID)
237 235
 		if err != nil {
238
-			beego.Error(err)
236
+			utils.LogError(err.Error())
239 237
 			return nil, err
240 238
 		}
241 239
 

+ 19
- 0
test.http Zobrazit soubor

@@ -0,0 +1,19 @@
1
+@domain = localhost:8080
2
+@guestAPI = api/guest
3
+@phone = 17714208769
4
+
5
+@contentForm = application/x-www-form-urlencoded
6
+@contentJSON = application/json
7
+# 验证码
8
+
9
+GET http://{{domain}}/{{guestAPI}}/captcha?phone={{phone}}
10
+
11
+
12
+###
13
+POST http://dev.ycjcjy.com/api-v2/api/guest/wxsignup
14
+content-type: {{contentForm}}
15
+
16
+phone={{phone}}
17
+&captcha=648633
18
+&case=1
19
+&sales=0

+ 2
- 0
utils/captcha.go Zobrazit soubor

@@ -73,6 +73,8 @@ func (c *CaptchaEngine) SendCaptcha(phone string) {
73 73
 
74 74
 	c.capList[phone] = theCap
75 75
 
76
+	LogError("验证码 - " + phone + " : " + theCap.Captcha)
77
+
76 78
 	SendSMS("captcha", theCap.Phone, theCap.Captcha)
77 79
 }
78 80