正在显示
34 个修改的文件
包含
1130 行增加
和
646 行删除
| @@ -9,5 +9,5 @@ require ( | @@ -9,5 +9,5 @@ require ( | ||
| 9 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 | 9 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 |
| 10 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect | 10 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect |
| 11 | github.com/shopspring/decimal v1.2.0 | 11 | github.com/shopspring/decimal v1.2.0 |
| 12 | - github.com/tiptok/gocomm v0.0.0-20190919092013-c230743f8095 | 12 | + github.com/tiptok/gocomm v1.0.0 |
| 13 | ) | 13 | ) |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
| 6 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 6 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
| 7 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg" | 7 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg" |
| 8 | + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/redis" | ||
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
| 9 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr" | 10 | _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr" |
| 10 | ) | 11 | ) |
| @@ -3,10 +3,7 @@ package auth | @@ -3,10 +3,7 @@ package auth | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" |
| 6 | - //"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/query" | ||
| 7 | - //"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/service" | ||
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
| 9 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr" | ||
| 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 11 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
| 12 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
| @@ -76,7 +73,7 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | @@ -76,7 +73,7 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | ||
| 76 | 73 | ||
| 77 | func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, err error) { | 74 | func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, err error) { |
| 78 | var data map[string]interface{} | 75 | var data map[string]interface{} |
| 79 | - sms := svr.NewHttplibMmmSmsApiServiceGateway() | 76 | + sms, _ := factory.CreateSmsCodeService() |
| 80 | data, err = sms.SendSms(request.Phone) | 77 | data, err = sms.SendSms(request.Phone) |
| 81 | rsp = &protocol.SmsCodeResponse{} | 78 | rsp = &protocol.SmsCodeResponse{} |
| 82 | if err != nil { | 79 | if err != nil { |
| @@ -106,6 +103,14 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke | @@ -106,6 +103,14 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke | ||
| 106 | rsp.AccessToken, _ = utils.GenerateToken(claim.UserId, protocol.TokenExpire*time.Second) | 103 | rsp.AccessToken, _ = utils.GenerateToken(claim.UserId, protocol.TokenExpire*time.Second) |
| 107 | rsp.RefreshToken, _ = utils.GenerateToken(claim.UserId, protocol.RefreshTokenExipre*time.Second) | 104 | rsp.RefreshToken, _ = utils.GenerateToken(claim.UserId, protocol.RefreshTokenExipre*time.Second) |
| 108 | rsp.ExpiresIn = protocol.TokenExpire | 105 | rsp.ExpiresIn = protocol.TokenExpire |
| 106 | + | ||
| 107 | + //auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(claim.UserId), | ||
| 108 | + // userAuth.WithAccessToken(rsp.AccessToken), | ||
| 109 | + // userAuth.WithRefreshToken(rsp.RefreshToken)) | ||
| 110 | + //if err = auth.AddAuth(); err != nil { | ||
| 111 | + // log.Error(err) | ||
| 112 | + // return | ||
| 113 | + //} | ||
| 109 | return | 114 | return |
| 110 | } | 115 | } |
| 111 | 116 | ||
| @@ -122,16 +127,29 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | @@ -122,16 +127,29 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT | ||
| 122 | err = protocol.NewErrWithMessage(1, fmt.Errorf("jwt refrshToken (%v) valid", request.RefreshToken)) | 127 | err = protocol.NewErrWithMessage(1, fmt.Errorf("jwt refrshToken (%v) valid", request.RefreshToken)) |
| 123 | return | 128 | return |
| 124 | } | 129 | } |
| 130 | + //oldAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(claim.UserId)) | ||
| 131 | + //if err = oldAuth.Check(userAuth.NewOptions(userAuth.WithRefreshToken(request.RefreshToken))); err != nil { | ||
| 132 | + // log.Error(err) | ||
| 133 | + // err = protocol.NewErrWithMessage(4140, err) | ||
| 134 | + // return | ||
| 135 | + //} | ||
| 125 | rsp.AccessToken, _ = utils.GenerateToken(claim.UserId, protocol.TokenExpire*time.Second) | 136 | rsp.AccessToken, _ = utils.GenerateToken(claim.UserId, protocol.TokenExpire*time.Second) |
| 126 | rsp.RefreshToken, _ = utils.GenerateToken(claim.UserId, protocol.RefreshTokenExipre*time.Second) | 137 | rsp.RefreshToken, _ = utils.GenerateToken(claim.UserId, protocol.RefreshTokenExipre*time.Second) |
| 127 | rsp.ExpiresIn = protocol.TokenExpire | 138 | rsp.ExpiresIn = protocol.TokenExpire |
| 128 | - return | 139 | + |
| 140 | + //newAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(claim.UserId), | ||
| 141 | + // userAuth.WithAccessToken(rsp.AccessToken), | ||
| 142 | + // userAuth.WithRefreshToken(rsp.RefreshToken)) | ||
| 143 | + //if err = newAuth.AddAuth(); err != nil { | ||
| 144 | + // log.Error(err) | ||
| 145 | + // return | ||
| 146 | + //} | ||
| 129 | return | 147 | return |
| 130 | } | 148 | } |
| 131 | 149 | ||
| 132 | //验证短信验证码 T | 150 | //验证短信验证码 T |
| 133 | func CheckSmsCode(phone, code string) (result bool, err error) { | 151 | func CheckSmsCode(phone, code string) (result bool, err error) { |
| 134 | - sms := svr.NewHttplibMmmSmsApiServiceGateway() | 152 | + sms, _ := factory.CreateSmsCodeService() |
| 135 | var data map[string]interface{} | 153 | var data map[string]interface{} |
| 136 | data, err = sms.CheckSmsCode(phone, code) | 154 | data, err = sms.CheckSmsCode(phone, code) |
| 137 | if err != nil { | 155 | if err != nil { |
| @@ -154,3 +172,18 @@ func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthChec | @@ -154,3 +172,18 @@ func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthChec | ||
| 154 | } | 172 | } |
| 155 | return | 173 | return |
| 156 | } | 174 | } |
| 175 | + | ||
| 176 | +//注销登录 | ||
| 177 | +func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rsp *protocol.RevokeResponse, err error) { | ||
| 178 | + //auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(header.UserId)) | ||
| 179 | + //rsp = &protocol.RevokeResponse{} | ||
| 180 | + //if !auth.Exist() { | ||
| 181 | + // return | ||
| 182 | + //} | ||
| 183 | + //if err = auth.RemoveAuth(); err != nil { | ||
| 184 | + // log.Error(err) | ||
| 185 | + // err = protocol.NewErrWithMessage(4140, err) | ||
| 186 | + // return | ||
| 187 | + //} | ||
| 188 | + return | ||
| 189 | +} |
| @@ -3,18 +3,17 @@ package dividend | @@ -3,18 +3,17 @@ package dividend | ||
| 3 | import ( | 3 | import ( |
| 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
| 6 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | ||
| 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
| 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
| 10 | "time" | 9 | "time" |
| 11 | ) | 10 | ) |
| 12 | 11 | ||
| 13 | -//分红统计 | ||
| 14 | -func DividendStatistics(header *protocol.RequestHeader, request *protocol.DividendStatisticsRequest) (rsp *protocol.DividendStatisticsResponse, err error) { | 12 | +// 分红统计 |
| 13 | +func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatisticsRequest) (rsp *protocol.DividendStatisticsResponse, err error) { | ||
| 15 | var ( | 14 | var ( |
| 16 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 17 | - OrderResponsitory, _ = factory.CreateOrderRepository(transactionContext) | 15 | + transactionContext, _ = factory.CreateTransactionContext(nil) |
| 16 | + OrderBaseResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext) | ||
| 18 | //beginTime = time.Unix(request.StartTime/1000, 0) | 17 | //beginTime = time.Unix(request.StartTime/1000, 0) |
| 19 | //endTime = time.Unix(request.EndTime/1000, 0) | 18 | //endTime = time.Unix(request.EndTime/1000, 0) |
| 20 | ) | 19 | ) |
| @@ -24,13 +23,13 @@ func DividendStatistics(header *protocol.RequestHeader, request *protocol.Divide | @@ -24,13 +23,13 @@ func DividendStatistics(header *protocol.RequestHeader, request *protocol.Divide | ||
| 24 | defer func() { | 23 | defer func() { |
| 25 | transactionContext.RollbackTransaction() | 24 | transactionContext.RollbackTransaction() |
| 26 | }() | 25 | }() |
| 27 | - _, orderAll, e := OrderResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: header.UserId, EndTime: time.Now(), SortByCreateTime: domain.DESC, OrderType: domain.OrderReal})) | 26 | + _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: header.UserId, EndTime: time.Now(), SortByCreateTime: domain.DESC, OrderType: domain.OrderReal, IsDisable: "0"})) |
| 28 | if e != nil { | 27 | if e != nil { |
| 29 | log.Error(e) | 28 | log.Error(e) |
| 30 | } | 29 | } |
| 31 | - var orderBetween []*domain.Order | 30 | + var orderBetween []*domain.OrderBase |
| 32 | for i := range orderAll { | 31 | for i := range orderAll { |
| 33 | - if orderAll[i].CreateAt.Unix() >= (request.StartTime/1000) && orderAll[i].CreateAt.Unix() < (request.EndTime/1000) { | 32 | + if orderAll[i].CreateTime.Unix() >= (request.StartTime/1000) && orderAll[i].CreateTime.Unix() < (request.EndTime/1000) { |
| 34 | orderBetween = append(orderBetween, orderAll[i]) | 33 | orderBetween = append(orderBetween, orderAll[i]) |
| 35 | } | 34 | } |
| 36 | } | 35 | } |
| @@ -46,8 +45,8 @@ func DividendStatistics(header *protocol.RequestHeader, request *protocol.Divide | @@ -46,8 +45,8 @@ func DividendStatistics(header *protocol.RequestHeader, request *protocol.Divide | ||
| 46 | return | 45 | return |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | -//累计分红 | ||
| 50 | -func AllBonusStatics(orders []*domain.Order, action int) (bonus protocol.Bonus) { | 48 | +// 累计分红 |
| 49 | +func AllBonusStatics(orders []*domain.OrderBase, action int) (bonus protocol.Bonus) { | ||
| 51 | bonus = protocol.Bonus{} | 50 | bonus = protocol.Bonus{} |
| 52 | for i := range orders { | 51 | for i := range orders { |
| 53 | o := orders[i] | 52 | o := orders[i] |
| @@ -57,12 +56,12 @@ func AllBonusStatics(orders []*domain.Order, action int) (bonus protocol.Bonus) | @@ -57,12 +56,12 @@ func AllBonusStatics(orders []*domain.Order, action int) (bonus protocol.Bonus) | ||
| 57 | return | 56 | return |
| 58 | } | 57 | } |
| 59 | 58 | ||
| 60 | -//订单-季度分红统计 | ||
| 61 | -func QuartersBonusStatics(orders []*domain.Order, action int) (bonus []protocol.Bonus) { | 59 | +// 订单-季度分红统计 |
| 60 | +func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus []protocol.Bonus) { | ||
| 62 | bonus = make([]protocol.Bonus, 4) | 61 | bonus = make([]protocol.Bonus, 4) |
| 63 | for i := range orders { | 62 | for i := range orders { |
| 64 | o := orders[i] | 63 | o := orders[i] |
| 65 | - quarter := (o.CreateAt.Month() - 1) / 3 | 64 | + quarter := (o.CreateTime.Month() - 1) / 3 |
| 66 | bonus[quarter].Received = utils.Decimal(bonus[quarter].Received + o.OrderBonusReceive()) | 65 | bonus[quarter].Received = utils.Decimal(bonus[quarter].Received + o.OrderBonusReceive()) |
| 67 | bonus[quarter].Outstanding = utils.Decimal(bonus[quarter].Outstanding + o.OrderBonusWait()) | 66 | bonus[quarter].Outstanding = utils.Decimal(bonus[quarter].Outstanding + o.OrderBonusWait()) |
| 68 | bonus[quarter].Expend = utils.Decimal(bonus[quarter].Expend + o.OrderBonusOutstanding()) | 67 | bonus[quarter].Expend = utils.Decimal(bonus[quarter].Expend + o.OrderBonusOutstanding()) |
| @@ -70,12 +69,12 @@ func QuartersBonusStatics(orders []*domain.Order, action int) (bonus []protocol. | @@ -70,12 +69,12 @@ func QuartersBonusStatics(orders []*domain.Order, action int) (bonus []protocol. | ||
| 70 | return | 69 | return |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | -//分红订单 | ||
| 74 | -func DividendOrders(header *protocol.RequestHeader, request *protocol.DividendOrdersRequest) (rsp *protocol.DividendOrdersResponse, err error) { | 72 | +// 分红订单 |
| 73 | +func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersRequest) (rsp *protocol.DividendOrdersResponse, err error) { | ||
| 75 | var ( | 74 | var ( |
| 76 | transactionContext, _ = factory.CreateTransactionContext(nil) | 75 | transactionContext, _ = factory.CreateTransactionContext(nil) |
| 77 | - OrderDao, _ = factory.CreateOrderDao(transactionContext) | ||
| 78 | - orders []*models.Order | 76 | + OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) |
| 77 | + orders []*domain.OrderBase | ||
| 79 | count int | 78 | count int |
| 80 | ) | 79 | ) |
| 81 | if err = transactionContext.StartTransaction(); err != nil { | 80 | if err = transactionContext.StartTransaction(); err != nil { |
| @@ -91,6 +90,7 @@ func DividendOrders(header *protocol.RequestHeader, request *protocol.DividendOr | @@ -91,6 +90,7 @@ func DividendOrders(header *protocol.RequestHeader, request *protocol.DividendOr | ||
| 91 | PartnerId: header.UserId, | 90 | PartnerId: header.UserId, |
| 92 | DetailAction: request.DetailAction, | 91 | DetailAction: request.DetailAction, |
| 93 | DividendAction: request.DividendAction, | 92 | DividendAction: request.DividendAction, |
| 93 | + IsDisable: "0", | ||
| 94 | StartTime: request.StartTime, | 94 | StartTime: request.StartTime, |
| 95 | EndTime: request.EndTime, | 95 | EndTime: request.EndTime, |
| 96 | Offset: request.PageIndex * request.PageSize, | 96 | Offset: request.PageIndex * request.PageSize, |
| @@ -104,10 +104,10 @@ func DividendOrders(header *protocol.RequestHeader, request *protocol.DividendOr | @@ -104,10 +104,10 @@ func DividendOrders(header *protocol.RequestHeader, request *protocol.DividendOr | ||
| 104 | for i := range orders { | 104 | for i := range orders { |
| 105 | o := orders[i] | 105 | o := orders[i] |
| 106 | item := &protocol.DividendOrderListItem{ | 106 | item := &protocol.DividendOrderListItem{ |
| 107 | - Id: o.Id, | ||
| 108 | - OrderNo: o.OrderCode, | ||
| 109 | - OrderAmount: o.OrderActualAmount, | ||
| 110 | - MyDividend: utils.Decimal(o.OrderActualAmount * (o.PartnerBonusPercent / 100.0)), | 107 | + Id: o.Id, |
| 108 | + DeliveryNo: o.DeliveryCode, | ||
| 109 | + OrderAmount: o.OrderAmount(), | ||
| 110 | + DividendReceivable: utils.Decimal(o.OrderTotalBonus()), | ||
| 111 | } | 111 | } |
| 112 | rsp.List = append(rsp.List, item) | 112 | rsp.List = append(rsp.List, item) |
| 113 | } | 113 | } |
| @@ -5,18 +5,10 @@ import ( | @@ -5,18 +5,10 @@ import ( | ||
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | -//func CreateTaskDao(options map[string]interface{}) (*dao.TaskDao, error) { | ||
| 9 | -// var transactionContext *pg.TransactionContext | ||
| 10 | -// if value, ok := options["transactionContext"]; ok { | ||
| 11 | -// transactionContext = value.(*pg.TransactionContext) | ||
| 12 | -// } | ||
| 13 | -// return dao.NewTaskDao(transactionContext) | ||
| 14 | -//} | ||
| 15 | - | ||
| 16 | -func CreateOrderDao(ctx *transaction.TransactionContext) (*dao.OrderDao, error) { | ||
| 17 | - return dao.NewOrderDao(ctx) | ||
| 18 | -} | ||
| 19 | - | ||
| 20 | func CreatePartnerInfoDao(ctx *transaction.TransactionContext) (*dao.PartnerInfoDao, error) { | 8 | func CreatePartnerInfoDao(ctx *transaction.TransactionContext) (*dao.PartnerInfoDao, error) { |
| 21 | return dao.NewPartnerInfoDao(ctx) | 9 | return dao.NewPartnerInfoDao(ctx) |
| 22 | } | 10 | } |
| 11 | + | ||
| 12 | +func CreateOrderBaseDao(ctx *transaction.TransactionContext) (*dao.OrderBaseDao, error) { | ||
| 13 | + return dao.NewOrderBaseDao(ctx) | ||
| 14 | +} |
| 1 | package factory | 1 | package factory |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | -//pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 5 | -//"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" | ||
| 6 | -//domainService "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/domain_service" | 4 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/service" |
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr" | ||
| 7 | ) | 6 | ) |
| 8 | 7 | ||
| 9 | -//func CreateReadSentNotificationService(options map[string]interface{}) (service.ReadSentNotificationService, error) { | ||
| 10 | -// var transactionContext *pgTransaction.TransactionContext | ||
| 11 | -// if value, ok := options["transactionContext"]; ok { | ||
| 12 | -// transactionContext = value.(*pgTransaction.TransactionContext) | ||
| 13 | -// } | ||
| 14 | -// return domainService.NewReadSentNotificationService(transactionContext) | ||
| 15 | -//} | 8 | +func CreateSmsCodeService() (service.SmsCodeService, error) { |
| 9 | + return svr.NewHttplibMmmSmsApiServiceGateway(), nil | ||
| 10 | +} |
| @@ -24,16 +24,6 @@ func CreateAdminUserRepository(options map[string]interface{}) (domain.AdminUser | @@ -24,16 +24,6 @@ func CreateAdminUserRepository(options map[string]interface{}) (domain.AdminUser | ||
| 24 | return repository.NewAdminUserRepository(transactionContext) | 24 | return repository.NewAdminUserRepository(transactionContext) |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | -//CreateOrderRepository 订单 | ||
| 28 | -func CreateOrderRepository(transactionContext *transaction.TransactionContext) (domain.OrderRepository, error) { | ||
| 29 | - return repository.NewOrderRepository(transactionContext) | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | -//CreateOrderRepository 订单 | ||
| 33 | -func CreateOrderPaymentRepository(transactionContext *transaction.TransactionContext) (domain.OrderPaymentRepository, error) { | ||
| 34 | - return repository.NewOrderPaymentRepository(transactionContext) | ||
| 35 | -} | ||
| 36 | - | ||
| 37 | func CreatePartnerInfoRepositoryIn(transactionContext *transaction.TransactionContext) (domain.PartnerInfoRepository, error) { | 27 | func CreatePartnerInfoRepositoryIn(transactionContext *transaction.TransactionContext) (domain.PartnerInfoRepository, error) { |
| 38 | return repository.NewPartnerInfoRepository(transactionContext) | 28 | return repository.NewPartnerInfoRepository(transactionContext) |
| 39 | } | 29 | } |
| @@ -46,3 +36,13 @@ func CreatePartnerSubAccountRepository(transactionContext *transaction.Transacti | @@ -46,3 +36,13 @@ func CreatePartnerSubAccountRepository(transactionContext *transaction.Transacti | ||
| 46 | func CreateCompanyRepository(transactionContext *transaction.TransactionContext) (domain.CompanyRepository, error) { | 36 | func CreateCompanyRepository(transactionContext *transaction.TransactionContext) (domain.CompanyRepository, error) { |
| 47 | return repository.NewCompanyRepository(transactionContext) | 37 | return repository.NewCompanyRepository(transactionContext) |
| 48 | } | 38 | } |
| 39 | + | ||
| 40 | +//CreateOrderBaseRepository 订单基础 | ||
| 41 | +func CreateOrderBaseRepository(transactionContext *transaction.TransactionContext) (domain.OrderBaseRepository, error) { | ||
| 42 | + return repository.NewOrderBaseRepository(transactionContext) | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +//CreateOrderGoodRepository 订单基础 | ||
| 46 | +func CreateOrderGoodRepository(transactionContext *transaction.TransactionContext) (domain.OrderGoodRepository, error) { | ||
| 47 | + return repository.NewOrderGoodRepository(transactionContext) | ||
| 48 | +} |
| @@ -2,10 +2,7 @@ package order | @@ -2,10 +2,7 @@ package order | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" |
| 5 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
| 6 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
| 8 | - "time" | ||
| 9 | ) | 6 | ) |
| 10 | 7 | ||
| 11 | func Template(header *protocol.RequestHeader, request *protocol.OrderDetailRequest) (rsp *protocol.OrderDetailResponse, err error) { | 8 | func Template(header *protocol.RequestHeader, request *protocol.OrderDetailRequest) (rsp *protocol.OrderDetailResponse, err error) { |
| @@ -23,195 +20,3 @@ func Template(header *protocol.RequestHeader, request *protocol.OrderDetailReque | @@ -23,195 +20,3 @@ func Template(header *protocol.RequestHeader, request *protocol.OrderDetailReque | ||
| 23 | err = transactionContext.CommitTransaction() | 20 | err = transactionContext.CommitTransaction() |
| 24 | return | 21 | return |
| 25 | } | 22 | } |
| 26 | - | ||
| 27 | -//订单详情 | ||
| 28 | -func OrderDetail(header *protocol.RequestHeader, request *protocol.OrderDetailRequest) (rsp *protocol.OrderDetailResponse, err error) { | ||
| 29 | - var ( | ||
| 30 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 31 | - OrderResponsitory, _ = factory.CreateOrderRepository(transactionContext) | ||
| 32 | - OrderDao, _ = factory.CreateOrderDao(transactionContext) | ||
| 33 | - order *domain.Order | ||
| 34 | - ) | ||
| 35 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 36 | - return nil, err | ||
| 37 | - } | ||
| 38 | - defer func() { | ||
| 39 | - transactionContext.RollbackTransaction() | ||
| 40 | - }() | ||
| 41 | - | ||
| 42 | - rsp = &protocol.OrderDetailResponse{} | ||
| 43 | - if order, err = OrderResponsitory.FindOne(utils.ObjectJsonToMap(request)); err != nil { | ||
| 44 | - return | ||
| 45 | - } | ||
| 46 | - rsp.Order = protocol.OrderDetail{ | ||
| 47 | - Id: order.Id, | ||
| 48 | - OrderNo: order.OrderCode, | ||
| 49 | - OrderName: order.OrderName, | ||
| 50 | - OrderStatus: order.OrderStatus, | ||
| 51 | - CreateTime: order.CreateAt.Unix() * 1000, | ||
| 52 | - UpdateTime: order.UpdateAt.Unix() * 1000, | ||
| 53 | - OrderQuantity: order.OrderActualCount, | ||
| 54 | - OrderAmount: order.OrderActualAmount, | ||
| 55 | - OrderAmountCancel: order.OrderAmountCancel(), | ||
| 56 | - OrderUpdateReason: order.Reason, | ||
| 57 | - OrderDistrict: map[string]interface{}{"id": order.OrderRegionInfo.RegionId, "name": order.OrderRegionInfo.RegionName}, | ||
| 58 | - Customer: protocol.Customer{Uname: order.Buyer.BuyerName, Phone: order.Buyer.ContactInfo}, | ||
| 59 | - MyDividend: order.OrderTotalBonus(), | ||
| 60 | - MyDividendPercent: order.PartnerBonusPercent, | ||
| 61 | - } | ||
| 62 | - if header.UserId == order.PartnerId && order.UpdateAt.After(order.LastViewTime) { | ||
| 63 | - if err = OrderDao.UpdateLastViewTime(order.Id, time.Now()); err != nil { | ||
| 64 | - return | ||
| 65 | - } | ||
| 66 | - } | ||
| 67 | - err = transactionContext.CommitTransaction() | ||
| 68 | - return | ||
| 69 | -} | ||
| 70 | - | ||
| 71 | -//订单统计 | ||
| 72 | -func OrderStatistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { | ||
| 73 | - var ( | ||
| 74 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 75 | - OrderDao, _ = factory.CreateOrderDao(transactionContext) | ||
| 76 | - ) | ||
| 77 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 78 | - return nil, err | ||
| 79 | - } | ||
| 80 | - defer func() { | ||
| 81 | - transactionContext.RollbackTransaction() | ||
| 82 | - }() | ||
| 83 | - rsp = &protocol.OrderStatisticsResponse{Statistics: protocol.OrderStatics{}} | ||
| 84 | - if rsp.Statistics.TodayIntentionQuantity, rsp.Statistics.TodayIntentionMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 85 | - BeginTime: utils.GetDayBegin().Unix() * 1000, | ||
| 86 | - EndTime: utils.GetDayEnd().Unix() * 1000, | ||
| 87 | - OrderType: domain.OrderIntention, | ||
| 88 | - PartnerId: header.UserId, | ||
| 89 | - }); err != nil { | ||
| 90 | - return | ||
| 91 | - } | ||
| 92 | - if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 93 | - BeginTime: utils.GetDayBegin().Unix() * 1000, | ||
| 94 | - EndTime: utils.GetDayEnd().Unix() * 1000, | ||
| 95 | - OrderType: domain.OrderReal, | ||
| 96 | - PartnerId: header.UserId, | ||
| 97 | - }); err != nil { | ||
| 98 | - return | ||
| 99 | - } | ||
| 100 | - if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 101 | - EndTime: time.Now().Unix() * 1000, | ||
| 102 | - OrderType: domain.OrderReal, | ||
| 103 | - PartnerId: header.UserId, | ||
| 104 | - }); err != nil { | ||
| 105 | - return | ||
| 106 | - } | ||
| 107 | - err = transactionContext.CommitTransaction() | ||
| 108 | - return | ||
| 109 | -} | ||
| 110 | - | ||
| 111 | -//订单列表 | ||
| 112 | -func OrderList(header *protocol.RequestHeader, request *protocol.OrderListRequest) (rsp *protocol.OrderListResponse, err error) { | ||
| 113 | - var ( | ||
| 114 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 115 | - OrderResponsitory, _ = factory.CreateOrderRepository(transactionContext) | ||
| 116 | - OrderDao, _ = factory.CreateOrderDao(transactionContext) | ||
| 117 | - orders []*domain.Order | ||
| 118 | - ) | ||
| 119 | - | ||
| 120 | - rsp = &protocol.OrderListResponse{ | ||
| 121 | - List: make([]*protocol.OrderListItem, 0), | ||
| 122 | - Statistics: make(map[string]interface{}), | ||
| 123 | - } | ||
| 124 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 125 | - return nil, err | ||
| 126 | - } | ||
| 127 | - defer func() { | ||
| 128 | - transactionContext.RollbackTransaction() | ||
| 129 | - }() | ||
| 130 | - queryOption := &domain.OrderQueryOption{ | ||
| 131 | - PartnerId: header.UserId, | ||
| 132 | - Limit: request.PageSize, | ||
| 133 | - Offset: request.PageSize * request.PageIndex, | ||
| 134 | - SortByUpdateTime: domain.DESC, | ||
| 135 | - } | ||
| 136 | - if request.OrderAction == 1 { | ||
| 137 | - queryOption.OrderStatus = domain.OrderStatusDeliverSome | ||
| 138 | - } else if request.OrderAction == 2 { | ||
| 139 | - queryOption.OrderStatus = domain.OrderStatusDeliverAll | ||
| 140 | - } | ||
| 141 | - if request.StartTime > 0 { | ||
| 142 | - queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) | ||
| 143 | - } | ||
| 144 | - if request.EndTime > 0 { | ||
| 145 | - queryOption.EndTime = time.Unix(request.EndTime/1000, 0) | ||
| 146 | - } | ||
| 147 | - queryOption.OrderType = request.OrderType | ||
| 148 | - _, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption)) | ||
| 149 | - //统计数据 | ||
| 150 | - if request.PageIndex == 0 { | ||
| 151 | - var ( | ||
| 152 | - partShipmentQuantity, allShipmentQuantity int | ||
| 153 | - cumulativeQuantity, intentionQuantity int | ||
| 154 | - ) | ||
| 155 | - //部分发货的订单数量 | ||
| 156 | - partShipmentQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 157 | - EndTime: request.EndTime, | ||
| 158 | - BeginTime: request.StartTime, | ||
| 159 | - OrderType: domain.OrderReal, | ||
| 160 | - PartnerId: header.UserId, | ||
| 161 | - OrderStatus: domain.OrderStatusDeliverSome, | ||
| 162 | - }) | ||
| 163 | - //全部发货的订单数量 | ||
| 164 | - allShipmentQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 165 | - EndTime: request.EndTime, | ||
| 166 | - BeginTime: request.StartTime, | ||
| 167 | - OrderType: domain.OrderReal, | ||
| 168 | - PartnerId: header.UserId, | ||
| 169 | - OrderStatus: domain.OrderStatusDeliverAll, | ||
| 170 | - }) | ||
| 171 | - //累计实发订单 | ||
| 172 | - cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 173 | - EndTime: time.Now().Unix() * 1000, | ||
| 174 | - //BeginTime: request.StartTime, | ||
| 175 | - OrderType: domain.OrderReal, | ||
| 176 | - PartnerId: header.UserId, | ||
| 177 | - }) | ||
| 178 | - //累计意向订单 | ||
| 179 | - intentionQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 180 | - EndTime: time.Now().Unix() * 1000, | ||
| 181 | - //BeginTime: request.StartTime, | ||
| 182 | - OrderType: domain.OrderIntention, | ||
| 183 | - PartnerId: header.UserId, | ||
| 184 | - }) | ||
| 185 | - //订单数量 | ||
| 186 | - rsp.Statistics["partShipmentQuantity"] = partShipmentQuantity | ||
| 187 | - rsp.Statistics["allShipmentQuantity"] = allShipmentQuantity | ||
| 188 | - rsp.Statistics["orderQuantity"] = partShipmentQuantity + allShipmentQuantity //所有订单 = 部分发货 + 已经发货 | ||
| 189 | - rsp.Statistics["cumulativeQuantity"] = cumulativeQuantity //实发订单 = 部分发货 + 全部发货 | ||
| 190 | - rsp.Statistics["intentionQuantity"] = intentionQuantity | ||
| 191 | - | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - if len(orders) == 0 { | ||
| 195 | - return | ||
| 196 | - } | ||
| 197 | - for i := range orders { | ||
| 198 | - rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i])) | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - err = transactionContext.CommitTransaction() | ||
| 202 | - return | ||
| 203 | -} | ||
| 204 | -func DomainOrderToOrderListItem(order *domain.Order) *protocol.OrderListItem { | ||
| 205 | - return &protocol.OrderListItem{ | ||
| 206 | - Id: order.Id, | ||
| 207 | - OrderType: order.OrderType, | ||
| 208 | - OrderNo: order.OrderCode, | ||
| 209 | - OrderName: order.OrderName, | ||
| 210 | - OrderAmount: order.OrderActualAmount, | ||
| 211 | - OrderActualCount: order.OrderActualCount, | ||
| 212 | - OrderStatus: order.OrderStatus, | ||
| 213 | - UpdateTime: order.UpdateAt.Unix() * 1000, | ||
| 214 | - MyDividend: order.OrderTotalBonus(), | ||
| 215 | - IsRead: order.IsRead(), | ||
| 216 | - } | ||
| 217 | -} |
pkg/application/order/order_v2.go
0 → 100644
| 1 | +package order | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | ||
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | ||
| 9 | + "time" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +// 订单详情 | ||
| 13 | +func Detail(header *protocol.RequestHeader, request *protocol.OrderDetailRequest) (rsp *protocol.OrderDetailResponse, err error) { | ||
| 14 | + var ( | ||
| 15 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 16 | + OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext) | ||
| 17 | + OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
| 18 | + order *domain.OrderBase | ||
| 19 | + ) | ||
| 20 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 21 | + return nil, err | ||
| 22 | + } | ||
| 23 | + defer func() { | ||
| 24 | + transactionContext.RollbackTransaction() | ||
| 25 | + }() | ||
| 26 | + | ||
| 27 | + rsp = &protocol.OrderDetailResponse{} | ||
| 28 | + if order, err = OrderResponsitory.FindOne(utils.ObjectJsonToMap(request)); err != nil { | ||
| 29 | + log.Error(err) | ||
| 30 | + return | ||
| 31 | + } | ||
| 32 | + rsp.Order = protocol.OrderDetailVO{ | ||
| 33 | + Id: order.Id, | ||
| 34 | + OrderNo: order.OrderCode, | ||
| 35 | + DeliveryNo: order.DeliveryCode, | ||
| 36 | + OrderStatus: orderStatus(order), | ||
| 37 | + CreateTime: order.CreateTime.Unix() * 1000, | ||
| 38 | + UpdateTime: order.UpdateTime.Unix() * 1000, | ||
| 39 | + OrderDistrict: map[string]interface{}{"id": order.RegionInfo.RegionId, "name": order.RegionInfo.RegionName}, | ||
| 40 | + Customer: protocol.Customer{Uname: order.Buyer.BuyerName, Phone: order.Buyer.ContactInfo}, | ||
| 41 | + Product: orderProducts(order), | ||
| 42 | + Total: orderTotalStatic(order), | ||
| 43 | + } | ||
| 44 | + if header.UserId == order.PartnerId && order.UpdateTime.After(order.LastViewTime) { | ||
| 45 | + if err = OrderDao.UpdateLastViewTime(order.Id, time.Now()); err != nil { | ||
| 46 | + return | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + err = transactionContext.CommitTransaction() | ||
| 50 | + return | ||
| 51 | +} | ||
| 52 | +func orderStatus(order *domain.OrderBase) int { | ||
| 53 | + var hasBonus = false | ||
| 54 | + for i := range order.OrderGood { | ||
| 55 | + good := order.OrderGood[i] | ||
| 56 | + if good.BonusStatus == domain.BonusPaid { | ||
| 57 | + hasBonus = true | ||
| 58 | + break | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + if hasBonus { | ||
| 62 | + if order.UseOrderCount > 0 && order.UseOrderCount < order.PlanOrderCount { | ||
| 63 | + return 3 // 已支付退货 | ||
| 64 | + } | ||
| 65 | + return 2 // 已支付分红 | ||
| 66 | + } | ||
| 67 | + if !hasBonus { | ||
| 68 | + if order.UseOrderCount > 0 && order.UseOrderCount < order.PlanOrderCount { | ||
| 69 | + return 4 // 待支付退货 | ||
| 70 | + } | ||
| 71 | + return 1 | ||
| 72 | + } | ||
| 73 | + return 1 | ||
| 74 | +} | ||
| 75 | +func orderProducts(order *domain.OrderBase) interface{} { | ||
| 76 | + var products []map[string]interface{} | ||
| 77 | + for i := range order.OrderGood { | ||
| 78 | + good := order.OrderGood[i] | ||
| 79 | + item := make(map[string]interface{}) | ||
| 80 | + item["productName"] = good.GoodName | ||
| 81 | + item["orderCount"] = good.PlanGoodNumber | ||
| 82 | + item["orderAmount"] = good.PlanAmount | ||
| 83 | + item["dividendPercent"] = good.PartnerBonusPercent | ||
| 84 | + item["dividendReceivable"] = good.PartnerBonusHas | ||
| 85 | + item["dividendUnReceive"] = good.PartnerBonusNot | ||
| 86 | + item["dividendExpend"] = good.PartnerBonusExpense | ||
| 87 | + if len(good.Remark) > 0 { | ||
| 88 | + item["orderUpdateReason"] = good.Remark | ||
| 89 | + } | ||
| 90 | + item["dividendStatus"] = good.Status() | ||
| 91 | + if good.Status() > 2 { | ||
| 92 | + item["countAdjust"] = good.UseGoodNumber | ||
| 93 | + item["amountAdjust"] = good.UseAmount | ||
| 94 | + } | ||
| 95 | + products = append(products, item) | ||
| 96 | + } | ||
| 97 | + return products | ||
| 98 | +} | ||
| 99 | +func orderTotalStatic(order *domain.OrderBase) interface{} { | ||
| 100 | + item := make(map[string]interface{}) | ||
| 101 | + item["totalCount"] = order.PlanOrderCount | ||
| 102 | + item["totalAmount"] = order.PlanOrderAmount | ||
| 103 | + item["totalDividendReceivable"] = order.OrderTotalBonus() | ||
| 104 | + item["totalReceived"] = order.OrderBonusReceive() | ||
| 105 | + item["totalUnReceive"] = order.OrderBonusWait() | ||
| 106 | + item["totalExpend"] = order.OrderBonusOutstanding() | ||
| 107 | + if order.UseOrderCount > 0 { | ||
| 108 | + item["totalCountAdjust"] = order.UseOrderCount | ||
| 109 | + item["totalAmountAdjust"] = order.UseOrderAmount | ||
| 110 | + } | ||
| 111 | + return item | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +// 订单统计 | ||
| 115 | +func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { | ||
| 116 | + var ( | ||
| 117 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 118 | + OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
| 119 | + ) | ||
| 120 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 121 | + return nil, err | ||
| 122 | + } | ||
| 123 | + defer func() { | ||
| 124 | + transactionContext.RollbackTransaction() | ||
| 125 | + }() | ||
| 126 | + rsp = &protocol.OrderStatisticsResponse{Statistics: protocol.OrderStatics{}} | ||
| 127 | + //if rsp.Statistics.TodayIntentionQuantity, rsp.Statistics.TodayIntentionMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 128 | + // BeginTime: utils.GetDayBegin().Unix() * 1000, | ||
| 129 | + // EndTime: utils.GetDayEnd().Unix() * 1000, | ||
| 130 | + // OrderType: domain.OrderIntention, | ||
| 131 | + // PartnerId: header.UserId, | ||
| 132 | + //}); err != nil { | ||
| 133 | + // return | ||
| 134 | + //} | ||
| 135 | + if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 136 | + BeginTime: utils.GetDayBegin().Unix() * 1000, | ||
| 137 | + EndTime: utils.GetDayEnd().Unix() * 1000, | ||
| 138 | + OrderType: domain.OrderReal, | ||
| 139 | + PartnerId: header.UserId, | ||
| 140 | + }); err != nil { | ||
| 141 | + return | ||
| 142 | + } | ||
| 143 | + if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 144 | + EndTime: time.Now().Unix() * 1000, | ||
| 145 | + OrderType: domain.OrderReal, | ||
| 146 | + PartnerId: header.UserId, | ||
| 147 | + }); err != nil { | ||
| 148 | + return | ||
| 149 | + } | ||
| 150 | + err = transactionContext.CommitTransaction() | ||
| 151 | + return | ||
| 152 | +} | ||
| 153 | + | ||
| 154 | +// 订单列表 | ||
| 155 | +func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (rsp *protocol.OrderListResponse, err error) { | ||
| 156 | + var ( | ||
| 157 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 158 | + OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext) | ||
| 159 | + OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
| 160 | + orders []*domain.OrderBase | ||
| 161 | + ) | ||
| 162 | + | ||
| 163 | + rsp = &protocol.OrderListResponse{ | ||
| 164 | + List: make([]*protocol.OrderListItem, 0), | ||
| 165 | + Statistics: make(map[string]interface{}), | ||
| 166 | + } | ||
| 167 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 168 | + return nil, err | ||
| 169 | + } | ||
| 170 | + defer func() { | ||
| 171 | + transactionContext.RollbackTransaction() | ||
| 172 | + }() | ||
| 173 | + queryOption := &domain.OrderQueryOption{ | ||
| 174 | + PartnerId: header.UserId, | ||
| 175 | + Limit: request.PageSize, | ||
| 176 | + Offset: request.PageSize * request.PageIndex, | ||
| 177 | + SortByUpdateTime: domain.DESC, | ||
| 178 | + IsDisable: "0", | ||
| 179 | + } | ||
| 180 | + if request.StartTime > 0 { | ||
| 181 | + queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) | ||
| 182 | + } | ||
| 183 | + if request.EndTime > 0 { | ||
| 184 | + queryOption.EndTime = time.Unix(request.EndTime/1000, 0) | ||
| 185 | + } | ||
| 186 | + queryOption.OrderType = request.OrderType | ||
| 187 | + _, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption)) | ||
| 188 | + //统计数据 | ||
| 189 | + if request.PageIndex == 0 { | ||
| 190 | + var ( | ||
| 191 | + partShipmentQuantity, allShipmentQuantity int | ||
| 192 | + cumulativeQuantity int | ||
| 193 | + ) | ||
| 194 | + //部分发货的订单数量 | ||
| 195 | + //partShipmentQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 196 | + // EndTime: request.EndTime, | ||
| 197 | + // BeginTime: request.StartTime, | ||
| 198 | + // OrderType: domain.OrderReal, | ||
| 199 | + // PartnerId: header.UserId, | ||
| 200 | + // OrderStatus: domain.OrderStatusDeliverSome, | ||
| 201 | + //}) | ||
| 202 | + //全部发货的订单数量 | ||
| 203 | + allShipmentQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 204 | + EndTime: request.EndTime, | ||
| 205 | + BeginTime: request.StartTime, | ||
| 206 | + OrderType: domain.OrderReal, | ||
| 207 | + PartnerId: header.UserId, | ||
| 208 | + //OrderStatus: domain.OrderStatusDeliverAll, | ||
| 209 | + }) | ||
| 210 | + //累计实发订单 | ||
| 211 | + cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 212 | + EndTime: time.Now().Unix() * 1000, | ||
| 213 | + //BeginTime: request.StartTime, | ||
| 214 | + OrderType: domain.OrderReal, | ||
| 215 | + PartnerId: header.UserId, | ||
| 216 | + }) | ||
| 217 | + //累计意向订单 | ||
| 218 | + //intentionQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 219 | + // EndTime: time.Now().Unix() * 1000, | ||
| 220 | + // //BeginTime: request.StartTime, | ||
| 221 | + // OrderType: domain.OrderIntention, | ||
| 222 | + // PartnerId: header.UserId, | ||
| 223 | + //}) | ||
| 224 | + //订单数量 | ||
| 225 | + //rsp.Statistics["partShipmentQuantity"] = partShipmentQuantity | ||
| 226 | + //rsp.Statistics["allShipmentQuantity"] = allShipmentQuantity | ||
| 227 | + rsp.Statistics["orderQuantity"] = partShipmentQuantity + allShipmentQuantity //所有订单 = 部分发货 + 已经发货 | ||
| 228 | + rsp.Statistics["cumulativeQuantity"] = cumulativeQuantity //实发订单 = 部分发货 + 全部发货 | ||
| 229 | + //rsp.Statistics["intentionQuantity"] = intentionQuantity | ||
| 230 | + | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + if len(orders) == 0 { | ||
| 234 | + return | ||
| 235 | + } | ||
| 236 | + for i := range orders { | ||
| 237 | + rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i])) | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + err = transactionContext.CommitTransaction() | ||
| 241 | + return | ||
| 242 | +} | ||
| 243 | +func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem { | ||
| 244 | + return &protocol.OrderListItem{ | ||
| 245 | + Id: order.Id, | ||
| 246 | + OrderType: order.OrderType, | ||
| 247 | + OrderNo: order.OrderCode, | ||
| 248 | + DeliveryNo: order.DeliveryCode, | ||
| 249 | + OrderAmount: order.OrderAmount(), | ||
| 250 | + UpdateTime: order.UpdateTime.Unix() * 1000, | ||
| 251 | + MyDividend: order.OrderTotalBonus(), | ||
| 252 | + IsRead: order.IsRead(), | ||
| 253 | + } | ||
| 254 | +} |
| @@ -144,6 +144,16 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo | @@ -144,6 +144,16 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo | ||
| 144 | }); err != nil { | 144 | }); err != nil { |
| 145 | return | 145 | return |
| 146 | } | 146 | } |
| 147 | + //清除auth token | ||
| 148 | + //auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(header.UserId)) | ||
| 149 | + //if !auth.Exist() { | ||
| 150 | + // return | ||
| 151 | + //} | ||
| 152 | + //if err = auth.RemoveAuth(); err != nil { | ||
| 153 | + // log.Error(err) | ||
| 154 | + // err = protocol.NewErrWithMessage(4140, err) | ||
| 155 | + // return | ||
| 156 | + //} | ||
| 147 | err = transactionContext.CommitTransaction() | 157 | err = transactionContext.CommitTransaction() |
| 148 | return | 158 | return |
| 149 | } | 159 | } |
| @@ -190,6 +200,16 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass | @@ -190,6 +200,16 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass | ||
| 190 | }); err != nil { | 200 | }); err != nil { |
| 191 | return | 201 | return |
| 192 | } | 202 | } |
| 203 | + //清除auth token | ||
| 204 | + //auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(header.UserId)) | ||
| 205 | + //if !auth.Exist() { | ||
| 206 | + // return | ||
| 207 | + //} | ||
| 208 | + //if err = auth.RemoveAuth(); err != nil { | ||
| 209 | + // log.Error(err) | ||
| 210 | + // err = protocol.NewErrWithMessage(4140, err) | ||
| 211 | + // return | ||
| 212 | + //} | ||
| 193 | err = transactionContext.CommitTransaction() | 213 | err = transactionContext.CommitTransaction() |
| 194 | return | 214 | return |
| 195 | } | 215 | } |
pkg/application/userAuth/user_auth.go
0 → 100644
| 1 | +package userAuth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "encoding/json" | ||
| 5 | + "fmt" | ||
| 6 | + "github.com/tiptok/gocomm/pkg/redis" | ||
| 7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 8 | + "strconv" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +var ( | ||
| 12 | + errDataType = fmt.Errorf("auth:data type assert error") | ||
| 13 | + errNoMatch = fmt.Errorf("auth:user auth no match") | ||
| 14 | + errNotFound = func(field string) error { return fmt.Errorf("auth:hset field (%v) not found", field) } | ||
| 15 | + errTokenNotEqual = func(target, compare string) error { | ||
| 16 | + return fmt.Errorf("auth:token not equal (%v != %v)", target, compare) | ||
| 17 | + } | ||
| 18 | +) | ||
| 19 | + | ||
| 20 | +type UserAuthManager interface { | ||
| 21 | + //添加用户权限 | ||
| 22 | + AddAuth() error | ||
| 23 | + //获取用户权限 | ||
| 24 | + GetAuth() (interface{}, error) | ||
| 25 | + //移除用户权限 | ||
| 26 | + RemoveAuth() error | ||
| 27 | + //检验权限 | ||
| 28 | + //检查 refreshToken assessToken 是否一致 | ||
| 29 | + Check(*Options) error | ||
| 30 | + //用户权限是否存在 | ||
| 31 | + //true:存在 false:不存在 | ||
| 32 | + Exist() bool | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +var _ UserAuthManager = (*RedisUserAuth)(nil) | ||
| 36 | + | ||
| 37 | +type Options struct { | ||
| 38 | + UserId int64 | ||
| 39 | + RefreshToken string | ||
| 40 | + AccessToken string | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +func NewOptions(options ...Option) *Options { | ||
| 44 | + Options := &Options{} | ||
| 45 | + for i := range options { | ||
| 46 | + options[i](Options) | ||
| 47 | + } | ||
| 48 | + return Options | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +type Option func(options *Options) | ||
| 52 | + | ||
| 53 | +//option 参数 | ||
| 54 | +func WithRefreshToken(token string) Option { | ||
| 55 | + return func(options *Options) { | ||
| 56 | + options.RefreshToken = token | ||
| 57 | + } | ||
| 58 | +} | ||
| 59 | +func WithAccessToken(token string) Option { | ||
| 60 | + return func(options *Options) { | ||
| 61 | + options.AccessToken = token | ||
| 62 | + } | ||
| 63 | +} | ||
| 64 | +func WithUserId(uid int64) Option { | ||
| 65 | + return func(options *Options) { | ||
| 66 | + options.UserId = uid | ||
| 67 | + } | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +//Redis用户权限 | ||
| 71 | +type RedisUserAuth struct { | ||
| 72 | + Options *Options | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +func NewRedisUserAuth(options ...Option) *RedisUserAuth { | ||
| 76 | + rua := &RedisUserAuth{ | ||
| 77 | + Options: NewOptions(options...), | ||
| 78 | + } | ||
| 79 | + return rua | ||
| 80 | +} | ||
| 81 | +func (auth RedisUserAuth) AddAuth() error { | ||
| 82 | + err := redis.Hset( | ||
| 83 | + auth.redisKey(), | ||
| 84 | + auth.field(), | ||
| 85 | + utils.JsonAssertString(NewRedisUserAuthData(auth.Options)), 0, | ||
| 86 | + ) | ||
| 87 | + return err | ||
| 88 | +} | ||
| 89 | +func (auth RedisUserAuth) RemoveAuth() error { | ||
| 90 | + if !auth.Exist() { | ||
| 91 | + return nil | ||
| 92 | + } | ||
| 93 | + return redis.Hdel(auth.redisKey(), auth.field()) | ||
| 94 | +} | ||
| 95 | +func (auth RedisUserAuth) GetAuth() (interface{}, error) { | ||
| 96 | + if !auth.Exist() { | ||
| 97 | + return nil, errNotFound(auth.field()) | ||
| 98 | + } | ||
| 99 | + data, err := redis.Hget(auth.redisKey(), auth.field()) | ||
| 100 | + if err != nil { | ||
| 101 | + return nil, err | ||
| 102 | + } | ||
| 103 | + var authData *RedisUserAuthData | ||
| 104 | + if err = json.Unmarshal([]byte(data), &authData); err != nil { | ||
| 105 | + return nil, err | ||
| 106 | + } | ||
| 107 | + return authData, nil | ||
| 108 | +} | ||
| 109 | +func (auth RedisUserAuth) Check(options *Options) error { | ||
| 110 | + data, err := auth.GetAuth() | ||
| 111 | + if err != nil { | ||
| 112 | + return err | ||
| 113 | + } | ||
| 114 | + authData, ok := data.(*RedisUserAuthData) | ||
| 115 | + if !ok { | ||
| 116 | + return errDataType | ||
| 117 | + } | ||
| 118 | + if options.AccessToken != "" { | ||
| 119 | + if authData.AccessToken != options.AccessToken { | ||
| 120 | + return errTokenNotEqual(authData.AccessToken, options.AccessToken) | ||
| 121 | + } | ||
| 122 | + return nil | ||
| 123 | + } | ||
| 124 | + if options.RefreshToken != "" { | ||
| 125 | + if authData.RefreshToken != options.RefreshToken { | ||
| 126 | + return errTokenNotEqual(authData.RefreshToken, options.RefreshToken) | ||
| 127 | + } | ||
| 128 | + return nil | ||
| 129 | + } | ||
| 130 | + return errNoMatch | ||
| 131 | +} | ||
| 132 | +func (auth RedisUserAuth) Exist() bool { | ||
| 133 | + return redis.Hexists(auth.redisKey(), auth.field()) | ||
| 134 | +} | ||
| 135 | +func (auth RedisUserAuth) redisKey() string { | ||
| 136 | + if auth.Options.UserId == 0 { | ||
| 137 | + return "" | ||
| 138 | + } | ||
| 139 | + return utils.RedisKey("user_auth") | ||
| 140 | +} | ||
| 141 | +func (auth RedisUserAuth) field() string { | ||
| 142 | + return strconv.Itoa(int(auth.Options.UserId)) | ||
| 143 | +} | ||
| 144 | + | ||
| 145 | +//存储到redis的数据结构 | ||
| 146 | +type RedisUserAuthData struct { | ||
| 147 | + UserId int64 `json:"userId"` | ||
| 148 | + RefreshToken string `json:"refreshToken"` | ||
| 149 | + AccessToken string `json:"accessToken"` | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +func NewRedisUserAuthData(options *Options) RedisUserAuthData { | ||
| 153 | + return RedisUserAuthData{ | ||
| 154 | + UserId: options.UserId, | ||
| 155 | + RefreshToken: options.RefreshToken, | ||
| 156 | + AccessToken: options.AccessToken, | ||
| 157 | + } | ||
| 158 | +} |
pkg/application/userAuth/user_auth_test.go
0 → 100644
| 1 | +package userAuth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "github.com/tiptok/gocomm/pkg/redis" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
| 7 | + "testing" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func initRedis() { | ||
| 11 | + redisSource := fmt.Sprintf("%v:%v", constant.REDIS_HOST, constant.REDIS_PORT) | ||
| 12 | + err := redis.InitWithDb(100, redisSource, constant.REDIS_AUTH, "0") | ||
| 13 | + if err != nil { | ||
| 14 | + panic(err) | ||
| 15 | + } | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func TestRedisUserAuth(t *testing.T) { | ||
| 19 | + initRedis() | ||
| 20 | + | ||
| 21 | + userAuth := NewRedisUserAuth(WithUserId(1), | ||
| 22 | + WithAccessToken("abc"), | ||
| 23 | + WithRefreshToken("cdf"), | ||
| 24 | + ) | ||
| 25 | + err := userAuth.AddAuth() | ||
| 26 | + if err != nil { | ||
| 27 | + t.Fatal(err) | ||
| 28 | + } | ||
| 29 | + _, err = userAuth.GetAuth() | ||
| 30 | + if err != nil { | ||
| 31 | + t.Fatal("get auth", err) | ||
| 32 | + } | ||
| 33 | + if !userAuth.Exist() { | ||
| 34 | + t.Fatal("except:true") | ||
| 35 | + } | ||
| 36 | + if err = userAuth.Check(NewOptions(WithAccessToken("abc"))); err != nil { | ||
| 37 | + t.Fatal("check accessToken:", err) | ||
| 38 | + } | ||
| 39 | + if err = userAuth.Check(NewOptions(WithRefreshToken("cdf"))); err != nil { | ||
| 40 | + t.Fatal("check refreshToken:", err) | ||
| 41 | + } | ||
| 42 | + if err = userAuth.RemoveAuth(); err != nil { | ||
| 43 | + t.Fatal("remove:", err) | ||
| 44 | + } | ||
| 45 | + if userAuth.field() != "1" { | ||
| 46 | + t.Fatal("except:1") | ||
| 47 | + } | ||
| 48 | + if userAuth.Exist() { | ||
| 49 | + t.Fatal("except:false") | ||
| 50 | + } | ||
| 51 | +} |
pkg/domain/order.go
已删除
100644 → 0
| 1 | -package domain | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 5 | - "time" | ||
| 6 | -) | ||
| 7 | - | ||
| 8 | -const ( | ||
| 9 | - OrderStatusReserve = iota + 1 //预定中 | ||
| 10 | - OrderStatusDeliverSome //部分发货 | ||
| 11 | - OrderStatusDeliverAll //全部发货 | ||
| 12 | -) | ||
| 13 | - | ||
| 14 | -const ( | ||
| 15 | - OrderReal = iota + 1 //实发订单 | ||
| 16 | - OrderIntention //意向订单 | ||
| 17 | -) | ||
| 18 | - | ||
| 19 | -type OrderRepository interface { | ||
| 20 | - Save(dm *Order) (*Order, error) | ||
| 21 | - Remove(dm *Order) (*Order, error) | ||
| 22 | - FindOne(queryOptions map[string]interface{}) (*Order, error) | ||
| 23 | - Find(queryOptions map[string]interface{}) (int64, []*Order, error) | ||
| 24 | -} | ||
| 25 | - | ||
| 26 | -//Order 订单信息 | ||
| 27 | -type Order struct { | ||
| 28 | - //id | ||
| 29 | - Id int64 `json:"Id,omitempty"` | ||
| 30 | - //订单类型 | ||
| 31 | - OrderType int `json:"orderType,omitempty"` | ||
| 32 | - //订单编号 | ||
| 33 | - OrderCode string `json:"orderCode,omitempty"` | ||
| 34 | - //订单名称 | ||
| 35 | - OrderName string `json:"orderName,omitempty"` | ||
| 36 | - //订单状态 | ||
| 37 | - OrderStatus int `json:"orderStatus,omitempty"` | ||
| 38 | - //订单数量 | ||
| 39 | - OrderCount int `json:"orderCount,omitempty"` | ||
| 40 | - //实际订单数量 | ||
| 41 | - OrderActualCount int `json:"orderActualCount,omitempty"` | ||
| 42 | - //订单金额 | ||
| 43 | - OrderAmount float64 `json:"admin_name,omitempty"` | ||
| 44 | - //订单实际金额 | ||
| 45 | - OrderActualAmount float64 `json:"orderActualAmount,omitempty"` | ||
| 46 | - //订单已支付金额(货款) | ||
| 47 | - OrderPaymentAmount float64 `json:"orderPaymentAmount,omitempty"` | ||
| 48 | - //订单区域信息 | ||
| 49 | - OrderRegionInfo *RegionInfo `json:"orderRegionInfo,omitempty"` | ||
| 50 | - | ||
| 51 | - Buyer *Buyer `json:"buyer,omitempty"` | ||
| 52 | - //合伙人编号 | ||
| 53 | - PartnerId int64 `json:"partnerId,omitempty"` | ||
| 54 | - //合伙人分红百分比 | ||
| 55 | - PartnerBonusPercent float64 `json:"partnerBonusPercent,omitempty"` | ||
| 56 | - //业务员分红百分比 | ||
| 57 | - SalesmanBonusPercent float64 `json:"salesmanBonusPercent,omitempty"` | ||
| 58 | - | ||
| 59 | - //创建时间 | ||
| 60 | - CreateAt time.Time `json:"createAt,omitempty"` | ||
| 61 | - //更新时间 | ||
| 62 | - UpdateAt time.Time `json:"updateAt,omitempty"` | ||
| 63 | - | ||
| 64 | - //上一次查看时间 已读情况 | ||
| 65 | - LastViewTime time.Time `json:"lastViewTime,omitempty"` | ||
| 66 | - //订单更新理由 | ||
| 67 | - Reason string `json:"reason,omitempty"` | ||
| 68 | -} | ||
| 69 | - | ||
| 70 | -func (m *Order) Identify() interface{} { | ||
| 71 | - if m.Id == 0 { | ||
| 72 | - return nil | ||
| 73 | - } | ||
| 74 | - return m.Id | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -func (m *Order) Update(data map[string]interface{}) error { | ||
| 78 | - if orderType, ok := data["orderType"]; ok && orderType != 0 { | ||
| 79 | - m.OrderType = orderType.(int) | ||
| 80 | - } | ||
| 81 | - if orderCode, ok := data["orderCode"]; ok && orderCode != "" { | ||
| 82 | - m.OrderCode = orderCode.(string) | ||
| 83 | - } | ||
| 84 | - if orderName, ok := data["orderName"]; ok && orderName != "" { | ||
| 85 | - m.OrderName = orderName.(string) | ||
| 86 | - } | ||
| 87 | - if orderStatus, ok := data["orderStatus"]; ok && orderStatus != 0 { | ||
| 88 | - m.OrderStatus = orderStatus.(int) | ||
| 89 | - } | ||
| 90 | - if lastViewTime, ok := data["lastViewTime"]; ok && lastViewTime != 0 { | ||
| 91 | - m.LastViewTime = lastViewTime.(time.Time) | ||
| 92 | - } | ||
| 93 | - m.UpdateAt = time.Now() | ||
| 94 | - return nil | ||
| 95 | -} | ||
| 96 | - | ||
| 97 | -//合伙人 | ||
| 98 | -//订单累计分红 | ||
| 99 | -func (m *Order) OrderTotalBonus() float64 { | ||
| 100 | - return utils.Decimal(m.OrderActualAmount * (m.PartnerBonusPercent / 100.0)) | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -//订单已收分红 | ||
| 104 | -func (m *Order) OrderBonusReceive() float64 { | ||
| 105 | - return utils.Decimal(m.OrderPaymentAmount * (m.PartnerBonusPercent / 100.0)) | ||
| 106 | -} | ||
| 107 | - | ||
| 108 | -//订单未收分红 | ||
| 109 | -func (m *Order) OrderBonusWait() float64 { | ||
| 110 | - bonusWait := m.OrderTotalBonus() - m.OrderBonusReceive() | ||
| 111 | - if bonusWait < 0 { | ||
| 112 | - return 0 | ||
| 113 | - } | ||
| 114 | - return bonusWait | ||
| 115 | -} | ||
| 116 | - | ||
| 117 | -//分红支出 | ||
| 118 | -func (m *Order) OrderBonusOutstanding() float64 { | ||
| 119 | - if m.OrderAmount <= m.OrderActualAmount { | ||
| 120 | - return 0 | ||
| 121 | - } | ||
| 122 | - return utils.Decimal((m.OrderAmount - m.OrderActualAmount) * (m.PartnerBonusPercent / 100.0)) | ||
| 123 | -} | ||
| 124 | - | ||
| 125 | -//订单被取消金额 | ||
| 126 | -func (m *Order) OrderAmountCancel() float64 { | ||
| 127 | - if m.OrderAmount <= m.OrderActualAmount { | ||
| 128 | - return 0 | ||
| 129 | - } | ||
| 130 | - return utils.Decimal(m.OrderAmount - m.OrderActualAmount) | ||
| 131 | -} | ||
| 132 | - | ||
| 133 | -//订单是否已读 | ||
| 134 | -func (m *Order) IsRead() int { | ||
| 135 | - if m.UpdateAt.After(m.LastViewTime) { | ||
| 136 | - return 0 | ||
| 137 | - } | ||
| 138 | - return 1 | ||
| 139 | -} | ||
| 140 | - | ||
| 141 | -type OrderQueryOption struct { | ||
| 142 | - PartnerId int64 `json:"partnerId,omitempty"` | ||
| 143 | - OrderType int `json:"orderType,omitempty"` | ||
| 144 | - OrderStatus int `json:"orderStatus,omitempty"` | ||
| 145 | - BeginTime time.Time `json:"beginTime,omitempty"` | ||
| 146 | - EndTime time.Time `json:"endTime,omitempty"` | ||
| 147 | - SortByCreateTime string `json:"sortByCreateTime,omitempty"` | ||
| 148 | - SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` | ||
| 149 | - Offset int `json:"offset,omitempty"` | ||
| 150 | - Limit int `json:"limit,omitempty"` | ||
| 151 | -} | ||
| 152 | - | ||
| 153 | -type DividendOrdersQueryOption struct { | ||
| 154 | - PartnerId int64 `json:"partnerId"` | ||
| 155 | - OrderType int `json:"orderType"` //订单类型 | ||
| 156 | - DetailAction int `json:"detailAction"` //明细类型(0已收明细、1未收明细) | ||
| 157 | - DividendAction int `json:"dividendAction"` //分红类型(0累计分红、1分红支出) | ||
| 158 | - StartTime int64 `json:"startTime" ` | ||
| 159 | - EndTime int64 `json:"endTime"` | ||
| 160 | - Offset int `json:"offset,omitempty"` | ||
| 161 | - Limit int `json:"limit,omitempty"` | ||
| 162 | - SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` | ||
| 163 | -} | ||
| 164 | - | ||
| 165 | -//买家 | ||
| 166 | -type Buyer struct { | ||
| 167 | - //买家姓名 | ||
| 168 | - BuyerName string `json:"buyerName"` | ||
| 169 | - //联系方式 | ||
| 170 | - ContactInfo string `json:"contactInfo"` | ||
| 171 | - //收获地址 | ||
| 172 | - ShippingAddress string `json:"shippingAddress"` | ||
| 173 | -} |
pkg/domain/order_base.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 5 | + "time" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +//OrderBase 订单基础 | ||
| 9 | +type OrderBase struct { | ||
| 10 | + //表id | ||
| 11 | + Id int64 | ||
| 12 | + //订单类型 1:实际订单 2:意向订单 | ||
| 13 | + OrderType int `pg:",notnull,default:1"` | ||
| 14 | + //订单编号 | ||
| 15 | + OrderCode string | ||
| 16 | + //交货编号 | ||
| 17 | + DeliveryCode string | ||
| 18 | + //买家 | ||
| 19 | + Buyer *Buyer | ||
| 20 | + //订单区域信息 | ||
| 21 | + RegionInfo *RegionInfo | ||
| 22 | + //订单对应的合伙人 | ||
| 23 | + PartnerId int64 | ||
| 24 | + //业务员抽成比例 | ||
| 25 | + SalesmanBonusPercent float64 | ||
| 26 | + //业务员抽成 | ||
| 27 | + SalesmanBonus float64 | ||
| 28 | + //预计的订单内货品总数 | ||
| 29 | + PlanOrderCount int | ||
| 30 | + //预计的订单的总金额 | ||
| 31 | + PlanOrderAmount float64 | ||
| 32 | + //按需使用的订单内货品总数 (初始值=-1) | ||
| 33 | + UseOrderCount int | ||
| 34 | + //按需使用的订单内货品总数 (初始值=-1) | ||
| 35 | + UseOrderAmount float64 | ||
| 36 | + //订单的创建时间 | ||
| 37 | + CreateTime time.Time | ||
| 38 | + //发货时间 | ||
| 39 | + DeliveryTime time.Time | ||
| 40 | + //更新时间 | ||
| 41 | + UpdateTime time.Time | ||
| 42 | + //上一次查看时间 已读情况 | ||
| 43 | + LastViewTime time.Time | ||
| 44 | + //合伙人应收分红 | ||
| 45 | + PlanPartnerBonus float64 | ||
| 46 | + //调整后的合伙人应收分红 (初始值=-1) | ||
| 47 | + UsePartnerBonus float64 | ||
| 48 | + //合伙人已收分红 | ||
| 49 | + PartnerBonusHas float64 | ||
| 50 | + //合伙人未收分红 | ||
| 51 | + PartnerBonusNot float64 | ||
| 52 | + //合伙人分红支出 | ||
| 53 | + PartnerBonusExpense float64 | ||
| 54 | + //是否关闭【0;否】【1:是】 | ||
| 55 | + IsDisable int8 | ||
| 56 | + //货物列表 | ||
| 57 | + OrderGood []*OrderGood | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +func (m *OrderBase) Identify() interface{} { | ||
| 61 | + if m.Id == 0 { | ||
| 62 | + return nil | ||
| 63 | + } | ||
| 64 | + return m.Id | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +//合伙人 | ||
| 68 | +//订单累计分红 | ||
| 69 | +func (m *OrderBase) OrderTotalBonus() float64 { | ||
| 70 | + if m.UsePartnerBonus >= 0 { | ||
| 71 | + return utils.Decimal(m.UsePartnerBonus) | ||
| 72 | + } | ||
| 73 | + return utils.Decimal(m.PlanPartnerBonus) | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +//订单已收分红 | ||
| 77 | +func (m *OrderBase) OrderBonusReceive() float64 { | ||
| 78 | + return utils.Decimal(m.PartnerBonusHas) | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +//订单未收分红 | ||
| 82 | +func (m *OrderBase) OrderBonusWait() float64 { | ||
| 83 | + bonusWait := m.OrderTotalBonus() - m.OrderBonusReceive() | ||
| 84 | + if bonusWait < 0 { | ||
| 85 | + return 0 | ||
| 86 | + } | ||
| 87 | + return bonusWait | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +//分红支出 | ||
| 91 | +func (m *OrderBase) OrderBonusOutstanding() float64 { | ||
| 92 | + return utils.Decimal(m.PartnerBonusExpense) | ||
| 93 | +} | ||
| 94 | + | ||
| 95 | +//订单被取消金额 | ||
| 96 | +func (m *OrderBase) OrderAmountCancel() float64 { | ||
| 97 | + if m.UseOrderAmount < 0 { | ||
| 98 | + return 0 | ||
| 99 | + } | ||
| 100 | + if m.PlanOrderAmount > m.UseOrderAmount { | ||
| 101 | + return 0 | ||
| 102 | + } | ||
| 103 | + return utils.Decimal(m.UseOrderAmount - m.PlanOrderAmount) | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +//订单金额 | ||
| 107 | +func (m *OrderBase) OrderAmount() float64 { | ||
| 108 | + if m.UseOrderAmount < 0 { | ||
| 109 | + return m.PlanOrderAmount | ||
| 110 | + } | ||
| 111 | + return m.UseOrderAmount | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +//订单是否已读 | ||
| 115 | +func (m *OrderBase) IsRead() int { | ||
| 116 | + if m.UpdateTime.After(m.LastViewTime) { | ||
| 117 | + return 0 | ||
| 118 | + } | ||
| 119 | + return 1 | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +type OrderQueryOption struct { | ||
| 123 | + PartnerId int64 `json:"partnerId,omitempty"` | ||
| 124 | + OrderType int `json:"orderType,omitempty"` | ||
| 125 | + OrderStatus int `json:"orderStatus,omitempty"` | ||
| 126 | + BeginTime time.Time `json:"beginTime,omitempty"` | ||
| 127 | + EndTime time.Time `json:"endTime,omitempty"` | ||
| 128 | + IsDisable string `json:"isDisable,omitempty"` | ||
| 129 | + SortByCreateTime string `json:"sortByCreateTime,omitempty"` | ||
| 130 | + SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` | ||
| 131 | + Offset int `json:"offset,omitempty"` | ||
| 132 | + Limit int `json:"limit,omitempty"` | ||
| 133 | +} | ||
| 134 | + | ||
| 135 | +type DividendOrdersQueryOption struct { | ||
| 136 | + PartnerId int64 `json:"partnerId"` | ||
| 137 | + OrderType int `json:"orderType"` //订单类型 | ||
| 138 | + DetailAction int `json:"detailAction"` //明细类型(0已收明细、1未收明细) | ||
| 139 | + DividendAction int `json:"dividendAction"` //分红类型(0累计分红、1分红支出) | ||
| 140 | + IsDisable string `json:"isDisable,omitempty"` | ||
| 141 | + StartTime int64 `json:"startTime" ` | ||
| 142 | + EndTime int64 `json:"endTime"` | ||
| 143 | + Offset int `json:"offset,omitempty"` | ||
| 144 | + Limit int `json:"limit,omitempty"` | ||
| 145 | + SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +//买家 | ||
| 149 | +type Buyer struct { | ||
| 150 | + //买家姓名 | ||
| 151 | + BuyerName string `json:"buyerName"` | ||
| 152 | + //联系方式 | ||
| 153 | + ContactInfo string `json:"contactInfo"` | ||
| 154 | + //收获地址 | ||
| 155 | + ShippingAddress string `json:"shippingAddress"` | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +type OrderBaseRepository interface { | ||
| 159 | + Save(dm *OrderBase) (*OrderBase, error) | ||
| 160 | + Remove(dm *OrderBase) (*OrderBase, error) | ||
| 161 | + FindOne(queryOptions map[string]interface{}) (*OrderBase, error) | ||
| 162 | + Find(queryOptions map[string]interface{}) (int64, []*OrderBase, error) | ||
| 163 | +} |
pkg/domain/order_good.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +//OrderGood 订单中的货品 | ||
| 4 | +type OrderGood struct { | ||
| 5 | + //货品id | ||
| 6 | + Id int64 | ||
| 7 | + //所属订单id | ||
| 8 | + OrderId int64 | ||
| 9 | + //货品名称 长度可能较长 | ||
| 10 | + GoodName string | ||
| 11 | + //预计的货品数量 | ||
| 12 | + PlanGoodNumber int | ||
| 13 | + //货品单价 | ||
| 14 | + Price float64 | ||
| 15 | + //预计的货品总额 | ||
| 16 | + PlanAmount float64 | ||
| 17 | + //调整后的货品数量 | ||
| 18 | + UseGoodNumber int | ||
| 19 | + //调整后的货品总额 | ||
| 20 | + UseAmount float64 | ||
| 21 | + //合伙人分红比例 | ||
| 22 | + PartnerBonusPercent float64 | ||
| 23 | + //预计的合伙人分红 | ||
| 24 | + PlanPartnerBonus float64 | ||
| 25 | + //合伙人应收分红调整 (初始值=-1) | ||
| 26 | + UsePartnerBonus float64 | ||
| 27 | + //合伙人已收分红 | ||
| 28 | + PartnerBonusHas float64 | ||
| 29 | + //合伙人未收分红 | ||
| 30 | + PartnerBonusNot float64 | ||
| 31 | + //合伙人分红支出 | ||
| 32 | + PartnerBonusExpense float64 | ||
| 33 | + //分红状态 | ||
| 34 | + BonusStatus int | ||
| 35 | + //备注信息 | ||
| 36 | + Remark string | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +func (g *OrderGood) Status() GoodStatus { | ||
| 40 | + if g.BonusStatus == BonusWaitPay && g.UseGoodNumber > 0 && g.UseGoodNumber < g.PlanGoodNumber { | ||
| 41 | + return goodStatusWithGoodsReturn | ||
| 42 | + } | ||
| 43 | + if g.BonusStatus == BonusWaitPay { | ||
| 44 | + return goodStatusWait | ||
| 45 | + } | ||
| 46 | + if g.BonusStatus == BonusPaid && g.UseGoodNumber > 0 && g.UseGoodNumber < g.PlanGoodNumber { | ||
| 47 | + return goodStatusPayWithGoodsReturn | ||
| 48 | + } | ||
| 49 | + if g.BonusStatus == BonusPaid { | ||
| 50 | + return goodStatusPay | ||
| 51 | + } | ||
| 52 | + return goodStatusWait | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +type GoodStatus int | ||
| 56 | + | ||
| 57 | +const ( | ||
| 58 | + // 待支付 | ||
| 59 | + goodStatusWait GoodStatus = GoodStatus(iota) | ||
| 60 | + // 已支付 | ||
| 61 | + goodStatusPay | ||
| 62 | + // 已支付退货 | ||
| 63 | + goodStatusPayWithGoodsReturn | ||
| 64 | + // 待支付退货 | ||
| 65 | + goodStatusWithGoodsReturn | ||
| 66 | +) | ||
| 67 | + | ||
| 68 | +func (m *OrderGood) Identify() interface{} { | ||
| 69 | + if m.Id == 0 { | ||
| 70 | + return nil | ||
| 71 | + } | ||
| 72 | + return m.Id | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +type OrderGoodRepository interface { | ||
| 76 | + Save(dm *OrderGood) (*OrderGood, error) | ||
| 77 | + Remove(dm *OrderGood) (*OrderGood, error) | ||
| 78 | + FindOne(queryOptions map[string]interface{}) (*OrderGood, error) | ||
| 79 | + Find(queryOptions map[string]interface{}) (int64, []*OrderGood, error) | ||
| 80 | +} |
pkg/domain/order_payment.go
已删除
100644 → 0
| 1 | -package domain | ||
| 2 | - | ||
| 3 | -import "time" | ||
| 4 | - | ||
| 5 | -const ( | ||
| 6 | - BonusWaitPay = iota + 1 //等待支付分红 | ||
| 7 | - BonusPaid //已经支付分红 | ||
| 8 | -) | ||
| 9 | - | ||
| 10 | -type OrderPaymentRepository interface { | ||
| 11 | - Save(dm *OrderPayment) (*OrderPayment, error) | ||
| 12 | - Remove(dm *OrderPayment) (*OrderPayment, error) | ||
| 13 | - FindOne(queryOptions map[string]interface{}) (*OrderPayment, error) | ||
| 14 | - Find(queryOptions map[string]interface{}) (int64, []*OrderPayment, error) | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | -type OrderPayment struct { | ||
| 18 | - //编号 | ||
| 19 | - Id int64 `json:"id"` | ||
| 20 | - //订单编号 | ||
| 21 | - OrderId int64 `json:"orderId"` | ||
| 22 | - //合伙人编号 | ||
| 23 | - PartnerId int64 `json:"partnerId"` | ||
| 24 | - //支付货款 | ||
| 25 | - PaymentAmount float64 `json:"paymentAmount"` | ||
| 26 | - //分红金额 | ||
| 27 | - BonusAmount float64 `json:"bonusAmount"` | ||
| 28 | - //分红状态 1.等待支付分红 2.已支付分红 | ||
| 29 | - BonusStatus int `json:"bonusStatus"` | ||
| 30 | - //创建时间 | ||
| 31 | - CreateAt time.Time `json:"createAt"` | ||
| 32 | - //更新时间 | ||
| 33 | - UpdateAt time.Time `json:"updateAt"` | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -func (m *OrderPayment) Identify() interface{} { | ||
| 37 | - if m.Id == 0 { | ||
| 38 | - return nil | ||
| 39 | - } | ||
| 40 | - return m.Id | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -func (m *OrderPayment) Update(data map[string]interface{}) error { | ||
| 44 | - if m.BonusStatus != BonusWaitPay { | ||
| 45 | - return nil | ||
| 46 | - } | ||
| 47 | - if paymentAmount, ok := data["paymentAmount"]; ok && paymentAmount != 0 { | ||
| 48 | - m.PaymentAmount = paymentAmount.(float64) | ||
| 49 | - } | ||
| 50 | - if bonusAmount, ok := data["bonusAmount"]; ok && bonusAmount != 0 { | ||
| 51 | - m.BonusAmount = bonusAmount.(float64) | ||
| 52 | - } | ||
| 53 | - if bonusStatus, ok := data["bonusStatus"]; ok && bonusStatus != 0 { | ||
| 54 | - m.BonusStatus = bonusStatus.(int) | ||
| 55 | - } | ||
| 56 | - m.UpdateAt = time.Now() | ||
| 57 | - return nil | ||
| 58 | -} |
| 1 | package domain | 1 | package domain |
| 2 | 2 | ||
| 3 | -//type OrderTodayStatic struct { | ||
| 4 | -// TodayIntentionQuantity int `json:"todayIntentionQuantity"` //今日新增意向订单 | ||
| 5 | -// TodayIntentionMoney int `json:"todayIntentionMoney"` //今日新增意向订单金额 | ||
| 6 | -// TodayRealQuantity int `json:"todayRealQuantity"` //今日新增实发订单 | ||
| 7 | -// TodayRealMoney int `json:"todayRealMoney"` //今日新增实发订单金额 | ||
| 8 | -// //CumulativeQuantity int `json:"cumulativeQuantity"` //累计实发订单 | ||
| 9 | -// //CumulativeMoney int `json:"cumulativeMoney"` //累计实发订单金额 | ||
| 10 | -//} | ||
| 11 | -////实发订单统计 | ||
| 12 | -//type OrderRealStatic struct { | ||
| 13 | -// CumulativeQuantity int `json:"cumulativeQuantity"` //累计实发订单 | ||
| 14 | -// CumulativeMoney int `json:"cumulativeMoney"` //累计实发订单金额 | ||
| 15 | -//} | ||
| 16 | -////意向订单统计 | ||
| 17 | -//type OrderIntentionStatic struct { | ||
| 18 | -// CumulativeQuantity int `json:"cumulativeQuantity"` //累计意向订单 | ||
| 19 | -// CumulativeMoney int `json:"cumulativeMoney"` //累计意向订单金额 | ||
| 20 | -//} | ||
| 21 | - | ||
| 22 | type OrderStatic struct { | 3 | type OrderStatic struct { |
| 23 | CumulativeQuantity int `json:"cumulativeQuantity"` //累计数量 | 4 | CumulativeQuantity int `json:"cumulativeQuantity"` //累计数量 |
| 24 | CumulativeMoney int `json:"cumulativeMoney"` //累计金额 | 5 | CumulativeMoney int `json:"cumulativeMoney"` //累计金额 |
| @@ -30,6 +11,7 @@ type OrderStaticQuery struct { | @@ -30,6 +11,7 @@ type OrderStaticQuery struct { | ||
| 30 | EndTime int64 `json:"endTime,omitempty"` | 11 | EndTime int64 `json:"endTime,omitempty"` |
| 31 | OrderStatus int `json:"orderStatus,omitempty"` | 12 | OrderStatus int `json:"orderStatus,omitempty"` |
| 32 | OrderType int `json:"orderType,omitempty"` | 13 | OrderType int `json:"orderType,omitempty"` |
| 14 | + IsDisable int `json:"isDisable,omitempty"` | ||
| 33 | } | 15 | } |
| 34 | 16 | ||
| 35 | type DividendOrdersQuery struct { | 17 | type DividendOrdersQuery struct { |
pkg/domain/service/sms_code_service.go
0 → 100644
| @@ -5,37 +5,37 @@ import ( | @@ -5,37 +5,37 @@ import ( | ||
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
| 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 9 | + "strconv" | ||
| 8 | "time" | 10 | "time" |
| 9 | ) | 11 | ) |
| 10 | 12 | ||
| 11 | -type OrderDao struct { | 13 | +type OrderBaseDao struct { |
| 12 | transactionContext *transaction.TransactionContext | 14 | transactionContext *transaction.TransactionContext |
| 13 | } | 15 | } |
| 14 | 16 | ||
| 15 | //订单统计 | 17 | //订单统计 |
| 16 | -func (dao *OrderDao) OrderStatics(option *domain.OrderStaticQuery) (count int, amount float64, err error) { | 18 | +func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count int, amount float64, err error) { |
| 17 | tx := dao.transactionContext.PgTx | 19 | tx := dao.transactionContext.PgTx |
| 18 | - order := new(models.Order) | 20 | + order := new(models.OrderBase) |
| 19 | var orderAmount float64 | 21 | var orderAmount float64 |
| 20 | q := tx.Model(order) | 22 | q := tx.Model(order) |
| 21 | q.ColumnExpr("count(*) count") | 23 | q.ColumnExpr("count(*) count") |
| 22 | - q.ColumnExpr("sum(order_actual_amount) total_order_actual_amount") | ||
| 23 | - q.ColumnExpr("sum(order_amount) total_order_amount") | 24 | + q.ColumnExpr("sum(case when use_order_amount >0 THEN use_order_amount else plan_order_amount END) total_order_actual_amount") |
| 25 | + q.ColumnExpr("sum(use_order_amount) total_order_amount") | ||
| 24 | if option.PartnerId > 0 { | 26 | if option.PartnerId > 0 { |
| 25 | - q.Where(`"order".partner_id =?`, option.PartnerId) | 27 | + q.Where(`"order_base".partner_id =?`, option.PartnerId) |
| 26 | } | 28 | } |
| 27 | if option.OrderType > 0 { | 29 | if option.OrderType > 0 { |
| 28 | - q.Where(`"order".order_type =?`, option.OrderType) | ||
| 29 | - } | ||
| 30 | - if option.OrderStatus > 0 { | ||
| 31 | - q.Where(`"order".order_status =?`, option.OrderStatus) | 30 | + q.Where(`"order_base".order_type =?`, option.OrderType) |
| 32 | } | 31 | } |
| 33 | if option.BeginTime > 0 { | 32 | if option.BeginTime > 0 { |
| 34 | - q.Where(`"order".create_at >=?`, time.Unix(option.BeginTime/1000, 0)) | 33 | + q.Where(`"order_base".create_time >=?`, time.Unix(option.BeginTime/1000, 0)) |
| 35 | } | 34 | } |
| 36 | if option.EndTime > 0 { | 35 | if option.EndTime > 0 { |
| 37 | - q.Where(`"order".create_at <?`, time.Unix(option.EndTime/1000, 0)) | 36 | + q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) |
| 38 | } | 37 | } |
| 38 | + q.Where(`"order_base".is_disable =?`, 0) | ||
| 39 | err = q.Select(&count, &amount, &orderAmount) | 39 | err = q.Select(&count, &amount, &orderAmount) |
| 40 | if option.OrderType == domain.OrderIntention { //意向订单值只有 order_amount order_actual_amount还未赋值 | 40 | if option.OrderType == domain.OrderIntention { //意向订单值只有 order_amount order_actual_amount还未赋值 |
| 41 | amount = orderAmount | 41 | amount = orderAmount |
| @@ -44,32 +44,35 @@ func (dao *OrderDao) OrderStatics(option *domain.OrderStaticQuery) (count int, a | @@ -44,32 +44,35 @@ func (dao *OrderDao) OrderStatics(option *domain.OrderStaticQuery) (count int, a | ||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | //分红订单 | 46 | //分红订单 |
| 47 | -func (dao *OrderDao) DividendOrders(option *domain.DividendOrdersQueryOption) (count int, orders []*models.Order, err error) { | 47 | +func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption) (count int, domainOrders []*domain.OrderBase, err error) { |
| 48 | tx := dao.transactionContext.PgTx | 48 | tx := dao.transactionContext.PgTx |
| 49 | + var orders []*models.OrderBase | ||
| 49 | q := tx.Model(&orders) | 50 | q := tx.Model(&orders) |
| 50 | - q.Column(`order.id`, `order.order_code`, `order.order_actual_amount`, `order.partner_bonus_percent`) | ||
| 51 | - //q.Where(`"order".order_status >=?`, domain.OrderStatusDeliverSome) //已经发货 | 51 | + //q.Column(`order_base.id`, `order_base.order_code`, `order_base.order_actual_amount`, `order_base.partner_bonus_percent`) |
| 52 | if option.OrderType > 0 { | 52 | if option.OrderType > 0 { |
| 53 | - q.Where(`"order".order_type=?`, option.OrderType) | 53 | + q.Where(`"order_base".order_type=?`, option.OrderType) |
| 54 | } | 54 | } |
| 55 | if option.PartnerId > 0 { | 55 | if option.PartnerId > 0 { |
| 56 | - q.Where(`"order".partner_id=?`, option.PartnerId) | 56 | + q.Where(`"order_base".partner_id=?`, option.PartnerId) |
| 57 | } | 57 | } |
| 58 | if option.StartTime > 0 { | 58 | if option.StartTime > 0 { |
| 59 | - q.Where(`"order".create_at >=?`, time.Unix(option.StartTime/1000, 0)) | 59 | + q.Where(`"order_base".create_time >=?`, time.Unix(option.StartTime/1000, 0)) |
| 60 | } | 60 | } |
| 61 | if option.EndTime > 0 { | 61 | if option.EndTime > 0 { |
| 62 | - q.Where(`"order".create_at <?`, time.Unix(option.EndTime/1000, 0)) | 62 | + q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) |
| 63 | + } | ||
| 64 | + if len(option.IsDisable) > 0 { | ||
| 65 | + value, _ := strconv.Atoi(option.IsDisable) | ||
| 66 | + q.Where(`"order_base".is_disable =?`, value) | ||
| 63 | } | 67 | } |
| 64 | if option.DividendAction == 0 { //累计分红 | 68 | if option.DividendAction == 0 { //累计分红 |
| 65 | if option.DetailAction == 0 { //已收明细 | 69 | if option.DetailAction == 0 { //已收明细 |
| 66 | - q.Join(`JOIN order_payment as a ON a.order_id="order".id`) | ||
| 67 | - q.Where(`"a".bonus_status=?`, domain.BonusPaid) | 70 | + q.Where(`"order_base".partner_bonus_has>0`) |
| 68 | } else if option.DetailAction == 1 { //未收明细 //实际金额>已支付金额 | 71 | } else if option.DetailAction == 1 { //未收明细 //实际金额>已支付金额 |
| 69 | - q.Where(`"order".order_actual_amount>"order".order_payment_amount`) | 72 | + q.Where(`"order_base".partner_bonus_not>0`) |
| 70 | } | 73 | } |
| 71 | } else if option.DividendAction == 1 { //分红支出 | 74 | } else if option.DividendAction == 1 { //分红支出 |
| 72 | - q.Where(`"order".order_amount>"order".order_actual_amount`) | 75 | + q.Where(`"order_base".partner_bonus_expense>0`) |
| 73 | } | 76 | } |
| 74 | if option.Limit > 0 { | 77 | if option.Limit > 0 { |
| 75 | q.Limit(option.Limit) | 78 | q.Limit(option.Limit) |
| @@ -78,26 +81,34 @@ func (dao *OrderDao) DividendOrders(option *domain.DividendOrdersQueryOption) (c | @@ -78,26 +81,34 @@ func (dao *OrderDao) DividendOrders(option *domain.DividendOrdersQueryOption) (c | ||
| 78 | q.Offset(option.Offset) | 81 | q.Offset(option.Offset) |
| 79 | } | 82 | } |
| 80 | if len(option.SortByUpdateTime) > 0 { | 83 | if len(option.SortByUpdateTime) > 0 { |
| 81 | - q.Order(fmt.Sprintf("order.id %v", option.SortByUpdateTime)) | 84 | + q.Order(fmt.Sprintf("order_base.id %v", option.SortByUpdateTime)) |
| 82 | } | 85 | } |
| 83 | count, err = q.Distinct().SelectAndCount() | 86 | count, err = q.Distinct().SelectAndCount() |
| 87 | + for i := range orders { | ||
| 88 | + var domainOrder *domain.OrderBase | ||
| 89 | + err = utils.GobModelTransform(&domainOrder, &orders[i]) | ||
| 90 | + if err != nil { | ||
| 91 | + return | ||
| 92 | + } | ||
| 93 | + domainOrders = append(domainOrders, domainOrder) | ||
| 94 | + } | ||
| 84 | return | 95 | return |
| 85 | } | 96 | } |
| 86 | 97 | ||
| 87 | -func (dao *OrderDao) UpdateLastViewTime(id int64, lastViewTime time.Time) (err error) { | 98 | +func (dao *OrderBaseDao) UpdateLastViewTime(id int64, lastViewTime time.Time) (err error) { |
| 88 | tx := dao.transactionContext.PgTx | 99 | tx := dao.transactionContext.PgTx |
| 89 | - order := new(models.Order) | 100 | + order := new(models.OrderBase) |
| 90 | q := tx.Model(order).Set("last_view_time = ?", lastViewTime) | 101 | q := tx.Model(order).Set("last_view_time = ?", lastViewTime) |
| 91 | q.Where("id=?", id) | 102 | q.Where("id=?", id) |
| 92 | _, err = q.Update() | 103 | _, err = q.Update() |
| 93 | return | 104 | return |
| 94 | } | 105 | } |
| 95 | 106 | ||
| 96 | -func NewOrderDao(transactionContext *transaction.TransactionContext) (*OrderDao, error) { | 107 | +func NewOrderBaseDao(transactionContext *transaction.TransactionContext) (*OrderBaseDao, error) { |
| 97 | if transactionContext == nil { | 108 | if transactionContext == nil { |
| 98 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 109 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
| 99 | } else { | 110 | } else { |
| 100 | - return &OrderDao{ | 111 | + return &OrderBaseDao{ |
| 101 | transactionContext: transactionContext, | 112 | transactionContext: transactionContext, |
| 102 | }, nil | 113 | }, nil |
| 103 | } | 114 | } |
| @@ -22,6 +22,7 @@ func init() { | @@ -22,6 +22,7 @@ func init() { | ||
| 22 | if !constant.DISABLE_SQL_GENERATE_PRINT { | 22 | if !constant.DISABLE_SQL_GENERATE_PRINT { |
| 23 | DB.AddQueryHook(SqlGeneratePrintHook{}) | 23 | DB.AddQueryHook(SqlGeneratePrintHook{}) |
| 24 | } | 24 | } |
| 25 | + //orm.RegisterTable((*models.OrderGood)(nil)) | ||
| 25 | if !constant.DISABLE_CREATE_TABLE { | 26 | if !constant.DISABLE_CREATE_TABLE { |
| 26 | for _, model := range []interface{}{ | 27 | for _, model := range []interface{}{ |
| 27 | //(*models.Employee)(nil), | 28 | //(*models.Employee)(nil), |
| @@ -30,6 +31,8 @@ func init() { | @@ -30,6 +31,8 @@ func init() { | ||
| 30 | (*models.OrderPayment)(nil), | 31 | (*models.OrderPayment)(nil), |
| 31 | (*models.PartnerSubAccount)(nil), | 32 | (*models.PartnerSubAccount)(nil), |
| 32 | (*models.Company)(nil), | 33 | (*models.Company)(nil), |
| 34 | + (*models.OrderBase)(nil), | ||
| 35 | + (*models.OrderGood)(nil), | ||
| 33 | } { | 36 | } { |
| 34 | err := DB.CreateTable(model, &orm.CreateTableOptions{ | 37 | err := DB.CreateTable(model, &orm.CreateTableOptions{ |
| 35 | Temp: false, | 38 | Temp: false, |
pkg/infrastructure/pg/models/order_base.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
| 5 | + "time" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +//OrderBase 订单基础 | ||
| 9 | +type OrderBase struct { | ||
| 10 | + tableName struct{} `pg:"order_base"` | ||
| 11 | + //表id | ||
| 12 | + Id int64 `pg:",pk"` | ||
| 13 | + //订单类型 1:实际订单 2:意向订单 | ||
| 14 | + OrderType int `pg:",notnull,default:1"` | ||
| 15 | + //订单编号 | ||
| 16 | + OrderCode string | ||
| 17 | + //交货编号 | ||
| 18 | + DeliveryCode string | ||
| 19 | + //买家 | ||
| 20 | + Buyer *domain.Buyer | ||
| 21 | + //订单区域信息 | ||
| 22 | + RegionInfo *domain.RegionInfo | ||
| 23 | + //订单对应的合伙人 | ||
| 24 | + PartnerId int64 | ||
| 25 | + //业务员抽成比例 | ||
| 26 | + SalesmanBonusPercent float64 | ||
| 27 | + //业务员抽成 | ||
| 28 | + SalesmanBonus float64 | ||
| 29 | + //预计的订单内货品总数 | ||
| 30 | + PlanOrderCount int | ||
| 31 | + //预计的订单的总金额 | ||
| 32 | + PlanOrderAmount float64 | ||
| 33 | + //按需使用的订单内货品总数 (初始值=-1) | ||
| 34 | + UseOrderCount int | ||
| 35 | + //按需使用的订单内货总金额 (初始值=-1) | ||
| 36 | + UseOrderAmount float64 | ||
| 37 | + //订单的创建时间 | ||
| 38 | + CreateTime time.Time | ||
| 39 | + //发货时间 | ||
| 40 | + DeliveryTime time.Time | ||
| 41 | + //更新时间 | ||
| 42 | + UpdateTime time.Time | ||
| 43 | + //上一次查看时间 已读情况 | ||
| 44 | + LastViewTime time.Time | ||
| 45 | + //合伙人应收分红 | ||
| 46 | + PlanPartnerBonus float64 | ||
| 47 | + //调整后的合伙人应收分红 (初始值=-1) | ||
| 48 | + UsePartnerBonus float64 | ||
| 49 | + //合伙人已收分红 | ||
| 50 | + PartnerBonusHas float64 | ||
| 51 | + //合伙人未收分红 | ||
| 52 | + PartnerBonusNot float64 | ||
| 53 | + //合伙人分红支出 | ||
| 54 | + PartnerBonusExpense float64 | ||
| 55 | + //是否关闭【0;否】【1:是】 | ||
| 56 | + IsDisable int8 | ||
| 57 | + //货物列表 | ||
| 58 | + OrderGood []*OrderGood `pg:"fk:order_id"` | ||
| 59 | +} |
pkg/infrastructure/pg/models/order_good.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +//OrderGood 订单中的货品 | ||
| 4 | +type OrderGood struct { | ||
| 5 | + tableName struct{} `pg:"order_good"` | ||
| 6 | + //货品id | ||
| 7 | + Id int64 `pg:",pk"` | ||
| 8 | + //所属订单id | ||
| 9 | + OrderId int64 | ||
| 10 | + //货品名称 长度可能较长 | ||
| 11 | + GoodName string | ||
| 12 | + //预计的货品数量 | ||
| 13 | + PlanGoodNumber int | ||
| 14 | + //货品单价 | ||
| 15 | + Price float64 | ||
| 16 | + //预计的货品总额 | ||
| 17 | + PlanAmount float64 | ||
| 18 | + //调整后的货品数量 | ||
| 19 | + UseGoodNumber int | ||
| 20 | + //调整后的货品总额 | ||
| 21 | + UseAmount float64 | ||
| 22 | + //合伙人分红比例 | ||
| 23 | + PartnerBonusPercent float64 | ||
| 24 | + //预计的合伙人分红 | ||
| 25 | + PlanPartnerBonus float64 | ||
| 26 | + //合伙人应收分红调整 (初始值=-1) | ||
| 27 | + UsePartnerBonus float64 | ||
| 28 | + //合伙人已收分红 | ||
| 29 | + PartnerBonusHas float64 | ||
| 30 | + //合伙人未收分红 | ||
| 31 | + PartnerBonusNot float64 | ||
| 32 | + //合伙人分红支出 | ||
| 33 | + PartnerBonusExpense float64 | ||
| 34 | + //分红状态 | ||
| 35 | + BonusStatus int | ||
| 36 | + //备注信息 | ||
| 37 | + Remark string | ||
| 38 | +} |
| @@ -4,12 +4,13 @@ import ( | @@ -4,12 +4,13 @@ import ( | ||
| 4 | "fmt" | 4 | "fmt" |
| 5 | "github.com/tiptok/gocomm/pkg/redis" | 5 | "github.com/tiptok/gocomm/pkg/redis" |
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
| 7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | ||
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | func init() { | 10 | func init() { |
| 10 | redisSource := fmt.Sprintf("%v:%v", constant.REDIS_HOST, constant.REDIS_PORT) | 11 | redisSource := fmt.Sprintf("%v:%v", constant.REDIS_HOST, constant.REDIS_PORT) |
| 11 | err := redis.InitWithDb(100, redisSource, constant.REDIS_AUTH, "0") | 12 | err := redis.InitWithDb(100, redisSource, constant.REDIS_AUTH, "0") |
| 12 | if err != nil { | 13 | if err != nil { |
| 13 | - panic(err) | 14 | + log.Error(err) |
| 14 | } | 15 | } |
| 15 | } | 16 | } |
| 1 | package repository | 1 | package repository |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "github.com/go-pg/pg/v10/orm" | ||
| 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
| 7 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 8 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 8 | ) | 9 | ) |
| 9 | 10 | ||
| 10 | -type OrderPaymentRepository struct { | 11 | +type OrderBaseRepository struct { |
| 11 | transactionContext *transaction.TransactionContext | 12 | transactionContext *transaction.TransactionContext |
| 12 | } | 13 | } |
| 13 | 14 | ||
| 14 | -func (repository *OrderPaymentRepository) Save(dm *domain.OrderPayment) (*domain.OrderPayment, error) { | 15 | +func (repository *OrderBaseRepository) Save(dm *domain.OrderBase) (*domain.OrderBase, error) { |
| 15 | var ( | 16 | var ( |
| 16 | err error | 17 | err error |
| 17 | - m = &models.OrderPayment{} | 18 | + m = &models.OrderBase{} |
| 18 | tx = repository.transactionContext.PgTx | 19 | tx = repository.transactionContext.PgTx |
| 19 | ) | 20 | ) |
| 20 | if err = GobModelTransform(m, dm); err != nil { | 21 | if err = GobModelTransform(m, dm); err != nil { |
| 21 | return nil, err | 22 | return nil, err |
| 22 | } | 23 | } |
| 23 | if dm.Identify() == nil { | 24 | if dm.Identify() == nil { |
| 24 | - if dm.Id, err = NewSnowflakeId(); err != nil { | ||
| 25 | - return dm, err | ||
| 26 | - } | ||
| 27 | - m.Id = dm.Id | 25 | + //if dm.Id, err = NewSnowflakeId(); err != nil { |
| 26 | + // return dm, err | ||
| 27 | + //} | ||
| 28 | + //m.Id = dm.Id | ||
| 28 | if err = tx.Insert(m); err != nil { | 29 | if err = tx.Insert(m); err != nil { |
| 29 | return nil, err | 30 | return nil, err |
| 30 | } | 31 | } |
| @@ -36,68 +37,75 @@ func (repository *OrderPaymentRepository) Save(dm *domain.OrderPayment) (*domain | @@ -36,68 +37,75 @@ func (repository *OrderPaymentRepository) Save(dm *domain.OrderPayment) (*domain | ||
| 36 | return dm, nil | 37 | return dm, nil |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | -func (repository *OrderPaymentRepository) Remove(OrderPayment *domain.OrderPayment) (*domain.OrderPayment, error) { | 40 | +func (repository *OrderBaseRepository) Remove(OrderBase *domain.OrderBase) (*domain.OrderBase, error) { |
| 40 | var ( | 41 | var ( |
| 41 | - tx = repository.transactionContext.PgTx | ||
| 42 | - OrderPaymentModel = &models.OrderPayment{Id: OrderPayment.Identify().(int64)} | 42 | + tx = repository.transactionContext.PgTx |
| 43 | + OrderBaseModel = &models.OrderBase{Id: OrderBase.Identify().(int64)} | ||
| 43 | ) | 44 | ) |
| 44 | - if _, err := tx.Model(OrderPaymentModel).Where("id = ?", OrderPayment.Id).Delete(); err != nil { | ||
| 45 | - return OrderPayment, err | 45 | + if _, err := tx.Model(OrderBaseModel).Where("id = ?", OrderBase.Id).Delete(); err != nil { |
| 46 | + return OrderBase, err | ||
| 46 | } | 47 | } |
| 47 | - return OrderPayment, nil | 48 | + return OrderBase, nil |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | -func (repository *OrderPaymentRepository) FindOne(queryOptions map[string]interface{}) (*domain.OrderPayment, error) { | 51 | +func (repository *OrderBaseRepository) FindOne(queryOptions map[string]interface{}) (*domain.OrderBase, error) { |
| 51 | tx := repository.transactionContext.PgTx | 52 | tx := repository.transactionContext.PgTx |
| 52 | - OrderPaymentModel := new(models.OrderPayment) | ||
| 53 | - query := NewQuery(tx.Model(OrderPaymentModel), queryOptions) | ||
| 54 | - query.SetWhere("order_payment.id = ?", "id") | ||
| 55 | - query.SetWhere("order_payment.order_id = ?", "orderId") | 53 | + OrderBaseModel := new(models.OrderBase) |
| 54 | + query := NewQuery(tx.Model(OrderBaseModel), queryOptions) | ||
| 55 | + query.ColumnExpr("order_base.*") | ||
| 56 | + query.Relation("OrderGood", func(q *orm.Query) (*orm.Query, error) { | ||
| 57 | + q.ColumnExpr("order_good.*") | ||
| 58 | + return q, nil | ||
| 59 | + }) | ||
| 60 | + query.SetWhere(`"order_base".id = ?`, "id") | ||
| 61 | + query.SetWhere(`"order_base".order_code = ?`, "order_code") | ||
| 62 | + | ||
| 56 | if err := query.First(); err != nil { | 63 | if err := query.First(); err != nil { |
| 57 | return nil, query.HandleError(err, "没有此订单") | 64 | return nil, query.HandleError(err, "没有此订单") |
| 58 | } | 65 | } |
| 59 | - if OrderPaymentModel.Id == 0 { | 66 | + if OrderBaseModel.Id == 0 { |
| 60 | return nil, nil | 67 | return nil, nil |
| 61 | } | 68 | } |
| 62 | - return repository.transformPgModelToDomainModel(OrderPaymentModel) | 69 | + return repository.transformPgModelToDomainModel(OrderBaseModel) |
| 63 | } | 70 | } |
| 64 | 71 | ||
| 65 | -func (repository *OrderPaymentRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OrderPayment, error) { | 72 | +func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OrderBase, error) { |
| 66 | tx := repository.transactionContext.PgTx | 73 | tx := repository.transactionContext.PgTx |
| 67 | - var OrderPaymentModels []*models.OrderPayment | ||
| 68 | - OrderPayments := make([]*domain.OrderPayment, 0) | ||
| 69 | - query := NewQuery(tx.Model(&OrderPaymentModels), queryOptions) | 74 | + var OrderBaseModels []*models.OrderBase |
| 75 | + OrderBases := make([]*domain.OrderBase, 0) | ||
| 76 | + query := NewQuery(tx.Model(&OrderBaseModels), queryOptions) | ||
| 70 | query. | 77 | query. |
| 71 | - SetWhere("order_payment.partner_id = ?", "partnerId"). | ||
| 72 | - SetWhere("order_payment.order_id = ?", "orderId"). | ||
| 73 | - SetWhere(`order_payment.create_at >= ?`, "beginTime"). | ||
| 74 | - SetWhere(`order_payment.create_at < ?`, "endTime"). | 78 | + SetWhere(`"order_base".partner_id= ?`, "partnerId"). |
| 79 | + SetWhere(`"order_base".order_type= ?`, "orderType"). | ||
| 80 | + SetWhere(`"order_base".create_time >= ?`, "beginTime"). | ||
| 81 | + SetWhere(`"order_base".create_time < ?`, "endTime"). | ||
| 82 | + SetWhere(`"order_base".is_disable = ?`, "isDisable"). | ||
| 75 | SetLimit(). | 83 | SetLimit(). |
| 76 | - SetOrder("order_payment.create_at", "sortByCreateTime"). | ||
| 77 | - SetOrder("order_payment.update_at", "sortByUpdateTime") | 84 | + SetOrder(`order_base.create_time`, "sortByCreateTime"). |
| 85 | + SetOrder(`order_base.update_time`, "sortByUpdateTime") | ||
| 78 | var err error | 86 | var err error |
| 79 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 87 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
| 80 | - return 0, OrderPayments, err | 88 | + return 0, OrderBases, err |
| 81 | } | 89 | } |
| 82 | - for _, OrderPaymentModel := range OrderPaymentModels { | ||
| 83 | - if OrderPayment, err := repository.transformPgModelToDomainModel(OrderPaymentModel); err != nil { | ||
| 84 | - return 0, OrderPayments, err | 90 | + for _, OrderBaseModel := range OrderBaseModels { |
| 91 | + if OrderBase, err := repository.transformPgModelToDomainModel(OrderBaseModel); err != nil { | ||
| 92 | + return 0, OrderBases, err | ||
| 85 | } else { | 93 | } else { |
| 86 | - OrderPayments = append(OrderPayments, OrderPayment) | 94 | + OrderBases = append(OrderBases, OrderBase) |
| 87 | } | 95 | } |
| 88 | } | 96 | } |
| 89 | - return int64(query.AffectRow), OrderPayments, nil | 97 | + return int64(query.AffectRow), OrderBases, nil |
| 90 | } | 98 | } |
| 91 | 99 | ||
| 92 | -func (repository *OrderPaymentRepository) transformPgModelToDomainModel(OrderPaymentModel *models.OrderPayment) (*domain.OrderPayment, error) { | ||
| 93 | - m := &domain.OrderPayment{} | ||
| 94 | - err := GobModelTransform(m, OrderPaymentModel) | 100 | +func (repository *OrderBaseRepository) transformPgModelToDomainModel(OrderBaseModel *models.OrderBase) (*domain.OrderBase, error) { |
| 101 | + m := &domain.OrderBase{} | ||
| 102 | + err := GobModelTransform(m, OrderBaseModel) | ||
| 95 | return m, err | 103 | return m, err |
| 96 | } | 104 | } |
| 97 | 105 | ||
| 98 | -func NewOrderPaymentRepository(transactionContext *transaction.TransactionContext) (*OrderPaymentRepository, error) { | 106 | +func NewOrderBaseRepository(transactionContext *transaction.TransactionContext) (*OrderBaseRepository, error) { |
| 99 | if transactionContext == nil { | 107 | if transactionContext == nil { |
| 100 | return nil, ERR_EMPTY_TC | 108 | return nil, ERR_EMPTY_TC |
| 101 | } | 109 | } |
| 102 | - return &OrderPaymentRepository{transactionContext: transactionContext}, nil | 110 | + return &OrderBaseRepository{transactionContext: transactionContext}, nil |
| 103 | } | 111 | } |
| @@ -7,14 +7,14 @@ import ( | @@ -7,14 +7,14 @@ import ( | ||
| 7 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 7 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | -type OrderRepository struct { | 10 | +type OrderGoodRepository struct { |
| 11 | transactionContext *transaction.TransactionContext | 11 | transactionContext *transaction.TransactionContext |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -func (repository *OrderRepository) Save(dm *domain.Order) (*domain.Order, error) { | 14 | +func (repository *OrderGoodRepository) Save(dm *domain.OrderGood) (*domain.OrderGood, error) { |
| 15 | var ( | 15 | var ( |
| 16 | err error | 16 | err error |
| 17 | - m = &models.Order{} | 17 | + m = &models.OrderGood{} |
| 18 | tx = repository.transactionContext.PgTx | 18 | tx = repository.transactionContext.PgTx |
| 19 | ) | 19 | ) |
| 20 | if err = GobModelTransform(m, dm); err != nil { | 20 | if err = GobModelTransform(m, dm); err != nil { |
| @@ -36,69 +36,66 @@ func (repository *OrderRepository) Save(dm *domain.Order) (*domain.Order, error) | @@ -36,69 +36,66 @@ func (repository *OrderRepository) Save(dm *domain.Order) (*domain.Order, error) | ||
| 36 | return dm, nil | 36 | return dm, nil |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | -func (repository *OrderRepository) Remove(Order *domain.Order) (*domain.Order, error) { | 39 | +func (repository *OrderGoodRepository) Remove(OrderGood *domain.OrderGood) (*domain.OrderGood, error) { |
| 40 | var ( | 40 | var ( |
| 41 | - tx = repository.transactionContext.PgTx | ||
| 42 | - OrderModel = &models.Order{Id: Order.Identify().(int64)} | 41 | + tx = repository.transactionContext.PgTx |
| 42 | + OrderGoodModel = &models.OrderGood{Id: OrderGood.Identify().(int64)} | ||
| 43 | ) | 43 | ) |
| 44 | - if _, err := tx.Model(OrderModel).Where("id = ?", Order.Id).Delete(); err != nil { | ||
| 45 | - return Order, err | 44 | + if _, err := tx.Model(OrderGoodModel).Where("id = ?", OrderGood.Id).Delete(); err != nil { |
| 45 | + return OrderGood, err | ||
| 46 | } | 46 | } |
| 47 | - return Order, nil | 47 | + return OrderGood, nil |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -func (repository *OrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.Order, error) { | 50 | +func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface{}) (*domain.OrderGood, error) { |
| 51 | tx := repository.transactionContext.PgTx | 51 | tx := repository.transactionContext.PgTx |
| 52 | - OrderModel := new(models.Order) | ||
| 53 | - query := NewQuery(tx.Model(OrderModel), queryOptions) | ||
| 54 | - query.SetWhere(`"order".id = ?`, "id") | ||
| 55 | - query.SetWhere(`"order".order_code = ?`, "orderCode") | 52 | + OrderGoodModel := new(models.OrderGood) |
| 53 | + query := NewQuery(tx.Model(OrderGoodModel), queryOptions) | ||
| 54 | + query.SetWhere(`id = ?`, "id") | ||
| 56 | if err := query.First(); err != nil { | 55 | if err := query.First(); err != nil { |
| 57 | return nil, query.HandleError(err, "没有此订单") | 56 | return nil, query.HandleError(err, "没有此订单") |
| 58 | } | 57 | } |
| 59 | - if OrderModel.Id == 0 { | 58 | + if OrderGoodModel.Id == 0 { |
| 60 | return nil, nil | 59 | return nil, nil |
| 61 | } | 60 | } |
| 62 | - return repository.transformPgModelToDomainModel(OrderModel) | 61 | + return repository.transformPgModelToDomainModel(OrderGoodModel) |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | -func (repository *OrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Order, error) { | 64 | +func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OrderGood, error) { |
| 66 | tx := repository.transactionContext.PgTx | 65 | tx := repository.transactionContext.PgTx |
| 67 | - var OrderModels []*models.Order | ||
| 68 | - Orders := make([]*domain.Order, 0) | ||
| 69 | - query := NewQuery(tx.Model(&OrderModels), queryOptions) | 66 | + var OrderGoodModels []*models.OrderGood |
| 67 | + OrderGoods := make([]*domain.OrderGood, 0) | ||
| 68 | + query := NewQuery(tx.Model(&OrderGoodModels), queryOptions) | ||
| 70 | query. | 69 | query. |
| 71 | - SetWhere(`"order".partner_id= ?`, "partnerId"). | ||
| 72 | - SetWhere(`"order".order_type= ?`, "orderType"). | ||
| 73 | - SetWhere(`"order".order_status= ?`, "orderStatus"). | ||
| 74 | - SetWhere(`"order".create_at >= ?`, "beginTime"). | ||
| 75 | - SetWhere(`"order".create_at < ?`, "endTime"). | 70 | + SetWhere(`partner_id= ?`, "partnerId"). |
| 71 | + SetWhere(`create_at >= ?`, "beginTime"). | ||
| 72 | + SetWhere(`create_at < ?`, "endTime"). | ||
| 76 | SetLimit(). | 73 | SetLimit(). |
| 77 | - SetOrder(`order.create_at`, "sortByCreateTime"). | ||
| 78 | - SetOrder(`order.update_at`, "sortByUpdateTime") | 74 | + SetOrder(`create_at`, "sortByCreateTime"). |
| 75 | + SetOrder(`update_at`, "sortByUpdateTime") | ||
| 79 | var err error | 76 | var err error |
| 80 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 77 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
| 81 | - return 0, Orders, err | 78 | + return 0, OrderGoods, err |
| 82 | } | 79 | } |
| 83 | - for _, OrderModel := range OrderModels { | ||
| 84 | - if Order, err := repository.transformPgModelToDomainModel(OrderModel); err != nil { | ||
| 85 | - return 0, Orders, err | 80 | + for _, OrderGoodModel := range OrderGoodModels { |
| 81 | + if OrderGood, err := repository.transformPgModelToDomainModel(OrderGoodModel); err != nil { | ||
| 82 | + return 0, OrderGoods, err | ||
| 86 | } else { | 83 | } else { |
| 87 | - Orders = append(Orders, Order) | 84 | + OrderGoods = append(OrderGoods, OrderGood) |
| 88 | } | 85 | } |
| 89 | } | 86 | } |
| 90 | - return int64(query.AffectRow), Orders, nil | 87 | + return int64(query.AffectRow), OrderGoods, nil |
| 91 | } | 88 | } |
| 92 | 89 | ||
| 93 | -func (repository *OrderRepository) transformPgModelToDomainModel(OrderModel *models.Order) (*domain.Order, error) { | ||
| 94 | - m := &domain.Order{} | ||
| 95 | - err := GobModelTransform(m, OrderModel) | 90 | +func (repository *OrderGoodRepository) transformPgModelToDomainModel(OrderGoodModel *models.OrderGood) (*domain.OrderGood, error) { |
| 91 | + m := &domain.OrderGood{} | ||
| 92 | + err := GobModelTransform(m, OrderGoodModel) | ||
| 96 | return m, err | 93 | return m, err |
| 97 | } | 94 | } |
| 98 | 95 | ||
| 99 | -func NewOrderRepository(transactionContext *transaction.TransactionContext) (*OrderRepository, error) { | 96 | +func NewOrderGoodRepository(transactionContext *transaction.TransactionContext) (*OrderGoodRepository, error) { |
| 100 | if transactionContext == nil { | 97 | if transactionContext == nil { |
| 101 | return nil, ERR_EMPTY_TC | 98 | return nil, ERR_EMPTY_TC |
| 102 | } | 99 | } |
| 103 | - return &OrderRepository{transactionContext: transactionContext}, nil | 100 | + return &OrderGoodRepository{transactionContext: transactionContext}, nil |
| 104 | } | 101 | } |
pkg/infrastructure/utils/redis.go
0 → 100644
| 1 | +package utils | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +//redis键值 | ||
| 9 | +func RedisKey(businessKey string) string { | ||
| 10 | + //项目:环境:业务码 | ||
| 11 | + return fmt.Sprintf("%v:%v", constant.SERVICE_NAME, businessKey) | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +//redis键值 项标识 | ||
| 15 | +func RedisKeyWithId(businessKey string, id int64) string { | ||
| 16 | + //项目:环境:业务码 | ||
| 17 | + return fmt.Sprintf("%v:%v:%v", constant.SERVICE_NAME, businessKey, id) | ||
| 18 | +} |
| @@ -103,18 +103,18 @@ func (this *AuthController) Revoke() { | @@ -103,18 +103,18 @@ func (this *AuthController) Revoke() { | ||
| 103 | defer func() { | 103 | defer func() { |
| 104 | this.Resp(msg) | 104 | this.Resp(msg) |
| 105 | }() | 105 | }() |
| 106 | - //var request *protocol.RevokeRequest | ||
| 107 | - //if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
| 108 | - // log.Error(err) | ||
| 109 | - // msg = protocol.BadRequestParam(1) | ||
| 110 | - // return | ||
| 111 | - //} | ||
| 112 | - //if b, m := this.Valid(request); !b { | ||
| 113 | - // msg = m | ||
| 114 | - // return | ||
| 115 | - //} | ||
| 116 | - //header := controllers.GetRequestHeader(this.Ctx) | ||
| 117 | - //msg = protocol.NewReturnResponse(auth.Revoke(header, request)) | 106 | + var request *protocol.RevokeRequest |
| 107 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
| 108 | + log.Error(err) | ||
| 109 | + msg = protocol.BadRequestParam(1) | ||
| 110 | + return | ||
| 111 | + } | ||
| 112 | + if b, m := this.Valid(request); !b { | ||
| 113 | + msg = m | ||
| 114 | + return | ||
| 115 | + } | ||
| 116 | + header := this.GetRequestHeader(this.Ctx) | ||
| 117 | + msg = protocol.NewReturnResponse(auth.Revoke(header, request)) | ||
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | //UpdateDevice | 120 | //UpdateDevice |
| @@ -25,7 +25,7 @@ func (this *DividendController) DividendStatistics() { | @@ -25,7 +25,7 @@ func (this *DividendController) DividendStatistics() { | ||
| 25 | return | 25 | return |
| 26 | } | 26 | } |
| 27 | header := this.GetRequestHeader(this.Ctx) | 27 | header := this.GetRequestHeader(this.Ctx) |
| 28 | - msg = protocol.NewReturnResponse(dividend.DividendStatistics(header, request)) | 28 | + msg = protocol.NewReturnResponse(dividend.Statistics(header, request)) |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | //DividendOrders 分红订单 | 31 | //DividendOrders 分红订单 |
| @@ -44,5 +44,5 @@ func (this *DividendController) DividendOrders() { | @@ -44,5 +44,5 @@ func (this *DividendController) DividendOrders() { | ||
| 44 | return | 44 | return |
| 45 | } | 45 | } |
| 46 | header := this.GetRequestHeader(this.Ctx) | 46 | header := this.GetRequestHeader(this.Ctx) |
| 47 | - msg = protocol.NewReturnResponse(dividend.DividendOrders(header, request)) | 47 | + msg = protocol.NewReturnResponse(dividend.OrderList(header, request)) |
| 48 | } | 48 | } |
| @@ -28,7 +28,7 @@ func (this *OrderController) Statistics() { | @@ -28,7 +28,7 @@ func (this *OrderController) Statistics() { | ||
| 28 | return | 28 | return |
| 29 | } | 29 | } |
| 30 | header := this.GetRequestHeader(this.Ctx) | 30 | header := this.GetRequestHeader(this.Ctx) |
| 31 | - msg = protocol.NewReturnResponse(order.OrderStatistics(header, request)) | 31 | + msg = protocol.NewReturnResponse(order.Statistics(header, request)) |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | //OrderDetail 订单详情 | 34 | //OrderDetail 订单详情 |
| @@ -48,7 +48,7 @@ func (this *OrderController) OrderDetail() { | @@ -48,7 +48,7 @@ func (this *OrderController) OrderDetail() { | ||
| 48 | return | 48 | return |
| 49 | } | 49 | } |
| 50 | header := this.GetRequestHeader(this.Ctx) | 50 | header := this.GetRequestHeader(this.Ctx) |
| 51 | - msg = protocol.NewReturnResponse(order.OrderDetail(header, request)) | 51 | + msg = protocol.NewReturnResponse(order.Detail(header, request)) |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | //OrderList | 54 | //OrderList |
| @@ -68,7 +68,7 @@ func (this *OrderController) OrderList() { | @@ -68,7 +68,7 @@ func (this *OrderController) OrderList() { | ||
| 68 | } | 68 | } |
| 69 | request.OrderType = domain.OrderReal | 69 | request.OrderType = domain.OrderReal |
| 70 | header := this.GetRequestHeader(this.Ctx) | 70 | header := this.GetRequestHeader(this.Ctx) |
| 71 | - msg = protocol.NewReturnResponse(order.OrderList(header, request)) | 71 | + msg = protocol.NewReturnResponse(order.List(header, request)) |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | //OrderList | 74 | //OrderList |
| @@ -89,5 +89,5 @@ func (this *OrderController) Intentions() { | @@ -89,5 +89,5 @@ func (this *OrderController) Intentions() { | ||
| 89 | request.EndTime = time.Now().Unix() * 1000 | 89 | request.EndTime = time.Now().Unix() * 1000 |
| 90 | request.OrderType = domain.OrderIntention | 90 | request.OrderType = domain.OrderIntention |
| 91 | header := this.GetRequestHeader(this.Ctx) | 91 | header := this.GetRequestHeader(this.Ctx) |
| 92 | - msg = protocol.NewReturnResponse(order.OrderList(header, request)) | 92 | + msg = protocol.NewReturnResponse(order.List(header, request)) |
| 93 | } | 93 | } |
| @@ -29,6 +29,16 @@ func CheckJWTToken(ctx *context.Context) { | @@ -29,6 +29,16 @@ func CheckJWTToken(ctx *context.Context) { | ||
| 29 | return | 29 | return |
| 30 | } else { | 30 | } else { |
| 31 | ctx.Input.SetData("UserId", u.UserId) | 31 | ctx.Input.SetData("UserId", u.UserId) |
| 32 | + | ||
| 33 | + //valid token | ||
| 34 | + //tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(u.UserId)) | ||
| 35 | + //err := tokenAuth.Check( | ||
| 36 | + // userAuth.NewOptions(userAuth.WithAccessToken(token)), | ||
| 37 | + //) | ||
| 38 | + //if err != nil { | ||
| 39 | + // msg = protocol.NewMesage(4141) | ||
| 40 | + // return | ||
| 41 | + //} | ||
| 32 | } | 42 | } |
| 33 | return | 43 | return |
| 34 | } | 44 | } |
| @@ -44,8 +44,9 @@ type DividendOrdersResponse struct { | @@ -44,8 +44,9 @@ type DividendOrdersResponse struct { | ||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | type DividendOrderListItem struct { | 46 | type DividendOrderListItem struct { |
| 47 | - Id int64 `json:"id"` | ||
| 48 | - OrderNo string `json:"orderNo"` | ||
| 49 | - OrderAmount float64 `json:"orderAmount"` | ||
| 50 | - MyDividend float64 `json:"myDividend"` | 47 | + Id int64 `json:"id"` |
| 48 | + OrderNo string `json:"-"` | ||
| 49 | + DeliveryNo string `json:"deliveryNo"` | ||
| 50 | + OrderAmount float64 `json:"orderAmount"` | ||
| 51 | + DividendReceivable float64 `json:"dividendReceivable"` | ||
| 51 | } | 52 | } |
| @@ -23,6 +23,18 @@ type OrderDetail struct { | @@ -23,6 +23,18 @@ type OrderDetail struct { | ||
| 23 | MyDividend float64 `json:"myDividend"` | 23 | MyDividend float64 `json:"myDividend"` |
| 24 | MyDividendPercent float64 `json:"myDividendPercent"` | 24 | MyDividendPercent float64 `json:"myDividendPercent"` |
| 25 | } | 25 | } |
| 26 | +type OrderDetailVO struct { | ||
| 27 | + Id int64 `json:"id"` | ||
| 28 | + OrderNo string `json:"orderNo"` //订单号 | ||
| 29 | + DeliveryNo string `json:"deliveryNo"` //发货单号 | ||
| 30 | + OrderStatus int `json:"orderStatus"` //订单状态 1.待支付 2.已支付 3.已支付退货 4待支付退货 | ||
| 31 | + CreateTime int64 `json:"createTime"` | ||
| 32 | + UpdateTime int64 `json:"updateTime"` | ||
| 33 | + OrderDistrict interface{} `json:"orderDistrict"` | ||
| 34 | + Customer Customer `json:"customer"` | ||
| 35 | + Product interface{} `json:"product"` | ||
| 36 | + Total interface{} `json:"total"` | ||
| 37 | +} | ||
| 26 | type Customer struct { | 38 | type Customer struct { |
| 27 | Uname string `json:"uname"` | 39 | Uname string `json:"uname"` |
| 28 | Phone string `json:"phone"` | 40 | Phone string `json:"phone"` |
| @@ -35,12 +47,12 @@ type OrderStatisticsResponse struct { | @@ -35,12 +47,12 @@ type OrderStatisticsResponse struct { | ||
| 35 | Statistics OrderStatics `json:"statistics"` | 47 | Statistics OrderStatics `json:"statistics"` |
| 36 | } | 48 | } |
| 37 | type OrderStatics struct { | 49 | type OrderStatics struct { |
| 38 | - TodayIntentionQuantity int `json:"todayIntentionQuantity"` //今日新增意向订单 | ||
| 39 | - TodayIntentionMoney float64 `json:"todayIntentionMoney"` //今日新增意向订单金额 | ||
| 40 | - TodayRealQuantity int `json:"todayRealQuantity"` //今日新增实发订单 | ||
| 41 | - TodayRealMoney float64 `json:"todayRealMoney"` //今日新增实发订单金额 | ||
| 42 | - CumulativeQuantity int `json:"cumulativeQuantity"` //累计实发订单 | ||
| 43 | - CumulativeMoney float64 `json:"cumulativeMoney"` //累计实发订单金额 | 50 | + TodayIntentionQuantity int `json:"-"` //今日新增意向订单 |
| 51 | + TodayIntentionMoney float64 `json:"-"` //今日新增意向订单金额 | ||
| 52 | + TodayRealQuantity int `json:"todayRealQuantity"` //今日新增实发订单 | ||
| 53 | + TodayRealMoney float64 `json:"todayRealMoney"` //今日新增实发订单金额 | ||
| 54 | + CumulativeQuantity int `json:"cumulativeQuantity"` //累计实发订单 | ||
| 55 | + CumulativeMoney float64 `json:"cumulativeMoney"` //累计实发订单金额 | ||
| 44 | } | 56 | } |
| 45 | 57 | ||
| 46 | /*OrderList */ | 58 | /*OrderList */ |
| @@ -63,18 +75,20 @@ type OrderListItem struct { | @@ -63,18 +75,20 @@ type OrderListItem struct { | ||
| 63 | //订单类型 | 75 | //订单类型 |
| 64 | OrderType int `json:"orderType"` | 76 | OrderType int `json:"orderType"` |
| 65 | //订单编号 | 77 | //订单编号 |
| 66 | - OrderNo string `json:"orderNo"` | 78 | + OrderNo string `json:"-"` |
| 79 | + //发货编号 | ||
| 80 | + DeliveryNo string `json:"deliveryNo"` | ||
| 67 | //订单名称 | 81 | //订单名称 |
| 68 | - OrderName string `json:"orderName"` | 82 | + OrderName string `json:"-"` |
| 69 | //订单状态 | 83 | //订单状态 |
| 70 | - OrderStatus int `json:"orderStatus"` | 84 | + OrderStatus int `json:"-"` |
| 71 | //实际订单数量 | 85 | //实际订单数量 |
| 72 | - OrderActualCount int `json:"orderActualCount"` | 86 | + OrderActualCount int `json:"-"` |
| 73 | //订单金额 | 87 | //订单金额 |
| 74 | OrderAmount float64 `json:"orderAmount"` | 88 | OrderAmount float64 `json:"orderAmount"` |
| 75 | UpdateTime int64 `json:"updateTime"` | 89 | UpdateTime int64 `json:"updateTime"` |
| 76 | //我的分红 | 90 | //我的分红 |
| 77 | - MyDividend float64 `json:"myDividend"` | 91 | + MyDividend float64 `json:"dividendReceivable"` |
| 78 | //是否已读(0未读,1已读) | 92 | //是否已读(0未读,1已读) |
| 79 | IsRead int `json:"isRead"` | 93 | IsRead int `json:"isRead"` |
| 80 | } | 94 | } |
| @@ -28,6 +28,11 @@ type User struct { | @@ -28,6 +28,11 @@ type User struct { | ||
| 28 | //合作时间 | 28 | //合作时间 |
| 29 | CooperateTime int64 `json:"cooperationTime"` | 29 | CooperateTime int64 `json:"cooperationTime"` |
| 30 | Salesman interface{} `json:"salesman"` | 30 | Salesman interface{} `json:"salesman"` |
| 31 | + | ||
| 32 | + // 网易云信 | ||
| 33 | + AccountID int64 `json:"accid"` // 网易云信ID | ||
| 34 | + ImToken string `json:"ImToken"` // 网易云信Token | ||
| 35 | + CsAccountID string `json:"csAccountId"` // 分配的客服ID | ||
| 31 | } | 36 | } |
| 32 | 37 | ||
| 33 | type Company struct { | 38 | type Company struct { |
-
请 注册 或 登录 后发表评论