作者 唐旭辉

Merge branch 'dev' into test

  1 +# Config file for [Air](https://github.com/cosmtrek/air) in TOML format
  2 +
  3 +# Working directory
  4 +# . or absolute path, please note that the directories following must be under root.
  5 +root = "."
  6 +tmp_dir = "tmp"
  7 +
  8 +[build]
  9 +# Just plain old shell command. You could use `make` as well.
  10 +cmd = "go build -o ./tmp/main ."
  11 +# Binary file yields from `cmd`.
  12 +bin = "tmp/main"
  13 +# Customize binary.
  14 +full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
  15 +# Watch these filename extensions.
  16 +include_ext = ["go", "tpl", "tmpl", "html"]
  17 +# Ignore these filename extensions or directories.
  18 +exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
  19 +# Watch these directories if you specified.
  20 +include_dir = []
  21 +# Exclude files.
  22 +exclude_file = []
  23 +# Exclude unchanged files.
  24 +exclude_unchanged = true
  25 +# This log file places in your tmp_dir.
  26 +log = "air.log"
  27 +# It's not necessary to trigger build each time file changes if it's too frequent.
  28 +delay = 1000 # ms
  29 +# Stop running old binary when build errors occur.
  30 +stop_on_error = true
  31 +# Send Interrupt signal before killing process (windows does not support this feature)
  32 +send_interrupt = false
  33 +# Delay after sending Interrupt signal
  34 +kill_delay = 500 # ms
  35 +
  36 +[log]
  37 +# Show log time
  38 +time = false
  39 +
  40 +[color]
  41 +# Customize each part's color. If no color found, use the raw app log.
  42 +main = "magenta"
  43 +watcher = "cyan"
  44 +build = "yellow"
  45 +runner = "green"
  46 +
  47 +[misc]
  48 +# Delete tmp directory on exit
  49 +clean_on_exit = true
@@ -83,7 +83,7 @@ spec: @@ -83,7 +83,7 @@ spec:
83 - name: UCENTER_CHECK_ALT 83 - name: UCENTER_CHECK_ALT
84 value: "6DwjBO735" 84 value: "6DwjBO735"
85 - name: BUSINESS_ADMIN_HOST 85 - name: BUSINESS_ADMIN_HOST
86 - value: "http://suplus-business-admin-dev.fjmaimaimai.com" 86 + value: "https://suplus-business-admin-dev.fjmaimaimai.com"
87 - name: KAFKA_HOST 87 - name: KAFKA_HOST
88 value: "" 88 value: ""
89 - name: KAFKA_CONSUMER_ID 89 - name: KAFKA_CONSUMER_ID
@@ -80,7 +80,7 @@ spec: @@ -80,7 +80,7 @@ spec:
80 - name: UCENTER_CHECK_ALT 80 - name: UCENTER_CHECK_ALT
81 value: "rsF0pL!6DwjBO735" 81 value: "rsF0pL!6DwjBO735"
82 - name: BUSINESS_ADMIN_HOST 82 - name: BUSINESS_ADMIN_HOST
83 - value: "http://suplus-business-admin-prd.fjmaimaimai.com" 83 + value: "https://suplus-business-admin-prd.fjmaimaimai.com"
84 - name: KAFKA_HOST 84 - name: KAFKA_HOST
85 value: "192.168.0.250:9092;192.168.0.251:9092;192.168.0.252:9092" 85 value: "192.168.0.250:9092;192.168.0.251:9092;192.168.0.252:9092"
86 - name: KAFKA_CONSUMER_ID 86 - name: KAFKA_CONSUMER_ID
@@ -80,7 +80,7 @@ spec: @@ -80,7 +80,7 @@ spec:
80 - name: UCENTER_CHECK_ALT 80 - name: UCENTER_CHECK_ALT
81 value: "rsF0pL!6DwjBO735" 81 value: "rsF0pL!6DwjBO735"
82 - name: BUSINESS_ADMIN_HOST 82 - name: BUSINESS_ADMIN_HOST
83 - value: "http://suplus-business-admin-test.fjmaimaimai.com" 83 + value: "https://suplus-business-admin-test.fjmaimaimai.com"
84 - name: KAFKA_HOST 84 - name: KAFKA_HOST
85 value: "192.168.0.250:9092;192.168.0.251:9092;192.168.0.252:9092" 85 value: "192.168.0.250:9092;192.168.0.251:9092;192.168.0.252:9092"
86 - name: KAFKA_CONSUMER_ID 86 - name: KAFKA_CONSUMER_ID
@@ -142,7 +142,10 @@ func (columnSettingService *ColumnSettingService) ListColumnSetting(listColumnSe @@ -142,7 +142,10 @@ func (columnSettingService *ColumnSettingService) ListColumnSetting(listColumnSe
142 } else { 142 } else {
143 columnSettingRepository = value 143 columnSettingRepository = value
144 } 144 }
145 - if count, columnSettings, err := columnSettingRepository.Find(tool_funs.SimpleStructToMap(listColumnSettingQuery)); err != nil { 145 + if count, columnSettings, err := columnSettingRepository.Find(domain.ColumnSettingFindQuery{
  146 + Offset: listColumnSettingQuery.Offset,
  147 + Limit: listColumnSettingQuery.Limit,
  148 + }); err != nil {
146 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 149 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
147 } else { 150 } else {
148 if err := transactionContext.CommitTransaction(); err != nil { 151 if err := transactionContext.CommitTransaction(); err != nil {
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/2
  4 + @note:
  5 +**/
  6 +
  7 +package query
  8 +
  9 +type ListOrderBonusForExcelQuery struct {
  10 + Type string `json:"type"` // 操作类型 ORDER_BASE
  11 + Where BonusWhere `json:"where"` // 导出条件
  12 + IDS []int `json:"ids"` // 勾选id
  13 +}
  14 +
  15 +type BonusWhere struct {
  16 + SearchWord string `json:"searchWord"`
  17 + OrderType int `json:"orderType"`
  18 + PageSize int `json:"pageSize"`
  19 + PageNumber int `json:"pageNumber"`
  20 + PartnerCategoryId int `json:"partnerCategoryId"`
  21 + CreateTime []string `json:"createTime"`
  22 +}
@@ -1004,8 +1004,8 @@ func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrder @@ -1004,8 +1004,8 @@ func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrder
1004 "orderId": ordersData[i].OrderCode, 1004 "orderId": ordersData[i].OrderCode,
1005 "shipmentsId": ordersData[i].DeliveryCode, 1005 "shipmentsId": ordersData[i].DeliveryCode,
1006 "partner": ordersData[i].PartnerName, 1006 "partner": ordersData[i].PartnerName,
1007 - "update_time": ordersData[i].UpdateTime,  
1008 - "create_time": ordersData[i].CreateTime, 1007 + "updateTime": ordersData[i].UpdateTime,
  1008 + "createTime": ordersData[i].CreateTime,
1009 "saleDate": t.Format("2006-01-02"), 1009 "saleDate": t.Format("2006-01-02"),
1010 "orderNum": fmt.Sprint(ordersData[i].PlanOrderCount), 1010 "orderNum": fmt.Sprint(ordersData[i].PlanOrderCount),
1011 "quantityControl": "", 1011 "quantityControl": "",
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/utils"
5 6
6 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
7 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
@@ -238,7 +239,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI @@ -238,7 +239,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI
238 239
239 /** 240 /**
240 * @Author SteveChan 241 * @Author SteveChan
241 - * @Description // 更新合伙人 242 + * @Description //TODO 更新合伙人,判断合伙类型是否有业务数据
242 * @Date 00:07 2020/12/30 243 * @Date 00:07 2020/12/30
243 * @Param 244 * @Param
244 * @return 245 * @return
@@ -261,7 +262,9 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd @@ -261,7 +262,9 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
261 var ( 262 var (
262 partnerInfoRepository domain.PartnerInfoRepository 263 partnerInfoRepository domain.PartnerInfoRepository
263 categoryRepository domain.PartnerCategoryRepository 264 categoryRepository domain.PartnerCategoryRepository
  265 + orderBaseRepository domain.OrderBaseRepository
264 categories []domain.PartnerCategory 266 categories []domain.PartnerCategory
  267 + orders []domain.OrderBase
265 partnerInfoDao *dao.PartnerInfoDao 268 partnerInfoDao *dao.PartnerInfoDao
266 ) 269 )
267 270
@@ -283,6 +286,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd @@ -283,6 +286,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
283 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 286 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
284 } 287 }
285 288
  289 + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
  290 + "transactionContext": transactionContext,
  291 + }); err != nil {
  292 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  293 + }
  294 +
286 // 获取合伙人类型 295 // 获取合伙人类型
287 var categoryMap = make(map[int64]string) 296 var categoryMap = make(map[int64]string)
288 _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ 297 _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
@@ -349,6 +358,34 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd @@ -349,6 +358,34 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
349 return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作") 358 return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作")
350 } 359 }
351 360
  361 + partnerCategoryInfos := partnerInfo.PartnerCategoryInfos
  362 +
  363 + //判断相应合伙类型下是否有订单数据
  364 + var notInPartnerCategoryInfos []int64
  365 + var categoryIdsQuery []int64
  366 + var categoryIdsCmd []int64
  367 + for _, partnerCategory := range partnerCategoryInfos {
  368 + categoryIdsQuery = append(categoryIdsQuery, partnerCategory.Id)
  369 + }
  370 + for _, category := range categories {
  371 + categoryIdsCmd = append(categoryIdsCmd, category.Id)
  372 + }
  373 + for _, v := range categoryIdsQuery {
  374 + if !utils.IsContainInt(categoryIdsCmd, v) {
  375 + notInPartnerCategoryInfos = append(notInPartnerCategoryInfos, v)
  376 + }
  377 + }
  378 + if len(notInPartnerCategoryInfos) > 0 {
  379 + orders, _, err = orderBaseRepository.Find(domain.OrderBaseFindQuery{
  380 + PartnerId: cmd.Id,
  381 + CompanyId: cmd.CompanyId,
  382 + PartnerCategoryIds: notInPartnerCategoryInfos,
  383 + })
  384 + if len(orders) > 0 {
  385 + return lib.ThrowError(lib.BUSINESS_ERROR, "该合伙类型下有业务数据,不可删除!")
  386 + }
  387 + }
  388 +
352 partnerInfo.Partner.PartnerName = cmd.PartnerName 389 partnerInfo.Partner.PartnerName = cmd.PartnerName
353 partnerInfo.Salesman = cmd.Salesman 390 partnerInfo.Salesman = cmd.Salesman
354 partnerInfo.Status = cmd.Status 391 partnerInfo.Status = cmd.Status
@@ -372,7 +409,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd @@ -372,7 +409,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd
372 // e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err) 409 // e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err)
373 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 410 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
374 // } 411 // }
375 - transactionContext.CommitTransaction() 412 + _ = transactionContext.CommitTransaction()
376 return 413 return
377 } 414 }
378 415
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "encoding/json" 4 "encoding/json"
5 "errors" 5 "errors"
6 "fmt" 6 "fmt"
  7 + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
7 "time" 8 "time"
8 9
9 "github.com/astaxie/beego/logs" 10 "github.com/astaxie/beego/logs"
@@ -101,6 +102,7 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { @@ -101,6 +102,7 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
101 var ( 102 var (
102 companyRespository domain.CompanyRepository 103 companyRespository domain.CompanyRepository
103 userRespository domain.UsersRepository 104 userRespository domain.UsersRepository
  105 + columnSettingRepository domain.ColumnSettingRepository
104 ) 106 )
105 if companyRespository, err = factory.CreateCompanyRepository(map[string]interface{}{ 107 if companyRespository, err = factory.CreateCompanyRepository(map[string]interface{}{
106 "transactionContext": transactionContext, 108 "transactionContext": transactionContext,
@@ -112,6 +114,11 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { @@ -112,6 +114,11 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
112 }); err != nil { 114 }); err != nil {
113 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 115 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
114 } 116 }
  117 + if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{
  118 + "transactionContext": transactionContext,
  119 + }); err != nil {
  120 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  121 + }
115 applets := []domain.CompanyApplets{} 122 applets := []domain.CompanyApplets{}
116 for _, v := range data.Company.Applets { 123 for _, v := range data.Company.Applets {
117 app := domain.CompanyApplets{ 124 app := domain.CompanyApplets{
@@ -163,6 +170,21 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { @@ -163,6 +170,21 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
163 if err != nil { 170 if err != nil {
164 return fmt.Errorf("添加用户数据失败,%s", err) 171 return fmt.Errorf("添加用户数据失败,%s", err)
165 } 172 }
  173 + // 初始化栏目设置
  174 + newColumnSetting := &domain.ColumnSetting{
  175 + Description: "订单管理栏目设置",
  176 + UserName: data.User.Name,
  177 + CompanyId: int(data.User.CompanyId),
  178 + Uid: data.User.Id,
  179 + Key: constant.ORDER_BASE, // 订单栏目模块名称
  180 + Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置
  181 + InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组
  182 + CreatedAt: time.Now(),
  183 + UpdatedAt: time.Now(),
  184 + }
  185 + if _, err = columnSettingRepository.Save(newColumnSetting); err != nil {
  186 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  187 + }
166 err = transactionContext.CommitTransaction() 188 err = transactionContext.CommitTransaction()
167 return nil 189 return nil
168 } 190 }
@@ -88,7 +88,7 @@ var _ SyncAction = (*SyncEmployeeService)(nil) @@ -88,7 +88,7 @@ var _ SyncAction = (*SyncEmployeeService)(nil)
88 88
89 /** 89 /**
90 * @Author SteveChan 90 * @Author SteveChan
91 - * @Description //TODO 新增、导入用户初始化栏目设置 91 + * @Description //新增、导入用户初始化栏目设置
92 * @Date 23:54 2021/1/26 92 * @Date 23:54 2021/1/26
93 * @Param 93 * @Param
94 * @return 94 * @return
@@ -263,6 +263,12 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro @@ -263,6 +263,12 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro
263 }); err != nil { 263 }); err != nil {
264 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 264 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
265 } 265 }
  266 + var columnSettingRepository domain.ColumnSettingRepository
  267 + if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{
  268 + "transactionContext": transactionContext,
  269 + }); err != nil {
  270 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  271 + }
266 for i := range datas { 272 for i := range datas {
267 data := datas[i] 273 data := datas[i]
268 var ( 274 var (
@@ -302,6 +308,21 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro @@ -302,6 +308,21 @@ func (service SyncEmployeeService) updateEmployeeData(datas []EmployeeData) erro
302 if err = usersRepository.Add(&newUser); err != nil { 308 if err = usersRepository.Add(&newUser); err != nil {
303 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 309 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
304 } 310 }
  311 + // 添加用户数据时初始化栏目设置
  312 + newColumnSetting := &domain.ColumnSetting{
  313 + Description: "订单管理栏目设置",
  314 + UserName: data.Name,
  315 + CompanyId: int(data.CompanyId),
  316 + Uid: data.Id,
  317 + Key: constant.ORDER_BASE, // 订单栏目模块名称
  318 + Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置
  319 + InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组
  320 + CreatedAt: time.Now(),
  321 + UpdatedAt: time.Now(),
  322 + }
  323 + if _, err = columnSettingRepository.Save(newColumnSetting); err != nil {
  324 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  325 + }
305 continue 326 continue
306 } else { 327 } else {
307 entryTime, _ := time.Parse("2006-01-02", data.EntryTime) 328 entryTime, _ := time.Parse("2006-01-02", data.EntryTime)
@@ -352,7 +373,7 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error @@ -352,7 +373,7 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error
352 if err = usersRepository.Remove(data.Ids); err != nil { 373 if err = usersRepository.Remove(data.Ids); err != nil {
353 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 374 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
354 } 375 }
355 - // TODO 删除栏目设置 376 + // 删除栏目设置
356 var columnSettingRepository domain.ColumnSettingRepository 377 var columnSettingRepository domain.ColumnSettingRepository
357 if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{ 378 if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{
358 "transactionContext": transactionContext, 379 "transactionContext": transactionContext,
@@ -361,7 +382,14 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error @@ -361,7 +382,14 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error
361 } else { 382 } else {
362 columnSettingRepository = value 383 columnSettingRepository = value
363 } 384 }
364 - _, columnSettingsFound, err := columnSettingRepository.Find(map[string]interface{}{"ids": data.Ids, "companyId": data.CompanyId}) 385 + var ids []int64
  386 + for _, d := range data.Ids {
  387 + ids = append(ids, d)
  388 + }
  389 + _, columnSettingsFound, err := columnSettingRepository.Find(domain.ColumnSettingFindQuery{
  390 + Ids: ids,
  391 + CompanyId: int(data.CompanyId),
  392 + })
365 if err != nil { 393 if err != nil {
366 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 394 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
367 } 395 }
@@ -92,11 +92,20 @@ type ColumnSetting struct { @@ -92,11 +92,20 @@ type ColumnSetting struct {
92 InvalidValue []Column `json:"invalidValue"` 92 InvalidValue []Column `json:"invalidValue"`
93 } 93 }
94 94
  95 +type ColumnSettingFindQuery struct {
  96 + Ids []int64
  97 + Uid int64
  98 + CompanyId int
  99 + Offset int
  100 + Limit int
  101 +}
  102 +
95 type ColumnSettingRepository interface { 103 type ColumnSettingRepository interface {
96 Save(columnSetting *ColumnSetting) (*ColumnSetting, error) 104 Save(columnSetting *ColumnSetting) (*ColumnSetting, error)
97 Remove(columnSetting *ColumnSetting, columnSettings []*ColumnSetting) (*ColumnSetting, []*ColumnSetting, error) 105 Remove(columnSetting *ColumnSetting, columnSettings []*ColumnSetting) (*ColumnSetting, []*ColumnSetting, error)
98 FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error) 106 FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error)
99 - Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error) 107 + //Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
  108 + Find(queryOptions ColumnSettingFindQuery) (int64, []*ColumnSetting, error)
100 } 109 }
101 110
102 func (columnSetting *ColumnSetting) Identify() interface{} { 111 func (columnSetting *ColumnSetting) Identify() interface{} {
@@ -315,6 +315,7 @@ type OrderBaseFindQuery struct { @@ -315,6 +315,7 @@ type OrderBaseFindQuery struct {
315 Limit int 315 Limit int
316 OrderType int 316 OrderType int
317 CompanyId int64 317 CompanyId int64
  318 + PartnerCategoryIds []int64
318 } 319 }
319 320
320 // 导入错误信息 321 // 导入错误信息
@@ -325,7 +325,8 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o @@ -325,7 +325,8 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o
325 sqlstr += ` AND t1.partner_category@>'{"id":?}' ` 325 sqlstr += ` AND t1.partner_category@>'{"id":?}' `
326 } 326 }
327 if len(partnerCategoryName) > 0 { 327 if len(partnerCategoryName) > 0 {
328 - params = append(params, partnerCategoryName) 328 + like := "%" + partnerCategoryName + "%"
  329 + params = append(params, like)
329 sqlstr += ` AND t1.partner_category->> 'name' like ?` 330 sqlstr += ` AND t1.partner_category->> 'name' like ?`
330 } 331 }
331 if len(updateTime[0]) > 0 { 332 if len(updateTime[0]) > 0 {
@@ -2,7 +2,7 @@ package repository @@ -2,7 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "github.com/go-pg/pg" 5 + "github.com/go-pg/pg/v10"
6 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" 6 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
7 7
8 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" 8 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
@@ -38,23 +38,7 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett @@ -38,23 +38,7 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett
38 if err != nil { 38 if err != nil {
39 return nil, err 39 return nil, err
40 } 40 }
41 - //_, err := repository.nextIdentify()  
42 - //if err != nil {  
43 - // return columnSetting, err  
44 - //}  
45 - //if _, errInsert := tx.QueryOne(  
46 - // pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value), pg.Array(&columnSetting.InvalidValue)),  
47 - // "INSERT INTO column_settings (company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value",  
48 - // columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), pg.Array(columnSetting.InvalidValue)); errInsert != nil {  
49 - // return columnSetting, errInsert  
50 - //}  
51 } else { 41 } else {
52 - //if _, errUpdate := tx.QueryOne(  
53 - // pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value), pg.Array(&columnSetting.InvalidValue)),  
54 - // "UPDATE column_settings SET company_id=?, created_at=?, description=?, key=?, uid=?, updated_at=?, user_name=?, value=?, invalid_value=? WHERE id=? RETURNING id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value",  
55 - // columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), pg.Array(columnSetting.InvalidValue), columnSetting.Identify()); errUpdate != nil {  
56 - // return columnSetting, errUpdate  
57 - //}  
58 _, err := tx.Model(columnSettingModel).WherePK(). 42 _, err := tx.Model(columnSettingModel).WherePK().
59 Column("company_id", "created_at", "description", "key", "uid", "updated_at", "user_name", "value", "invalid_value").Update() 43 Column("company_id", "created_at", "description", "key", "uid", "updated_at", "user_name", "value", "invalid_value").Update()
60 if err != nil { 44 if err != nil {
@@ -67,27 +51,26 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett @@ -67,27 +51,26 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett
67 func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) { 51 func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) {
68 tx := repository.transactionContext.PgTx 52 tx := repository.transactionContext.PgTx
69 53
70 - if columnSetting != nil {  
71 // 单个删除 54 // 单个删除
  55 + if columnSetting != nil {
72 columnSettingModel := new(models.ColumnSetting) 56 columnSettingModel := new(models.ColumnSetting)
73 columnSettingModel.Id = columnSetting.Identify().(int64) 57 columnSettingModel.Id = columnSetting.Identify().(int64)
74 - if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil { 58 + if _, err := tx.Model(&columnSettingModel).WherePK().Delete(); err != nil {
75 return columnSetting, nil, err 59 return columnSetting, nil, err
76 } 60 }
77 } 61 }
78 62
79 // 批量删除 63 // 批量删除
80 if len(columnSettings) > 0 { 64 if len(columnSettings) > 0 {
81 - var columnSettingModels []*models.ColumnSetting 65 + var ids []int64
82 for _, setting := range columnSettings { 66 for _, setting := range columnSettings {
83 - columnSettingModels = append(columnSettingModels, &models.ColumnSetting{  
84 - Id: setting.Identify().(int64),  
85 - }) 67 + ids = append(ids, setting.Identify().(int64))
86 } 68 }
87 - if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil { 69 + if _, err := tx.Model((*models.ColumnSetting)(nil)).Where("id IN (?)", pg.In(ids)).Delete(); err != nil {
88 return nil, columnSettings, err 70 return nil, columnSettings, err
89 } 71 }
90 } 72 }
  73 +
91 return columnSetting, columnSettings, nil 74 return columnSetting, columnSettings, nil
92 } 75 }
93 76
@@ -118,33 +101,25 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter @@ -118,33 +101,25 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter
118 } 101 }
119 } 102 }
120 103
121 -func (repository *ColumnSettingRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ColumnSetting, error) { 104 +func (repository *ColumnSettingRepository) Find(queryOptions domain.ColumnSettingFindQuery) (int64, []*domain.ColumnSetting, error) {
122 tx := repository.transactionContext.PgTx 105 tx := repository.transactionContext.PgTx
123 - var columnSettingModels []*models.ColumnSetting 106 + var columnSettingModels []models.ColumnSetting
124 columnSettings := make([]*domain.ColumnSetting, 0) 107 columnSettings := make([]*domain.ColumnSetting, 0)
125 query := tx.Model(&columnSettingModels) 108 query := tx.Model(&columnSettingModels)
126 - if ids, ok := queryOptions["ids"]; ok {  
127 - query = query.Where("column_setting.uid IN (?)", pg.In(ids.([]int64)))  
128 - }  
129 - if uid, ok := queryOptions["uid"]; ok {  
130 - query = query.Where("column_setting.uid = ?", uid) 109 + if len(queryOptions.Ids) > 0 {
  110 + query = query.Where("column_setting.uid IN (?)", pg.In(queryOptions.Ids))
131 } 111 }
132 - if companyId, ok := queryOptions["companyId"]; ok {  
133 - query = query.Where("column_setting.company_id = ?", companyId) 112 + if queryOptions.Uid > 0 {
  113 + query = query.Where("column_setting.uid = ?", queryOptions.Uid)
134 } 114 }
135 - if offset, ok := queryOptions["offset"]; ok {  
136 - queryOffset := offset.(int)  
137 - if queryOffset > -1 {  
138 - query = query.Offset(queryOffset)  
139 - }  
140 - } else {  
141 - query = query.Offset(0) 115 + if queryOptions.CompanyId > 0 {
  116 + query = query.Where("column_setting.company_id = ?", queryOptions.CompanyId)
142 } 117 }
143 - if limit, ok := queryOptions["limit"]; ok {  
144 - queryLimit := limit.(int)  
145 - if queryLimit > -1 {  
146 - query = query.Limit(queryLimit) 118 + if queryOptions.Offset > -1 {
  119 + query = query.Offset(queryOptions.Offset)
147 } 120 }
  121 + if queryOptions.Limit > 0 {
  122 + query = query.Limit(queryOptions.Limit)
148 } else { 123 } else {
149 query = query.Limit(20) 124 query = query.Limit(20)
150 } 125 }
@@ -152,7 +127,7 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac @@ -152,7 +127,7 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac
152 return 0, columnSettings, err 127 return 0, columnSettings, err
153 } else { 128 } else {
154 for _, columnSettingModel := range columnSettingModels { 129 for _, columnSettingModel := range columnSettingModels {
155 - if columnSetting, errTrans := repository.transformPgModelToDomainModel(columnSettingModel); errTrans != nil { 130 + if columnSetting, errTrans := repository.transformPgModelToDomainModel(&columnSettingModel); errTrans != nil {
156 return 0, columnSettings, errTrans 131 return 0, columnSettings, errTrans
157 } else { 132 } else {
158 columnSettings = append(columnSettings, columnSetting) 133 columnSettings = append(columnSettings, columnSetting)
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/go-pg/pg/v10"
5 6
6 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" 7 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" 8 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
@@ -84,9 +85,6 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { @@ -84,9 +85,6 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
84 Remark: orderInfo.Remark, 85 Remark: orderInfo.Remark,
85 PartnerCategory: orderInfo.PartnerCategory, 86 PartnerCategory: orderInfo.PartnerCategory,
86 } 87 }
87 - //if m.OrderType > 2 { // TODO 非平台自建订单,默认销售日期取订单创建日期  
88 - // m.SaleDate = orderInfo.CreateTime  
89 - //}  
90 if m.Id == 0 { 88 if m.Id == 0 {
91 _, err = tx.Model(m). 89 _, err = tx.Model(m).
92 Returning("*"). 90 Returning("*").
@@ -124,6 +122,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery @@ -124,6 +122,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
124 if queryOption.CompanyId > 0 { 122 if queryOption.CompanyId > 0 {
125 query = query.Where("company_id=?", queryOption.CompanyId) 123 query = query.Where("company_id=?", queryOption.CompanyId)
126 } 124 }
  125 + if len(queryOption.PartnerCategoryIds) > 0 {
  126 + query = query.Where(`(order_base.partner_category->>'id')::int IN (?)`, pg.In(queryOption.PartnerCategoryIds))
  127 + }
127 if queryOption.Offset > -1 { 128 if queryOption.Offset > -1 {
128 query = query.Offset(queryOption.Offset) 129 query = query.Offset(queryOption.Offset)
129 } 130 }
@@ -47,3 +47,19 @@ func IsContain(items []string, item string) bool { @@ -47,3 +47,19 @@ func IsContain(items []string, item string) bool {
47 } 47 }
48 return false 48 return false
49 } 49 }
  50 +
  51 +/**
  52 + * @Author SteveChan
  53 + * @Description //TODO
  54 + * @Date 23:34 2021/2/2
  55 + * @Param
  56 + * @return
  57 + **/
  58 +func IsContainInt(items []int64, item int64) bool {
  59 + for _, eachItem := range items {
  60 + if eachItem == item {
  61 + return true
  62 + }
  63 + }
  64 + return false
  65 +}
@@ -23,7 +23,7 @@ func (controller *ColumnSettingController) Prepare() { @@ -23,7 +23,7 @@ func (controller *ColumnSettingController) Prepare() {
23 if ok := controller.ValidJWTToken(); !ok { 23 if ok := controller.ValidJWTToken(); !ok {
24 return 24 return
25 } 25 }
26 - if ok := controller.ValidAdminPermission(domain.PERMINSSION_PARTNER); !ok { 26 + if ok := controller.ValidAdminPermission(domain.PERMISSION_ORDER); !ok {
27 return 27 return
28 } 28 }
29 } 29 }
@@ -54,7 +54,7 @@ func (controller *ColumnSettingController) CreateColumnSetting() { @@ -54,7 +54,7 @@ func (controller *ColumnSettingController) CreateColumnSetting() {
54 54
55 /** 55 /**
56 * @Author SteveChan 56 * @Author SteveChan
57 - * @Description // 更新栏目设置 57 + * @Description 更新栏目设置
58 * @Date 22:52 2021/1/26 58 * @Date 22:52 2021/1/26
59 * @Param 59 * @Param
60 * @return 60 * @return
@@ -292,16 +292,18 @@ func (c *OrderDividendController) EditOrderRemarkBonus() { @@ -292,16 +292,18 @@ func (c *OrderDividendController) EditOrderRemarkBonus() {
292 } 292 }
293 293
294 func (c *OrderDividendController) ListOrderBonusForExcel() { 294 func (c *OrderDividendController) ListOrderBonusForExcel() {
295 - type Parameter struct {  
296 - SearchWord string `json:"searchWord"`  
297 - OrderType int `json:"orderType"`  
298 - PageSize int `json:"pageSize"`  
299 - PageNumber int `json:"pageNumber"`  
300 - PartnerCategoryId int `json:"partnerCategoryId"`  
301 - CreateTime []string `json:"createTime"`  
302 - } 295 + //type Parameter struct {
  296 + // SearchWord string `json:"searchWord"`
  297 + // OrderType int `json:"orderType"`
  298 + // PageSize int `json:"pageSize"`
  299 + // PageNumber int `json:"pageNumber"`
  300 + // PartnerCategoryId int `json:"partnerCategoryId"`
  301 + // CreateTime []string `json:"createTime"`
  302 + //}
  303 +
303 var ( 304 var (
304 - param Parameter 305 + //param Parameter
  306 + param orderQuery.ListOrderBonusForExcelQuery
305 err error 307 err error
306 ) 308 )
307 if err = c.BindJsonData(&param); err != nil { 309 if err = c.BindJsonData(&param); err != nil {
@@ -309,9 +311,14 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { @@ -309,9 +311,14 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
309 c.ResponseError(errors.New("json数据解析失败")) 311 c.ResponseError(errors.New("json数据解析失败"))
310 return 312 return
311 } 313 }
312 - if !(param.OrderType == 0 ||  
313 - param.OrderType == domain.OrderReal ||  
314 - param.OrderType == domain.OrderTypeBestShop) { 314 + if param.Type != "ORDER_DIVIDEND" {
  315 + logs.Error(err)
  316 + c.ResponseError(errors.New("错误的操作类型"))
  317 + return
  318 + }
  319 + if !(param.Where.OrderType == 0 ||
  320 + param.Where.OrderType == domain.OrderReal ||
  321 + param.Where.OrderType == domain.OrderTypeBestShop) {
315 c.ResponseError(errors.New("参数异常")) 322 c.ResponseError(errors.New("参数异常"))
316 return 323 return
317 } 324 }
@@ -319,9 +326,9 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { @@ -319,9 +326,9 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
319 createTimeBegin string 326 createTimeBegin string
320 createTimeEnd string 327 createTimeEnd string
321 ) 328 )
322 - if len(param.CreateTime) > 0 {  
323 - if len(param.CreateTime[0]) > 0 {  
324 - t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local) 329 + if len(param.Where.CreateTime) > 0 {
  330 + if len(param.Where.CreateTime[0]) > 0 {
  331 + t, err := time.ParseInLocation("2006-01-02", param.Where.CreateTime[0], time.Local)
325 if err != nil { 332 if err != nil {
326 c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误")) 333 c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误"))
327 return 334 return
@@ -329,9 +336,9 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { @@ -329,9 +336,9 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
329 createTimeBegin = t.Format("2006-01-02 15:04:05-07") 336 createTimeBegin = t.Format("2006-01-02 15:04:05-07")
330 } 337 }
331 } 338 }
332 - if len(param.CreateTime) > 1 {  
333 - if len(param.CreateTime[1]) > 0 {  
334 - t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local) 339 + if len(param.Where.CreateTime) > 1 {
  340 + if len(param.Where.CreateTime[1]) > 0 {
  341 + t, err := time.ParseInLocation("2006-01-02", param.Where.CreateTime[1], time.Local)
335 if err != nil { 342 if err != nil {
336 c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误")) 343 c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误"))
337 return 344 return
@@ -345,10 +352,10 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { @@ -345,10 +352,10 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
345 orderSrv := orderService.NewOrderInfoService(nil) 352 orderSrv := orderService.NewOrderInfoService(nil)
346 dataResult, column, err := orderSrv.ListOrderBonusForExcel( 353 dataResult, column, err := orderSrv.ListOrderBonusForExcel(
347 orderQuery.ListOrderBonusQuery{ 354 orderQuery.ListOrderBonusQuery{
348 - OrderType: param.OrderType,  
349 - PartnerOrCode: param.SearchWord, 355 + OrderType: param.Where.OrderType,
  356 + PartnerOrCode: param.Where.SearchWord,
350 CompanyId: companyId, 357 CompanyId: companyId,
351 - PartnerCategory: param.PartnerCategoryId, 358 + PartnerCategory: param.Where.PartnerCategoryId,
352 CreateTimeBegin: createTimeBegin, 359 CreateTimeBegin: createTimeBegin,
353 CreateTimeEnd: createTimeEnd, 360 CreateTimeEnd: createTimeEnd,
354 }) 361 })
@@ -1146,12 +1146,15 @@ func (c *OrderInfoController) ImportOrderFromExcel() { @@ -1146,12 +1146,15 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
1146 // 销售日期时间格式转换 1146 // 销售日期时间格式转换
1147 timeValue, err := time.ParseInLocation("2006/01/02", row[4], time.Local) 1147 timeValue, err := time.ParseInLocation("2006/01/02", row[4], time.Local)
1148 if err != nil { 1148 if err != nil {
1149 - e := lib.ThrowError(lib.ARG_ERROR, err.Error())  
1150 - c.ResponseError(e)  
1151 - return 1149 + var tmpRow []string
  1150 + tmpRow = append(tmpRow, "无效的销售日期") // 错误信息
  1151 + s := strconv.Itoa(i + 1)
  1152 + tmpRow = append(tmpRow, s) // 行号
  1153 + tmpRow = append(tmpRow, row...) // 错误行数据
  1154 + partnerDataList = append(partnerDataList, tmpRow)
  1155 + break
1152 } 1156 }
1153 1157
1154 - //saleDate, err := time.ParseInLocation("2006-01-02 15:04:05", param.SaleDate, time.Local)  
1155 saleDateWithTz := time.Date(timeValue.Year(), timeValue.Month(), timeValue.Day(), time.Now().Hour(), time.Now().Minute(), time.Now().Second(), time.Now().Nanosecond(), time.Local) 1158 saleDateWithTz := time.Date(timeValue.Year(), timeValue.Month(), timeValue.Day(), time.Now().Hour(), time.Now().Minute(), time.Now().Second(), time.Now().Nanosecond(), time.Local)
1156 1159
1157 fmt.Print("销售日期:", saleDateWithTz, "\n") 1160 fmt.Print("销售日期:", saleDateWithTz, "\n")
不能预览此文件类型