|
@@ -83,15 +83,17 @@ func (s *CaseServ) AddKeys(orgid, caseid string, beginnum, endnum int) error {
|
83
|
83
|
|
84
|
84
|
// LockKeyByPhone 根据手机号绑定钥匙
|
85
|
85
|
func (s *CaseServ) LockKeyByPhone(phone, keyId string) error {
|
86
|
|
- var count int = 0
|
87
|
86
|
customer, err := s.customerdao.GetCustomerByPhone(phone)
|
88
|
87
|
if err != nil {
|
89
|
88
|
utils.LogError("根据手机号绑定钥匙失败: " + err.Error())
|
90
|
89
|
return errors.New("根据手机号绑定钥匙失败")
|
91
|
90
|
}
|
92
|
|
- count, err = s.dao.CustomerIsBind(customer.CustomerId)
|
93
|
|
- if err != nil {
|
94
|
|
- utils.LogError("绑定钥匙失败: " + err.Error())
|
|
91
|
+ if customer == nil {
|
|
92
|
+ return errors.New("非注册用户不可绑定")
|
|
93
|
+ }
|
|
94
|
+ count, err1 := s.dao.CustomerIsBind(customer.CustomerId)
|
|
95
|
+ if err1 != nil {
|
|
96
|
+ utils.LogError("绑定钥匙失败: " + err1.Error())
|
95
|
97
|
return errors.New("绑定钥匙失败")
|
96
|
98
|
}
|
97
|
99
|
if count > 0 {
|
|
@@ -149,6 +151,34 @@ func (s *CaseServ) LockKey(keyId, customerId, customerName string) error {
|
149
|
151
|
return nil
|
150
|
152
|
}
|
151
|
153
|
|
|
154
|
+func (s *CaseServ) LockKeyVerify(keyId, customerId string) error {
|
|
155
|
+ customer, err := s.customerdao.GetCustomerByID(customerId)
|
|
156
|
+ if err != nil {
|
|
157
|
+ utils.LogError("绑定钥匙失败: " + err.Error())
|
|
158
|
+ return errors.New("绑定钥匙失败")
|
|
159
|
+ }
|
|
160
|
+ count, err := s.dao.CustomerIsBind(customerId)
|
|
161
|
+ if err != nil {
|
|
162
|
+ utils.LogError("绑定钥匙失败: " + err.Error())
|
|
163
|
+ return errors.New("绑定钥匙失败")
|
|
164
|
+ }
|
|
165
|
+ if count > 0 {
|
|
166
|
+ return errors.New("用户已绑定钥匙,不可重复绑定")
|
|
167
|
+ }
|
|
168
|
+ err = s.dao.BindKeyToUser(keyId, customerId, customer.CustomerName)
|
|
169
|
+ if err != nil {
|
|
170
|
+ utils.LogError("绑定钥匙失败: " + err.Error())
|
|
171
|
+ return errors.New("绑定钥匙失败")
|
|
172
|
+ }
|
|
173
|
+ err = s.dao.UpdateKeyState(keyId, 1)
|
|
174
|
+ if err != nil {
|
|
175
|
+ utils.LogError("绑定钥匙失败: " + err.Error())
|
|
176
|
+ return errors.New("绑定钥匙失败")
|
|
177
|
+ }
|
|
178
|
+ return nil
|
|
179
|
+
|
|
180
|
+}
|
|
181
|
+
|
152
|
182
|
// DelKey 刪除
|
153
|
183
|
func (s *CaseServ) DelKey(keyid string) error {
|
154
|
184
|
use, err := s.dao.GetCurrentKey(keyid)
|