作者 陈志颖

refactor:增加合伙人编号

正在显示 37 个修改的文件 包含 247 行增加264 行删除
1 appname = partnermg 1 appname = partnermg
2 runmode = "${RUN_MODE||dev}" 2 runmode = "${RUN_MODE||dev}"
3 -httpport = "${HTTP_PORT||8082}" 3 +httpport = "${HTTP_PORT||8083}"
4 4
5 #开启监控 5 #开启监控
6 EnableAdmin = false 6 EnableAdmin = false
@@ -4,7 +4,6 @@ go 1.14 @@ -4,7 +4,6 @@ go 1.14
4 4
5 require ( 5 require (
6 github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1 6 github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1
7 - github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2  
8 github.com/Shopify/sarama v1.23.1 7 github.com/Shopify/sarama v1.23.1
9 github.com/ajg/form v1.5.1 // indirect 8 github.com/ajg/form v1.5.1 // indirect
10 github.com/astaxie/beego v1.12.2 9 github.com/astaxie/beego v1.12.2
@@ -17,7 +17,7 @@ type CreatePartnerInfoCommand struct { @@ -17,7 +17,7 @@ type CreatePartnerInfoCommand struct {
17 // 状态(1:启用或者0:禁用) 17 // 状态(1:启用或者0:禁用)
18 Status int `json:"status"` 18 Status int `json:"status"`
19 // 合伙类别 19 // 合伙类别
20 - PartnerCategory []int64 `json:"partnerCategory,omitempty"` 20 + PartnerCategory []*domain.PartnerCategory `json:"partnerCategory,omitempty"`
21 //合作时间 21 //合作时间
22 CooperateTime time.Time `json:"cooperateTime"` 22 CooperateTime time.Time `json:"cooperateTime"`
23 // 区域 23 // 区域
@@ -26,6 +26,8 @@ type CreatePartnerInfoCommand struct { @@ -26,6 +26,8 @@ type CreatePartnerInfoCommand struct {
26 Salesman []domain.Salesman `json:"salesman,omitempty"` 26 Salesman []domain.Salesman `json:"salesman,omitempty"`
27 //公司id 27 //公司id
28 CompanyId int64 `json:"companyId"` 28 CompanyId int64 `json:"companyId"`
  29 + //备注
  30 + Remark string `json:"remark"`
29 } 31 }
30 32
31 func (command CreatePartnerInfoCommand) ValidateCommand() error { 33 func (command CreatePartnerInfoCommand) ValidateCommand() error {
  1 +/**
  2 + @author: stevechan
  3 + @date: 2020/12/29
  4 + @note:
  5 +**/
  6 +
  7 +package command
  8 +
  9 +import (
  10 + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
  11 +)
  12 +
  13 +// 移除合伙人
  14 +type RemovePartnerInfoCommand struct {
  15 + // 合伙人Id
  16 + Id int64 `json:"id" valid:"Required"`
  17 +}
  18 +
  19 +func (command *RemovePartnerInfoCommand) ValidateCommand() error {
  20 + if command.Id == 0 {
  21 + return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误")
  22 + }
  23 + return nil
  24 +}
@@ -13,7 +13,7 @@ type UpdatePartnerInfoCommand struct { @@ -13,7 +13,7 @@ type UpdatePartnerInfoCommand struct {
13 // 状态(1:启用或者0:禁用) 13 // 状态(1:启用或者0:禁用)
14 Status int `json:"status"` 14 Status int `json:"status"`
15 // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) 15 // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
16 - PartnerCategory []int64 `json:"partnerCategory,omitempty"` 16 + PartnerCategory []*domain.PartnerCategory `json:"partnerCategory,omitempty"`
17 // 区域 17 // 区域
18 RegionInfo *domain.RegionInfo `json:"regionInfo"` 18 RegionInfo *domain.RegionInfo `json:"regionInfo"`
19 //关联业务员 19 //关联业务员
@@ -22,6 +22,8 @@ type UpdatePartnerInfoCommand struct { @@ -22,6 +22,8 @@ type UpdatePartnerInfoCommand struct {
22 CooperateTime time.Time `json:"cooperateTime"` 22 CooperateTime time.Time `json:"cooperateTime"`
23 //公司id 23 //公司id
24 CompanyId int64 `json:"companyId"` 24 CompanyId int64 `json:"companyId"`
  25 + //备注
  26 + Remark string `json:"remark"`
25 } 27 }
26 28
27 func (command *UpdatePartnerInfoCommand) ValidateCommand() error { 29 func (command *UpdatePartnerInfoCommand) ValidateCommand() error {
@@ -2,11 +2,12 @@ package query @@ -2,11 +2,12 @@ package query
2 2
3 type ListPartnerInfoQuery struct { 3 type ListPartnerInfoQuery struct {
4 // 合伙人类别 4 // 合伙人类别
5 - Partnertype int `json:"partnerType"` 5 + PartnerType int `json:"partnerType"`
6 //所属区域 6 //所属区域
7 RegionInfo string `json:"regionInfo"` 7 RegionInfo string `json:"regionInfo"`
8 // 合伙人姓名 8 // 合伙人姓名
9 PartnerName string `json:"partnerName"` 9 PartnerName string `json:"partnerName"`
  10 + // 公司id
10 CompanyId int64 `json:"companyId"` 11 CompanyId int64 `json:"companyId"`
11 // 查询偏离量 12 // 查询偏离量
12 Offset int `json:"offset"` 13 Offset int `json:"offset"`
@@ -15,6 +16,5 @@ type ListPartnerInfoQuery struct { @@ -15,6 +16,5 @@ type ListPartnerInfoQuery struct {
15 } 16 }
16 17
17 func (q *ListPartnerInfoQuery) ValidateQuery() error { 18 func (q *ListPartnerInfoQuery) ValidateQuery() error {
18 -  
19 return nil 19 return nil
20 } 20 }
@@ -21,7 +21,13 @@ func NewPartnerInfoService(options map[string]interface{}) *PartnerInfoService { @@ -21,7 +21,13 @@ func NewPartnerInfoService(options map[string]interface{}) *PartnerInfoService {
21 return newPartnerInfoService 21 return newPartnerInfoService
22 } 22 }
23 23
24 -// CreatePartnerInfo 创建合伙人 24 +/**
  25 + * @Author SteveChan
  26 + * @Description //TODO 创建合伙人,判断编号是否重复
  27 + * @Date 15:42 2020/12/29
  28 + * @Param
  29 + * @return
  30 + **/
25 func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.CreatePartnerInfoCommand) (data *domain.PartnerInfo, err error) { 31 func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.CreatePartnerInfoCommand) (data *domain.PartnerInfo, err error) {
26 var ( 32 var (
27 transactionContext, _ = factory.CreateTransactionContext(nil) 33 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -35,16 +41,17 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre @@ -35,16 +41,17 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre
35 defer func() { 41 defer func() {
36 transactionContext.RollbackTransaction() 42 transactionContext.RollbackTransaction()
37 }() 43 }()
  44 +
38 //检查账号是否存在 45 //检查账号是否存在
39 var ( 46 var (
40 - partnerinfoDao *dao.PartnerInfoDao 47 + partnerInfoDao *dao.PartnerInfoDao
41 ) 48 )
42 - if partnerinfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{ 49 + if partnerInfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{
43 "transactionContext": transactionContext, 50 "transactionContext": transactionContext,
44 }); err != nil { 51 }); err != nil {
45 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 52 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
46 } 53 }
47 - ok, err := partnerinfoDao.PartnerAccountExist(cmd.Account, cmd.CompanyId) 54 + ok, err := partnerInfoDao.PartnerAccountExist(cmd.Account, cmd.CompanyId)
48 if err != nil { 55 if err != nil {
49 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 56 return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
50 } 57 }
@@ -55,7 +62,7 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre @@ -55,7 +62,7 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre
55 var ( 62 var (
56 partnerInfoRepository domain.PartnerInfoRepository 63 partnerInfoRepository domain.PartnerInfoRepository
57 categoryRepository domain.PartnerCategoryRepository 64 categoryRepository domain.PartnerCategoryRepository
58 - categorys []domain.PartnerCategory 65 + categories []domain.PartnerCategory
59 ) 66 )
60 if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ 67 if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
61 "transactionContext": transactionContext, 68 "transactionContext": transactionContext,
@@ -67,13 +74,18 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre @@ -67,13 +74,18 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre
67 }); err != nil { 74 }); err != nil {
68 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 75 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
69 } 76 }
70 - _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{  
71 - Ids: cmd.PartnerCategory, 77 + var ids []int64
  78 + for _, partnerCategory := range cmd.PartnerCategory {
  79 + ids = append(ids, partnerCategory.Id)
  80 + }
  81 + _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
  82 + Ids: ids,
72 }) 83 })
73 if err != nil { 84 if err != nil {
74 e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) 85 e := fmt.Sprintf("获取合伙人分类数据失败:%s", err)
75 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 86 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
76 } 87 }
  88 +
77 newPartnerInfo := domain.PartnerInfo{ 89 newPartnerInfo := domain.PartnerInfo{
78 Partner: domain.Partner{ 90 Partner: domain.Partner{
79 Account: cmd.Account, 91 Account: cmd.Account,
@@ -86,7 +98,7 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre @@ -86,7 +98,7 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre
86 Salesman: cmd.Salesman, 98 Salesman: cmd.Salesman,
87 CooperateTime: cmd.CooperateTime, 99 CooperateTime: cmd.CooperateTime,
88 CompanyId: cmd.CompanyId, 100 CompanyId: cmd.CompanyId,
89 - PartnerCategoryInfos: categorys, 101 + PartnerCategoryInfos: categories,
90 } 102 }
91 if err = partnerInfoRepository.Save(&newPartnerInfo); err != nil { 103 if err = partnerInfoRepository.Save(&newPartnerInfo); err != nil {
92 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 104 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
@@ -106,7 +118,13 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre @@ -106,7 +118,13 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre
106 return &newPartnerInfo, nil 118 return &newPartnerInfo, nil
107 } 119 }
108 120
109 -// GetPartnerInfo 返回合伙人 121 +/**
  122 + * @Author SteveChan
  123 + * @Description //TODO 返回合伙人,增加合伙人编号字段
  124 + * @Date 15:43 2020/12/29
  125 + * @Param
  126 + * @return
  127 + **/
110 func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerInfoQuery) (data *domain.PartnerInfo, err error) { 128 func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerInfoQuery) (data *domain.PartnerInfo, err error) {
111 var ( 129 var (
112 transactionContext, _ = factory.CreateTransactionContext(nil) 130 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -123,7 +141,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI @@ -123,7 +141,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI
123 var ( 141 var (
124 PartnerInfoRepository domain.PartnerInfoRepository 142 PartnerInfoRepository domain.PartnerInfoRepository
125 categoryRepository domain.PartnerCategoryRepository 143 categoryRepository domain.PartnerCategoryRepository
126 - categorys []domain.PartnerCategory 144 + categories []domain.PartnerCategory
127 partnerData *domain.PartnerInfo 145 partnerData *domain.PartnerInfo
128 ) 146 )
129 if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ 147 if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
@@ -145,19 +163,19 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI @@ -145,19 +163,19 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI
145 }); err != nil { 163 }); err != nil {
146 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 164 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
147 } 165 }
148 - categoryIds := []int64{} 166 + var categoryIds []int64
149 for _, v := range partnerData.PartnerCategoryInfos { 167 for _, v := range partnerData.PartnerCategoryInfos {
150 categoryIds = append(categoryIds, v.Id) 168 categoryIds = append(categoryIds, v.Id)
151 } 169 }
152 if len(categoryIds) > 0 { 170 if len(categoryIds) > 0 {
153 - _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ 171 + _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
154 Ids: categoryIds, 172 Ids: categoryIds,
155 }) 173 })
156 if err != nil { 174 if err != nil {
157 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 175 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
158 } 176 }
159 } 177 }
160 - partnerData.PartnerCategoryInfos = categorys 178 + partnerData.PartnerCategoryInfos = categories
161 err = transactionContext.CommitTransaction() 179 err = transactionContext.CommitTransaction()
162 return partnerData, nil 180 return partnerData, nil
163 } 181 }
@@ -191,15 +209,20 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd @@ -191,15 +209,20 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
191 }); err != nil { 209 }); err != nil {
192 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 210 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
193 } 211 }
  212 + var ids []int64
  213 + for _, partnerCategory := range cmd.PartnerCategory {
  214 + ids = append(ids, partnerCategory.Id)
  215 + }
194 _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ 216 _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
195 - Ids: cmd.PartnerCategory, 217 + Ids: ids,
196 }) 218 })
197 if err != nil { 219 if err != nil {
198 e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) 220 e := fmt.Sprintf("获取合伙人分类数据失败:%s", err)
199 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 221 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
200 } 222 }
201 partnerInfo, err := partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{ 223 partnerInfo, err := partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
202 - UserId: cmd.Id, CompanyId: cmd.CompanyId, 224 + UserId: cmd.Id,
  225 + CompanyId: cmd.CompanyId,
203 }) 226 })
204 if err != nil { 227 if err != nil {
205 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 228 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
@@ -246,14 +269,13 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue @@ -246,14 +269,13 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue
246 return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 269 return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
247 } 270 }
248 defer func() { 271 defer func() {
249 -  
250 transactionContext.RollbackTransaction() 272 transactionContext.RollbackTransaction()
251 -  
252 }() 273 }()
  274 +
253 var ( 275 var (
254 partnerInfoRepository domain.PartnerInfoRepository 276 partnerInfoRepository domain.PartnerInfoRepository
255 categoryRepository domain.PartnerCategoryRepository 277 categoryRepository domain.PartnerCategoryRepository
256 - categorys []domain.PartnerCategory 278 + categories []domain.PartnerCategory
257 ) 279 )
258 if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ 280 if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
259 "transactionContext": transactionContext, 281 "transactionContext": transactionContext,
@@ -271,8 +293,8 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue @@ -271,8 +293,8 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue
271 PartnerName: listPartnerInfoQuery.PartnerName, 293 PartnerName: listPartnerInfoQuery.PartnerName,
272 CompanyId: listPartnerInfoQuery.CompanyId, 294 CompanyId: listPartnerInfoQuery.CompanyId,
273 } 295 }
274 - if listPartnerInfoQuery.Partnertype > 0 {  
275 - queryOption.PartnerCategory = []int{listPartnerInfoQuery.Partnertype} 296 + if listPartnerInfoQuery.PartnerType > 0 {
  297 + queryOption.PartnerCategory = []int{listPartnerInfoQuery.PartnerType}
276 } 298 }
277 // RegionInfo 299 // RegionInfo
278 if len(listPartnerInfoQuery.RegionInfo) > 0 { 300 if len(listPartnerInfoQuery.RegionInfo) > 0 {
@@ -284,18 +306,18 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue @@ -284,18 +306,18 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue
284 if count, err = partnerInfoRepository.CountAll(queryOption); err != nil { 306 if count, err = partnerInfoRepository.CountAll(queryOption); err != nil {
285 return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 307 return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
286 } 308 }
287 - _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{}) 309 + _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{})
288 if err != nil { 310 if err != nil {
289 return count, partnerInfos, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 311 return count, partnerInfos, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
290 } 312 }
291 - categorysMap := make(map[int64]domain.PartnerCategory)  
292 - for i := range categorys {  
293 - categorysMap[categorys[i].Id] = categorys[i] 313 + categoriesMap := make(map[int64]domain.PartnerCategory)
  314 + for i := range categories {
  315 + categoriesMap[categories[i].Id] = categories[i]
294 } 316 }
295 for i := range partnerInfos { 317 for i := range partnerInfos {
296 - categoryInPartner := []domain.PartnerCategory{} 318 + var categoryInPartner []domain.PartnerCategory
297 for _, vv := range partnerInfos[i].PartnerCategoryInfos { 319 for _, vv := range partnerInfos[i].PartnerCategoryInfos {
298 - if categoryData, ok := categorysMap[vv.Id]; ok { 320 + if categoryData, ok := categoriesMap[vv.Id]; ok {
299 categoryInPartner = append(categoryInPartner, categoryData) 321 categoryInPartner = append(categoryInPartner, categoryData)
300 } 322 }
301 } 323 }
@@ -307,6 +329,30 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue @@ -307,6 +329,30 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue
307 return count, partnerInfos, nil 329 return count, partnerInfos, nil
308 } 330 }
309 331
  332 +/**
  333 + * @Author SteveChan
  334 + * @Description //TODO 移除合伙人
  335 + * @Date 16:40 2020/12/29
  336 + * @Param
  337 + * @return
  338 + **/
  339 +func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(cmd command.RemovePartnerInfoCommand) (err error) {
  340 + var (
  341 + transactionContext, _ = factory.CreateTransactionContext(nil)
  342 + )
  343 + if err = cmd.ValidateCommand(); err != nil {
  344 + return application.ThrowError(application.ARG_ERROR, err.Error())
  345 + }
  346 + if err = transactionContext.StartTransaction(); err != nil {
  347 + return err
  348 + }
  349 + defer func() {
  350 + transactionContext.RollbackTransaction()
  351 + }()
  352 +
  353 + return nil
  354 +}
  355 +
310 func (PartnerInfoService *PartnerInfoService) UpdateStatus(cmd command.StatusPartnerInfoCommand) (err error) { 356 func (PartnerInfoService *PartnerInfoService) UpdateStatus(cmd command.StatusPartnerInfoCommand) (err error) {
311 if len(cmd.Ids) == 0 { 357 if len(cmd.Ids) == 0 {
312 return nil 358 return nil
@@ -324,14 +370,14 @@ func (PartnerInfoService *PartnerInfoService) UpdateStatus(cmd command.StatusPar @@ -324,14 +370,14 @@ func (PartnerInfoService *PartnerInfoService) UpdateStatus(cmd command.StatusPar
324 transactionContext.RollbackTransaction() 370 transactionContext.RollbackTransaction()
325 }() 371 }()
326 var ( 372 var (
327 - partnerinfoDao *dao.PartnerInfoDao 373 + partnerInfoDao *dao.PartnerInfoDao
328 ) 374 )
329 - if partnerinfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{ 375 + if partnerInfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{
330 "transactionContext": transactionContext, 376 "transactionContext": transactionContext,
331 }); err != nil { 377 }); err != nil {
332 return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) 378 return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
333 } 379 }
334 - err = partnerinfoDao.UpdatePartnerStatus(cmd.Ids, cmd.CompanyId, cmd.Status) 380 + err = partnerInfoDao.UpdatePartnerStatus(cmd.Ids, cmd.CompanyId, cmd.Status)
335 if err != nil { 381 if err != nil {
336 e := fmt.Sprintf("更新合伙人(id=%v)的数据失败;%s", cmd.Ids, err) 382 e := fmt.Sprintf("更新合伙人(id=%v)的数据失败;%s", cmd.Ids, err)
337 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 383 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
@@ -8,14 +8,14 @@ var LOG_LEVEL = "debug" @@ -8,14 +8,14 @@ var LOG_LEVEL = "debug"
8 var LOG_File = "./logs/partnermg.log" 8 var LOG_File = "./logs/partnermg.log"
9 9
10 var ( 10 var (
11 - UCENTER_HOST = "https://suplus-ucenter-dev.fjmaimaimai.com" //统一用户中心地址 11 + UCENTER_HOST = "https://suplus-ucenter-test.fjmaimaimai.com" //统一用户中心地址
12 UCENTER_SECRET = "cykbjnfqgctn" 12 UCENTER_SECRET = "cykbjnfqgctn"
13 UCENTER_APP_KEY = "39aefef9e22744a3b2d2d3791824ae7b" 13 UCENTER_APP_KEY = "39aefef9e22744a3b2d2d3791824ae7b"
14 UCENTER_CHECK_ALT = "rsF0pL!6DwjBO735" 14 UCENTER_CHECK_ALT = "rsF0pL!6DwjBO735"
15 ) 15 )
16 16
17 var ( 17 var (
18 - BUSINESS_ADMIN_HOST = "http://suplus-business-admin-dev.fjmaimaimai.com" //企业平台的地址 18 + BUSINESS_ADMIN_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" //企业平台的地址
19 ) 19 )
20 20
21 func init() { 21 func init() {
@@ -34,9 +34,7 @@ func init() { @@ -34,9 +34,7 @@ func init() {
34 if os.Getenv("UCENTER_CHECK_ALT") != "" { 34 if os.Getenv("UCENTER_CHECK_ALT") != "" {
35 UCENTER_CHECK_ALT = os.Getenv("UCENTER_CHECK_ALT") 35 UCENTER_CHECK_ALT = os.Getenv("UCENTER_CHECK_ALT")
36 } 36 }
37 -  
38 if os.Getenv("BUSINESS_ADMIN_HOST") != "" { 37 if os.Getenv("BUSINESS_ADMIN_HOST") != "" {
39 BUSINESS_ADMIN_HOST = os.Getenv("BUSINESS_ADMIN_HOST") 38 BUSINESS_ADMIN_HOST = os.Getenv("BUSINESS_ADMIN_HOST")
40 } 39 }
41 -  
42 } 40 }
@@ -14,7 +14,7 @@ var KafkaCfg KafkaConfig @@ -14,7 +14,7 @@ var KafkaCfg KafkaConfig
14 14
15 func init() { 15 func init() {
16 KafkaCfg = KafkaConfig{ 16 KafkaCfg = KafkaConfig{
17 - Servers: []string{""}, 17 + Servers: []string{"127.0.0.1:9092"},
18 ConsumerId: "partnermg_local", 18 ConsumerId: "partnermg_local",
19 } 19 }
20 if os.Getenv("KAFKA_HOST") != "" { 20 if os.Getenv("KAFKA_HOST") != "" {
@@ -2,7 +2,7 @@ package constant @@ -2,7 +2,7 @@ package constant
2 2
3 import "os" 3 import "os"
4 4
5 -var POSTGRESQL_DB_NAME = "partner_dev" 5 +var POSTGRESQL_DB_NAME = "partner_test"
6 var POSTGRESQL_USER = "postgres" 6 var POSTGRESQL_USER = "postgres"
7 var POSTGRESQL_PASSWORD = "eagle1010" 7 var POSTGRESQL_PASSWORD = "eagle1010"
8 var POSTGRESQL_HOST = "114.55.200.59" 8 var POSTGRESQL_HOST = "114.55.200.59"
@@ -114,7 +114,7 @@ type OrderBase struct { @@ -114,7 +114,7 @@ type OrderBase struct {
114 DataFrom OrderDataFrom `json:"dataFrom"` 114 DataFrom OrderDataFrom `json:"dataFrom"`
115 //备注 115 //备注
116 Remark OrderBaseRemark `json:"remark"` 116 Remark OrderBaseRemark `json:"remark"`
117 - 117 + //合伙人类型
118 PartnerCategory PartnerCategory `json:"partnerCategory"` 118 PartnerCategory PartnerCategory `json:"partnerCategory"`
119 } 119 }
120 120
@@ -6,6 +6,8 @@ type PartnerCategory struct { @@ -6,6 +6,8 @@ type PartnerCategory struct {
6 Id int64 `json:"id"` 6 Id int64 `json:"id"`
7 // 名称 7 // 名称
8 Name string `json:"name,omitempty"` 8 Name string `json:"name,omitempty"`
  9 + // 合伙人编码
  10 + Code string `json:"code"`
9 } 11 }
10 12
11 type PartnerCategoryFindQuery struct { 13 type PartnerCategoryFindQuery struct {
@@ -48,6 +48,8 @@ type PartnerInfo struct { @@ -48,6 +48,8 @@ type PartnerInfo struct {
48 PartnerCategory int `json:"partnerCategory"` 48 PartnerCategory int `json:"partnerCategory"`
49 //公司id 49 //公司id
50 CompanyId int64 `json:"companyId"` 50 CompanyId int64 `json:"companyId"`
  51 + //备注
  52 + Remark string `json:"remark"`
51 } 53 }
52 54
53 func (p *PartnerInfo) IsUsable() bool { 55 func (p *PartnerInfo) IsUsable() bool {
@@ -78,5 +80,6 @@ type PartnerInfoRepository interface { @@ -78,5 +80,6 @@ type PartnerInfoRepository interface {
78 Save(dm *PartnerInfo) error 80 Save(dm *PartnerInfo) error
79 FindOne(queryOptions PartnerFindOneQuery) (*PartnerInfo, error) 81 FindOne(queryOptions PartnerFindOneQuery) (*PartnerInfo, error)
80 Find(queryOptions PartnerFindQuery) ([]PartnerInfo, error) 82 Find(queryOptions PartnerFindQuery) ([]PartnerInfo, error)
  83 + Remove(Id int64) error
81 CountAll(queryOptions PartnerFindQuery) (int, error) 84 CountAll(queryOptions PartnerFindQuery) (int, error)
82 } 85 }
@@ -42,3 +42,14 @@ func (dao PartnerInfoDao) UpdatePartnerStatus(ids []int64, companyId int64, stat @@ -42,3 +42,14 @@ func (dao PartnerInfoDao) UpdatePartnerStatus(ids []int64, companyId int64, stat
42 Update() 42 Update()
43 return err 43 return err
44 } 44 }
  45 +
  46 +/**
  47 + * @Author SteveChan
  48 + * @Description //TODO 编号查重
  49 + * @Date 17:55 2020/12/28
  50 + * @Param
  51 + * @return
  52 + **/
  53 +func (dao PartnerInfoDao) CheckDuplication() {
  54 +
  55 +}
@@ -7,4 +7,6 @@ type PartnerCategoryInfo struct { @@ -7,4 +7,6 @@ type PartnerCategoryInfo struct {
7 Id int64 7 Id int64
8 // 名称 8 // 名称
9 Name string 9 Name string
  10 + // 合伙人编码
  11 + Code string
10 } 12 }
@@ -36,6 +36,8 @@ type PartnerInfo struct { @@ -36,6 +36,8 @@ type PartnerInfo struct {
36 PartnerCategoryInfos []domain.PartnerCategory 36 PartnerCategoryInfos []domain.PartnerCategory
37 //公司id 37 //公司id
38 CompanyId int64 38 CompanyId int64
  39 + //备注
  40 + Remark string
39 } 41 }
40 42
41 var _ pg.BeforeUpdateHook = (*PartnerInfo)(nil) 43 var _ pg.BeforeUpdateHook = (*PartnerInfo)(nil)
@@ -12,21 +12,6 @@ type PartnerCategoryRepository struct { @@ -12,21 +12,6 @@ type PartnerCategoryRepository struct {
12 transactionContext *transaction.TransactionContext 12 transactionContext *transaction.TransactionContext
13 } 13 }
14 14
15 -func (repository PartnerCategoryRepository) transformPgModelToDomainModel(m *models.PartnerCategoryInfo) (domain.PartnerCategory, error) {  
16 - pc := domain.PartnerCategory{  
17 - Id: m.Id,  
18 - Name: m.Name,  
19 - }  
20 - return pc, nil  
21 -}  
22 -  
23 -func NewPartnerCategoryRepository(transactionContext *transaction.TransactionContext) (*PartnerCategoryRepository, error) {  
24 - if transactionContext == nil {  
25 - return nil, fmt.Errorf("transactionContext参数不能为nil")  
26 - }  
27 - return &PartnerCategoryRepository{transactionContext: transactionContext}, nil  
28 -}  
29 -  
30 func (repository PartnerCategoryRepository) Find(queryOptions domain.PartnerCategoryFindQuery) (int, []domain.PartnerCategory, error) { 15 func (repository PartnerCategoryRepository) Find(queryOptions domain.PartnerCategoryFindQuery) (int, []domain.PartnerCategory, error) {
31 tx := repository.transactionContext.PgTx 16 tx := repository.transactionContext.PgTx
32 var ( 17 var (
@@ -48,3 +33,19 @@ func (repository PartnerCategoryRepository) Find(queryOptions domain.PartnerCate @@ -48,3 +33,19 @@ func (repository PartnerCategoryRepository) Find(queryOptions domain.PartnerCate
48 } 33 }
49 return cnt, partnerCategoryInfos, nil 34 return cnt, partnerCategoryInfos, nil
50 } 35 }
  36 +
  37 +func (repository PartnerCategoryRepository) transformPgModelToDomainModel(m *models.PartnerCategoryInfo) (domain.PartnerCategory, error) {
  38 + pc := domain.PartnerCategory{
  39 + Id: m.Id,
  40 + Name: m.Name,
  41 + Code: m.Code,
  42 + }
  43 + return pc, nil
  44 +}
  45 +
  46 +func NewPartnerCategoryRepository(transactionContext *transaction.TransactionContext) (*PartnerCategoryRepository, error) {
  47 + if transactionContext == nil {
  48 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  49 + }
  50 + return &PartnerCategoryRepository{transactionContext: transactionContext}, nil
  51 +}
@@ -18,50 +18,18 @@ var ( @@ -18,50 +18,18 @@ var (
18 _ domain.PartnerInfoRepository = (*PartnerInfoRepository)(nil) 18 _ domain.PartnerInfoRepository = (*PartnerInfoRepository)(nil)
19 ) 19 )
20 20
21 -func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerInfoModel *models.PartnerInfo) (domain.PartnerInfo, error) {  
22 - m := domain.PartnerInfo{  
23 - Partner: domain.Partner{  
24 - Id: partnerInfoModel.Id,  
25 - PartnerName: partnerInfoModel.PartnerName,  
26 - Account: partnerInfoModel.Account,  
27 - },  
28 - PartnerCategory: partnerInfoModel.PartnerCategory,  
29 - Password: partnerInfoModel.Password,  
30 - Status: partnerInfoModel.Status,  
31 - CreateAt: partnerInfoModel.CreateAt,  
32 - Salesman: partnerInfoModel.Salesman,  
33 - RegionInfo: partnerInfoModel.RegionInfo,  
34 - CooperateTime: partnerInfoModel.CooperateTime,  
35 - CompanyId: partnerInfoModel.CompanyId,  
36 - }  
37 - p := []domain.PartnerCategory{}  
38 - for _, v := range partnerInfoModel.PartnerCategoryInfos {  
39 - catagory := domain.PartnerCategory{  
40 - Id: v.Id,  
41 - }  
42 - p = append(p, catagory)  
43 - }  
44 - m.PartnerCategoryInfos = p  
45 - return m, nil  
46 -}  
47 -  
48 -func NewPartnerInfoRepository(transactionContext *transaction.TransactionContext) (*PartnerInfoRepository, error) {  
49 - if transactionContext == nil {  
50 - return nil, fmt.Errorf("transactionContext参数不能为nil")  
51 - }  
52 - return &PartnerInfoRepository{transactionContext: transactionContext}, nil  
53 -}  
54 -  
55 func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error { 21 func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error {
56 var ( 22 var (
57 err error 23 err error
58 tx = repository.transactionContext.PgTx 24 tx = repository.transactionContext.PgTx
59 ) 25 )
60 26
61 - categorys := []domain.PartnerCategory{} 27 + var categories []domain.PartnerCategory
62 for _, v := range dm.PartnerCategoryInfos { 28 for _, v := range dm.PartnerCategoryInfos {
63 - categorys = append(categorys, domain.PartnerCategory{ 29 + categories = append(categories, domain.PartnerCategory{
64 Id: v.Id, 30 Id: v.Id,
  31 + Name: v.Name,
  32 + Code: v.Code,
65 }) 33 })
66 } 34 }
67 m := &models.PartnerInfo{ 35 m := &models.PartnerInfo{
@@ -75,7 +43,8 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error { @@ -75,7 +43,8 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error {
75 RegionInfo: dm.RegionInfo, 43 RegionInfo: dm.RegionInfo,
76 CooperateTime: dm.CooperateTime, 44 CooperateTime: dm.CooperateTime,
77 CompanyId: dm.CompanyId, 45 CompanyId: dm.CompanyId,
78 - PartnerCategoryInfos: categorys, 46 + PartnerCategoryInfos: categories,
  47 + Remark: dm.Remark,
79 } 48 }
80 if m.Id == 0 { 49 if m.Id == 0 {
81 err = tx.Insert(m) 50 err = tx.Insert(m)
@@ -86,7 +55,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error { @@ -86,7 +55,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error {
86 } else { 55 } else {
87 _, err = tx.Model(m).WherePK(). 56 _, err = tx.Model(m).WherePK().
88 Column("partner_name", "account", "password", "status", "partner_category", "salesman", 57 Column("partner_name", "account", "password", "status", "partner_category", "salesman",
89 - "region_info", "cooperate_time", "update_at", "partner_category_infos"). 58 + "region_info", "cooperate_time", "update_at", "partner_category_infos, remark").
90 Update() 59 Update()
91 if err != nil { 60 if err != nil {
92 return err 61 return err
@@ -124,7 +93,7 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFind @@ -124,7 +93,7 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFind
124 93
125 func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuery) ([]domain.PartnerInfo, error) { 94 func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuery) ([]domain.PartnerInfo, error) {
126 db := repository.transactionContext.PgTx 95 db := repository.transactionContext.PgTx
127 - partnerModels := []models.PartnerInfo{} 96 + var partnerModels []models.PartnerInfo
128 query := db.Model(&partnerModels) 97 query := db.Model(&partnerModels)
129 if len(queryOption.PartnerName) > 0 { 98 if len(queryOption.PartnerName) > 0 {
130 query = query.Where("partner_name like ?", "%"+queryOption.PartnerName+"%") 99 query = query.Where("partner_name like ?", "%"+queryOption.PartnerName+"%")
@@ -174,7 +143,28 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer @@ -174,7 +143,28 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer
174 return partnerReturn, nil 143 return partnerReturn, nil
175 } 144 }
176 145
177 -func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQuery) (int, error) { 146 +/**
  147 + * @Author SteveChan
  148 + * @Description //TODO 移除合伙人
  149 + * @Date 15:33 2020/12/29
  150 + * @Param
  151 + * @return
  152 + **/
  153 +func (repository *PartnerInfoRepository) Remove(id int64) error {
  154 + var (
  155 + err error
  156 + tx = repository.transactionContext.PgTx
  157 + )
  158 + m := &models.PartnerInfo{
  159 + Id: id,
  160 + }
  161 + _, err = tx.Model(m).
  162 + Where("id=?", id).
  163 + Delete()
  164 + return err
  165 +}
  166 +
  167 +func (repository *PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQuery) (int, error) {
178 db := repository.transactionContext.PgTx 168 db := repository.transactionContext.PgTx
179 partnerModels := models.PartnerInfo{} 169 partnerModels := models.PartnerInfo{}
180 query := db.Model(&partnerModels) 170 query := db.Model(&partnerModels)
@@ -202,3 +192,40 @@ func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQ @@ -202,3 +192,40 @@ func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQ
202 cnt, err := query.Count() 192 cnt, err := query.Count()
203 return cnt, err 193 return cnt, err
204 } 194 }
  195 +
  196 +func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerInfoModel *models.PartnerInfo) (domain.PartnerInfo, error) {
  197 + m := domain.PartnerInfo{
  198 + Partner: domain.Partner{
  199 + Id: partnerInfoModel.Id,
  200 + PartnerName: partnerInfoModel.PartnerName,
  201 + Account: partnerInfoModel.Account,
  202 + },
  203 + PartnerCategory: partnerInfoModel.PartnerCategory,
  204 + Password: partnerInfoModel.Password,
  205 + Status: partnerInfoModel.Status,
  206 + CreateAt: partnerInfoModel.CreateAt,
  207 + Salesman: partnerInfoModel.Salesman,
  208 + RegionInfo: partnerInfoModel.RegionInfo,
  209 + CooperateTime: partnerInfoModel.CooperateTime,
  210 + CompanyId: partnerInfoModel.CompanyId,
  211 + Remark: partnerInfoModel.Remark,
  212 + }
  213 + var p []domain.PartnerCategory
  214 + for _, v := range partnerInfoModel.PartnerCategoryInfos {
  215 + category := domain.PartnerCategory{
  216 + Id: v.Id,
  217 + Name: v.Name,
  218 + Code: v.Code,
  219 + }
  220 + p = append(p, category)
  221 + }
  222 + m.PartnerCategoryInfos = p
  223 + return m, nil
  224 +}
  225 +
  226 +func NewPartnerInfoRepository(transactionContext *transaction.TransactionContext) (*PartnerInfoRepository, error) {
  227 + if transactionContext == nil {
  228 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  229 + }
  230 + return &PartnerInfoRepository{transactionContext: transactionContext}, nil
  231 +}
@@ -36,7 +36,7 @@ func (c *PartnerInfoController) CreatePartnerInfo() { @@ -36,7 +36,7 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
36 //用与适配前端定义的数据结构 36 //用与适配前端定义的数据结构
37 type Parameter struct { 37 type Parameter struct {
38 PartnerName string `json:"partnerName"` 38 PartnerName string `json:"partnerName"`
39 - PartnerType []int64 `json:"partnerType"` 39 + PartnerType []*domain.PartnerCategory `json:"partnerType"`
40 Area string `json:"area"` 40 Area string `json:"area"`
41 Account string `json:"account"` 41 Account string `json:"account"`
42 State int `json:"state"` 42 State int `json:"state"`
@@ -104,7 +104,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { @@ -104,7 +104,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() {
104 //用与适配前端定义的数据结构 104 //用与适配前端定义的数据结构
105 type Parameter struct { 105 type Parameter struct {
106 ID int64 `json:"id"` 106 ID int64 `json:"id"`
107 - PartnerType []int64 `json:"partnerType"` 107 + PartnerType []*domain.PartnerCategory `json:"partnerType"`
108 Area string `json:"area"` 108 Area string `json:"area"`
109 State int `json:"state"` 109 State int `json:"state"`
110 CooperationTime string `json:"cooperationTime"` 110 CooperationTime string `json:"cooperationTime"`
@@ -195,11 +195,12 @@ func (c *PartnerInfoController) GetPartnerInfo() { @@ -195,11 +195,12 @@ func (c *PartnerInfoController) GetPartnerInfo() {
195 rspResult["salesmanName"] = partnerInfo.Salesman[0].Name 195 rspResult["salesmanName"] = partnerInfo.Salesman[0].Name
196 rspResult["phone"] = partnerInfo.Salesman[0].Telephone 196 rspResult["phone"] = partnerInfo.Salesman[0].Telephone
197 } 197 }
198 - partnerTypes := []map[string]interface{}{} 198 + var partnerTypes []map[string]interface{}
199 for _, v := range partnerInfo.PartnerCategoryInfos { 199 for _, v := range partnerInfo.PartnerCategoryInfos {
200 m := map[string]interface{}{ 200 m := map[string]interface{}{
201 "id": v.Id, 201 "id": v.Id,
202 "name": v.Name, 202 "name": v.Name,
  203 + "code": v.Code,
203 } 204 }
204 partnerTypes = append(partnerTypes, m) 205 partnerTypes = append(partnerTypes, m)
205 } 206 }
@@ -208,6 +209,17 @@ func (c *PartnerInfoController) GetPartnerInfo() { @@ -208,6 +209,17 @@ func (c *PartnerInfoController) GetPartnerInfo() {
208 return 209 return
209 } 210 }
210 211
  212 +/**
  213 + * @Author SteveChan
  214 + * @Description //TODO 移除合伙人
  215 + * @Date 15:31 2020/12/29
  216 + * @Param
  217 + * @return
  218 + **/
  219 +func (c *PartnerInfoController) RemovePartnerInfo() {
  220 +
  221 +}
  222 +
211 //PartnerInfoSetState 合伙人批量禁用.启用 223 //PartnerInfoSetState 合伙人批量禁用.启用
212 func (c *PartnerInfoController) PartnerInfoSetState() { 224 func (c *PartnerInfoController) PartnerInfoSetState() {
213 //用与适配前端定义的数据结构 225 //用与适配前端定义的数据结构
@@ -224,19 +236,19 @@ func (c *PartnerInfoController) PartnerInfoSetState() { @@ -224,19 +236,19 @@ func (c *PartnerInfoController) PartnerInfoSetState() {
224 c.ResponseError(errors.New("json数据解析失败")) 236 c.ResponseError(errors.New("json数据解析失败"))
225 return 237 return
226 } 238 }
227 - comanyId := c.GetUserCompany() 239 + companyId := c.GetUserCompany()
228 var cmd partnerInfoCmd.StatusPartnerInfoCommand 240 var cmd partnerInfoCmd.StatusPartnerInfoCommand
229 switch param.Status { 241 switch param.Status {
230 case 0: 242 case 0:
231 cmd = partnerInfoCmd.StatusPartnerInfoCommand{ 243 cmd = partnerInfoCmd.StatusPartnerInfoCommand{
232 Ids: param.Id, 244 Ids: param.Id,
233 - CompanyId: comanyId, 245 + CompanyId: companyId,
234 Status: domain.PARTNER_STATUS_NO, 246 Status: domain.PARTNER_STATUS_NO,
235 } 247 }
236 case 1: 248 case 1:
237 cmd = partnerInfoCmd.StatusPartnerInfoCommand{ 249 cmd = partnerInfoCmd.StatusPartnerInfoCommand{
238 Ids: param.Id, 250 Ids: param.Id,
239 - CompanyId: comanyId, 251 + CompanyId: companyId,
240 Status: domain.PARTNER_STATUS_YES, 252 Status: domain.PARTNER_STATUS_YES,
241 } 253 }
242 default: 254 default:
@@ -256,7 +268,7 @@ func (c *PartnerInfoController) PartnerInfoSetState() { @@ -256,7 +268,7 @@ func (c *PartnerInfoController) PartnerInfoSetState() {
256 //ListPartnerInfo 合伙人列表 268 //ListPartnerInfo 合伙人列表
257 func (c *PartnerInfoController) ListPartnerInfo() { 269 func (c *PartnerInfoController) ListPartnerInfo() {
258 type Parameter struct { 270 type Parameter struct {
259 - Partnertype int `json:"partnerType"` 271 + PartnerType int `json:"partnerType"`
260 Area string `json:"area"` 272 Area string `json:"area"`
261 PartnerName string `json:"partnerName"` 273 PartnerName string `json:"partnerName"`
262 PageSize int `json:"pageSize"` 274 PageSize int `json:"pageSize"`
@@ -280,7 +292,7 @@ func (c *PartnerInfoController) ListPartnerInfo() { @@ -280,7 +292,7 @@ func (c *PartnerInfoController) ListPartnerInfo() {
280 } 292 }
281 companyId := c.GetUserCompany() 293 companyId := c.GetUserCompany()
282 query := partnerQuery.ListPartnerInfoQuery{ 294 query := partnerQuery.ListPartnerInfoQuery{
283 - Partnertype: param.Partnertype, 295 + PartnerType: param.PartnerType,
284 PartnerName: param.PartnerName, 296 PartnerName: param.PartnerName,
285 RegionInfo: param.Area, 297 RegionInfo: param.Area,
286 Limit: param.PageSize, 298 Limit: param.PageSize,
@@ -294,7 +306,7 @@ func (c *PartnerInfoController) ListPartnerInfo() { @@ -294,7 +306,7 @@ func (c *PartnerInfoController) ListPartnerInfo() {
294 c.ResponseError(err) 306 c.ResponseError(err)
295 return 307 return
296 } 308 }
297 - resp := []map[string]interface{}{} 309 + var resp []map[string]interface{}
298 indexBegin := query.Offset 310 indexBegin := query.Offset
299 for i := range partners { 311 for i := range partners {
300 m := map[string]interface{}{ 312 m := map[string]interface{}{
@@ -32,7 +32,7 @@ func (c *UserController) ListUser() { @@ -32,7 +32,7 @@ func (c *UserController) ListUser() {
32 //用与适配前端定义的数据结构 32 //用与适配前端定义的数据结构
33 type Paramter struct { 33 type Paramter struct {
34 SearchText string `json:"searchText"` 34 SearchText string `json:"searchText"`
35 - PageSize int `json::"pageSize"` 35 + PageSize int `json:"pageSize"`
36 PageNumber int `json:"pageNumber"` 36 PageNumber int `json:"pageNumber"`
37 } 37 }
38 var ( 38 var (
@@ -23,6 +23,7 @@ func init() { @@ -23,6 +23,7 @@ func init() {
23 beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"), 23 beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"),
24 beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"), 24 beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"),
25 beego.NSRouter("/batchDisabled", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), 25 beego.NSRouter("/batchDisabled", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"),
  26 + beego.NSRouter("/:id", &controllers.PartnerInfoController{}, "DELETE:RemovePartnerInfo"),
26 ), 27 ),
27 beego.NSNamespace("/dividends", 28 beego.NSNamespace("/dividends",
28 beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), 29 beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"),
@@ -51,6 +51,7 @@ func (c *MessageConsumer) ConsumeClaim(groupSession sarama.ConsumerGroupSession, @@ -51,6 +51,7 @@ func (c *MessageConsumer) ConsumeClaim(groupSession sarama.ConsumerGroupSession,
51 } 51 }
52 if err = topicHandle(message); err != nil { 52 if err = topicHandle(message); err != nil {
53 logs.Error("Message claimed: kafka消息处理错误 topic =", message.Topic, message.Offset, err) 53 logs.Error("Message claimed: kafka消息处理错误 topic =", message.Topic, message.Offset, err)
  54 +
54 } 55 }
55 groupSession.MarkMessage(message, "") 56 groupSession.MarkMessage(message, "")
56 } 57 }
@@ -30,6 +30,9 @@ func init() { @@ -30,6 +30,9 @@ func init() {
30 if runEnv == "partnermg_prd" { 30 if runEnv == "partnermg_prd" {
31 initHandleRoutersProd() 31 initHandleRoutersProd()
32 } 32 }
  33 + if runEnv == "partnermg_dev" {
  34 + initHandleRoutersDev()
  35 + }
33 } 36 }
34 37
35 func initHandleRoutersTest() { 38 func initHandleRoutersTest() {
@@ -39,3 +42,7 @@ func initHandleRoutersTest() { @@ -39,3 +42,7 @@ func initHandleRoutersTest() {
39 func initHandleRoutersProd() { 42 func initHandleRoutersProd() {
40 TopicHandleRouters["xiangmi_project"] = handles.DataFromXiangMi 43 TopicHandleRouters["xiangmi_project"] = handles.DataFromXiangMi
41 } 44 }
  45 +
  46 +func initHandleRoutersDev() {
  47 + TopicHandleRouters["xiangmi_project_dev"] = handles.DataFromXiangMi
  48 +}
1 -package geetest  
2 -  
3 -import (  
4 - "crypto/md5"  
5 - "encoding/hex"  
6 - "encoding/json"  
7 - "errors"  
8 - "io/ioutil"  
9 - "net/http"  
10 - "net/url"  
11 - "strings"  
12 - "time"  
13 -)  
14 -  
15 -type GeetestLib struct {  
16 - CaptchaID string  
17 - PrivateKey string  
18 - Client *http.Client  
19 -}  
20 -  
21 -type FailbackRegisterRespnse struct {  
22 - Success int `json:"success"`  
23 - GT string `json:"gt"`  
24 - Challenge string `json:"challenge"`  
25 - NewCaptcha int `json:"new_captcha"`  
26 -}  
27 -  
28 -const (  
29 - geetestHost = "http://api.geetest.com"  
30 - registerURL = geetestHost + "/register.php"  
31 - validateURL = geetestHost + "/validate.php"  
32 -)  
33 -  
34 -func MD5Encode(input string) string {  
35 - md5Instant := md5.New()  
36 - md5Instant.Write([]byte(input))  
37 - return hex.EncodeToString(md5Instant.Sum(nil))  
38 -}  
39 -  
40 -// 初始化 GeetestLib  
41 -func NewGeetestLib(capthcaID string, privateKey string, timeOut time.Duration) (geetest GeetestLib){  
42 - client := &http.Client{Timeout: timeOut}  
43 - geetest = GeetestLib{capthcaID, privateKey, client}  
44 - return  
45 -}  
46 -  
47 -func (g *GeetestLib) getFailBackRegisterResponse(success int, challenge string) []byte {  
48 - if challenge == "" {  
49 - challenge = hex.EncodeToString(md5.New().Sum(nil))  
50 - }  
51 -  
52 - response := FailbackRegisterRespnse{  
53 - success,  
54 - g.CaptchaID,  
55 - challenge,  
56 - 1,  
57 - }  
58 - res, _ := json.Marshal(response)  
59 - return res  
60 -}  
61 -  
62 -func (g *GeetestLib) do(req *http.Request) (body []byte, err error) {  
63 - req.Header.Set("Content-Type", "application/x-www-form-urlencoded")  
64 - var resp *http.Response  
65 - if resp, err = g.Client.Do(req); err != nil {  
66 - return  
67 - }  
68 - defer resp.Body.Close()  
69 - if resp.StatusCode >= http.StatusInternalServerError {  
70 - err = errors.New("http status code 5xx")  
71 - return  
72 - }  
73 -  
74 - if body, err = ioutil.ReadAll(resp.Body); err != nil {  
75 - return  
76 - }  
77 - return  
78 -}  
79 -  
80 -func (g *GeetestLib) PreProcess(userID string, userIP string) (int8, []byte) {  
81 - params := url.Values{}  
82 - params.Add("gt", g.CaptchaID)  
83 - params.Add("new_captcha", "1")  
84 - if userID != "" {  
85 - params.Add("user_id", userID)  
86 - }  
87 - if userIP != "" {  
88 - params.Add("ip_adress", userIP)  
89 - }  
90 - req, _ := http.NewRequest("GET", registerURL+"?"+params.Encode(), nil)  
91 - body, err := g.do(req)  
92 - if err != nil {  
93 - return 0, g.getFailBackRegisterResponse(0, "")  
94 - }  
95 - challenge := string(body)  
96 - if len(challenge) != 32 {  
97 - return 0, g.getFailBackRegisterResponse(0, "")  
98 - } else {  
99 - challenge = MD5Encode(challenge + g.PrivateKey)  
100 - return 1, g.getFailBackRegisterResponse(1, challenge)  
101 - }  
102 -}  
103 -  
104 -func (g *GeetestLib) checkParas(challenge string, validate string, seccode string) bool {  
105 - if challenge == "" || validate == "" || seccode == "" {  
106 - return false  
107 - }  
108 - return true  
109 -}  
110 -  
111 -func (g *GeetestLib) checkSuccessRes(challenge string, validate string) bool {  
112 - return MD5Encode(g.PrivateKey+"geetest"+challenge) == validate  
113 -}  
114 -  
115 -func (g *GeetestLib) checkFailbackRes(challenge string, validate string) bool {  
116 - return MD5Encode(challenge) == validate  
117 -}  
118 -  
119 -func (g *GeetestLib) SuccessValidate(challenge string, validate string, seccode string, userID string, userIP string) bool {  
120 - if !g.checkParas(challenge, validate, seccode) {  
121 - return false  
122 - }  
123 - if !g.checkSuccessRes(challenge, validate) {  
124 - return false  
125 - }  
126 - params := url.Values{}  
127 - params.Add("seccode", seccode)  
128 - params.Add("challenge", challenge)  
129 - params.Add("captchaid", g.CaptchaID)  
130 - params.Add("sdk", "golang_v1.0.0")  
131 - if userID != "" {  
132 - params.Add("user_id", userID)  
133 - }  
134 - if userIP != "" {  
135 - params.Add("ip_adress", userIP)  
136 - }  
137 - req, _ := http.NewRequest("POST", validateURL, strings.NewReader(params.Encode()))  
138 - body, err := g.do(req)  
139 - if err != nil {  
140 - return false  
141 - }  
142 - res := string(body)  
143 - return res == MD5Encode(seccode)  
144 -}  
145 -  
146 -func (g *GeetestLib) FailbackValidate(challenge string, validate string, seccode string) bool {  
147 - if !g.checkParas(challenge, validate, seccode) {  
148 - return false  
149 - }  
150 - if !g.checkFailbackRes(challenge, validate) {  
151 - return false  
152 - }  
153 - return true  
154 -}  
@@ -3,9 +3,6 @@ @@ -3,9 +3,6 @@
3 github.com/360EntSecGroup-Skylar/excelize/v2 3 github.com/360EntSecGroup-Skylar/excelize/v2
4 # github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 4 # github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798
5 github.com/DataDog/zstd 5 github.com/DataDog/zstd
6 -# github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2  
7 -## explicit  
8 -github.com/GeeTeam/gt3-golang-sdk/geetest  
9 # github.com/Shopify/sarama v1.23.1 6 # github.com/Shopify/sarama v1.23.1
10 ## explicit 7 ## explicit
11 github.com/Shopify/sarama 8 github.com/Shopify/sarama